ADDF445D06DA511D00C4E7F8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADDF445C06DA511D00C4E7F8 /* Foundation.framework */; };
/* End PBXBuildFile section */
-/* Begin PBXBuildStyle section */
- ADDF431206DA4E2000C4E7F8 /* Development */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "APPLE_RUNTIME=1",
- "NeXT_Foundation_LIBRARY=1",
- "COCOA_Foundation_LIBRARY=1",
- "NeXT_RUNTIME=1",
- "COMPILE_AS_FRAMEWORK=1",
- "DEBUG=1",
- );
- };
- name = Development;
- };
- ADDF431306DA4E2000C4E7F8 /* Wrapper */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = YES;
- DEPLOYMENT_LOCATION = NO;
- DEPLOYMENT_POSTPROCESSING = YES;
- DSTROOT = /;
- DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/";
- FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
- GCC_OPTIMIZATION_LEVEL = 3;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "APPLE_RUNTIME=1",
- "NeXT_Foundation_LIBRARY=1",
- "COCOA_Foundation_LIBRARY=1",
- "NeXT_RUNTIME=1",
- "COMPILE_AS_FRAMEWORK=1",
- );
- SKIP_INSTALL = YES;
- SYMROOT = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks";
- TEMP_DIR = "$(SYMROOT)/$(PROJECT_NAME).build";
- UNSTRIPPED_PRODUCT = NO;
- ZERO_LINK = NO;
- };
- name = Wrapper;
- };
-/* End PBXBuildStyle section */
-
/* Begin PBXFileReference section */
ADDF431F06DA4E3500C4E7F8 /* EOControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EOControl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
ADDF432106DA4E3500C4E7F8 /* EOControl-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "EOControl-Info.plist"; sourceTree = "<group>"; };
);
buildRules = (
);
- buildSettings = {
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.64;
- FRAMEWORK_VERSION = A;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = common.h;
- GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
- GCC_WARN_UNKNOWN_PRAGMAS = NO;
- INFOPLIST_FILE = "EOControl-Info.plist";
- INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
- OTHER_CFLAGS = "";
- OTHER_LDFLAGS = (
- "-seg1addr",
- 0xC1000000,
- "-headerpad_max_install_names",
- );
- OTHER_REZFLAGS = "";
- PRODUCT_NAME = EOControl;
- SECTORDER_FLAGS = "";
- WARNING_CFLAGS = "-Wmost";
- };
dependencies = (
);
name = EOControl;
productName = EOControl;
productReference = ADDF431F06DA4E3500C4E7F8 /* EOControl.framework */;
- productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>EOControl</string>
- <key>CFBundleIdentifier</key>
- <string>com.yourcompany.EOControl</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
-</dict>
-</plist>
-";
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
ADDF431406DA4E2000C4E7F8 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = ADA077C30857382200993825 /* Build configuration list for PBXProject "EOControl" */;
- buildSettings = {
- };
- buildStyles = (
- ADDF431206DA4E2000C4E7F8 /* Development */,
- ADDF431306DA4E2000C4E7F8 /* Wrapper */,
- );
hasScannedForEncodings = 0;
mainGroup = ADDF431006DA4E2000C4E7F8;
productRefGroup = ADDF432006DA4E3500C4E7F8 /* Products */;
buildSettings = {
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.64;
+ DYLIB_CURRENT_VERSION = 4.5.70;
FRAMEWORK_VERSION = A;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
DEPLOYMENT_POSTPROCESSING = YES;
DSTROOT = /;
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.64;
+ DYLIB_CURRENT_VERSION = 4.5.70;
DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/";
FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks";
FRAMEWORK_VERSION = A;
isa = XCBuildConfiguration;
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.64;
+ DYLIB_CURRENT_VERSION = 4.5.70;
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = common.h;
- (id)computeSumForKey:(NSString *)_key {
unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
-#if LIB_FOUNDATION_LIBRARY
- double sum;
+ id (*objAtIdx)(id, SEL, unsigned int);
+ double sum;
if (cc == 0) return [NSNumber numberWithDouble:0.0];
-
+
objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
for (i = 0, sum = 0.0; i < cc; i++) {
register id o;
o = objAtIdx(self, @selector(objectAtIndex:), i);
+ o = [o valueForKey:_key];
sum += [o doubleValue];
}
return [NSNumber numberWithDouble:sum];
-#else
- NSDecimalNumber *n;
-
- n = [NSDecimalNumber zero]
- if (cc == 0) return n;
-
- objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
-
- for (i = 0, sum = 0.0; i < cc; i++) {
- register id o;
-
- o = objAtIdx(self, @selector(objectAtIndex:), i);
-
- if ([o isKindOfClass:[NSDecimalNumber class]])
- n = [n decimalNumberByAdding:o];
- else {
- n = [n decimalNumberByAdding:
- [NSDecimalNumber numberWithDouble:[o doubleValue]]];
- }
- }
- return n;
-#endif
}
- (id)computeAvgForKey:(NSString *)_key {
- unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double sum;
+ unsigned cc = [self count];
+ NSNumber *sum;
- if (cc == 0) return [NSNumber numberWithDouble:0.0];
+ if (cc == 0) return nil;
- objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
-
- for (i = 0, sum = 0.0; i < cc; i++) {
- register id o;
-
- o = objAtIdx(self, @selector(objectAtIndex:), i);
-
- sum += [o doubleValue];
- }
- return [NSNumber numberWithDouble:(sum / (double)cc)];
+ sum = [self computeSumForKey:_key];
+ return [NSNumber numberWithDouble:([sum doubleValue] / (double)cc)];
}
- (id)computeCountForKey:(NSString *)_key {
- (id)computeMaxForKey:(NSString *)_key {
unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double max;
+ id (*objAtIdx)(id, SEL, unsigned int);
+ double max;
if (cc == 0) return nil;
objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
- max = [objAtIdx(self, @selector(objectAtIndex:), 0) doubleValue];
+ max = [[objAtIdx(self, @selector(objectAtIndex:), 0) valueForKey:_key]
+ doubleValue];
for (i = 1; i < cc; i++) {
register double ov;
- ov = [objAtIdx(self, @selector(objectAtIndex:), i) doubleValue];
+ ov = [[objAtIdx(self, @selector(objectAtIndex:), i) valueForKey:_key]
+ doubleValue];
if (ov > max) max = ov;
}
return [NSNumber numberWithDouble:max];
- (id)computeMinForKey:(NSString *)_key {
unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double min;
-
+ id (*objAtIdx)(id, SEL, unsigned int);
+ double min;
+
if (cc == 0) return nil;
objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
- min = [objAtIdx(self, @selector(objectAtIndex:), 0) doubleValue];
+ min = [[objAtIdx(self, @selector(objectAtIndex:), 0) valueForKey:_key]
+ doubleValue];
for (i = 1; i < cc; i++) {
register double ov;
- ov = [objAtIdx(self, @selector(objectAtIndex:), i) doubleValue];
+ ov = [[objAtIdx(self, @selector(objectAtIndex:), i) valueForKey:_key]
+ doubleValue];
if (ov < min) min = ov;
}
return [NSNumber numberWithDouble:min];
@implementation NSArray(EOKeyValueCoding)
+static Class NSDecimalNumberClass = Nil;
+
++ (void)initialize {
+ static BOOL didInit = NO;
+ if (didInit) return;
+ didInit = YES;
+ NSDecimalNumberClass = [NSDecimalNumber class];
+}
+
- (id)computeSumForKey:(NSString *)_key {
- unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double sum;
+ id (*objAtIdx)(id, SEL, unsigned int);
+ unsigned i, cc = [self count];
+ NSDecimalNumber *sum;
+
+ sum = [NSDecimalNumber zero];
+ if (cc == 0) return sum;
- if (cc == 0) return [NSNumber numberWithDouble:0.0];
-
objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
-
- for (i = 0, sum = 0.0; i < cc; i++) {
+
+ for (i = 0; i < cc; i++) {
register id o;
-
+
o = objAtIdx(self, @selector(objectAtIndex:), i);
- sum += [o doubleValue];
+ o = [o valueForKey:_key];
+
+ if (![o isKindOfClass:NSDecimalNumberClass])
+ o = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:[o doubleValue]];
+ sum = [sum decimalNumberByAdding:o];
}
- return [NSNumber numberWithDouble:sum];
+ return sum;
}
- (id)computeAvgForKey:(NSString *)_key {
- unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double sum;
-
- if (cc == 0) return [NSNumber numberWithDouble:0.0];
-
- objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
+ unsigned cc = [self count];
+ NSDecimalNumber *sum, *div;
- for (i = 0, sum = 0.0; i < cc; i++) {
- register id o;
-
- o = objAtIdx(self, @selector(objectAtIndex:), i);
-
- sum += [o doubleValue];
- }
- return [NSNumber numberWithDouble:(sum / (double)cc)];
+ if (cc == 0) return nil;
+
+ sum = [self computeSumForKey:_key];
+ div = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInt:cc];
+ return [sum decimalNumberByDividingBy:div];
}
- (id)computeCountForKey:(NSString *)_key {
}
- (id)computeMaxForKey:(NSString *)_key {
- unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double max;
-
+ id (*objAtIdx)(id, SEL, unsigned int);
+ unsigned i, cc = [self count];
+ NSDecimalNumber *max;
+
if (cc == 0) return nil;
-
- objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
- max = [objAtIdx(self, @selector(objectAtIndex:), 0) doubleValue];
+ objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
+ max = [objAtIdx(self, @selector(objectAtIndex:), 0) valueForKey:_key];
+
for (i = 1; i < cc; i++) {
- register double ov;
+ register id o;
- ov = [objAtIdx(self, @selector(objectAtIndex:), i) doubleValue];
- if (ov > max) max = ov;
+ o = [objAtIdx(self, @selector(objectAtIndex:), i) valueForKey:_key];
+ if ([max compare:o] == NSOrderedAscending)
+ max = o;
}
- return [NSNumber numberWithDouble:max];
+ return max;
}
- (id)computeMinForKey:(NSString *)_key {
- unsigned i, cc = [self count];
- id (*objAtIdx)(id, SEL, unsigned int);
- double min;
-
+ id (*objAtIdx)(id, SEL, unsigned int);
+ unsigned i, cc = [self count];
+ NSDecimalNumber *min;
+
if (cc == 0) return nil;
- objAtIdx = (void *)[self methodForSelector:@selector(objectAtIndex:)];
-
- min = [objAtIdx(self, @selector(objectAtIndex:), 0) doubleValue];
+ objAtIdx = (void*)[self methodForSelector:@selector(objectAtIndex:)];
+ min = [objAtIdx(self, @selector(objectAtIndex:), 0) valueForKey:_key];
+
for (i = 1; i < cc; i++) {
- register double ov;
-
- ov = [objAtIdx(self, @selector(objectAtIndex:), i) doubleValue];
- if (ov < min) min = ov;
+ register id o;
+
+ o = [objAtIdx(self, @selector(objectAtIndex:), i) valueForKey:_key];
+ if ([min compare:o] == NSOrderedDescending)
+ min = o;
}
- return [NSNumber numberWithDouble:min];
+ return min;
}
- (id)valueForKey:(NSString *)_key {