From 3df5d8e527e1e55604812345067856b83a1efe1b Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 31 Oct 2000 16:17:33 +0000 Subject: [PATCH] Basic tidyup for start of support for apple runtime git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7949 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 ++ Headers/gnustep/base/NSObjCRuntime.h | 75 +++++++++++++- Headers/gnustep/base/NSZone.h | 5 +- Headers/gnustep/base/fast.x | 149 --------------------------- Source/GNUmakefile | 1 - Source/GSString.m | 77 +++++++------- Source/Makefile.postamble | 16 --- Source/NSArchiver.m | 14 ++- Source/NSArray.m | 2 - Source/NSAttributedString.m | 1 - Source/NSCTemplateValue.m | 9 +- Source/NSCalendarDate.m | 3 +- Source/NSConcreteValue.m | 17 +-- Source/NSCountedSet.m | 3 +- Source/NSData.m | 22 ++-- Source/NSDate.m | 5 +- Source/NSDictionary.m | 7 +- Source/NSDistantObject.m | 3 +- Source/NSGAttributedString.m | 11 +- Source/NSGDictionary.m | 9 +- Source/NSGSet.m | 5 +- Source/NSInvocation.m | 1 - Source/NSNotificationCenter.m | 1 - Source/NSNumber.m | 34 +++--- Source/NSObjCRuntime.m | 5 +- Source/NSObject.m | 81 +++++++-------- Source/NSPage.m | 1 + Source/NSPortCoder.m | 10 +- Source/NSPortMessage.m | 2 +- Source/NSProxy.m | 2 +- Source/NSRunLoop.m | 1 - Source/NSScanner.m | 3 +- Source/NSSerializer.m | 17 ++- Source/NSSet.m | 3 +- Source/NSString.m | 38 ++++--- Source/NSUnarchiver.m | 7 +- Source/NSUser.m | 2 +- Source/NSZone.m | 2 +- Source/mframe.m | 1 + 39 files changed, 266 insertions(+), 388 deletions(-) delete mode 100644 Headers/gnustep/base/fast.x diff --git a/ChangeLog b/ChangeLog index a6ae35bbd..06370f954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2000-10-31 Richard Frith-Macdonald + + Loads of files modified, fast.x removed. + Found it unexpectedly easy to tidy up so that all functions for + accessing the runtime are now in NSObjCRuntime.h. + Now all :-) we need are Apple runtime implementations, configuration + auto-detect for the apple runtime, and loads of updating of any + bits of code that call the runtime directly. + 2000-10-31 Richard Frith-Macdonald * Headers/gnustep/base/NSGString.h: diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index 50bacd24b..50b15bc44 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.h @@ -25,6 +25,7 @@ #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE #include +#include #include #if BUILD_libgnustep_base_DLL @@ -36,6 +37,7 @@ #endif #define GS_DECLARE +@class NSObject; @class NSString; GS_EXPORT NSString *NSStringFromSelector(SEL aSelector); @@ -73,15 +75,84 @@ 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. + * GSObjCClass() return the class of an instance. * The argument to this function must NOT be nil. */ FOUNDATION_STATIC_INLINE Class -GSObjCClassOfObject(id obj) +GSObjCClass(id obj) { return obj->class_pointer; } +/* + * GSObjCIsInstance() tests to see if an id is an instance. + * The argument to this function must NOT be nil. + */ +FOUNDATION_STATIC_INLINE BOOL +GSObjCIsInstance(id obj) +{ + return CLS_ISCLASS(obj->class_pointer); +} + +/* + * GSObjCIsKindOf() tests to see if a class inherits from another class + * The argument to this function must NOT be nil. + */ +FOUNDATION_STATIC_INLINE BOOL +GSObjCIsKindOf(Class this, Class other) +{ + while (this != Nil) + { + if (this == other) + { + return YES; + } + this = class_get_super_class(this); + } + return NO; +} + +FOUNDATION_STATIC_INLINE const char* +GSObjCName(Class this) +{ + return this->name; +} + +FOUNDATION_STATIC_INLINE const char* +GSObjCSelectorName(SEL this) +{ + return sel_get_name(this); +} + +FOUNDATION_STATIC_INLINE const char* +GSObjCSelectorTypes(SEL this) +{ + return sel_get_type(this); +} + +FOUNDATION_STATIC_INLINE Class +GSObjCSuper(Class this) +{ + return class_get_super_class(this); +} + +FOUNDATION_STATIC_INLINE int +GSObjCVersion(Class this) +{ + return this->version; +} + +/* + * Return the zone in which an object belongs, without using the zone method + */ +#include +NSZone *GSObjCZone(NSObject *obj); + +/* + * Quickly return autoreleased data. + */ +void *_fastMallocBuffer(unsigned size); + #endif #endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/NSZone.h b/Headers/gnustep/base/NSZone.h index b81362374..9bb0b1814 100644 --- a/Headers/gnustep/base/NSZone.h +++ b/Headers/gnustep/base/NSZone.h @@ -23,11 +23,12 @@ #ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE #define __NSZone_h_GNUSTEP_BASE_INCLUDE -#include +typedef struct _NSZone NSZone; + +#include @class NSString; -typedef struct _NSZone NSZone; /* The members are the same as the structure mstats which is in the GNU C library. */ diff --git a/Headers/gnustep/base/fast.x b/Headers/gnustep/base/fast.x deleted file mode 100644 index c21a9be7d..000000000 --- a/Headers/gnustep/base/fast.x +++ /dev/null @@ -1,149 +0,0 @@ -/* Performance enhancing utilities GNUStep - Copyright (C) 1998 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Date: October 1998 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - */ - -#ifndef fast_x_INCLUDE -#define fast_x_INCLUDE - -#include -#include -#include - -#ifndef INLINE -#define INLINE inline -#endif - -/* - * This file is all to do with improving performance by avoiding the - * Objective-C messaging overhead in time-critical code. - * - * THIS STUFF IS GOING AWAY! - * - * 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. - */ - -/* - * The '_fastMallocBuffer()' function is called to get a chunk of - * memory that will automatically be released when the current - * autorelease pool goes away. - */ -GS_EXPORT void *_fastMallocBuffer(unsigned size); - -/* - * Fast access to class info - DON'T pass nil to these! - */ - -static INLINE BOOL -fastIsInstance(id obj) -{ - return CLS_ISCLASS(obj->class_pointer); -} - -static INLINE BOOL -fastIsClass(Class c) -{ - return CLS_ISCLASS(c); -} - -static INLINE Class -fastClass(NSObject* obj) -{ - return ((id)obj)->class_pointer; -} - -static INLINE Class -fastClassOfInstance(NSObject* obj) -{ - if (fastIsInstance((id)obj)) - return fastClass(obj); - return Nil; -} - -static INLINE Class -fastSuper(Class cls) -{ - return cls->super_class; -} - -static INLINE BOOL -fastClassIsKindOfClass(Class c0, Class c1) -{ - while (c0 != Nil) - { - if (c0 == c1) - return YES; - c0 = class_get_super_class(c0); - } - return NO; -} - -static INLINE BOOL -fastInstanceIsKindOfClass(NSObject *obj, Class c) -{ - Class ic = fastClassOfInstance(obj); - - if (ic == Nil) - return NO; - return fastClassIsKindOfClass(ic, c); -} - -static INLINE const char* -fastClassName(Class c) -{ - return c->name; -} - -static INLINE int -fastClassVersion(Class c) -{ - return c->version; -} - -static INLINE const char* -fastSelectorName(SEL s) -{ - return sel_get_name(s); -} - -static INLINE const char* -fastSelectorTypes(SEL s) -{ - return sel_get_type(s); -} - -/* - * fastZone(NSObject *obj) - * This function gets the zone that would be returned by the - * [NSObject -zone] instance method. Using this could mess you up in - * the unlikely event that you had an object that had overridden the - * '-zone' method. - * This function DOES know about NXConstantString, so it's pretty safe - * for normal use. - */ -GS_EXPORT NSZone *fastZone(NSObject* obj); - - -#endif diff --git a/Source/GNUmakefile b/Source/GNUmakefile index e0c4a584a..4e1b28dec 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -117,7 +117,6 @@ win32-def.top \ libgnustep-base.def GNU_HEADERS = \ -fast.x \ GSLocale.h \ GSUnion.h \ GSIArray.h \ diff --git a/Source/GSString.m b/Source/GSString.m index 67a7d0f4d..7a8c39c4d 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -47,7 +47,6 @@ #include /* memcpy(), strlen(), strcmp() are gcc builtin's */ -#include #include /* @@ -357,14 +356,14 @@ compare_c(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"compare with nil"]; - if (fastIsInstance(aString) == NO) + if (GSObjCIsInstance(aString) == NO) return strCompCsNs((id)self, aString, mask, aRange); - c = GSObjCClassOfObject(aString); - if (fastClassIsKindOfClass(c, GSUStringClass) == YES + c = GSObjCClass(aString); + if (GSObjCIsKindOf(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strCompCsUs((id)self, aString, mask, aRange); - else if (fastClassIsKindOfClass(c, GSCStringClass) == YES + else if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 0)) return strCompCsCs((id)self, aString, mask, aRange); @@ -379,14 +378,14 @@ compare_u(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"compare with nil"]; - if (fastIsInstance(aString) == NO) + if (GSObjCIsInstance(aString) == NO) return strCompUsNs((id)self, aString, mask, aRange); - c = GSObjCClassOfObject(aString); - if (fastClassIsKindOfClass(c, GSUStringClass) + c = GSObjCClass(aString); + if (GSObjCIsKindOf(c, GSUStringClass) || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strCompUsUs((id)self, aString, mask, aRange); - else if (fastClassIsKindOfClass(c, GSCStringClass) + else if (GSObjCIsKindOf(c, GSCStringClass) || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 0)) return strCompUsCs((id)self, aString, mask, aRange); @@ -767,11 +766,11 @@ isEqual_c(ivars self, id anObject) { return NO; } - if (fastIsInstance(anObject) == NO) + if (GSObjCIsInstance(anObject) == NO) { return NO; } - c = fastClassOfInstance(anObject); + c = GSObjCClass(anObject); if (c == NXConstantStringClass) { ivars other = (ivars)anObject; @@ -781,7 +780,7 @@ isEqual_c(ivars self, id anObject) return YES; return NO; } - else if (fastClassIsKindOfClass(c, GSStringClass) == YES) + else if (GSObjCIsKindOf(c, GSStringClass) == YES) { ivars other = (ivars)anObject; NSRange r = {0, self->_count}; @@ -811,7 +810,7 @@ isEqual_c(ivars self, id anObject) } return NO; } - else if (fastClassIsKindOfClass(c, NSStringClass)) + else if (GSObjCIsKindOf(c, NSStringClass)) { return (*equalImp)((id)self, equalSel, anObject); } @@ -834,11 +833,11 @@ isEqual_u(ivars self, id anObject) { return NO; } - if (fastIsInstance(anObject) == NO) + if (GSObjCIsInstance(anObject) == NO) { return NO; } - c = fastClassOfInstance(anObject); + c = GSObjCClass(anObject); if (c == NXConstantStringClass) { ivars other = (ivars)anObject; @@ -848,7 +847,7 @@ isEqual_u(ivars self, id anObject) return YES; return NO; } - else if (fastClassIsKindOfClass(c, GSStringClass) == YES) + else if (GSObjCIsKindOf(c, GSStringClass) == YES) { ivars other = (ivars)anObject; NSRange r = {0, self->_count}; @@ -878,7 +877,7 @@ isEqual_u(ivars self, id anObject) } return NO; } - else if (fastClassIsKindOfClass(c, NSStringClass)) + else if (GSObjCIsKindOf(c, NSStringClass)) { return (*equalImp)((id)self, equalSel, anObject); } @@ -951,7 +950,7 @@ makeHole(ivars self, int index, int size) #if GS_WITH_GC self->_zone = GSAtomicMallocZone(); #else - self->_zone = fastZone((NSObject*)self); + self->_zone = GSObjCZone((NSObject*)self); #endif } if (self->_flags.wide == 1) @@ -1055,14 +1054,14 @@ rangeOfString_c(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"range of nil"]; - if (fastIsInstance(aString) == NO) + if (GSObjCIsInstance(aString) == NO) return strRangeCsNs((id)self, aString, mask, aRange); - c = GSObjCClassOfObject(aString); - if (fastClassIsKindOfClass(c, GSUStringClass) == YES + c = GSObjCClass(aString); + if (GSObjCIsKindOf(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strRangeCsUs((id)self, aString, mask, aRange); - else if (fastClassIsKindOfClass(c, GSCStringClass) == YES + else if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 0)) return strRangeCsCs((id)self, aString, mask, aRange); @@ -1077,14 +1076,14 @@ rangeOfString_u(ivars self, NSString *aString, unsigned mask, NSRange aRange) if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"range of nil"]; - if (fastIsInstance(aString) == NO) + if (GSObjCIsInstance(aString) == NO) return strRangeUsNs((id)self, aString, mask, aRange); - c = GSObjCClassOfObject(aString); - if (fastClassIsKindOfClass(c, GSUStringClass) == YES + c = GSObjCClass(aString); + if (GSObjCIsKindOf(c, GSUStringClass) == YES || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 1)) return strRangeUsUs((id)self, aString, mask, aRange); - else if (fastClassIsKindOfClass(c, GSCStringClass) == YES + else if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)aString)->_flags.wide == 0)) return strRangeUsCs((id)self, aString, mask, aRange); @@ -1138,7 +1137,7 @@ transmute(ivars self, NSString *aString) { ivars other; BOOL transmute; - Class c = GSObjCClassOfObject(aString); // NB aString must not be nil + Class c = GSObjCClass(aString); // NB aString must not be nil other = (ivars)aString; transmute = YES; @@ -2063,7 +2062,7 @@ transmute(ivars self, NSString *aString) #if GS_WITH_GC _zone = GSAtomicMallocZone(); #else - _zone = fastZone(self); + _zone = GSObjCZone(self); #endif _contents.c = NSZoneMalloc(_zone, capacity + 1); _flags.wide = 0; @@ -2206,7 +2205,7 @@ transmute(ivars self, NSString *aString) if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"replace characters with nil string"]; - if (fastIsInstance(aString) == NO) + if (GSObjCIsInstance(aString) == NO) [NSException raise: NSInvalidArgumentException format: @"replace characters with non-string"]; @@ -2543,13 +2542,13 @@ transmute(ivars self, NSString *aString) { return NO; } - if (fastIsInstance(anObject) == NO) + if (GSObjCIsInstance(anObject) == NO) { return NO; } - c = fastClassOfInstance(anObject); + c = GSObjCClass(anObject); - if (fastClassIsKindOfClass(c, GSCStringClass) == YES + if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)anObject)->_flags.wide == 0)) { @@ -2561,14 +2560,14 @@ transmute(ivars self, NSString *aString) return NO; return YES; } - else if (fastClassIsKindOfClass(c, GSUStringClass) == YES + else if (GSObjCIsKindOf(c, GSUStringClass) == YES || c == GSMStringClass) { if (strCompCsUs(self, anObject, 0, (NSRange){0,_count}) == NSOrderedSame) return YES; return NO; } - else if (fastClassIsKindOfClass(c, NSStringClass)) + else if (GSObjCIsKindOf(c, NSStringClass)) { return (*equalImp)(self, equalSel, anObject); } @@ -2590,13 +2589,13 @@ transmute(ivars self, NSString *aString) { return NO; } - if (fastIsInstance(anObject) == NO) + if (GSObjCIsInstance(anObject) == NO) { return NO; } - c = fastClassOfInstance(anObject); + c = GSObjCClass(anObject); - if (fastClassIsKindOfClass(c, GSCStringClass) == YES + if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NXConstantStringClass || (c == GSMStringClass && ((ivars)anObject)->_flags.wide == 0)) { @@ -2608,14 +2607,14 @@ transmute(ivars self, NSString *aString) return NO; return YES; } - else if (fastClassIsKindOfClass(c, GSUStringClass) == YES + else if (GSObjCIsKindOf(c, GSUStringClass) == YES || c == GSMStringClass) { if (strCompCsUs(self, anObject, 0, (NSRange){0,_count}) == NSOrderedSame) return YES; return NO; } - else if (fastClassIsKindOfClass(c, NSStringClass)) + else if (GSObjCIsKindOf(c, NSStringClass)) { return (*equalImp)(self, equalSel, anObject); } diff --git a/Source/Makefile.postamble b/Source/Makefile.postamble index c3ee4df1b..56aba46c9 100644 --- a/Source/Makefile.postamble +++ b/Source/Makefile.postamble @@ -228,22 +228,6 @@ $(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \ $(GNUSTEP_OBJ_DIR)/NSSerializer.o \ : $(HEADER_DIR)/GSIMap.h $(HEADER_DIR)/GSUnion.h -# -# Files that include fast.x 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)/fast.x - # # Files that include NSObjCRuntime.h will need a rebuild if it is changed. # diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index 054aa8134..67460e9d9 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -22,7 +22,6 @@ */ #include -#include /* * Setup for inline operation of pointer map tables. */ @@ -39,14 +38,13 @@ #include #undef _IN_NSARCHIVER_M +#include #include #include #include #include #include -#include - typedef unsigned char uchar; @@ -80,7 +78,7 @@ static Class NSMutableDataMallocClass; { NSMutableData *d; - d = [[NSMutableDataMallocClass allocWithZone: fastZone(self)] init]; + d = [[NSMutableDataMallocClass allocWithZone: GSObjCZone(self)] init]; self = [self initForWritingWithMutableData: d]; RELEASE(d); return self; @@ -415,9 +413,9 @@ static Class NSMutableDataMallocClass; } while (done == NO) { - int tmp = fastClassVersion(c); + int tmp = GSObjCVersion(c); unsigned version = tmp; - Class s = fastSuper(c); + Class s = GSObjCSuper(c); if (tmp < 0) { @@ -777,7 +775,7 @@ static Class NSMutableDataMallocClass; } obj = [anObject replacementObjectForArchiver: self]; - if (fastIsInstance(obj) == NO) + if (GSObjCIsInstance(obj) == NO) { /* * If the object we have been given is actually a class, @@ -829,7 +827,7 @@ static Class NSMutableDataMallocClass; if (node) { c = (Class)node->value.ptr; - return [NSString stringWithCString: fastClassName(c)]; + return [NSString stringWithCString: GSObjCName(c)]; } } return trueName; diff --git a/Source/NSArray.m b/Source/NSArray.m index 12135fc69..d0e700ddb 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -40,8 +40,6 @@ #include #include -#include - @class NSArrayEnumerator; @class NSArrayEnumeratorReverse; diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index f3ca25d2c..474a57fea 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -45,7 +45,6 @@ #include "config.h" #include -#include #include #include diff --git a/Source/NSCTemplateValue.m b/Source/NSCTemplateValue.m index e0bc3d56e..a37fa913c 100644 --- a/Source/NSCTemplateValue.m +++ b/Source/NSCTemplateValue.m @@ -29,7 +29,6 @@ #include #include #include -#include /* This file should be run through a preprocessor with the macro TYPE_ORDER defined to a number from 0 to 4 cooresponding to each value type */ @@ -82,8 +81,8 @@ - (BOOL) isEqual: (id)other { - if (other != nil - && fastInstanceIsKindOfClass(other, GSObjCClassOfObject(self))) + if (other != nil && GSObjCIsInstance(other) == YES + && GSObjCIsKindOf(GSObjCClass(other), GSObjCClass(self))) { return [self isEqualToValue: other]; } @@ -94,8 +93,8 @@ { typedef __typeof__(data) _dt; - if (aValue != nil - && fastInstanceIsKindOfClass(aValue, GSObjCClassOfObject(self))) + if (aValue != nil && GSObjCIsInstance(aValue) == YES + && GSObjCIsKindOf(GSObjCClass(aValue), GSObjCClass(self))) { _dt val = [aValue TYPE_METHOD]; #if TYPE_ORDER == 0 diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 8a5823fdb..0632a7495 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -23,8 +23,7 @@ #include #include -#include -#include +#include #include #include #include diff --git a/Source/NSConcreteValue.m b/Source/NSConcreteValue.m index 9b94f4972..fef3a516a 100644 --- a/Source/NSConcreteValue.m +++ b/Source/NSConcreteValue.m @@ -30,7 +30,6 @@ #include #include #include -#include /* This is the real, general purpose value object. I've implemented all the methods here (like pointValue) even though most likely, other concrete @@ -64,10 +63,10 @@ return nil; } - data = (void *)NSZoneMalloc(fastZone(self), size); + data = (void *)NSZoneMalloc(GSObjCZone(self), size); memcpy(data, value, size); - objctype = (char *)NSZoneMalloc(fastZone(self), strlen(type)+1); + objctype = (char *)NSZoneMalloc(GSObjCZone(self), strlen(type)+1); strcpy(objctype, type); return self; } @@ -75,9 +74,9 @@ - (void) dealloc { if (objctype) - NSZoneFree(fastZone(self), objctype); + NSZoneFree(GSObjCZone(self), objctype); if (data) - NSZoneFree(fastZone(self), data); + NSZoneFree(GSObjCZone(self), data); [super dealloc]; } @@ -105,7 +104,9 @@ - (BOOL) isEqualToValue: (NSValue*)aValue { - if (GSObjCClassOfObject(aValue) != GSObjCClassOfObject(self)) + if (aValue == nil) + return NO; + if (GSObjCClass(aValue) != GSObjCClass(self)) return NO; if (strcmp(objctype, ((NSConcreteValue*)aValue)->objctype) != 0) return NO; @@ -178,10 +179,10 @@ unsigned size; [coder decodeValueOfObjCType: @encode(unsigned) at: &size]; - objctype = (void *)NSZoneMalloc(fastZone(self), size); + objctype = (void *)NSZoneMalloc(GSObjCZone(self), size); [coder decodeArrayOfObjCType: @encode(char) count: size at: objctype]; [coder decodeValueOfObjCType: @encode(unsigned) at: &size]; - data = (void *)NSZoneMalloc(fastZone(self), size); + data = (void *)NSZoneMalloc(GSObjCZone(self), size); [coder decodeArrayOfObjCType: @encode(unsigned char) count: size at: data]; return self; diff --git a/Source/NSCountedSet.m b/Source/NSCountedSet.m index 5a11c0ae4..d271e2930 100644 --- a/Source/NSCountedSet.m +++ b/Source/NSCountedSet.m @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -111,7 +110,7 @@ static Class NSCountedSet_concrete_class; - (id) initWithCoder: (NSCoder*)aCoder { unsigned count; - Class c = GSObjCClassOfObject(self); + Class c = GSObjCClass(self); if (c == NSCountedSet_abstract_class) { diff --git a/Source/NSData.m b/Source/NSData.m index c899f0031..8bb23c6d9 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -61,10 +61,8 @@ */ #include -#include -#include -#include #include +#include #include #include #include @@ -464,7 +462,7 @@ failure: #if GS_WITH_GC zone = GSAtomicMallocZone(); #else - zone = fastZone(self); + zone = GSObjCZone(self); #endif if (readContentsOfFile(path, &fileBytes, &fileLength, zone) == NO) { @@ -482,7 +480,7 @@ failure: { #if HAVE_MMAP RELEASE(self); - self = [NSDataMappedFile allocWithZone: fastZone(self)]; + self = [NSDataMappedFile allocWithZone: GSObjCZone(self)]; return [self initWithContentsOfMappedFile: path]; #else return [self initWithContentsOfFile: path]; @@ -1697,7 +1695,7 @@ failure: } case _C_CLASS: { - const char *name = *(Class*)data?fastClassName(*(Class*)data):""; + const char *name = *(Class*)data?GSObjCName(*(Class*)data):""; gsu16 ln = (gsu16)strlen(name); gsu16 ni; @@ -1711,9 +1709,9 @@ failure: } case _C_SEL: { - const char *name = *(SEL*)data?fastSelectorName(*(SEL*)data):""; + const char *name = *(SEL*)data?GSObjCSelectorName(*(SEL*)data):""; gsu16 ln = (name == 0) ? 0 : (gsu16)strlen(name); - const char *types = *(SEL*)data?fastSelectorTypes(*(SEL*)data):""; + const char *types = *(SEL*)data?GSObjCSelectorTypes(*(SEL*)data):""; gsu16 lt = (types == 0) ? 0 : (gsu16)strlen(types); gsu16 ni; @@ -2593,7 +2591,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) #if GS_WITH_GC zone = GSAtomicMallocZone(); #else - zone = fastZone(self); + zone = GSObjCZone(self); #endif if (size) { @@ -2863,7 +2861,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _C_CLASS: { - const char *name = *(Class*)data?fastClassName(*(Class*)data):""; + const char *name = *(Class*)data?GSObjCName(*(Class*)data):""; gsu16 ln = (gsu16)strlen(name); gsu16 minimum = length + ln + sizeof(gsu16); gsu16 ni; @@ -2884,9 +2882,9 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _C_SEL: { - const char *name = *(SEL*)data?fastSelectorName(*(SEL*)data):""; + const char *name = *(SEL*)data?GSObjCSelectorName(*(SEL*)data):""; gsu16 ln = (name == 0) ? 0 : (gsu16)strlen(name); - const char *types = *(SEL*)data?fastSelectorTypes(*(SEL*)data):""; + const char *types = *(SEL*)data?GSObjCSelectorTypes(*(SEL*)data):""; gsu16 lt = (types == 0) ? 0 : (gsu16)strlen(types); gsu16 minimum = length + ln + lt + 2*sizeof(gsu16); gsu16 ni; diff --git a/Source/NSDate.m b/Source/NSDate.m index 8a8a0a2c4..d29bed5c3 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -36,7 +36,6 @@ #include #include #include -#include #if HAVE_SYS_TIME_H #include #endif @@ -102,9 +101,9 @@ otherTime(NSDate* other) if (other == nil) [NSException raise: NSInvalidArgumentException format: @"other time nil"]; - if (fastIsInstance(other) == NO) + if (GSObjCIsInstance(other) == NO) [NSException raise: NSInvalidArgumentException format: @"other time bad"]; - c = GSObjCClassOfObject(other); + c = GSObjCClass(other); if (c == concreteClass || c == calendarClass) return ((NSGDate*)other)->_seconds_since_ref; else diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index a392f40da..e87abf801 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -780,14 +779,14 @@ static NSString *indentStrings[] = { for (i = 0; i < numKeys; i++) { - if (GSObjCClassOfObject(keys[i]) == lastClass) + if (GSObjCClass(keys[i]) == lastClass) continue; if ([keys[i] respondsToSelector: @selector(compare:)] == NO) { canCompare = NO; break; } - lastClass = GSObjCClassOfObject(keys[i]); + lastClass = GSObjCClass(keys[i]); } if (canCompare == YES) @@ -831,7 +830,7 @@ static NSString *indentStrings[] = { Class x; NSComparisonResult r; - x = GSObjCClassOfObject(a); + x = GSObjCClass(a); if (x != lastClass) { lastClass = x; diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index a4e2dc10e..88578d781 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -743,7 +742,7 @@ enum - (IMP) methodForSelector: (SEL)aSelector { - return get_imp(GSObjCClassOfObject((id)self), aSelector); + return get_imp(GSObjCClass((id)self), aSelector); } - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector diff --git a/Source/NSGAttributedString.m b/Source/NSGAttributedString.m index 7cf187e96..fe84701ab 100644 --- a/Source/NSGAttributedString.m +++ b/Source/NSGAttributedString.m @@ -51,7 +51,6 @@ #include #include #include -#include #define SANITY_CHECKS 0 @@ -150,7 +149,7 @@ _setAttributesFrom( NSRange aRange, NSMutableArray *_infoArray) { - NSZone *z = fastZone(_infoArray); + NSZone *z = GSObjCZone(_infoArray); NSRange range; NSDictionary *attr; GSAttrInfo *info; @@ -272,7 +271,7 @@ _attributesAtIndexEffectiveRange( - (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes { - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); _infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1]; if (aString != nil && [aString isKindOfClass: [NSAttributedString class]]) @@ -356,7 +355,7 @@ _attributesAtIndexEffectiveRange( - (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes { - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); _infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1]; if (aString != nil && [aString isKindOfClass: [NSAttributedString class]]) @@ -402,7 +401,7 @@ SANITY(); NSRange effectiveRange; unsigned afterRangeLoc, beginRangeLoc; NSDictionary *attrs; - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); GSAttrInfo *info; if (range.length == 0) @@ -504,7 +503,7 @@ SANITY(); NSDictionary *attrs; GSAttrInfo *info; int moveLocations; - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); unsigned start; SANITY(); diff --git a/Source/NSGDictionary.m b/Source/NSGDictionary.m index 7e50c6dbc..cf89ee5d1 100644 --- a/Source/NSGDictionary.m +++ b/Source/NSGDictionary.m @@ -32,7 +32,6 @@ #include #include -#include /* * The 'Fastmap' stuff provides an inline implementation of a mapping @@ -133,7 +132,7 @@ static SEL objSel; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; - GSIMapInitWithZoneAndCapacity(&map, fastZone(self), count); + GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), count); while (count-- > 0) { (*imp)(aCoder, sel, type, &key); @@ -148,7 +147,7 @@ static SEL objSel; { int i; - GSIMapInitWithZoneAndCapacity(&map, fastZone(self), c); + GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), c); for (i = 0; i < c; i++) { GSIMapNode node; @@ -187,7 +186,7 @@ static SEL objSel; - (id) initWithDictionary: (NSDictionary*)other copyItems: (BOOL)shouldCopy { - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); unsigned c = [other count]; GSIMapInitWithZoneAndCapacity(&map, z, c); @@ -284,7 +283,7 @@ static SEL objSel; /* Designated initialiser */ - (id) initWithCapacity: (unsigned)cap { - GSIMapInitWithZoneAndCapacity(&map, fastZone(self), cap); + GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), cap); return self; } diff --git a/Source/NSGSet.m b/Source/NSGSet.m index fef35c095..21600cd26 100644 --- a/Source/NSGSet.m +++ b/Source/NSGSet.m @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -250,7 +249,7 @@ static Class mutableSetClass; return NO; // Loop for all members in otherSet - c = GSObjCClassOfObject(otherSet); + c = GSObjCClass(otherSet); if (c == setClass || c == mutableSetClass) { GSIMapNode node = ((NSGSet*)otherSet)->map.firstNode; @@ -320,7 +319,7 @@ static Class mutableSetClass; } else { - Class c = GSObjCClassOfObject(other); + Class c = GSObjCClass(other); if (c == setClass || c == mutableSetClass) { diff --git a/Source/NSInvocation.m b/Source/NSInvocation.m index 0b1e8ff8b..29deaf6c2 100644 --- a/Source/NSInvocation.m +++ b/Source/NSInvocation.m @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index 5a3dd5f54..03aa9bbb2 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -30,7 +30,6 @@ #include #include #include -#include typedef struct { @defs(NSNotification) diff --git a/Source/NSNumber.m b/Source/NSNumber.m index c9004c542..8f9985174 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +58,7 @@ GSNumberInfoFromObject(NSNumber *o) if (o == nil) return nil; - c = GSObjCClassOfObject(o); + c = GSObjCClass(o); info = (GSNumberInfo*)NSMapGet (numberMap, (void*)c); if (info == 0) { @@ -667,7 +666,7 @@ static Class doubleNumberClass; - (NSString*) descriptionWithLocale: (NSDictionary*)locale { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) { [NSException raise: NSInternalInconsistencyException format: @"descriptionWithLocale: for abstract NSNumber"]; @@ -728,7 +727,7 @@ static Class doubleNumberClass; /* All the rest of these methods must be implemented by a subclass */ - (BOOL) boolValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get boolValue from abstract NSNumber"]; else @@ -838,7 +837,7 @@ static Class doubleNumberClass; - (signed char) charValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get charValue from abstract NSNumber"]; else @@ -948,7 +947,7 @@ static Class doubleNumberClass; - (double) doubleValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get doubleValue from abstract NSNumber"]; else @@ -1058,7 +1057,7 @@ static Class doubleNumberClass; - (float) floatValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get floatValue from abstract NSNumber"]; else @@ -1168,7 +1167,7 @@ static Class doubleNumberClass; - (signed int) intValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get intValue from abstract NSNumber"]; else @@ -1278,7 +1277,7 @@ static Class doubleNumberClass; - (signed long long) longLongValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get longLongValue from abstract NSNumber"]; else @@ -1388,7 +1387,7 @@ static Class doubleNumberClass; - (signed long) longValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get longValue from abstract NSNumber"]; else @@ -1498,7 +1497,7 @@ static Class doubleNumberClass; - (signed short) shortValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get shortValue from abstract NSNumber"]; else @@ -1613,7 +1612,7 @@ static Class doubleNumberClass; - (unsigned char) unsignedCharValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedCharrValue from abstract NSNumber"]; else @@ -1723,7 +1722,7 @@ static Class doubleNumberClass; - (unsigned int) unsignedIntValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedIntValue from abstract NSNumber"]; else @@ -1833,7 +1832,7 @@ static Class doubleNumberClass; - (unsigned long long) unsignedLongLongValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedLongLongValue from abstract NSNumber"]; else @@ -1943,7 +1942,7 @@ static Class doubleNumberClass; - (unsigned long) unsignedLongValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedLongValue from abstract NSNumber"]; else @@ -2053,7 +2052,7 @@ static Class doubleNumberClass; - (unsigned short) unsignedShortValue { - if (GSObjCClassOfObject(self) == abstractClass) + if (GSObjCClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException format: @"get unsignedShortValue from abstract NSNumber"]; else @@ -2227,7 +2226,8 @@ static Class doubleNumberClass; { return NO; } - else if (fastIsInstance(o) && fastInstanceIsKindOfClass(o, abstractClass)) + else if (GSObjCIsInstance(o) == YES + && GSObjCIsKindOf(GSObjCClass(o), abstractClass)) { return [self isEqualToNumber: (NSNumber*)o]; } diff --git a/Source/NSObjCRuntime.m b/Source/NSObjCRuntime.m index 93675cecf..71e9b8ac7 100644 --- a/Source/NSObjCRuntime.m +++ b/Source/NSObjCRuntime.m @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -32,7 +31,7 @@ NSString * NSStringFromSelector(SEL aSelector) { if (aSelector != (SEL)0) - return [NSString stringWithCString: (char*)sel_get_name(aSelector)]; + return [NSString stringWithCString: GSObjCSelectorName(aSelector)]; return nil; } @@ -56,7 +55,7 @@ NSString * NSStringFromClass(Class aClass) { if (aClass != (Class)0) - return [NSString stringWithCString: (char*)fastClassName(aClass)]; + return [NSString stringWithCString: (char*)GSObjCName(aClass)]; return nil; } diff --git a/Source/NSObject.m b/Source/NSObject.m index eaf4999a4..97a958a43 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -43,8 +42,6 @@ #include #include -#include - extern BOOL __objc_responds_to(id, SEL); @class _FastMallocBuffer; @@ -330,7 +327,7 @@ NSExtraRefCount (id anObject) #include inline NSZone * -fastZone(NSObject *object) +GSObjCZone(NSObject *object) { return 0; } @@ -363,7 +360,8 @@ NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone) if (gc_type == 0) { new = NSZoneMalloc(zone, size); - NSLog(@"No garbage collection information for '%s'", aClass->name); + NSLog(@"No garbage collection information for '%s'", + GSObjCName(aClass)); } else if ([aClass requiresTypedMemory]) { @@ -407,9 +405,9 @@ NSDeallocateObject(NSObject *anObject) #if defined(CACHE_ZONE) inline NSZone * -fastZone(NSObject *object) +GSObjCZone(NSObject *object) { - if (GSObjCClassOfObject(object) == NXConstantStringClass) + if (GSObjCClass(object) == NXConstantStringClass) return NSDefaultMallocZone(); return ((obj)object)[-1].zone; } @@ -417,9 +415,9 @@ fastZone(NSObject *object) #else /* defined(CACHE_ZONE) */ inline NSZone * -fastZone(NSObject *object) +GSObjCZone(NSObject *object) { - if (GSObjCClassOfObject(object) == NXConstantStringClass) + if (GSObjCClass(object) == NXConstantStringClass) return NSDefaultMallocZone(); return NSZoneFromPointer(&((obj)object)[-1]); } @@ -464,7 +462,7 @@ NSDeallocateObject(NSObject *anObject) if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer)) { obj o = &((obj)anObject)[-1]; - NSZone *z = fastZone(anObject); + NSZone *z = GSObjCZone(anObject); #ifndef NDEBUG GSDebugAllocationRemove(((id)anObject)->class_pointer); @@ -478,9 +476,9 @@ NSDeallocateObject(NSObject *anObject) #else inline NSZone * -fastZone(NSObject *object) +GSObjCZone(NSObject *object) { - if (GSObjCClassOfObject(object) == NXConstantStringClass) + if (GSObjCClass(object) == NXConstantStringClass) return NSDefaultMallocZone(); return NSZoneFromPointer(object); } @@ -530,7 +528,7 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone) return YES; #else return (!requestedZone || requestedZone == NSDefaultMallocZone() - || fastZone(anObject) == requestedZone); + || GSObjCZone(anObject) == requestedZone); #endif } @@ -738,12 +736,12 @@ static BOOL deallocNotifications = NO; - (IMP) methodForSelector: (SEL)aSelector { /* - * If 'self' is an instance, GSObjCClassOfObject() will get the class, + * If 'self' is an instance, GSObjCClass() will get the class, * and get_imp() will get the instance method. - * If 'self' is a class, GSObjCClassOfObject() will get the meta-class, + * If 'self' is a class, GSObjCClass() will get the meta-class, * and get_imp() will get the class method. */ - return get_imp(GSObjCClassOfObject(self), aSelector); + return get_imp(GSObjCClass(self), aSelector); } + (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector @@ -761,9 +759,9 @@ static BOOL deallocNotifications = NO; { struct objc_method *mth; - mth = (object_is_instance(self) - ? class_get_instance_method(self->isa, aSelector) - : class_get_class_method(self->isa, aSelector)); + mth = (GSObjCIsInstance(self) + ? class_get_instance_method(GSObjCClass(self), aSelector) + : class_get_class_method(GSObjCClass(self), aSelector)); if (mth == 0) { return nil; @@ -894,7 +892,7 @@ static BOOL deallocNotifications = NO; * use get_imp() because NSDistantObject doesn't implement * methodForSelector: */ - proxyImp = get_imp(GSObjCClassOfObject((id)proxyClass), + proxyImp = get_imp(GSObjCClass((id)proxyClass), @selector(proxyWithLocal:connection:)); } @@ -970,26 +968,19 @@ static BOOL deallocNotifications = NO; - (BOOL) isKindOfClass: (Class)aClass { - Class class; + Class class = GSObjCClass(self); - for (class = self->isa; - class != Nil; - class = class_get_super_class (class)) - { - if (class == aClass) - return YES; - } - return NO; + return GSObjCIsKindOf(class, aClass); } + (BOOL) isMemberOfClass: (Class)aClass { - return self == aClass; + return (self == aClass) ? YES : NO; } - (BOOL) isMemberOfClass: (Class)aClass { - return self->isa==aClass; + return (GSObjCClass(self) == aClass) ? YES : NO; } - (BOOL) isProxy @@ -1008,7 +999,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(GSObjCClassOfObject(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1029,7 +1020,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(GSObjCClassOfObject(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1053,7 +1044,7 @@ static BOOL deallocNotifications = NO; return nil; } - msg = get_imp(GSObjCClassOfObject(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException @@ -1095,10 +1086,10 @@ static BOOL deallocNotifications = NO; - (BOOL) respondsToSelector: (SEL)aSelector { #if 0 - if (fastIsInstance(self)) - return (class_get_instance_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL); + if (GSObjCIsInstance(self)) + return (class_get_instance_method(GSObjCClass(self), aSelector)!=METHOD_NULL); else - return (class_get_class_method(GSObjCClassOfObject(self), aSelector)!=METHOD_NULL); + return (class_get_class_method(GSObjCClass(self), aSelector)!=METHOD_NULL); #else return __objc_responds_to(self, aSelector); #endif @@ -1138,7 +1129,7 @@ static BOOL deallocNotifications = NO; - (NSZone*) zone { - return fastZone(self); + return GSObjCZone(self); } - (void) encodeWithCoder: (NSCoder*)aCoder @@ -1181,7 +1172,7 @@ static BOOL deallocNotifications = NO; va_list ap; sprintf(fmt, FMT, object_get_class_name(self), - object_is_instance(self)?"instance":"class", + GSObjCIsInstance(self)?"instance":"class", (aString!=NULL)?aString:""); va_start(ap, aString); /* xxx What should `code' argument be? Current 0. */ @@ -1344,13 +1335,13 @@ static BOOL deallocNotifications = NO; - (BOOL) isInstance { - return object_is_instance(self); + return GSObjCIsInstance(self); } - (BOOL) isMemberOfClassNamed: (const char*)aClassName { return ((aClassName!=NULL) - &&!strcmp(class_get_class_name(self->isa), aClassName)); + &&!strcmp(GSObjCName(GSObjCClass(self)), aClassName)); } + (struct objc_method_description *) descriptionForInstanceMethod: (SEL)aSel @@ -1362,14 +1353,14 @@ static BOOL deallocNotifications = NO; - (struct objc_method_description *) descriptionForMethod: (SEL)aSel { return ((struct objc_method_description *) - (object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))); + (GSObjCIsInstance(self) + ?class_get_instance_method(GSObjCClass(self), aSel) + :class_get_class_method(GSObjCClass(self), aSel))); } - (Class) transmuteClassTo: (Class)aClassObject { - if (object_is_instance(self)) + if (GSObjCIsInstance(self) == YES) if (class_is_class(aClassObject)) if (class_get_instance_size(aClassObject)==class_get_instance_size(isa)) if ([self isKindOfClass:aClassObject]) diff --git a/Source/NSPage.m b/Source/NSPage.m index c2e0fcae2..8a74d329d 100644 --- a/Source/NSPage.m +++ b/Source/NSPage.m @@ -23,6 +23,7 @@ #include #include +#include #include #include #ifdef __WIN32__ diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index 581163da9..035fa22af 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -31,8 +31,8 @@ #include #include -#include +#include #include #include #include @@ -43,8 +43,6 @@ #include #include -#include - /* * Setup for inline operation of pointer map tables. */ @@ -1229,7 +1227,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ } obj = [anObject replacementObjectForPortCoder: self]; - if (fastIsInstance(obj) == NO) + if (GSObjCIsInstance(obj) == NO) { /* * If the object we have been given is actually a class, @@ -1456,9 +1454,9 @@ static IMP _xRefImp; /* Serialize a crossref. */ } while (done == NO) { - int tmp = fastClassVersion(c); + int tmp = GSObjCVersion(c); unsigned version = tmp; - Class s = fastSuper(c); + Class s = GSObjCSuper(c); if (tmp < 0) { diff --git a/Source/NSPortMessage.m b/Source/NSPortMessage.m index b49df9be0..fcea13ebe 100644 --- a/Source/NSPortMessage.m +++ b/Source/NSPortMessage.m @@ -22,11 +22,11 @@ */ #include -#include #include #include #include #include +#include @implementation NSPortMessage diff --git a/Source/NSProxy.m b/Source/NSProxy.m index cfbb9cd2d..05522b614 100644 --- a/Source/NSProxy.m +++ b/Source/NSProxy.m @@ -27,9 +27,9 @@ #include #include #include +#include #include "limits.h" -#include @implementation NSProxy diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 2dffadc45..d47ec3486 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/Source/NSScanner.m b/Source/NSScanner.m index cb24dc991..573cf91ca 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -127,7 +126,7 @@ typedef struct { aString = @""; } - c = GSObjCClassOfObject(aString); + c = GSObjCClass(aString); if (c == GSUString_class) { _isUnicode = YES; diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 98b70a226..c7012d97d 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -136,7 +135,7 @@ initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u) { Class c; - c = GSObjCClassOfObject(d); + c = GSObjCClass(d); info->data = d; info->appImp = (void (*)())get_imp(c, appSel); info->datImp = (void* (*)())get_imp(c, datSel); @@ -164,14 +163,14 @@ serializeToInfo(id object, _NSSerializerInfo* info) { Class c; - c = GSObjCClassOfObject(object); - if (fastIsClass(c) == NO) + if (object == nil || GSObjCIsInstance(object) == NO) { [NSException raise: NSInvalidArgumentException format: @"Class (%@) in property list - expected instance", [c description]]; } - if (fastClassIsKindOfClass(c, CStringClass) + c = GSObjCClass(object); + if (GSObjCIsKindOf(c, CStringClass) || (c == MStringClass && ((ivars)object)->_flags.wide == 0)) { GSIMapNode node; @@ -201,7 +200,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) (*info->serImp)(info->data, serSel, node->value.uint); } } - else if (fastClassIsKindOfClass(c, StringClass)) + else if (GSObjCIsKindOf(c, StringClass)) { GSIMapNode node; @@ -230,7 +229,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) (*info->serImp)(info->data, serSel, node->value.uint); } } - else if (fastClassIsKindOfClass(c, ArrayClass)) + else if (GSObjCIsKindOf(c, ArrayClass)) { unsigned int count; @@ -254,7 +253,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) } } } - else if (fastClassIsKindOfClass(c, DictionaryClass)) + else if (GSObjCIsKindOf(c, DictionaryClass)) { NSEnumerator *e = [object keyEnumerator]; id k; @@ -278,7 +277,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) serializeToInfo(o, info); } } - else if (fastClassIsKindOfClass(c, DataClass)) + else if (GSObjCIsKindOf(c, DataClass)) { (*info->appImp)(info->data, appSel, &st_data, 1); (*info->serImp)(info->data, serSel, [object length]); diff --git a/Source/NSSet.m b/Source/NSSet.m index 4b52bed3d..334ba5d29 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -123,7 +122,7 @@ static Class NSMutableSet_concrete_class; unsigned count; Class c; - c = GSObjCClassOfObject(self); + c = GSObjCClass(self); if (c == NSSet_abstract_class) { RELEASE(self); diff --git a/Source/NSString.m b/Source/NSString.m index f230ea9ab..4ce6a6605 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -70,8 +70,6 @@ #include -#include - @class GSString; @class GSMString; @class GSUString; @@ -440,7 +438,7 @@ handle_printf_atsign (FILE *stream, { char *s; - s = NSZoneMalloc(fastZone(self), length); + s = NSZoneMalloc(GSObjCZone(self), length); for (i = 0; i < length; i++) { @@ -454,7 +452,7 @@ handle_printf_atsign (FILE *stream, { unichar *s; - s = NSZoneMalloc(fastZone(self), sizeof(unichar)*length); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length); memcpy(s, chars, sizeof(unichar)*length); self = [self initWithCharactersNoCopy: s @@ -483,7 +481,7 @@ handle_printf_atsign (FILE *stream, { if (length > 0) { - char *s = NSZoneMalloc(fastZone(self), length); + char *s = NSZoneMalloc(GSObjCZone(self), length); if (byteString != 0) { @@ -511,7 +509,7 @@ handle_printf_atsign (FILE *stream, if (length > 0) { - unichar *s = NSZoneMalloc(fastZone(self), sizeof(unichar)*length); + unichar *s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length); [string getCharacters: s]; self = [self initWithCharactersNoCopy: s @@ -553,7 +551,7 @@ handle_printf_atsign (FILE *stream, { unichar *s; - s = NSZoneMalloc(fastZone(self), sizeof(unichar)*length); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length); length = encode_strtoustr(s, bytes, length+1, NSUTF8StringEncoding); self = [self initWithCharactersNoCopy: s length: length @@ -604,7 +602,7 @@ handle_printf_atsign (FILE *stream, NSString *ret; #if ! HAVE_REGISTER_PRINTF_FUNCTION - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); /* If the available libc doesn't have `register_printf_function()', then the `%@' printf directive isn't available with printf() and friends. @@ -894,7 +892,7 @@ handle_printf_atsign (FILE *stream, if (len > 0) { - char *s = NSZoneMalloc(fastZone(self), len); + char *s = NSZoneMalloc(GSObjCZone(self), len); [data getBytes: s]; self = [self initWithCStringNoCopy: s length: len freeWhenDone: YES]; @@ -929,7 +927,7 @@ handle_printf_atsign (FILE *stream, { unichar *u; - u = NSZoneMalloc(fastZone(self), sizeof(unichar)*length); + u = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length); length = encode_strtoustr(u, bytes, length+1, NSUTF8StringEncoding); self = [self initWithCharactersNoCopy: u length: length @@ -947,7 +945,7 @@ handle_printf_atsign (FILE *stream, return [self initWithCStringNoCopy: 0 length: 0 freeWhenDone: NO]; b = [data bytes]; - u = NSZoneMalloc(fastZone(self), sizeof(unichar)*(len+1)); + u = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*(len+1)); if (encoding == NSUnicodeStringEncoding) { if ((b[0]==0xFE) & (b[1]==0xFF)) @@ -1080,7 +1078,7 @@ handle_printf_atsign (FILE *stream, { unsigned len = [self length]; unsigned otherLength = [aString length]; - NSZone *z = fastZone(self); + NSZone *z = GSObjCZone(self); unichar *s = NSZoneMalloc(z, (len+otherLength)*sizeof(unichar)); NSString *tmp; @@ -1148,7 +1146,7 @@ handle_printf_atsign (FILE *stream, if (aRange.length == 0) return @""; - buf = NSZoneMalloc(fastZone(self), sizeof(unichar)*aRange.length); + buf = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*aRange.length); [self getCharacters: buf range: aRange]; ret = [[GSStringClass allocWithZone: NSDefaultMallocZone()] initWithCharactersNoCopy: buf length: aRange.length freeWhenDone: YES]; @@ -1323,13 +1321,13 @@ handle_printf_atsign (FILE *stream, { return YES; } - if (anObject != nil) + if (anObject != nil && GSObjCIsInstance(anObject) == YES) { - Class c = fastClassOfInstance(anObject); + Class c = GSObjCClass(anObject); if (c != nil) { - if (fastClassIsKindOfClass(c, NSStringClass)) + if (GSObjCIsKindOf(c, NSStringClass)) { return [self isEqualToString: anObject]; } @@ -1674,7 +1672,7 @@ handle_printf_atsign (FILE *stream, if (whitespce == nil) setupWhitespce(); - s = NSZoneMalloc(fastZone(self), sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); [self getCharacters: s]; while (count < len) { @@ -1722,7 +1720,7 @@ handle_printf_atsign (FILE *stream, { return self; } - s = NSZoneMalloc(fastZone(self), sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); caiImp = (unichar (*)())[self methodForSelector: caiSel]; for (count = 0; count < len; count++) { @@ -1743,7 +1741,7 @@ handle_printf_atsign (FILE *stream, { return self; } - s = NSZoneMalloc(fastZone(self), sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); caiImp = (unichar (*)())[self methodForSelector: caiSel]; for (count = 0; count < len; count++) { @@ -2895,7 +2893,7 @@ handle_printf_atsign (FILE *stream, #if GS_WITH_GC zone = GSAtomicMallocZone(); #else - zone = fastZone(self); + zone = GSObjCZone(self); #endif if (enc == NSUnicodeStringEncoding) diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index 4ad28c9cb..da0d3da1b 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -23,11 +23,10 @@ #include #include -#include +#include #include #include #include -#include /* * Setup for inline operation of arrays. @@ -48,8 +47,6 @@ #include #include -#include - static const char* typeToName1(char type) { @@ -1149,7 +1146,7 @@ static Class NSDataMallocClass; TEST_RELEASE(data); data = RETAIN(anObject); - c = GSObjCClassOfObject(data); + c = GSObjCClass(data); if (src != self) { src = data; diff --git a/Source/NSUser.m b/Source/NSUser.m index d68b3ea47..a0f56b429 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -22,8 +22,8 @@ */ #include -#include #include +#include #include #include #include diff --git a/Source/NSZone.m b/Source/NSZone.m index 6e3b974a8..783ddbb35 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -85,7 +85,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Source/mframe.m b/Source/mframe.m index f98055570..0e9b30713 100644 --- a/Source/mframe.m +++ b/Source/mframe.m @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include