diff --git a/ChangeLog b/ChangeLog index f2e1d0e45..a6ae35bbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,32 @@ * Headers/gnustep/base/NSGString.h: * Headers/gnustep/base/NSGCString.h: * Source/NSGString.m: - * Source/NSGCString.m: Removed classes - no loinger used. + * Source/NSGCString.m: Removed classes - no longer used. + * Headers/gnustep/base/NSObjCRuntime.h: + * Headers/gnustep/base/fast.x: + * Source/GSString.m: + * Source/Makefile.postamble: + * Source/NSArchiver.m: + * Source/NSCTemplateValue.m: + * Source/NSConcreteValue.m: + * Source/NSCountedSet.m: + * Source/NSDate.m: + * Source/NSDictionary.m: + * Source/NSDistantObject.m: + * Source/NSGSet.m: + * Source/NSNumber.m: + * Source/NSObject.m: + * Source/NSScanner.m: + * Source/NSSerializer.m: + * Source/NSSet.m: + * Source/NSUnarchiver.m: + Changed calls to 'fastClass()' to use 'GSObjCClassOfObject()' and + added that to NSObjCRuntime.h. Removed central class and + implementation caching from NSObject.m and fast.x since it was not + being effectively used. New intention to do removal of fast.x and + add similar functionality to NSObjCRuntime.h - intention being to + combine functionality of fast access to the runtime, and hiding both + GNU and Apple runtime behind a single interface. 2000-10-30 Richard Frith-Macdonald diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index eaf51cce8..50bacd24b 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.h @@ -1,5 +1,5 @@ /* Interface to ObjC runtime for GNUStep - Copyright (C) 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc. Written by: Andrew Kachites McCallum Date: 1995 @@ -38,21 +38,22 @@ @class NSString; -GS_EXPORT NSString *NSStringFromSelector(SEL aSelector); -GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); -GS_EXPORT Class NSClassFromString(NSString *aClassName); -GS_EXPORT NSString *NSStringFromClass(Class aClass); -GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, unsigned int *sizep, unsigned int *alignp); +GS_EXPORT NSString *NSStringFromSelector(SEL aSelector); +GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); +GS_EXPORT Class NSClassFromString(NSString *aClassName); +GS_EXPORT NSString *NSStringFromClass(Class aClass); +GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, + unsigned int *sizep, unsigned int *alignp); /* Logging */ /* OpenStep spec states that log messages go to stderr, but just in case someone wants them to go somewhere else, they can implement a function like this */ typedef void NSLog_printf_handler (NSString* message); -GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler; +GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler; -GS_EXPORT void NSLog (NSString* format, ...); -GS_EXPORT void NSLogv (NSString* format, va_list args); +GS_EXPORT void NSLog (NSString* format, ...); +GS_EXPORT void NSLogv (NSString* format, va_list args); #ifndef YES #define YES 1 @@ -64,12 +65,23 @@ GS_EXPORT void NSLogv (NSString* format, va_list args); #define nil 0 #endif nil -#ifndef NO_GNUSTEP -GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data); -GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data); -#endif - #define FOUNDATION_EXPORT #define FOUNDATION_STATIC_INLINE static inline +#ifndef NO_GNUSTEP +GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data); +GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data); + +/* + * GSObjCClassOfInstance() return the class of an instance. + * The argument to this function must NOT be nil. + */ +FOUNDATION_STATIC_INLINE Class +GSObjCClassOfObject(id obj) +{ + return obj->class_pointer; +} + +#endif + #endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/fast.x b/Headers/gnustep/base/fast.x index ad3495a0f..c21a9be7d 100644 --- a/Headers/gnustep/base/fast.x +++ b/Headers/gnustep/base/fast.x @@ -36,61 +36,15 @@ * This file is all to do with improving performance by avoiding the * Objective-C messaging overhead in time-critical code. * - * The motiviation behind it is to keep all the information needed to - * do that in one place (using a single mechanism), so that optimization - * attempts can be kept track of. + * THIS STUFF IS GOING AWAY! * - * The optimisations are of three sorts - - * - * 1. inline functions - * There are many operations that can be speeded up by using inline - * code to examine objects rather than sending messages to them to - * ask them about themselves. Often, the objc runtime provides - * functions to do this, but these sometimes perform unnecessary - * checks. Here we attempt to provide some basics. - * - * 2. class comparison - * It is often necessary to check the class of objects - instead of - * using [+class] method, we can cache certain classes in a global - * structure (The [NSObject +initialize] method does the caching) - * and refer to the structure elements directly. - * - * 3. direct method despatch - * A common techique is to obtain the method implementation for a - * specific message sent to a particular class of object, and call - * the implementation directly to avoid repeated lookup within the - * objc runtime. - * While there is no huge speed advantage to caching the method - * implementations, it does make it easy to search the source for - * code that is using this technique and referring to a cached - * method implementation. + * The intention is to provide similar functionality in NSObjCRuntime.h + * There will be GNUstep specific (mostly inline) functions added to + * the header to provide direct access to runtime functinality and the + * internals of objects. Hopefully a simple configuration option will + * let us build for either the GNU or the Apple runtime. */ -/* - * Structure to cache class information. - * By convention, the name of the structure element is the name of the - * class with an underscore prepended. - */ -typedef struct { - Class _NSArray; - Class _NSMutableArray; - Class _NSDictionary; - Class _NSMutableDictionary; - Class _NSDataMalloc; - Class _NSMutableDataMalloc; -} fastCls; -GS_EXPORT fastCls _fastCls; /* Populated by _fastBuildCache() */ - -/* - * The '_fastBuildCache()' function is called to populate the cache - * structures. This is (at present) called in [NSObject +initialize] - * but you may call it explicitly later to repopulate the cache after - * changes have been made to the runtime by loading of categories or - * by classes posing as other classes. - */ -GS_EXPORT void _fastBuildCache(); - - /* * The '_fastMallocBuffer()' function is called to get a chunk of * memory that will automatically be released when the current @@ -100,9 +54,6 @@ GS_EXPORT void *_fastMallocBuffer(unsigned size); /* * Fast access to class info - DON'T pass nil to these! - * These should really do different things conditional upon the objc - * runtime in use, but we will probably only ever want to support the - * latest GNU runtime, so I haven't bothered about that. */ static INLINE BOOL diff --git a/Source/GSString.m b/Source/GSString.m index 2c2994766..67a7d0f4d 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -43,6 +43,7 @@ #include #include #include +#include #include /* memcpy(), strlen(), strcmp() are gcc builtin's */ @@ -359,7 +360,7 @@ compare_c(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (fastIsInstance(aString) == NO) return strCompCsNs((id)self, aString, mask, aRange); - c = fastClass(aString); + c = GSObjCClassOfObject(aString); if (fastClassIsKindOfClass(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strCompCsUs((id)self, aString, mask, aRange); @@ -381,7 +382,7 @@ compare_u(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (fastIsInstance(aString) == NO) return strCompUsNs((id)self, aString, mask, aRange); - c = fastClass(aString); + c = GSObjCClassOfObject(aString); if (fastClassIsKindOfClass(c, GSUStringClass) || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strCompUsUs((id)self, aString, mask, aRange); @@ -1057,7 +1058,7 @@ rangeOfString_c(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (fastIsInstance(aString) == NO) return strRangeCsNs((id)self, aString, mask, aRange); - c = fastClass(aString); + c = GSObjCClassOfObject(aString); if (fastClassIsKindOfClass(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strRangeCsUs((id)self, aString, mask, aRange); @@ -1079,7 +1080,7 @@ rangeOfString_u(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (fastIsInstance(aString) == NO) return strRangeUsNs((id)self, aString, mask, aRange); - c = fastClass(aString); + c = GSObjCClassOfObject(aString); if (fastClassIsKindOfClass(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strRangeUsUs((id)self, aString, mask, aRange); @@ -1137,7 +1138,7 @@ transmute(ivars self, NSString *aString) { ivars other; BOOL transmute; - Class c = fastClass(aString); + Class c = GSObjCClassOfObject(aString); // NB aString must not be nil other = (ivars)aString; transmute = YES; @@ -2202,6 +2203,12 @@ transmute(ivars self, NSString *aString) unsigned length; GS_RANGE_CHECK(aRange, _count); + if (aString == nil) + [NSException raise: NSInvalidArgumentException + format: @"replace characters with nil string"]; + if (fastIsInstance(aString) == NO) + [NSException raise: NSInvalidArgumentException + format: @"replace characters with non-string"]; length = (aString == nil) ? 0 : [aString length]; offset = length - aRange.length; diff --git a/Source/Makefile.postamble b/Source/Makefile.postamble index d66ca973d..c3ee4df1b 100644 --- a/Source/Makefile.postamble +++ b/Source/Makefile.postamble @@ -244,6 +244,22 @@ $(GNUSTEP_OBJ_DIR)/NSString.o \ $(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \ : $(HEADER_DIR)/fast.x +# +# Files that include NSObjCRuntime.h will need a rebuild if it is changed. +# +$(GNUSTEP_OBJ_DIR)/GSString.o \ +$(GNUSTEP_OBJ_DIR)/NSArchiver.o \ +$(GNUSTEP_OBJ_DIR)/NSArray.o \ +$(GNUSTEP_OBJ_DIR)/NSData.o \ +$(GNUSTEP_OBJ_DIR)/NSGDictionary.o \ +$(GNUSTEP_OBJ_DIR)/NSInvocation.o \ +$(GNUSTEP_OBJ_DIR)/NSObjCRuntime.o \ +$(GNUSTEP_OBJ_DIR)/NSObject.o \ +$(GNUSTEP_OBJ_DIR)/NSSerializer.o \ +$(GNUSTEP_OBJ_DIR)/NSString.o \ +$(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \ + : $(HEADER_DIR)/NSObjCRuntime.h + # # Files that include GSeq.h will need a rebuild if it is changed. # diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index 57fb15385..054aa8134 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -60,6 +60,9 @@ static SEL xRefSel; static SEL eObjSel; static SEL eValSel; +@class NSMutableDataMalloc; +static Class NSMutableDataMallocClass; + + (void) initialize { if (self == [NSArchiver class]) @@ -69,6 +72,7 @@ static SEL eValSel; xRefSel = @selector(serializeTypeTag:andCrossRef:); eObjSel = @selector(encodeObject:); eValSel = @selector(encodeValueOfObjCType:at:); + NSMutableDataMallocClass = [NSMutableDataMalloc class]; } } @@ -76,7 +80,7 @@ static SEL eValSel; { NSMutableData *d; - d = [[_fastCls._NSMutableDataMalloc allocWithZone: fastZone(self)] init]; + d = [[NSMutableDataMallocClass allocWithZone: fastZone(self)] init]; self = [self initForWritingWithMutableData: d]; RELEASE(d); return self; @@ -162,7 +166,7 @@ static SEL eValSel; id d; NSZone *z = NSDefaultMallocZone(); - d = [[_fastCls._NSMutableDataMalloc allocWithZone: z] initWithCapacity: 0]; + d = [[NSMutableDataMallocClass allocWithZone: z] initWithCapacity: 0]; if (d == nil) { return nil; diff --git a/Source/NSCTemplateValue.m b/Source/NSCTemplateValue.m index d374613ac..e0bc3d56e 100644 --- a/Source/NSCTemplateValue.m +++ b/Source/NSCTemplateValue.m @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,8 @@ - (BOOL) isEqual: (id)other { - if (other != nil && fastInstanceIsKindOfClass(other, fastClass(self))) + if (other != nil + && fastInstanceIsKindOfClass(other, GSObjCClassOfObject(self))) { return [self isEqualToValue: other]; } @@ -92,7 +94,8 @@ { typedef __typeof__(data) _dt; - if (aValue != nil && fastInstanceIsKindOfClass(aValue, fastClass(self))) + if (aValue != nil + && fastInstanceIsKindOfClass(aValue, GSObjCClassOfObject(self))) { _dt val = [aValue TYPE_METHOD]; #if TYPE_ORDER == 0 diff --git a/Source/NSConcreteValue.m b/Source/NSConcreteValue.m index f6b9a6a0a..9b94f4972 100644 --- a/Source/NSConcreteValue.m +++ b/Source/NSConcreteValue.m @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -104,7 +105,7 @@ - (BOOL) isEqualToValue: (NSValue*)aValue { - if (fastClass(aValue) != fastClass(self)) + if (GSObjCClassOfObject(aValue) != GSObjCClassOfObject(self)) return NO; if (strcmp(objctype, ((NSConcreteValue*)aValue)->objctype) != 0) return NO; diff --git a/Source/NSCountedSet.m b/Source/NSCountedSet.m index 31a098c3f..5a11c0ae4 100644 --- a/Source/NSCountedSet.m +++ b/Source/NSCountedSet.m @@ -33,6 +33,7 @@ #include #include #include +#include @class NSSetNonCore; @class NSMutableSetNonCore; @@ -110,7 +111,7 @@ static Class NSCountedSet_concrete_class; - (id) initWithCoder: (NSCoder*)aCoder { unsigned count; - Class c = fastClass(self); + Class c = GSObjCClassOfObject(self); if (c == NSCountedSet_abstract_class) { diff --git a/Source/NSDate.m b/Source/NSDate.m index b9fd6de32..8a8a0a2c4 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -97,8 +98,13 @@ findInArray(NSArray *array, unsigned pos, NSString *str) static inline NSTimeInterval otherTime(NSDate* other) { - Class c = fastClass(other); + Class c; + if (other == nil) + [NSException raise: NSInvalidArgumentException format: @"other time nil"]; + if (fastIsInstance(other) == NO) + [NSException raise: NSInvalidArgumentException format: @"other time bad"]; + c = GSObjCClassOfObject(other); if (c == concreteClass || c == calendarClass) return ((NSGDate*)other)->_seconds_since_ref; else diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index f3f680b2d..a392f40da 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -35,6 +35,7 @@ #include #include #include +#include @interface NSDictionaryNonCore : NSDictionary @end @@ -779,14 +780,14 @@ static NSString *indentStrings[] = { for (i = 0; i < numKeys; i++) { - if (fastClass(keys[i]) == lastClass) + if (GSObjCClassOfObject(keys[i]) == lastClass) continue; if ([keys[i] respondsToSelector: @selector(compare:)] == NO) { canCompare = NO; break; } - lastClass = fastClass(keys[i]); + lastClass = GSObjCClassOfObject(keys[i]); } if (canCompare == YES) @@ -830,7 +831,7 @@ static NSString *indentStrings[] = { Class x; NSComparisonResult r; - x = fastClass(a); + x = GSObjCClassOfObject(a); if (x != lastClass) { lastClass = x; diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index 2896092a1..a4e2dc10e 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -30,6 +30,7 @@ #include #include #include +#include static int debug_proxy = 0; static Class placeHolder = 0; @@ -742,7 +743,7 @@ enum - (IMP) methodForSelector: (SEL)aSelector { - return get_imp(fastClass((id)self), aSelector); + return get_imp(GSObjCClassOfObject((id)self), aSelector); } - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector diff --git a/Source/NSGSet.m b/Source/NSGSet.m index 0905e084b..fef35c095 100644 --- a/Source/NSGSet.m +++ b/Source/NSGSet.m @@ -33,6 +33,7 @@ #include #include #include +#include #define GSI_MAP_HAS_VALUE 0 #define GSI_MAP_KTYPES GSUNION_OBJ @@ -249,7 +250,7 @@ static Class mutableSetClass; return NO; // Loop for all members in otherSet - c = fastClass(otherSet); + c = GSObjCClassOfObject(otherSet); if (c == setClass || c == mutableSetClass) { GSIMapNode node = ((NSGSet*)otherSet)->map.firstNode; @@ -319,7 +320,7 @@ static Class mutableSetClass; } else { - Class c = fastClass(other); + Class c = GSObjCClassOfObject(other); if (c == setClass || c == mutableSetClass) { diff --git a/Source/NSNumber.m b/Source/NSNumber.m index ef94815ae..c9004c542 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -36,6 +36,7 @@ #include #include #include +#include @implementation NSNumber @@ -56,7 +57,9 @@ GSNumberInfoFromObject(NSNumber *o) Class c; GSNumberInfo *info; - c = fastClass(o); + if (o == nil) + return nil; + c = GSObjCClassOfObject(o); info = (GSNumberInfo*)NSMapGet (numberMap, (void*)c); if (info == 0) { @@ -664,7 +667,7 @@ static Class doubleNumberClass; - (NSString*) descriptionWithLocale: (NSDictionary*)locale { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) { [NSException raise: NSInternalInconsistencyException format: @"descriptionWithLocale: for abstract NSNumber"]; @@ -725,7 +728,7 @@ static Class doubleNumberClass; /* All the rest of these methods must be implemented by a subclass */ - (BOOL) boolValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get boolValue from abstract NSNumber"]; else @@ -835,7 +838,7 @@ static Class doubleNumberClass; - (signed char) charValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get charValue from abstract NSNumber"]; else @@ -945,7 +948,7 @@ static Class doubleNumberClass; - (double) doubleValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get doubleValue from abstract NSNumber"]; else @@ -1055,7 +1058,7 @@ static Class doubleNumberClass; - (float) floatValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get floatValue from abstract NSNumber"]; else @@ -1165,7 +1168,7 @@ static Class doubleNumberClass; - (signed int) intValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get intValue from abstract NSNumber"]; else @@ -1275,7 +1278,7 @@ static Class doubleNumberClass; - (signed long long) longLongValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get longLongValue from abstract NSNumber"]; else @@ -1385,7 +1388,7 @@ static Class doubleNumberClass; - (signed long) longValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get longValue from abstract NSNumber"]; else @@ -1495,7 +1498,7 @@ static Class doubleNumberClass; - (signed short) shortValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get shortValue from abstract NSNumber"]; else @@ -1610,7 +1613,7 @@ static Class doubleNumberClass; - (unsigned char) unsignedCharValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedCharrValue from abstract NSNumber"]; else @@ -1720,7 +1723,7 @@ static Class doubleNumberClass; - (unsigned int) unsignedIntValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedIntValue from abstract NSNumber"]; else @@ -1830,7 +1833,7 @@ static Class doubleNumberClass; - (unsigned long long) unsignedLongLongValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedLongLongValue from abstract NSNumber"]; else @@ -1940,7 +1943,7 @@ static Class doubleNumberClass; - (unsigned long) unsignedLongValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedLongValue from abstract NSNumber"]; else @@ -2050,7 +2053,7 @@ static Class doubleNumberClass; - (unsigned short) unsignedShortValue { - if (fastClass(self) == abstractClass) + if (GSObjCClassOfObject(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedShortValue from abstract NSNumber"]; else diff --git a/Source/NSObject.m b/Source/NSObject.m index 123d572b7..eaf4999a4 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -40,14 +40,13 @@ #include #include #include +#include #include #include extern BOOL __objc_responds_to(id, SEL); -fastCls _fastCls; /* Structure to cache classes. */ - @class _FastMallocBuffer; static Class fastMallocClass; static unsigned fastMallocOffset; @@ -57,20 +56,6 @@ static Class NXConstantStringClass; @class NSDataMalloc; @class NSMutableDataMalloc; -void _fastBuildCache() -{ - /* - * Cache some classes for quick access later. - */ - - _fastCls._NSArray = [NSArray class]; - _fastCls._NSMutableArray = [NSMutableArray class]; - _fastCls._NSDictionary = [NSDictionary class]; - _fastCls._NSMutableDictionary = [NSMutableDictionary class]; - _fastCls._NSDataMalloc = [NSDataMalloc class]; - _fastCls._NSMutableDataMalloc = [NSMutableDataMalloc class]; -} - /* * Reference count and memory management @@ -424,7 +409,7 @@ NSDeallocateObject(NSObject *anObject) inline NSZone * fastZone(NSObject *object) { - if (fastClass(object) == NXConstantStringClass) + if (GSObjCClassOfObject(object) == NXConstantStringClass) return NSDefaultMallocZone(); return ((obj)object)[-1].zone; } @@ -434,7 +419,7 @@ fastZone(NSObject *object) inline NSZone * fastZone(NSObject *object) { - if (fastClass(object) == NXConstantStringClass) + if (GSObjCClassOfObject(object) == NXConstantStringClass) return NSDefaultMallocZone(); return NSZoneFromPointer(&((obj)object)[-1]); } @@ -495,7 +480,7 @@ NSDeallocateObject(NSObject *anObject) inline NSZone * fastZone(NSObject *object) { - if (fastClass(object) == NXConstantStringClass) + if (GSObjCClassOfObject(object) == NXConstantStringClass) return NSDefaultMallocZone(); return NSZoneFromPointer(object); } @@ -622,7 +607,6 @@ static BOOL double_release_check_enabled = NO; fastMallocOffset = 0; #endif NXConstantStringClass = [NXConstantString class]; - _fastBuildCache(); GSBuildStrings(); [[NSNotificationCenter defaultCenter] addObserver: self @@ -754,12 +738,12 @@ static BOOL deallocNotifications = NO; - (IMP) methodForSelector: (SEL)aSelector { /* - * If 'self' is an instance, fastClass() will get the class, + * If 'self' is an instance, GSObjCClassOfObject() will get the class, * and get_imp() will get the instance method. - * If 'self' is a class, fastClass() will get the meta-class, + * If 'self' is a class, GSObjCClassOfObject() will get the meta-class, * and get_imp() will get the class method. */ - return get_imp(fastClass(self), aSelector); + return get_imp(GSObjCClassOfObject(self), aSelector); } + (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector @@ -843,7 +827,6 @@ static BOOL deallocNotifications = NO; * We may have replaced a class in the cache, or may have replaced one * which had cached methods, so we must rebuild the cache. */ - _fastBuildCache(); } - (void) doesNotRecognizeSelector: (SEL)aSelector @@ -911,7 +894,7 @@ static BOOL deallocNotifications = NO; * use get_imp() because NSDistantObject doesn't implement * methodForSelector: */ - proxyImp = get_imp(fastClass((id)proxyClass), + proxyImp = get_imp(GSObjCClassOfObject((id)proxyClass), @selector(proxyWithLocal:connection:)); } @@ -1025,7 +1008,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(fastClass(self), aSelector); + msg = get_imp(GSObjCClassOfObject(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1046,7 +1029,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(fastClass(self), aSelector); + msg = get_imp(GSObjCClassOfObject(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1070,7 +1053,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(fastClass(self), aSelector); + msg = get_imp(GSObjCClassOfObject(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1113,9 +1096,9 @@ static BOOL deallocNotifications = NO; { #if 0 if (fastIsInstance(self)) - return (class_get_instance_method(fastClass(self), aSelector)!=METHOD_NULL); + return (class_get_instance_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL); else - return (class_get_class_method(fastClass(self), aSelector)!=METHOD_NULL); + return (class_get_class_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL); #else return __objc_responds_to(self, aSelector); #endif diff --git a/Source/NSScanner.m b/Source/NSScanner.m index 016be0d07..cb24dc991 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -126,7 +127,7 @@ typedef struct { aString = @""; } - c = fastClass(aString); + c = GSObjCClassOfObject(aString); if (c == GSUString_class) { _isUnicode = YES; diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 35aca19c5..98b70a226 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -133,8 +134,9 @@ static SEL setSel; static void initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u) { - Class c = fastClass(d); + Class c; + c = GSObjCClassOfObject(d); info->data = d; info->appImp = (void (*)())get_imp(c, appSel); info->datImp = (void* (*)())get_imp(c, datSel); @@ -160,8 +162,9 @@ endSerializerInfo(_NSSerializerInfo* info) static void serializeToInfo(id object, _NSSerializerInfo* info) { - Class c = fastClass(object); + Class c; + c = GSObjCClassOfObject(object); if (fastIsClass(c) == NO) { [NSException raise: NSInvalidArgumentException diff --git a/Source/NSSet.m b/Source/NSSet.m index 2f5244f72..4b52bed3d 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -31,6 +31,7 @@ #include #include #include +#include @interface NSSetNonCore : NSSet @end @@ -120,8 +121,9 @@ static Class NSMutableSet_concrete_class; - (id) initWithCoder: (NSCoder*)aCoder { unsigned count; - Class c = fastClass(self); + Class c; + c = GSObjCClassOfObject(self); if (c == NSSet_abstract_class) { RELEASE(self); diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index 1f6a75e92..4ad28c9cb 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -27,6 +27,7 @@ #include #include #include +#include /* * Setup for inline operation of arrays. @@ -294,6 +295,9 @@ mapClassName(NSUnarchiverObjectInfo *info) @implementation NSUnarchiver +@class NSDataMalloc; +static Class NSDataMallocClass; + + (void) initialize { if ([self class] == [NSUnarchiver class]) @@ -302,6 +306,7 @@ mapClassName(NSUnarchiverObjectInfo *info) tagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:); dValSel = @selector(decodeValueOfObjCType:at:); clsDict = [[NSMutableDictionary alloc] initWithCapacity: 200]; + NSDataMallocClass = [NSDataMalloc class]; } } @@ -328,7 +333,7 @@ mapClassName(NSUnarchiverObjectInfo *info) + (id) unarchiveObjectWithFile: (NSString*)path { - NSData *d = [_fastCls._NSDataMalloc dataWithContentsOfFile: path]; + NSData *d = [NSDataMallocClass dataWithContentsOfFile: path]; if (d != nil) { @@ -1144,7 +1149,7 @@ mapClassName(NSUnarchiverObjectInfo *info) TEST_RELEASE(data); data = RETAIN(anObject); - c = fastClass(data); + c = GSObjCClassOfObject(data); if (src != self) { src = data;