]> err.no Git - sope/commitdiff
various bugfixes for the computeXXX: methods, proper implementations for Foundations...
authorznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 2 Dec 2006 18:56:36 +0000 (18:56 +0000)
committerznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 2 Dec 2006 18:56:36 +0000 (18:56 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1385 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-core/EOControl/ChangeLog
sope-core/EOControl/EOControl.xcodeproj/project.pbxproj
sope-core/EOControl/EOKeyValueCoding.m
sope-core/EOControl/Version

index 92a267ccec6cf04d582808a843e8e39169148853..e742bdf520b09365c02f172bedf5cee76a171a99 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-02  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * EOKeyValueCoding.m: fixed numerous bugs in the computeXXX: methods
+         and provided proper implementations according to the WO4.5 specs
+         for gnustep-base and Apple Foundation (v4.5.70)
+
 2006-12-02  Helge Hess  <helge.hess@opengroupware.org>
 
        * EOKeyValueCoding.m: added NSDecimalNumber implementation for
index 7e7c3dee51f9e87fb1bae783cd0e51e74d6e528b..46ba9dd9b1975c932614c2807f50e1aab45b9a3d 100644 (file)
                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;
index 5e1cdb67ee269564b775ebb6c36346b843361a24..c790f6149110df63b80279eaffb96c9acfc105eb 100644 (file)
@@ -866,62 +866,31 @@ static inline BOOL setValue(NSString* key, id instance, id value)
 
 - (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 {
@@ -930,18 +899,20 @@ static inline BOOL setValue(NSString* key, id instance, id value)
 
 - (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];
@@ -949,18 +920,20 @@ static inline BOOL setValue(NSString* key, id instance, id value)
 
 - (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];
@@ -1447,41 +1420,47 @@ static void doubleIvarSetFunc(void* info1, void* info2, id self, id val) {
 
 @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 {
@@ -1489,41 +1468,43 @@ static void doubleIvarSetFunc(void* info1, void* info2, id self, id val) {
 }
 
 - (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 {
index 0817bde00fe5355966fb89cffdb3fd5d27e62da4..51ff5d2326a8492693f01a86a5e3a5ee4e262419 100644 (file)
@@ -1,3 +1,3 @@
 # version file
 
-SUBMINOR_VERSION:=69
+SUBMINOR_VERSION:=70