From fea268900fe94d2a21e877030f0efdcab0799455 Mon Sep 17 00:00:00 2001 From: Dave Wetzel Date: Mon, 26 Apr 2010 22:05:17 +0000 Subject: [PATCH] * EOControl/EOEditingContext.m: added @implementation EOCustomObject (AssociationsHack) re-added registerAssociationForDeallocHack * EOControl/*: ported to new runtime and OS X git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30244 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 +- EOControl/EOAndQualifier.m | 4 +- EOControl/EOCheapArray.m | 6 +- EOControl/EOClassDescription.m | 3 +- EOControl/EOCustomObject.m | 3 + EOControl/EODebug.h | 1 - EOControl/EODebug.m | 104 ++++++++++++++----------- EOControl/EODetailDataSource.m | 2 +- EOControl/EOEditingContext.m | 37 +++++++-- EOControl/EOFault.m | 67 +--------------- EOControl/EOFaultHandler.m | 36 +++++---- EOControl/EOFetchSpecification.m | 2 +- EOControl/EOGenericRecord.m | 24 +++--- EOControl/EOGlobalID.m | 2 +- EOControl/EOKeyComparisonQualifier.m | 20 ++--- EOControl/EOKeyGlobalID.m | 4 +- EOControl/EOKeyValueArchiver.m | 2 +- EOControl/EOKeyValueCoding.m | 25 ++++-- EOControl/EOKeyValueQualifier.m | 22 +++--- EOControl/EOMultiReaderLock.m | 3 +- EOControl/EONSAddOns.m | 10 ++- EOControl/EOObjectStore.m | 1 - EOControl/EOObjectStoreCoordinator.m | 2 +- EOControl/EOObserver.m | 109 ++++++++++++--------------- EOControl/EOOrQualifier.m | 4 +- EOControl/EOPrivate.h | 6 +- EOControl/EOPrivate.m | 29 ++++--- EOControl/EOQualifier.m | 20 ++--- 28 files changed, 270 insertions(+), 284 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3efdb3c..a7cfd08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,7 +17,11 @@ fixed leaks * EOAccess/Makefile.preamble: added -Werror-implicit-function-declaration * EOAccess/*: ported to new runtime and OS X - + * EOControl/EOMutableKnownKeyDictionary.*: ported, works for me, please double check + * EOControl/EOEditingContext.m: + added @implementation EOCustomObject (AssociationsHack) + re-added registerAssociationForDeallocHack + * EOControl/*: ported to new runtime and OS X 2010-04-21 Sergey Golovin diff --git a/EOControl/EOAndQualifier.m b/EOControl/EOAndQualifier.m index f9f33a3..8c8d83d 100644 --- a/EOControl/EOAndQualifier.m +++ b/EOControl/EOAndQualifier.m @@ -51,7 +51,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -249,7 +249,7 @@ RCS_ID("$Id$") NSString *dscr; dscr = [NSString stringWithFormat: @"<%s %p - qualifiers: %@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, _qualifiers]; diff --git a/EOControl/EOCheapArray.m b/EOControl/EOCheapArray.m index a40bd58..d0d5b36 100644 --- a/EOControl/EOCheapArray.m +++ b/EOControl/EOCheapArray.m @@ -119,10 +119,6 @@ RCS_ID("$Id$") - (void) dealloc { -#ifdef DEBUG - NSDebugFLog(@"Deallocate EOCheapCopyArray %p zone=%p _contents_array=%p _count=%d _refcount=%d", - self, [self zone], _contents_array, _count, _refcount); -#endif if (_contents_array) { @@ -165,7 +161,7 @@ RCS_ID("$Id$") [super release]; } -- (unsigned int) retainCount +- (NSUInteger) retainCount { #ifdef DEBUG NSDebugFLog(@"retainCount EOCheapCopyArray %p. %@", diff --git a/EOControl/EOClassDescription.m b/EOControl/EOClassDescription.m index 1e64f37..5b431d0 100644 --- a/EOControl/EOClassDescription.m +++ b/EOControl/EOClassDescription.m @@ -1,3 +1,4 @@ + /** EOClassDescription.m EOClassDescription Class @@ -57,7 +58,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include diff --git a/EOControl/EOCustomObject.m b/EOControl/EOCustomObject.m index dddeb00..36856d1 100644 --- a/EOControl/EOCustomObject.m +++ b/EOControl/EOCustomObject.m @@ -44,6 +44,9 @@ RCS_ID("$Id: EOGenericRecord.m 30111 2010-04-09 10:09:41Z ayers $") #include #else #include +#include +#include +#include #endif #include "EOCustomObject.h" diff --git a/EOControl/EODebug.h b/EOControl/EODebug.h index d7e121c..af16b01 100644 --- a/EOControl/EODebug.h +++ b/EOControl/EODebug.h @@ -40,7 +40,6 @@ #endif #ifndef GNUSTEP -#include #endif #include diff --git a/EOControl/EODebug.m b/EOControl/EODebug.m index 6fe39ac..0896170 100644 --- a/EOControl/EODebug.m +++ b/EOControl/EODebug.m @@ -45,7 +45,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -67,12 +67,12 @@ EOFLogC_(const char *file, int line, const char *string) if ([NSThread isMultiThreaded]) { fprintf(stderr, "%s PID=(%d) ", - [[GSCurrentThread() description] cString], + [[[NSThread currentThread] description] cStringUsingEncoding:NSUTF8StringEncoding], (int)getpid()); } fprintf(stderr, "File %s: %d. ", file, line); - fprintf(stderr, string); + fprintf(stderr, string, NULL); // the NULL makes the compiler happy -- dw len = strlen(string); @@ -128,14 +128,14 @@ IVarInString(const char* _type, void* _value) { Class *pvalue = (Class*)_value; return [NSString stringWithFormat: @"Class:%s", - class_get_class_name(*pvalue)]; + class_getName(*pvalue)]; } break; case _C_SEL: { SEL *pvalue = (SEL*)_value; return [NSString stringWithFormat: @"SEL:%s", - sel_get_name(*pvalue)]; + sel_getName(*pvalue)]; } break; case _C_CHR: @@ -321,69 +321,81 @@ TypeToNSString(const char* _type) static void DumpIVar(id object, GSIVar ivar, int deep) { +#ifndef GNUSTEP +#warning DumpIVar() is not ported to your platform +#else if (ivar && object && deep >= 0) + { + void *pValue = ((void*)object) + ivar->ivar_offset; + NSString *pType = TypeToNSString(ivar->ivar_type); + NSString *pIVar = IVarInString(ivar->ivar_type,pValue); + + NSDebugFLog(@"IVar %s type:%@ value:%@\n", + ivar->ivar_name, + pType, + pIVar); + + if (deep > 0 && ivar->ivar_type && *ivar->ivar_type == _C_ID && pValue) { - void *pValue = ((void*)object) + ivar->ivar_offset; - NSString *pType = TypeToNSString(ivar->ivar_type); - NSString *pIVar = IVarInString(ivar->ivar_type,pValue); - - NSDebugFLog(@"IVar %s type:%@ value:%@\n", - ivar->ivar_name, - pType, - pIVar); - - if (deep > 0 && ivar->ivar_type && *ivar->ivar_type == _C_ID && pValue) - { - EOFLogDumpObject_(NULL, 0, *((id*)pValue), deep); - } + EOFLogDumpObject_(NULL, 0, *((id*)pValue), deep); } + } +#endif } //Dump object void EOFLogDumpObject_(const char *file, int line, id object, int deep) { +#ifndef GNUSTEP +#warning EOFLogDumpObject_() is not ported to your platform +#else + USTART - + if (object && deep > 0) + { + struct objc_ivar_list *ivars = NULL; + Class class = [object class]; + + if (class) { - struct objc_ivar_list *ivars = NULL; - Class class = [object class]; - - if (class) - { - NSDebugFLog(@"--%s %d [%d] Dumping object %p of Class %s Description:%@\n", - (file && isalpha(*file) && line >= 0 - && line<=20000) ? file :"", - line, - deep, - (void*)object, - class->name, - objectDescription(object)); - while (class) + NSDebugFLog(@"--%s %d [%d] Dumping object %p of Class %s Description:%@\n", + (file && isalpha(*file) && line >= 0 + && line<=20000) ? file :"", + line, + deep, + (void*)object, + class_getName(class), + objectDescription(object)); + while (class) { ivars = class->ivars; - class = class->super_class; - + class = class_getSuperclass(class); + if (ivars) - { - int i; - - for (i = 0; i < ivars->ivar_count; i++) - { - DumpIVar(object,&ivars->ivar_list[i],deep-1); - } - } - } + { + int i; + + for (i = 0; i < ivars->ivar_count; i++) + { + DumpIVar(object,&ivars->ivar_list[i],deep-1); + } } + } } - + } + USTOP +#endif } void EOFLogAssertGood_(const char *file, int line, id object) { +#ifndef GNUSTEP +#warning EOFLogDumpObject_() is not ported to your platform +#else if (object) { if (object->class_pointer == ((Class)0xdeadface)) @@ -404,6 +416,8 @@ EOFLogAssertGood_(const char *file, int line, id object) line); NSCParameterAssert(object); } +#endif + } #endif diff --git a/EOControl/EODetailDataSource.m b/EOControl/EODetailDataSource.m index fe33e3b..ba6ff60 100644 --- a/EOControl/EODetailDataSource.m +++ b/EOControl/EODetailDataSource.m @@ -302,7 +302,7 @@ RCS_ID("$Id$") - (NSString*) description { return [NSString stringWithFormat: @"<%s %p : masterDataSource=%@ masterObject=%@ detailKey=%@ masterClassDescriptionName=%@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, _masterDataSource, _masterObject, diff --git a/EOControl/EOEditingContext.m b/EOControl/EOEditingContext.m index 82545ee..1e36904 100644 --- a/EOControl/EOEditingContext.m +++ b/EOControl/EOEditingContext.m @@ -37,7 +37,7 @@ RCS_ID("$Id$") //TODO EOMultiReaderLocks #ifndef GNUSTEP #include -#include +#include #endif #include @@ -172,7 +172,7 @@ static EOObjectStore *defaultParentStore = nil; static NSTimeInterval defaultFetchLag = 3600.0; //static NSHashTable *ecDeallocHT = 0; -//static NSHashTable *assocDeallocHT = 0; +static NSHashTable *assocDeallocHT = 0; /* Notifications */ NSString *EOObjectsChangedInEditingContextNotification @@ -265,15 +265,21 @@ _mergeValueForKey(id obj, id value, } } +// rename to _objectWillDealloc: ? -- dw + (void)_objectDeallocated:(id)object { - [[object editingContext] forgetObject: object]; - if (EOAssociationClass != nil) { - [EOAssociationClass objectDeallocated: object]; // rename to _objectDeallocated: ? -- dw + if (assocDeallocHT && NSHashGet(assocDeallocHT, object)) + { + // rename to _objectWillDealloc: ? -- dw + [EOAssociationClass objectDeallocated: object]; + NSHashRemove(assocDeallocHT,object); + } } + [[object editingContext] forgetObject: object]; + } + (NSTimeInterval)defaultFetchTimestampLag @@ -4020,3 +4026,24 @@ static BOOL usesContextRelativeEncoding = NO; [self notImplemented: _cmd]; //TODO } @end + +@implementation EOCustomObject (AssociationsHack) + +/* + this is used for EOAssociations + */ + +- (void) registerAssociationForDeallocHack:(id)object +{ + if (EOAssociationClass != nil) + { + if (!assocDeallocHT) + { + assocDeallocHT = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 64); + } + + NSHashInsert(assocDeallocHT, object); + } +} + +@end diff --git a/EOControl/EOFault.m b/EOControl/EOFault.m index 6097535..17c3005 100644 --- a/EOControl/EOFault.m +++ b/EOControl/EOFault.m @@ -56,7 +56,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -78,22 +78,8 @@ static Class EOFaultClass = NULL; + (void)initialize { - // Must be here as initialize is called for each root class - // without asking if it responds to it ! if (EOFaultClass == NULL) { - GSMethod nsfwd = GSGetMethod([NSObject class], - @selector(forward::), - YES,NO); - if (nsfwd != NULL) - { - GSMethod eofwd = GSGetMethod(self, - @selector(forward::), - YES,NO); - eofwd->method_imp = nsfwd->method_imp; - GSFlushMethodCacheForClass(self); - } - EOFaultClass = [EOFault class]; } } @@ -172,7 +158,7 @@ static Class EOFaultClass = NULL; /* * Since 'self' is an class, get_imp() will get the instance method. */ - return get_imp((Class)self, selector); + return class_getMethodImplementation((Class)self, selector); } // Fault class methods @@ -312,43 +298,12 @@ static Class EOFaultClass = NULL; - (BOOL)conformsToProtocol: (Protocol *)protocol { - int i; - struct objc_protocol_list* protos; - Class class, sClass; - - class = [_handler targetClass]; - - for (protos = class->protocols; protos; protos = protos->next) - { - for (i = 0; i < protos->count; i++) - if ([protos->list[i] conformsTo: protocol]) - return YES; - } - - sClass = [class superclass]; - - if (sClass) - return [sClass conformsToProtocol: protocol]; - else - return NO; + return class_conformsToProtocol([_handler targetClass], protocol); } - (BOOL)respondsToSelector: (SEL)selector { - Class class; - BOOL respondsToSelector; - - NSDebugFLLog(@"gsdb", @"START self=%p", self); - - class = [_handler targetClass]; - NSDebugFLLog(@"gsdb", @"class=%@ selector=%@", class, - NSStringFromSelector(selector)); - - respondsToSelector - = (GSGetMethod(class, selector, YES, YES) != (GSMethod)0); - NSDebugFLLog(@"gsdb", @"STOP self=%p", self); - - return respondsToSelector; + return class_respondsToSelector([_handler targetClass], selector); } - (NSMethodSignature *)methodSignatureForSelector: (SEL)selector @@ -489,20 +444,6 @@ static Class EOFaultClass = NULL; NSStringFromSelector(selector)]; } -/** - * This method is replaced by the current implementation of NSObject (if any). - * - * It is assumed that this method will not be called if NSObject does not - * implement it. - */ -- (retval_t)forward: (SEL)selector - : (arglist_t)args -{ - retval_t ret = 0; - NSAssert(NO,@"This should never be called (see +initialize)."); - return ret; -} - - (void)forwardInvocation: (NSInvocation *)invocation { NSDebugFLLog(@"gsdb",@"invocation selector=%@ target: %p", diff --git a/EOControl/EOFaultHandler.m b/EOControl/EOFaultHandler.m index bf850ec..97c0081 100644 --- a/EOControl/EOFaultHandler.m +++ b/EOControl/EOFaultHandler.m @@ -50,7 +50,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include @@ -124,7 +124,7 @@ RCS_ID("$Id$") { Class class; - for (class = _targetClass; class != Nil; class = class_get_super_class(class)) + for (class = _targetClass; class != Nil; class = class_getSuperclass(class)) { if (class == aclass) return YES; @@ -142,25 +142,31 @@ RCS_ID("$Id$") - (BOOL)conformsToProtocol: (Protocol *)protocol forFault: (id)fault { - int i; - struct objc_protocol_list *proto_list; - Class class; - - for(class = _targetClass; class != Nil; class = class_get_super_class(class)) + + // TODO: check on GNUstep if class_conformsToProtocol() works -- dw + //int i; + //struct objc_protocol_list *proto_list; + //Class class; + + return class_conformsToProtocol(_targetClass, protocol); + +/* + for(class = _targetClass; class != Nil; class = class_getSuperclass(class)) + { + for (proto_list = + ((struct objc_class *)_targetClass)->class_pointer->protocols; + proto_list; proto_list = proto_list->next) { - for (proto_list = - ((struct objc_class *)_targetClass)->class_pointer->protocols; - proto_list; proto_list = proto_list->next) - { - for (i = 0; i < proto_list->count; i++) + for (i = 0; i < proto_list->count; i++) { if ([proto_list->list[i] conformsTo: protocol]) - return YES; + return YES; } - } } - + } + return NO; + */ } - (BOOL)respondsToSelector: (SEL)sel diff --git a/EOControl/EOFetchSpecification.m b/EOControl/EOFetchSpecification.m index 2f10093..0d474f4 100644 --- a/EOControl/EOFetchSpecification.m +++ b/EOControl/EOFetchSpecification.m @@ -46,7 +46,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#import #endif #include diff --git a/EOControl/EOGenericRecord.m b/EOControl/EOGenericRecord.m index 2824fc6..3b4ba01 100644 --- a/EOControl/EOGenericRecord.m +++ b/EOControl/EOGenericRecord.m @@ -53,7 +53,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -1112,7 +1112,7 @@ infinite loop in description **/ } return [NSString stringWithFormat: @"<%s %p : classDescription=%@\nvalues=%@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, classDescription, dict]; @@ -1202,7 +1202,7 @@ infinite loop in description **/ } return [NSString stringWithFormat: @"<%s %p : classDescription=%@\nvalues=%@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, classDescription, dict]; @@ -1517,16 +1517,14 @@ You can override this to exclude properties manually handled by derived object * - (unsigned int)eoGetSize { - unsigned int size = 0; + size_t size = 0; Class selfClass = Nil; - -// EOFLOGObjectFnStartOrCond(@"EOGenericRecord"); - + selfClass = [self class]; - size = selfClass->instance_size; - -// EOFLOGObjectFnStopOrCond(@"EOGenericRecord"); + // size = selfClass->instance_size; + size = class_getInstanceSize(selfClass); + return size; } @@ -1539,12 +1537,8 @@ You can override this to exclude properties manually handled by derived object * unsigned int size; //consider 2bytes string - //EOFLOGObjectFnStartOrCond(@"EOGenericRecord"); - size = [super eoGetSize] + [self length] * 2; - //EOFLOGObjectFnStopOrCond(@"EOGenericRecord"); - return size; } @@ -1619,7 +1613,7 @@ You can override this to exclude properties manually handled by derived object * [processed setObject: [NSNumber numberWithUnsignedInt: 0] forKey: objectP]; - size += objectClass->instance_size; + size += class_getInstanceSize(objectClass); if ([object isKindOfClass: [NSArray class]]) baseSize += size; diff --git a/EOControl/EOGlobalID.m b/EOControl/EOGlobalID.m index d642d04..bcd30bf 100644 --- a/EOControl/EOGlobalID.m +++ b/EOControl/EOGlobalID.m @@ -259,7 +259,7 @@ static unsigned short sequence = USHRT_MAX; } dst[j] = 0; return [NSString stringWithFormat: @"<%s %s>", - GSClassNameFromObject(self), dst]; + object_getClassName(self), dst]; } @end diff --git a/EOControl/EOKeyComparisonQualifier.m b/EOControl/EOKeyComparisonQualifier.m index 2c14bfa..0f67905 100644 --- a/EOControl/EOKeyComparisonQualifier.m +++ b/EOControl/EOKeyComparisonQualifier.m @@ -188,41 +188,41 @@ RCS_ID("$Id$") { return (*imp) (leftVal, _selector, rightVal); } - if (sel_eq(_selector, EOQualifierOperatorEqual) == YES) + if (sel_isEqual(_selector, EOQualifierOperatorEqual) == YES) { return [leftVal isEqual: rightVal]; } - else if (sel_eq(_selector, EOQualifierOperatorNotEqual) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorNotEqual) == YES) { return ([leftVal isEqual: rightVal]?NO:YES); } - else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLessThan) == YES) { return [leftVal compare: rightVal] == NSOrderedAscending; } - else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorGreaterThan) == YES) { return [leftVal compare: rightVal] == NSOrderedDescending; } - else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) { return [leftVal compare: rightVal] != NSOrderedDescending; } - else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) { return [leftVal compare: rightVal] != NSOrderedAscending; } - else if (sel_eq(_selector, EOQualifierOperatorContains) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorContains) == YES) { return [(id)leftVal rangeOfString: (id)rightVal].location != NSNotFound; } - else if (sel_eq(_selector, EOQualifierOperatorLike) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLike) == YES) { NSEmitTODO(); //TODO return [leftVal isEqual: rightVal] == NSOrderedSame; } - else if (sel_eq(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES) { NSEmitTODO(); //TODO return [[(id)leftVal uppercaseString] isEqual: [(id)rightVal uppercaseString]] @@ -260,7 +260,7 @@ RCS_ID("$Id$") selectorString = NSStringFromSelector(_selector); } return [NSString stringWithFormat:@"<%s %p - %@ %@ %@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, _leftKey, selectorString, diff --git a/EOControl/EOKeyGlobalID.m b/EOControl/EOKeyGlobalID.m index 1020c30..25177c7 100644 --- a/EOControl/EOKeyGlobalID.m +++ b/EOControl/EOKeyGlobalID.m @@ -47,7 +47,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -200,7 +200,7 @@ RCS_ID("$Id$") int i; dscr = [NSString stringWithFormat: @"<%s %p - Entity %@ - keysValues:", - object_get_class_name(self), + object_getClassName(self), (void*)self, _entityName]; diff --git a/EOControl/EOKeyValueArchiver.m b/EOControl/EOKeyValueArchiver.m index 8a3dc3e..97f643e 100644 --- a/EOControl/EOKeyValueArchiver.m +++ b/EOControl/EOKeyValueArchiver.m @@ -76,7 +76,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include diff --git a/EOControl/EOKeyValueCoding.m b/EOControl/EOKeyValueCoding.m index a1cbf1a..11584fe 100644 --- a/EOControl/EOKeyValueCoding.m +++ b/EOControl/EOKeyValueCoding.m @@ -1,3 +1,4 @@ + /** EOKeyValueCoding.m EOKeyValueCoding @@ -60,7 +61,8 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include +#include #endif #include @@ -384,12 +386,14 @@ initialize(void) INITIALIZE; - EOFLOGObjectFnStartCond(@"EOKVC"); - mode = [[NSDecimalNumber defaultBehavior] roundingMode]; count = [self count]; - NSDecimalFromComponents(&result, 0, 0, NO); + + // does not seem to exist on snow leopad -- dw + // NSDecimalFromComponents(&result, 0, 0, NO); + result = [[NSDecimalNumber zero] decimalValue]; + if (count>0) { unsigned int i=0; @@ -403,7 +407,7 @@ initialize(void) }; ret = [NSDecimalNumber decimalNumberWithDecimal: result]; - EOFLOGObjectFnStopCond(@"EOKVC"); + return ret; } @@ -425,7 +429,11 @@ initialize(void) EOFLOGObjectFnStartCond(@"EOKVC"); mode = [[NSDecimalNumber defaultBehavior] roundingMode]; count = [self count]; - NSDecimalFromComponents(&result, 0, 0, NO); + + result = [[NSDecimalNumber zero] decimalValue]; + + // not available on snow leo -- dw + // NSDecimalFromComponents(&result, 0, 0, NO); if (count>0) { @@ -445,7 +453,10 @@ initialize(void) } left = result; - NSDecimalFromComponents(&right, (unsigned long long) count, 0, NO); + + right = [[NSNumber numberWithUnsignedLongLong:count] decimalValue]; + +// NSDecimalFromComponents(&right, (unsigned long long) count, 0, NO); NSDecimalDivide(&result, &left, &right, mode); diff --git a/EOControl/EOKeyValueQualifier.m b/EOControl/EOKeyValueQualifier.m index de9b15f..52c64a7 100644 --- a/EOControl/EOKeyValueQualifier.m +++ b/EOControl/EOKeyValueQualifier.m @@ -52,7 +52,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -229,15 +229,15 @@ RCS_ID("$Id$") { return (*imp) (objectValue, _selector, selfValue); } - if (sel_eq(_selector, EOQualifierOperatorEqual) == YES) + if (sel_isEqual(_selector, EOQualifierOperatorEqual) == YES) { return [objectValue isEqual: selfValue]; } - else if (sel_eq(_selector, EOQualifierOperatorNotEqual) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorNotEqual) == YES) { return ([objectValue isEqual: selfValue]?NO:YES); } - else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLessThan) == YES) { if (objectValue==GDL2_EONull) return ((selfValue==GDL2_EONull) ? NO : YES); @@ -246,7 +246,7 @@ RCS_ID("$Id$") else return [objectValue compare: selfValue] == NSOrderedAscending; } - else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorGreaterThan) == YES) { if (objectValue==GDL2_EONull) return NO; @@ -255,7 +255,7 @@ RCS_ID("$Id$") else return [objectValue compare: selfValue] == NSOrderedDescending; } - else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) { if (objectValue==GDL2_EONull) return YES; @@ -264,7 +264,7 @@ RCS_ID("$Id$") else return [objectValue compare: selfValue] != NSOrderedDescending; } - else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) { if (objectValue==GDL2_EONull) return ((selfValue==GDL2_EONull) ? YES : NO); @@ -273,7 +273,7 @@ RCS_ID("$Id$") else return [objectValue compare: selfValue] != NSOrderedAscending; } - else if (sel_eq(_selector, EOQualifierOperatorContains) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorContains) == YES) { //Philosophical question: does nil contains nil ?? @@ -285,13 +285,13 @@ RCS_ID("$Id$") return [(NSString*)objectValue rangeOfString: (NSString*)selfValue].location != NSNotFound; } - else if (sel_eq(_selector, EOQualifierOperatorLike) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorLike) == YES) { NSEmitTODO(); //TODO //How to handle nil like ? return [objectValue isEqual: selfValue]; } - else if (sel_eq(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES) + else if (sel_isEqual(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES) { NSEmitTODO(); //TODO //How to handle nil like ? @@ -335,7 +335,7 @@ RCS_ID("$Id$") selectorString = NSStringFromSelector(_selector); } return [NSString stringWithFormat:@"<%s %p - %@ %@ (%@)'%@'>", - object_get_class_name(self), + object_getClassName(self), (void*)self, _key, selectorString, diff --git a/EOControl/EOMultiReaderLock.m b/EOControl/EOMultiReaderLock.m index 5b59650..8b116db 100644 --- a/EOControl/EOMultiReaderLock.m +++ b/EOControl/EOMultiReaderLock.m @@ -28,7 +28,6 @@ #ifndef GNUSTEP #include -#include #include #else #include @@ -122,6 +121,8 @@ - (void)lockForReading { NSThread *ct = [NSThread currentThread]; + +#warning is int good here? I don't think so. -- dw int cnt = (int)NSMapGet(_readerThreads,ct); if (ct == _writerLockThread) diff --git a/EOControl/EONSAddOns.m b/EOControl/EONSAddOns.m index 564453e..29af892 100644 --- a/EOControl/EONSAddOns.m +++ b/EOControl/EONSAddOns.m @@ -54,6 +54,7 @@ RCS_ID("$Id$") #include #include #include +#include #endif #include #include @@ -177,7 +178,7 @@ GDL2_Activate(Class sup, Class cls) @"%@: No result for object %@ resultOfPerformingSelector:\"%s\" withEachObjectInArray:", self, object, - sel_get_name(sel)); + sel_getName(sel)); [results addObject: result]; } @@ -573,10 +574,13 @@ GDL2_Activate(Class sup, Class cls) unichar *chars; unsigned int length = [self length]; - chars = objc_malloc(length * sizeof(unichar)); + chars = NSZoneMalloc(NSDefaultMallocZone(),length * sizeof(unichar)); [self getCharacters: chars]; chars[0]=uni_toupper(chars[0]); + + // CHECKME: does this really free how we want it? -- dw + return AUTORELEASE([[NSString alloc] initWithCharactersNoCopy: chars length: length freeWhenDone: YES]); @@ -663,7 +667,7 @@ GDL2_Activate(Class sup, Class cls) [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - msg = get_imp(GSObjCClass(self), selector); + msg = class_getMethodImplementation([self class], selector); if (!msg) { [NSException raise: NSGenericException diff --git a/EOControl/EOObjectStore.m b/EOControl/EOObjectStore.m index cb89ac5..51df375 100644 --- a/EOControl/EOObjectStore.m +++ b/EOControl/EOObjectStore.m @@ -43,7 +43,6 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include #endif #include diff --git a/EOControl/EOObjectStoreCoordinator.m b/EOControl/EOObjectStoreCoordinator.m index ceeb2d3..e2e4e01 100644 --- a/EOControl/EOObjectStoreCoordinator.m +++ b/EOControl/EOObjectStoreCoordinator.m @@ -48,7 +48,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include diff --git a/EOControl/EOObserver.m b/EOControl/EOObserver.m index 354fd04..27717bf 100644 --- a/EOControl/EOObserver.m +++ b/EOControl/EOObserver.m @@ -49,7 +49,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include @@ -68,12 +68,7 @@ RCS_ID("$Id$") */ - (void)willChange { - EOFLOGObjectFnStart(); - - EOFLOGObjectLevelArgs(@"EOObserver", @"willChange self=%p", self); [EOObserverCenter notifyObserversObjectWillChange: self]; - - EOFLOGObjectFnStop(); } @end @@ -200,61 +195,49 @@ static id lastObject; */ + (void)notifyObserversObjectWillChange: (id)object { - EOFLOGClassFnStart(); - - EOFLOGObjectLevelArgs(@"EOObserver", @"object=%p", object); - if (!notificationSuppressCount) + { + SEL objectWillChangeSel = @selector(objectWillChange:); + + if (object == nil) { - SEL objectWillChangeSel = @selector(objectWillChange:); - EOFLOGObjectLevelArgs(@"EOObserver", @"object=%p lastObject=%p", - object, lastObject); - - if (object == nil) - { - NSHashEnumerator omniscEnum = NSEnumerateHashTable(omniscientHash); - id obj; - - lastObject = nil; - while ((obj = (id)NSNextHashEnumeratorItem(&omniscEnum))) + NSHashEnumerator omniscEnum = NSEnumerateHashTable(omniscientHash); + id obj; + + lastObject = nil; + while ((obj = (id)NSNextHashEnumeratorItem(&omniscEnum))) { [obj performSelector:objectWillChangeSel withObject:object]; } - } - else if (lastObject != object) - { - NSHashTable *observersHash; - NSHashEnumerator observersEnum; - id obj; - - lastObject = object; - - observersHash = NSMapGet(observersMap, object); - - if (observersHash) + } + else if (lastObject != object) + { + NSHashTable *observersHash; + NSHashEnumerator observersEnum; + id obj; + + lastObject = object; + + observersHash = NSMapGet(observersMap, object); + + if (observersHash) { observersEnum = NSEnumerateHashTable(observersHash); - EOFLOGObjectLevelArgs(@"EOObserver", @"observersArray count=%d", - NSCountHashTable(observersHash)); - + while ((obj = (id)NSNextHashEnumeratorItem(&observersEnum))) - { - [obj performSelector:objectWillChangeSel withObject:object]; - } + { + [obj performSelector:objectWillChangeSel withObject:object]; + } } - - EOFLOGObjectLevelArgs(@"EOObserver", @"omniscientObservers count=%d", - NSCountHashTable(omniscientHash)); - - observersEnum = NSEnumerateHashTable(omniscientHash); - while ((obj = (id)NSNextHashEnumeratorItem(&observersEnum))) + + observersEnum = NSEnumerateHashTable(omniscientHash); + while ((obj = (id)NSNextHashEnumeratorItem(&observersEnum))) { [obj performSelector:objectWillChangeSel withObject:object]; } - } } - - EOFLOGClassFnStop(); + } + } /** @@ -288,25 +271,29 @@ static id lastObject; + (id)observerForObject: (id)object ofClass: (Class)targetClass { NSHashTable *observersHash; - + id observer = nil; + if (object == nil) return nil; - + observersHash = NSMapGet(observersMap, object); if (observersHash) + { + NSHashEnumerator observersEnum; + observersEnum = NSEnumerateHashTable(observersHash); + + while ((observer = (id)NSNextHashEnumeratorItem(&observersEnum))) { - NSHashEnumerator observersEnum; - observersEnum = NSEnumerateHashTable(observersHash); - id observer; - - while ((observer = (id)NSNextHashEnumeratorItem(&observersEnum))) - { - if ([observer isKindOfClass: targetClass]) - return observer; - } + if ([observer isKindOfClass: targetClass]) + { + break; + } } - - return nil; + // avoid memory leak! -- dw + NSEndHashTableEnumeration(&observersEnum); + } + + return observer; } /** diff --git a/EOControl/EOOrQualifier.m b/EOControl/EOOrQualifier.m index 60e55eb..116b51c 100644 --- a/EOControl/EOOrQualifier.m +++ b/EOControl/EOOrQualifier.m @@ -49,7 +49,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include #include -#include +#include #endif #include @@ -235,7 +235,7 @@ RCS_ID("$Id$") NSString *dscr; dscr = [NSString stringWithFormat: @"<%s %p - qualifiers: %@>", - object_get_class_name(self), + object_getClassName(self), (void*)self, _qualifiers]; return dscr; diff --git a/EOControl/EOPrivate.h b/EOControl/EOPrivate.h index f43544e..0df07f0 100644 --- a/EOControl/EOPrivate.h +++ b/EOControl/EOPrivate.h @@ -39,7 +39,7 @@ @class EOMKKDInitializer; @class EOGlobalID; -typedef unsigned int (*GDL2IMP_UINT)(id, SEL, ...); +typedef NSUInteger (*GDL2IMP_UINT)(id, SEL, ...); typedef BOOL (*GDL2IMP_BOOL)(id, SEL, ...); typedef NSStringEncoding (*GDL2IMP_NSStringEncoding)(id, SEL, ...); @@ -357,8 +357,8 @@ GDL2CONTROL_EXPORT void EOMKKD_setObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* GDL2CONTROL_EXPORT void EOMKKD_removeObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,NSString* key); GDL2CONTROL_EXPORT BOOL EOMKKD_hasKeyWithImpPtr(NSDictionary* mkkd,GDL2IMP_BOOL* impPtr,NSString* key); -GDL2CONTROL_EXPORT unsigned int EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd,GDL2IMP_UINT* impPtr,NSString* key); -GDL2CONTROL_EXPORT unsigned int EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit,GDL2IMP_UINT* impPtr,NSString* key); +GDL2CONTROL_EXPORT NSUInteger EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd,GDL2IMP_UINT* impPtr,NSString* key); +GDL2CONTROL_EXPORT NSUInteger EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit,GDL2IMP_UINT* impPtr,NSString* key); // ==== EOEditingContext ==== diff --git a/EOControl/EOPrivate.m b/EOControl/EOPrivate.m index 475a2d6..3061676 100644 --- a/EOControl/EOPrivate.m +++ b/EOControl/EOPrivate.m @@ -329,7 +329,7 @@ EOMKKD_hasKeyWithImpPtr(NSDictionary* mkkd, return NO; }; -unsigned int +NSUInteger EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd, GDL2IMP_UINT* impPtr, NSString* key) @@ -355,8 +355,7 @@ EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd, return 0; }; -unsigned int -EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit, +NSUInteger EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit, GDL2IMP_UINT* impPtr, NSString* key) { @@ -478,7 +477,7 @@ void EOHashAddTable(NSHashTable *to, NSHashTable *from) static SEL eqSel; @interface GDL2NonRetainingMutableArray (PrivateExceptions) -- (void) _raiseRangeExceptionWithIndex:(unsigned) index from:(SEL)selector; +- (void) _raiseRangeExceptionWithIndex:(NSUInteger) index from:(SEL)selector; @end /** @@ -516,7 +515,7 @@ static SEL eqSel; } /* designated initializer */ -- (id) initWithCapacity:(unsigned)capacity +- (id) initWithCapacity:(NSUInteger)capacity { self = [super init]; _contents = NSZoneMalloc([self zone], sizeof(GSIArray_t)); @@ -524,7 +523,7 @@ static SEL eqSel; return self; } -- (id) initWithObjects:(id *)objects count:(unsigned)count +- (id) initWithObjects:(id *)objects count:(NSUInteger)count { int i; self = [self initWithCapacity:count]; @@ -534,12 +533,12 @@ static SEL eqSel; } /* These are *this* subclasses responsibility */ -- (unsigned) count +- (NSUInteger) count { return GSIArrayCount(_contents); } -- (id) objectAtIndex:(unsigned) index +- (id) objectAtIndex:(NSUInteger) index { if (index >= GSIArrayCount(_contents)) [self _raiseRangeExceptionWithIndex:index from:_cmd]; @@ -559,7 +558,7 @@ static SEL eqSel; GSIArrayAddItem(_contents, (GSIArrayItem)object); } -- (void) replaceObjectAtIndex:(unsigned)index withObject:(id)object +- (void) replaceObjectAtIndex:(NSUInteger)index withObject:(id)object { if (object == nil) { @@ -576,7 +575,7 @@ static SEL eqSel; GSIArraySetItemAtIndex(_contents, (GSIArrayItem)object, index); } -- (void) insertObject:(id)object atIndex:(unsigned)index +- (void) insertObject:(id)object atIndex:(NSUInteger)index { if (object == nil) { @@ -592,7 +591,7 @@ static SEL eqSel; GSIArrayInsertItem(_contents, (GSIArrayItem)object, index); } -- (void) removeObjectAtIndex:(unsigned)index +- (void) removeObjectAtIndex:(NSUInteger)index { if (index >= GSIArrayCount(_contents)) { @@ -639,16 +638,16 @@ static SEL eqSel; } /* private methods. */ -- (void) _raiseRangeExceptionWithIndex: (unsigned)index from: (SEL)sel +- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel { NSDictionary *info; NSException *exception; NSString *reason; - unsigned count = GSIArrayCount(_contents); + NSUInteger count = GSIArrayCount(_contents); info = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithUnsignedInt: index], @"Index", - [NSNumber numberWithUnsignedInt: count], @"Count", + [NSNumber numberWithUnsignedInteger: index], @"Index", + [NSNumber numberWithUnsignedInteger: count], @"Count", self, @"Array", nil, nil]; reason = [NSString stringWithFormat: @"Index %d is out of range %d (in '%@')", index, count, NSStringFromSelector(sel)]; diff --git a/EOControl/EOQualifier.m b/EOControl/EOQualifier.m index ca3eded..cb78a9f 100644 --- a/EOControl/EOQualifier.m +++ b/EOControl/EOQualifier.m @@ -55,7 +55,7 @@ RCS_ID("$Id$") #ifndef GNUSTEP #include -#include +#include #endif #include @@ -939,23 +939,23 @@ _qualifierWithArgs(id self, SEL _cmd, NSString *format, NSArray *array, va_list + (NSString *)stringForOperatorSelector: (SEL)selector { - if (sel_eq(selector, EOQualifierOperatorEqual)) + if (sel_isEqual(selector, EOQualifierOperatorEqual)) return @"="; - else if (sel_eq(selector, EOQualifierOperatorNotEqual)) + else if (sel_isEqual(selector, EOQualifierOperatorNotEqual)) return @"<>"; - else if (sel_eq(selector, EOQualifierOperatorLessThan)) + else if (sel_isEqual(selector, EOQualifierOperatorLessThan)) return @"<"; - else if (sel_eq(selector, EOQualifierOperatorGreaterThan)) + else if (sel_isEqual(selector, EOQualifierOperatorGreaterThan)) return @">"; - else if (sel_eq(selector, EOQualifierOperatorLessThanOrEqualTo)) + else if (sel_isEqual(selector, EOQualifierOperatorLessThanOrEqualTo)) return @"<="; - else if (sel_eq(selector, EOQualifierOperatorGreaterThanOrEqualTo)) + else if (sel_isEqual(selector, EOQualifierOperatorGreaterThanOrEqualTo)) return @">="; - else if (sel_eq(selector, EOQualifierOperatorContains)) + else if (sel_isEqual(selector, EOQualifierOperatorContains)) return @"doesContain"; - else if (sel_eq(selector, EOQualifierOperatorLike)) + else if (sel_isEqual(selector, EOQualifierOperatorLike)) return @"like"; - else if (sel_eq(selector, EOQualifierOperatorCaseInsensitiveLike)) + else if (sel_isEqual(selector, EOQualifierOperatorCaseInsensitiveLike)) return @"caseInsensitiveLike"; return NSStringFromSelector(selector);