diff --git a/ChangeLog b/ChangeLog index a70a03f65..0dd06d0bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2002-02-01 Richard Frith-Macdonald + + * Source/NSHashTable.m: Fixed bug intorduced by last change to add + error checking!! + * Source/GSAttributedString.m: Make new or old GSI stuff optional. + * Source/GSCountedSet.m: ditto + * Source/GSDictionary.m: ditto + * Source/GSFFCallInvocation.m: ditto + * Source/NSArchiver.m: ditto + * Source/NSConnection.m: ditto + * Source/NSFileManager.m: ditto + * Source/NSNotificationCenter.m: ditto + * Source/NSObject.m: ditto + * Source/NSPortCoder.m: ditto + * Source/NSRunLoop.m: ditto + * Source/NSSerializer.m: ditto + * Source/NSUnarchiver.m: ditto + Interim phase ... version of source which should build with new or + old GSIMap and GSIArray APIs at the defination of GSI_NEW + 2002-01-31 Adam Fedor * Old/*: Removed (now at diff --git a/Source/GSAttributedString.m b/Source/GSAttributedString.m index f543265ad..49d2dd9d5 100644 --- a/Source/GSAttributedString.m +++ b/Source/GSAttributedString.m @@ -91,12 +91,19 @@ -#define GSI_NEW 1 +#ifdef GSI_NEW 1 #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) #define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToDictionary: (Y).obj] +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#define GSI_MAP_EQUAL(X,Y) [(X).obj isEqualToDictionary: (Y).obj] +#endif #define GSI_MAP_KTYPES GSUNION_OBJ #define GSI_MAP_VTYPES GSUNION_INT diff --git a/Source/GSCountedSet.m b/Source/GSCountedSet.m index 7e31707de..ebedf487b 100644 --- a/Source/GSCountedSet.m +++ b/Source/GSCountedSet.m @@ -32,9 +32,14 @@ #include -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) +#else +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#endif + #define GSI_MAP_KTYPES GSUNION_OBJ #define GSI_MAP_VTYPES GSUNION_INT @@ -293,7 +298,11 @@ { GSIMapNode node; +#ifdef GSI_NEW node = GSIMapNodeForKeyInBucket(&map, bucket, (GSIMapKey)anObject); +#else + node = GSIMapNodeForKeyInBucket(bucket, (GSIMapKey)anObject); +#endif if (node != 0) { if (--node->value.uint == 0) diff --git a/Source/GSDictionary.m b/Source/GSDictionary.m index a2a890ff9..f88d63551 100644 --- a/Source/GSDictionary.m +++ b/Source/GSDictionary.m @@ -33,17 +33,23 @@ #include -#define GSI_NEW 1 /* * The 'Fastmap' stuff provides an inline implementation of a mapping * table - for maximum performance. */ #define GSI_MAP_KTYPES GSUNION_OBJ #define GSI_MAP_VTYPES GSUNION_OBJ +#ifdef GSI_NEW #define GSI_MAP_HASH(M, X) [X.obj hash] #define GSI_MAP_EQUAL(M, X,Y) [X.obj isEqual: Y.obj] #define GSI_MAP_RETAIN_KEY(M, X) ((id)(X).obj) = \ [((id)(X).obj) copyWithZone: map->zone] +#else +#define GSI_MAP_HASH(X) [X.obj hash] +#define GSI_MAP_EQUAL(X,Y) [X.obj isEqual: Y.obj] +#define GSI_MAP_RETAIN_KEY(X) ((id)(X).obj) = \ + [((id)(X).obj) copyWithZone: map->zone] +#endif #include diff --git a/Source/GSFFCallInvocation.m b/Source/GSFFCallInvocation.m index b6780720a..158ed57f1 100644 --- a/Source/GSFFCallInvocation.m +++ b/Source/GSFFCallInvocation.m @@ -106,13 +106,21 @@ ReturnTypeEqualsReturnType (vacallReturnTypeInfo *a, vacallReturnTypeInfo *b) && (a->type == b->type); } -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_HASH(M, X) ReturnTypeHash (X.ptr) #define GSI_MAP_EQUAL(M, X,Y) ReturnTypeEqualsReturnType (X.ptr, Y.ptr) #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RELEASE_VAL(M, X) +#else +#define GSI_MAP_HASH(X) ReturnTypeHash (X.ptr) +#define GSI_MAP_EQUAL(X,Y) ReturnTypeEqualsReturnType (X.ptr, Y.ptr) +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RELEASE_VAL(X) +#endif #include diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index 541009bf0..6eea27d94 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -28,13 +28,21 @@ /* * Setup for inline operation of pointer map tables. */ -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) #define GSI_MAP_HASH(M, X) ((X).uint) #define GSI_MAP_EQUAL(M, X,Y) ((X).uint == (Y).uint) +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#define GSI_MAP_HASH(X) ((X).uint) +#define GSI_MAP_EQUAL(X ,Y) ((X).uint == (Y).uint) +#endif #include diff --git a/Source/NSConnection.m b/Source/NSConnection.m index d4b176758..219df5c80 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -37,13 +37,21 @@ /* * Setup for inline operation of pointer map tables. */ -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) #define GSI_MAP_HASH(M, X) ((X).uint ^ ((X).uint >> 3)) #define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr) +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#define GSI_MAP_HASH(X) ((X).uint ^ ((X).uint >> 3)) +#define GSI_MAP_EQUAL(X,Y) ((X).ptr == (Y).ptr) +#endif #include diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index b90ee2827..e1c354e46 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -1376,12 +1376,16 @@ inline void gsedRelease(GSEnumeratedDirectory X) closedir(X.pointer); } -#define GSI_NEW 1 #define GSI_ARRAY_TYPES 0 +#ifdef GSI_NEW #define GSI_ARRAY_TYPE GSEnumeratedDirectory - #define GSI_ARRAY_RELEASE(A, X) gsedRelease(X.ext) #define GSI_ARRAY_RETAIN(A, X) +#else +#define GSI_ARRAY_EXTRA GSEnumeratedDirectory +#define GSI_ARRAY_RELEASE(X) gsedRelease(X.ext) +#define GSI_ARRAY_RETAIN(X) +#endif #include diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index 71263706f..bf8831ebb 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -110,16 +110,20 @@ static void obsRetain(Observation *o); static void obsFree(Observation *o); -#define GSI_NEW 1 - #define GSI_ARRAY_TYPES 0 +#ifdef GSI_NEW #define GSI_ARRAY_TYPE Observation* - #define GSI_ARRAY_RELEASE(A, X) obsFree(X.ext) #define GSI_ARRAY_RETAIN(A, X) obsRetain(X.ext) +#else +#define GSI_ARRAY_EXTRA Observation* +#define GSI_ARRAY_RELEASE(X) obsFree(X.ext) +#define GSI_ARRAY_RETAIN(X) obsRetain(X.ext) +#endif #include +#ifdef GSI_NEW #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) ({if ((((gsaddr)X.obj) & 1) == 0) \ RELEASE(X.obj);}) @@ -127,6 +131,15 @@ static void obsFree(Observation *o); #define GSI_MAP_EQUAL(M, X,Y) doEqual(X.obj, Y.obj) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) ({if ((((gsaddr)X.obj) & 1) == 0) \ + RELEASE(X.obj);}) +#define GSI_MAP_HASH(X) doHash(X.obj) +#define GSI_MAP_EQUAL(X,Y) doEqual(X.obj, Y.obj) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#endif #define GSI_MAP_KTYPES GSUNION_OBJ|GSUNION_INT #define GSI_MAP_VTYPES GSUNION_PTR diff --git a/Source/NSObject.m b/Source/NSObject.m index 5c88b229f..e1aa9733e 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -225,13 +225,21 @@ NSDecrementExtraRefCountWasZero(id anObject) #else -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_EQUAL(M, X, Y) (X.obj == Y.obj) #define GSI_MAP_HASH(M, X) (X.ptr >> 2) #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) +#else +#define GSI_MAP_EQUAL(X, Y) (X.obj == Y.obj) +#define GSI_MAP_HASH(X) (X.ptr >> 2) +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#endif #define GSI_MAP_KTYPES GSUNION_OBJ #define GSI_MAP_VTYPES GSUNION_INT diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index 6eb838b68..049941a1e 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -49,21 +49,34 @@ /* * Setup for inline operation of pointer map tables. */ -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) #define GSI_MAP_HASH(M, X) ((X).uint) #define GSI_MAP_EQUAL(M, X,Y) ((X).uint == (Y).uint) +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#define GSI_MAP_HASH(X) ((X).uint) +#define GSI_MAP_EQUAL(X,Y) ((X).uint == (Y).uint) +#endif #include /* * Setup for inline operation of arrays. */ +#ifdef GSI_NEW #define GSI_ARRAY_RETAIN(A, X) #define GSI_ARRAY_RELEASE(A, X) +#else +#define GSI_ARRAY_RETAIN(X) +#define GSI_ARRAY_RELEASE(X) +#endif #define GSI_ARRAY_TYPES GSUNION_OBJ|GSUNION_SEL|GSUNION_STR #include diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 7876d891d..7ea5112f7 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -306,10 +306,10 @@ static inline BOOL timerInvalidated(NSTimer* timer) * Setup for inline operation of arrays. */ -#define GSI_NEW 1 - #define GSI_ARRAY_TYPES GSUNION_OBJ +#ifdef GSI_NEW + #if GS_WITH_GC == 0 #define GSI_ARRAY_RELEASE(A, X) [(X).obj release] #define GSI_ARRAY_RETAIN(A, X) [(X).obj retain] @@ -318,6 +318,18 @@ static inline BOOL timerInvalidated(NSTimer* timer) #define GSI_ARRAY_RETAIN(A, X) #endif +#else + +#if GS_WITH_GC == 0 +#define GSI_ARRAY_RELEASE(X) [(X).obj release] +#define GSI_ARRAY_RETAIN(X) [(X).obj retain] +#else +#define GSI_ARRAY_RELEASE(X) +#define GSI_ARRAY_RETAIN(X) +#endif + +#endif + #include static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 9ba61a095..549e93ad7 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -50,21 +50,34 @@ /* * Setup for inline operation of string map tables. */ -#define GSI_NEW 1 +#ifdef GSI_NEW #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) #define GSI_MAP_RELEASE_VAL(M, X) #define GSI_MAP_HASH(M, X) [(X).obj hash] #define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToString: (Y).obj] +#else +#define GSI_MAP_RETAIN_KEY(X) +#define GSI_MAP_RELEASE_KEY(X) +#define GSI_MAP_RETAIN_VAL(X) +#define GSI_MAP_RELEASE_VAL(X) +#define GSI_MAP_HASH(X) [(X).obj hash] +#define GSI_MAP_EQUAL(X,Y) [(X).obj isEqualToString: (Y).obj] +#endif #include /* * Setup for inline operation of string arrays. */ +#ifdef GSI_NEW #define GSI_ARRAY_RETAIN(A, X) #define GSI_ARRAY_RELEASE(A, X) +#else +#define GSI_ARRAY_RETAIN(X) +#define GSI_ARRAY_RELEASE(X) +#endif #define GSI_ARRAY_TYPES GSUNION_OBJ #include diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index e6cfc8c55..d66a47d1d 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -31,12 +31,16 @@ #include #include -#define GSI_NEW 1 /* * Setup for inline operation of arrays. */ +#ifdef GSI_NEW #define GSI_ARRAY_RETAIN(A, X) #define GSI_ARRAY_RELEASE(A, X) +#else +#define GSI_ARRAY_RETAIN(X) +#define GSI_ARRAY_RELEASE(X) +#endif #define GSI_ARRAY_TYPES GSUNION_OBJ|GSUNION_SEL|GSUNION_STR #include