Minor modification for Apple runtime

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7933 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-10-30 18:00:27 +00:00
parent c6ae88eece
commit 7310a9148b
23 changed files with 294 additions and 111 deletions

View file

@ -3,6 +3,30 @@
* Headers/gnustep/base/NSInvocation.h: Removed non-standard macros * Headers/gnustep/base/NSInvocation.h: Removed non-standard macros
* Headers/gnustep/base/behavior.h: Removed unused macro * Headers/gnustep/base/behavior.h: Removed unused macro
CALL_METHOD_IN_CLASS() CALL_METHOD_IN_CLASS()
* Source/GSString.m:
* Source/GSXML.m:
* Source/NSArchiver.m:
* Source/NSArray.m:
* Source/NSAttributedString.m:
* Source/NSData.m:
* Source/NSDictionary.m:
* Source/NSGArray.m:
* Source/NSGAttributedString.m:
* Source/NSGCString.m:
* Source/NSGDictionary.m:
* Source/NSGeometry.m:
* Source/NSObject.m:
* Source/NSPortCoder.m:
* Source/NSProcessInfo.m:
* Source/NSRange.m:
* Source/NSRunLoop.m:
* Source/NSScanner.m:
* Source/NSSerializer.m:
* Source/NSString.m:
* Source/NSUnarchiver.m:
* Source/NSUserDefaults.m:
Updated to move static SEL variable initialisation to +initialize
methods so that it should (I think) work with the Apple runtime.
2000-10-29 Adam Fedor <fedor@gnu.org> 2000-10-29 Adam Fedor <fedor@gnu.org>

View file

@ -186,12 +186,12 @@ static Class GSUInlineStringClass = 0;
static Class GSMStringClass = 0; static Class GSMStringClass = 0;
static Class NXConstantStringClass = 0; static Class NXConstantStringClass = 0;
static SEL convertSel = @selector(canBeConvertedToEncoding:); static SEL convertSel;
static BOOL (*convertImp)(id, SEL, NSStringEncoding) = 0; static BOOL (*convertImp)(id, SEL, NSStringEncoding);
static SEL equalSel = @selector(isEqualToString:); static SEL equalSel;
static BOOL (*equalImp)(id, SEL, id) = 0; static BOOL (*equalImp)(id, SEL, id);
static SEL hashSel = @selector(hash); static SEL hashSel;
static unsigned (*hashImp)(id, SEL) = 0; static unsigned (*hashImp)(id, SEL);
static NSStringEncoding defEnc = 0; static NSStringEncoding defEnc = 0;
@ -220,10 +220,13 @@ setup()
GSMStringClass = [GSMString class]; GSMStringClass = [GSMString class];
NXConstantStringClass = [NXConstantString class]; NXConstantStringClass = [NXConstantString class];
convertSel = @selector(canBeConvertedToEncoding:);
convertImp = (BOOL (*)(id, SEL, NSStringEncoding)) convertImp = (BOOL (*)(id, SEL, NSStringEncoding))
[NSStringClass instanceMethodForSelector: convertSel]; [NSStringClass instanceMethodForSelector: convertSel];
equalSel = @selector(isEqualToString:);
equalImp = (BOOL (*)(id, SEL, id)) equalImp = (BOOL (*)(id, SEL, id))
[NSStringClass instanceMethodForSelector: equalSel]; [NSStringClass instanceMethodForSelector: equalSel];
hashSel = @selector(hash);
hashImp = (unsigned (*)(id, SEL)) hashImp = (unsigned (*)(id, SEL))
[NSStringClass instanceMethodForSelector: hashSel]; [NSStringClass instanceMethodForSelector: hashSel];

View file

@ -48,7 +48,7 @@ extern int xmlGetWarningsDefaultValue;
*/ */
static Class NSString_class; static Class NSString_class;
static IMP usImp; static IMP usImp;
static SEL usSel = @selector(stringWithUTF8String:); static SEL usSel;
inline static NSString* inline static NSString*
UTF8Str(const char *bytes) UTF8Str(const char *bytes)
@ -78,6 +78,7 @@ setupCache()
{ {
cacheDone = YES; cacheDone = YES;
NSString_class = [NSString class]; NSString_class = [NSString class];
usSel = @selector(stringWithUTF8String:);
usImp = [NSString_class methodForSelector: usSel]; usImp = [NSString_class methodForSelector: usSel];
} }
} }

View file

@ -52,14 +52,26 @@ typedef unsigned char uchar;
#define PREFIX "GNUstep archive" #define PREFIX "GNUstep archive"
static SEL serSel = @selector(serializeDataAt:ofObjCType:context:);
static SEL tagSel = @selector(serializeTypeTag:);
static SEL xRefSel = @selector(serializeTypeTag:andCrossRef:);
static SEL eObjSel = @selector(encodeObject:);
static SEL eValSel = @selector(encodeValueOfObjCType:at:);
@implementation NSArchiver @implementation NSArchiver
static SEL serSel;
static SEL tagSel;
static SEL xRefSel;
static SEL eObjSel;
static SEL eValSel;
+ (void) initialize
{
if (self == [NSArchiver class])
{
serSel = @selector(serializeDataAt:ofObjCType:context:);
tagSel = @selector(serializeTypeTag:);
xRefSel = @selector(serializeTypeTag:andCrossRef:);
eObjSel = @selector(encodeObject:);
eValSel = @selector(encodeValueOfObjCType:at:);
}
}
- (id) init - (id) init
{ {
NSMutableData *d; NSMutableData *d;

View file

@ -50,31 +50,46 @@
@interface NSMutableArrayNonCore : NSMutableArray @interface NSMutableArrayNonCore : NSMutableArray
@end @end
@class NSGInlineArray;
static Class NSArray_abstract_class; static Class NSArray_abstract_class;
static Class NSArray_concrete_class; static Class NSArray_concrete_class;
static Class NSMutableArray_abstract_class; static Class NSMutableArray_abstract_class;
static Class NSMutableArray_concrete_class; static Class NSMutableArray_concrete_class;
static Class NSGInlineArrayClass;
static SEL addSel = @selector(addObject:);
static SEL appSel = @selector(appendString:);
static SEL countSel = @selector(count);
static SEL eqSel = @selector(isEqual:);
static SEL oaiSel = @selector(objectAtIndex:);
static SEL remSel = @selector(removeObjectAtIndex:);
static SEL rlSel = @selector(removeLastObject);
@implementation NSArray @implementation NSArray
static SEL addSel;
static SEL appSel;
static SEL countSel;
static SEL eqSel;
static SEL oaiSel;
static SEL remSel;
static SEL rlSel;
+ (void) initialize + (void) initialize
{ {
if (self == [NSArray class]) if (self == [NSArray class])
{ {
[self setVersion: 1];
addSel = @selector(addObject:);
appSel = @selector(appendString:);
countSel = @selector(count);
eqSel = @selector(isEqual:);
oaiSel = @selector(objectAtIndex:);
remSel = @selector(removeObjectAtIndex:);
rlSel = @selector(removeLastObject);
NSArray_abstract_class = [NSArray class]; NSArray_abstract_class = [NSArray class];
behavior_class_add_class (self, [NSArrayNonCore class]);
NSMutableArray_abstract_class = [NSMutableArray class]; NSMutableArray_abstract_class = [NSMutableArray class];
NSArray_concrete_class = [NSGArray class]; NSArray_concrete_class = [NSGArray class];
NSMutableArray_concrete_class = [NSGMutableArray class]; NSMutableArray_concrete_class = [NSGMutableArray class];
behavior_class_add_class (self, [NSArrayNonCore class]); NSMutableArray_concrete_class = [NSGMutableArray class];
NSGInlineArrayClass = [NSGInlineArray class];
} }
} }
@ -107,13 +122,16 @@ static SEL rlSel = @selector(removeLastObject);
initWithContentsOfFile: file]); initWithContentsOfFile: file]);
} }
+ (id) arrayWithObject: anObject + (id) arrayWithObject: (id)anObject
{ {
id o;
if (anObject == nil) if (anObject == nil)
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add nil"]; format: @"Tried to add nil"];
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] o = NSAllocateObject(NSGInlineArrayClass, sizeof(id), NSDefaultMallocZone());
initWithObjects: &anObject count: 1]); o = [o initWithObjects: &anObject count: 1];
return AUTORELEASE(o);
} }
/* This is the designated initializer for NSArray. */ /* This is the designated initializer for NSArray. */
@ -807,6 +825,14 @@ static NSString *indentStrings[] = {
} }
} }
+ (id) arrayWithObject: (id)anObject
{
NSMutableArray *obj = [self allocWithZone: NSDefaultMallocZone()];
obj = [obj initWithObjects: &anObject count: 1];
return AUTORELEASE(self);
}
- (Class) classForCoder - (Class) classForCoder
{ {
return NSMutableArray_abstract_class; return NSMutableArray_abstract_class;

View file

@ -55,18 +55,19 @@
#include <Foundation/NSPortCoder.h> #include <Foundation/NSPortCoder.h>
#include <Foundation/NSRange.h> #include <Foundation/NSRange.h>
static SEL eqSel = @selector(isEqual:);
static SEL setSel = @selector(setAttributes:range:);
static SEL getSel = @selector(attributesAtIndex:effectiveRange:);
static SEL addDictSel = @selector(addEntriesFromDictionary:);
static SEL setDictSel = @selector(setObject:forKey:);
static SEL relDictSel = @selector(release);
static SEL remDictSel = @selector(removeObjectForKey:);
@class NSGMutableDictionary; @class NSGMutableDictionary;
static Class dictionaryClass = 0; static Class dictionaryClass = 0;
static SEL allocDictSel = @selector(allocWithZone:);
static SEL initDictSel = @selector(initWithDictionary:); static SEL eqSel;
static SEL setSel;
static SEL getSel;
static SEL allocDictSel;
static SEL initDictSel;
static SEL addDictSel;
static SEL setDictSel;
static SEL relDictSel;
static SEL remDictSel;
static IMP allocDictImp; static IMP allocDictImp;
static IMP initDictImp; static IMP initDictImp;
static IMP addDictImp; static IMP addDictImp;
@ -100,6 +101,17 @@ static Class NSMutableAttributedString_concrete_class;
NSMutableAttributedString_concrete_class NSMutableAttributedString_concrete_class
= [NSGMutableAttributedString class]; = [NSGMutableAttributedString class];
dictionaryClass = [NSGMutableDictionary class]; dictionaryClass = [NSGMutableDictionary class];
eqSel = @selector(isEqual:);
setSel = @selector(setAttributes:range:);
getSel = @selector(attributesAtIndex:effectiveRange:);
allocDictSel = @selector(allocWithZone:);
initDictSel = @selector(initWithDictionary:);
addDictSel = @selector(addEntriesFromDictionary:);
setDictSel = @selector(setObject:forKey:);
relDictSel = @selector(release);
remDictSel = @selector(removeObjectForKey:);
allocDictImp = [dictionaryClass methodForSelector: allocDictSel]; allocDictImp = [dictionaryClass methodForSelector: allocDictSel];
initDictImp = [dictionaryClass instanceMethodForSelector: initDictSel]; initDictImp = [dictionaryClass instanceMethodForSelector: initDictSel];
addDictImp = [dictionaryClass instanceMethodForSelector: addDictSel]; addDictImp = [dictionaryClass instanceMethodForSelector: addDictSel];

View file

@ -107,12 +107,13 @@
* Some static variables to cache classes and methods for quick access - * Some static variables to cache classes and methods for quick access -
* these are set up at process startup or in [NSData +initialize] * these are set up at process startup or in [NSData +initialize]
*/ */
static SEL appendSel = @selector(appendBytes:length:); static SEL appendSel;
static Class dataStatic; static Class dataStatic;
static Class dataMalloc; static Class dataMalloc;
static Class mutableDataMalloc; static Class mutableDataMalloc;
static Class NSDataAbstract; static Class NSDataAbstract;
static Class NSMutableDataAbstract; static Class NSMutableDataAbstract;
static SEL appendSel;
static IMP appendImp; static IMP appendImp;
static BOOL static BOOL
@ -334,6 +335,7 @@ failure:
dataMalloc = [NSDataMalloc class]; dataMalloc = [NSDataMalloc class];
dataStatic = [NSDataStatic class]; dataStatic = [NSDataStatic class];
mutableDataMalloc = [NSMutableDataMalloc class]; mutableDataMalloc = [NSMutableDataMalloc class];
appendSel = @selector(appendBytes:length:);
appendImp = [mutableDataMalloc instanceMethodForSelector: appendSel]; appendImp = [mutableDataMalloc instanceMethodForSelector: appendSel];
} }
} }

View file

@ -52,11 +52,12 @@ static Class NSMutableDictionary_abstract_class;
static Class NSDictionary_concrete_class; static Class NSDictionary_concrete_class;
static Class NSMutableDictionary_concrete_class; static Class NSMutableDictionary_concrete_class;
static SEL nxtSel = @selector(nextObject); static SEL eqSel;
static SEL objSel = @selector(objectForKey:); static SEL nxtSel;
static SEL remSel = @selector(removeObjectForKey:); static SEL objSel;
static SEL setSel = @selector(setObject:forKey:); static SEL remSel;
static SEL appSel = @selector(appendString:); static SEL setSel;
static SEL appSel;
+ (void) initialize + (void) initialize
{ {
@ -68,6 +69,13 @@ static SEL appSel = @selector(appendString:);
NSMutableDictionary_abstract_class = [NSMutableDictionary class]; NSMutableDictionary_abstract_class = [NSMutableDictionary class];
NSDictionary_concrete_class = [NSGDictionary class]; NSDictionary_concrete_class = [NSGDictionary class];
NSMutableDictionary_concrete_class = [NSGMutableDictionary class]; NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
eqSel = @selector(isEqual:);
nxtSel = @selector(nextObject);
objSel = @selector(objectForKey:);
remSel = @selector(removeObjectForKey:);
setSel = @selector(setObject:forKey:);
appSel = @selector(appendString:);
} }
} }
@ -543,7 +551,6 @@ static SEL appSel = @selector(appendString:);
} }
else else
{ {
static SEL eqSel = @selector(isEqual:);
NSEnumerator *e = [self keyEnumerator]; NSEnumerator *e = [self keyEnumerator];
IMP nxtObj = [e methodForSelector: nxtSel]; IMP nxtObj = [e methodForSelector: nxtSel];
IMP myObj = [self methodForSelector: objSel]; IMP myObj = [self methodForSelector: objSel];

View file

@ -30,7 +30,7 @@
#include <Foundation/NSPortCoder.h> #include <Foundation/NSPortCoder.h>
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
static SEL eqSel = @selector(isEqual:); static SEL eqSel;
@class NSGArrayEnumerator; @class NSGArrayEnumerator;
@class NSGArrayEnumeratorReverse; @class NSGArrayEnumeratorReverse;
@ -43,6 +43,11 @@ static SEL eqSel = @selector(isEqual:);
} }
@end @end
@interface NSGInlineArray : NSGArray
{
}
@end
@interface NSGMutableArray : NSMutableArray @interface NSGMutableArray : NSMutableArray
{ {
@public @public
@ -62,6 +67,7 @@ static SEL eqSel = @selector(isEqual:);
if (self == [NSGArray class]) if (self == [NSGArray class])
{ {
[self setVersion: 1]; [self setVersion: 1];
eqSel = @selector(isEqual:);
behavior_class_add_class(self, [NSArrayNonCore class]); behavior_class_add_class(self, [NSArrayNonCore class]);
} }
} }
@ -87,7 +93,7 @@ static SEL eqSel = @selector(isEqual:);
#endif #endif
NSZoneFree([self zone], _contents_array); NSZoneFree([self zone], _contents_array);
} }
[super dealloc]; NSDeallocateObject(self);
} }
/* This is the designated initializer for NSArray. */ /* This is the designated initializer for NSArray. */
@ -271,6 +277,45 @@ static SEL eqSel = @selector(isEqual:);
@end @end
@implementation NSGInlineArray
- (void) dealloc
{
if (_contents_array)
{
#if !GS_WITH_GC
unsigned i;
for (i = 0; i < _count; i++)
{
[_contents_array[i] release];
}
#endif
}
NSDeallocateObject(self);
}
- (id) initWithObjects: (id*)objects count: (unsigned)count
{
_contents_array = (id*)&self[1];
if (count > 0)
{
unsigned i;
for (i = 0; i < count; i++)
{
if ((_contents_array[i] = RETAIN(objects[i])) == nil)
{
_count = i;
RELEASE(self);
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil"];
}
}
_count = count;
}
return self;
}
@end
@class NSMutableArrayNonCore; @class NSMutableArrayNonCore;
@implementation NSGMutableArray @implementation NSGMutableArray
@ -659,7 +704,7 @@ static SEL eqSel = @selector(isEqual:);
- (void) dealloc - (void) dealloc
{ {
RELEASE(array); RELEASE(array);
[super dealloc]; NSDeallocateObject(self);
} }
@end @end

View file

@ -97,23 +97,19 @@
static Class infCls = 0; static Class infCls = 0;
static SEL infSel = @selector(newWithZone:value:at:); static SEL infSel;
static IMP infImp = 0; static SEL addSel;
static SEL cntSel;
static SEL insSel;
static SEL oatSel;
static SEL remSel;
static SEL addSel = @selector(addObject:); static IMP infImp;
static void (*addImp)() = 0; static void (*addImp)();
static unsigned (*cntImp)();
static SEL cntSel = @selector(count); static void (*insImp)();
static unsigned (*cntImp)() = 0; static IMP oatImp;
static void (*remImp)();
static SEL insSel = @selector(insertObject:atIndex:);
static void (*insImp)() = 0;
static SEL oatSel = @selector(objectAtIndex:);
static IMP oatImp = 0;
static SEL remSel = @selector(removeObjectAtIndex:);
static void (*remImp)() = 0;
#define NEWINFO(Z,O,L) ((*infImp)(infCls, infSel, (Z), (O), (L))) #define NEWINFO(Z,O,L) ((*infImp)(infCls, infSel, (Z), (O), (L)))
#define ADDOBJECT(O) ((*addImp)(_infoArray, addSel, (O))) #define ADDOBJECT(O) ((*addImp)(_infoArray, addSel, (O)))
@ -127,6 +123,13 @@ static void _setup()
{ {
NSMutableArray *a; NSMutableArray *a;
infSel = @selector(newWithZone:value:at:);
addSel = @selector(addObject:);
cntSel = @selector(count);
insSel = @selector(insertObject:atIndex:);
oatSel = @selector(objectAtIndex:);
remSel = @selector(removeObjectAtIndex:);
infCls = [GSAttrInfo class]; infCls = [GSAttrInfo class];
infImp = [infCls methodForSelector: infSel]; infImp = [infCls methodForSelector: infSel];

View file

@ -69,8 +69,8 @@
#define GSPLUNI 0 #define GSPLUNI 0
#include "propList.h" #include "propList.h"
static SEL csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:); static SEL csInitSel;
static SEL msInitSel = @selector(initWithCapacity:); static SEL msInitSel;
static IMP csInitImp; /* designated initialiser for cString */ static IMP csInitImp; /* designated initialiser for cString */
static IMP msInitImp; /* designated initialiser for mutable */ static IMP msInitImp; /* designated initialiser for mutable */
@ -86,6 +86,8 @@ static IMP msInitImp; /* designated initialiser for mutable */
if (!done) if (!done)
{ {
done = 1; done = 1;
csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:);
msInitSel = @selector(initWithCapacity:);
csInitImp = [NSGCString instanceMethodForSelector: csInitSel]; csInitImp = [NSGCString instanceMethodForSelector: csInitSel];
msInitImp = [NSGMutableCString instanceMethodForSelector: msInitSel]; msInitImp = [NSGMutableCString instanceMethodForSelector: msInitSel];
} }

View file

@ -76,10 +76,15 @@
@implementation NSGDictionary @implementation NSGDictionary
static SEL nxtSel;
static SEL objSel;
+ (void) initialize + (void) initialize
{ {
if (self == [NSGDictionary class]) if (self == [NSGDictionary class])
{ {
nxtSel = @selector(nextObject);
objSel = @selector(objectForKey:);
behavior_class_add_class(self, [NSDictionaryNonCore class]); behavior_class_add_class(self, [NSDictionaryNonCore class]);
} }
} }
@ -189,8 +194,6 @@
if (c > 0) if (c > 0)
{ {
static SEL nxtSel = @selector(nextObject);
static SEL objSel = @selector(objectForKey:);
NSEnumerator *e = [other keyEnumerator]; NSEnumerator *e = [other keyEnumerator];
IMP nxtObj = [e methodForSelector: nxtSel]; IMP nxtObj = [e methodForSelector: nxtSel];
IMP otherObj = [other methodForSelector: objSel]; IMP otherObj = [other methodForSelector: objSel];

View file

@ -41,9 +41,9 @@ extern BOOL GSMacOSXCompatibleGeometry(); // Compatibility mode
static Class NSStringClass = 0; static Class NSStringClass = 0;
static Class NSScannerClass = 0; static Class NSScannerClass = 0;
static SEL scanFloatSel = @selector(scanFloat:); static SEL scanFloatSel;
static SEL scanStringSel = @selector(scanString:intoString:); static SEL scanStringSel;
static SEL scannerSel = @selector(scannerWithString:); static SEL scannerSel;
static BOOL (*scanFloatImp)(NSScanner*, SEL, float*); static BOOL (*scanFloatImp)(NSScanner*, SEL, float*);
static BOOL (*scanStringImp)(NSScanner*, SEL, NSString*, NSString**); static BOOL (*scanStringImp)(NSScanner*, SEL, NSString*, NSString**);
static id (*scannerImp)(Class, SEL, NSString*); static id (*scannerImp)(Class, SEL, NSString*);
@ -55,6 +55,9 @@ setupCache()
{ {
NSStringClass = [NSString class]; NSStringClass = [NSString class];
NSScannerClass = [NSScanner class]; NSScannerClass = [NSScanner class];
scanFloatSel = @selector(scanFloat:);
scanStringSel = @selector(scanString:intoString:);
scannerSel = @selector(scannerWithString:);
scanFloatImp = (BOOL (*)(NSScanner*, SEL, float*)) scanFloatImp = (BOOL (*)(NSScanner*, SEL, float*))
[NSScannerClass instanceMethodForSelector: scanFloatSel]; [NSScannerClass instanceMethodForSelector: scanFloatSel];
scanStringImp = (BOOL (*)(NSScanner*, SEL, NSString*, NSString**)) scanStringImp = (BOOL (*)(NSScanner*, SEL, NSString*, NSString**))

View file

@ -556,8 +556,8 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
need mutex protection, since it is simply a pointer that gets read need mutex protection, since it is simply a pointer that gets read
and set. */ and set. */
static id autorelease_class = nil; static id autorelease_class = nil;
static SEL autorelease_sel = @selector(addObject:); static SEL autorelease_sel;
static IMP autorelease_imp = 0; static IMP autorelease_imp;
/* When this is `YES', every call to release/autorelease, checks to /* When this is `YES', every call to release/autorelease, checks to
make sure isn't being set up to release itself too many times. make sure isn't being set up to release itself too many times.
@ -609,6 +609,7 @@ static BOOL double_release_check_enabled = NO;
// Create the global lock // Create the global lock
gnustep_global_lock = [[NSRecursiveLock alloc] init]; gnustep_global_lock = [[NSRecursiveLock alloc] init];
autorelease_class = [NSAutoreleasePool class]; autorelease_class = [NSAutoreleasePool class];
autorelease_sel = @selector(addObject:);
autorelease_imp = [autorelease_class methodForSelector: autorelease_sel]; autorelease_imp = [autorelease_class methodForSelector: autorelease_sel];
fastMallocClass = [_FastMallocBuffer class]; fastMallocClass = [_FastMallocBuffer class];
#if GS_WITH_GC == 0 #if GS_WITH_GC == 0

View file

@ -78,14 +78,14 @@ typedef unsigned char uchar;
#define PREFIX "GNUstep DO archive" #define PREFIX "GNUstep DO archive"
static SEL eSerSel = @selector(serializeDataAt:ofObjCType:context:); static SEL eSerSel;
static SEL eTagSel = @selector(serializeTypeTag:); static SEL eTagSel;
static SEL xRefSel = @selector(serializeTypeTag:andCrossRef:); static SEL xRefSel;
static SEL eObjSel = @selector(encodeObject:); static SEL eObjSel;
static SEL eValSel = @selector(encodeValueOfObjCType:at:); static SEL eValSel;
static SEL dDesSel = @selector(deserializeDataAt:ofObjCType:atCursor:context:); static SEL dDesSel;
static SEL dTagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:); static SEL dTagSel;
static SEL dValSel = @selector(decodeValueOfObjCType:at:); static SEL dValSel;
@ -311,6 +311,14 @@ static IMP _xRefImp; /* Serialize a crossref. */
connectionClass = [NSConnection class]; connectionClass = [NSConnection class];
mutableArrayClass = [NSMutableArray class]; mutableArrayClass = [NSMutableArray class];
mutableDataClass = [NSMutableDataMalloc class]; mutableDataClass = [NSMutableDataMalloc class];
eSerSel = @selector(serializeDataAt:ofObjCType:context:);
eTagSel = @selector(serializeTypeTag:);
xRefSel = @selector(serializeTypeTag:andCrossRef:);
eObjSel = @selector(encodeObject:);
eValSel = @selector(encodeValueOfObjCType:at:);
dDesSel = @selector(deserializeDataAt:ofObjCType:atCursor:context:);
dTagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:);
dValSel = @selector(decodeValueOfObjCType:at:);
_eSerImp = [mutableDataClass instanceMethodForSelector: eSerSel]; _eSerImp = [mutableDataClass instanceMethodForSelector: eSerSel];
_eTagImp = [mutableDataClass instanceMethodForSelector: eTagSel]; _eTagImp = [mutableDataClass instanceMethodForSelector: eTagSel];
_xRefImp = [mutableDataClass instanceMethodForSelector: xRefSel]; _xRefImp = [mutableDataClass instanceMethodForSelector: xRefSel];

View file

@ -618,11 +618,12 @@ int main(int argc, char *argv[], char *env[])
*/ */
BOOL GSDebugSet(NSString *val) BOOL GSDebugSet(NSString *val)
{ {
static SEL debugSel = @selector(member:);
static IMP debugImp = 0; static IMP debugImp = 0;
static SEL debugSel;
if (debugImp == 0) if (debugImp == 0)
{ {
debugSel = @selector(member:);
if (_debug_set == nil) if (_debug_set == nil)
{ {
[[NSProcessInfo processInfo] debugSet]; [[NSProcessInfo processInfo] debugSet];

View file

@ -14,9 +14,9 @@
static Class NSStringClass = 0; static Class NSStringClass = 0;
static Class NSScannerClass = 0; static Class NSScannerClass = 0;
static SEL scanIntSel = @selector(scanInt:); static SEL scanIntSel;
static SEL scanStringSel = @selector(scanString:intoString:); static SEL scanStringSel;
static SEL scannerSel = @selector(scannerWithString:); static SEL scannerSel;
static BOOL (*scanIntImp)(NSScanner*, SEL, int*); static BOOL (*scanIntImp)(NSScanner*, SEL, int*);
static BOOL (*scanStringImp)(NSScanner*, SEL, NSString*, NSString**); static BOOL (*scanStringImp)(NSScanner*, SEL, NSString*, NSString**);
static id (*scannerImp)(Class, SEL, NSString*); static id (*scannerImp)(Class, SEL, NSString*);
@ -28,6 +28,9 @@ setupCache()
{ {
NSStringClass = [NSString class]; NSStringClass = [NSString class];
NSScannerClass = [NSScanner class]; NSScannerClass = [NSScanner class];
scanIntSel = @selector(scanInt:);
scanStringSel = @selector(scanString:intoString:);
scannerSel = @selector(scannerWithString:);
scanIntImp = (BOOL (*)(NSScanner*, SEL, int*)) scanIntImp = (BOOL (*)(NSScanner*, SEL, int*))
[NSScannerClass instanceMethodForSelector: scanIntSel]; [NSScannerClass instanceMethodForSelector: scanIntSel];
scanStringImp = (BOOL (*)(NSScanner*, SEL, NSString*, NSString**)) scanStringImp = (BOOL (*)(NSScanner*, SEL, NSString*, NSString**))

View file

@ -86,7 +86,7 @@ static NSDate *theFuture = nil;
* NB. This class is private to NSRunLoop and must not be subclassed. * NB. This class is private to NSRunLoop and must not be subclassed.
*/ */
static SEL eventSel = @selector(receivedEvent:type:extra:forMode:); static SEL eventSel; /* Initialized in [NSRunLoop +initialize] */
@interface GSRunLoopWatcher: NSObject @interface GSRunLoopWatcher: NSObject
{ {
@ -641,8 +641,8 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
@implementation NSRunLoop @implementation NSRunLoop
#if GS_WITH_GC == 0 #if GS_WITH_GC == 0
static SEL wRelSel = @selector(release); static SEL wRelSel;
static SEL wRetSel = @selector(retain); static SEL wRetSel;
static IMP wRelImp; static IMP wRelImp;
static IMP wRetImp; static IMP wRetImp;
@ -695,7 +695,10 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
{ {
[self currentRunLoop]; [self currentRunLoop];
theFuture = RETAIN([NSDate distantFuture]); theFuture = RETAIN([NSDate distantFuture]);
eventSel = @selector(receivedEvent:type:extra:forMode:);
#if GS_WITH_GC == 0 #if GS_WITH_GC == 0
wRelSel = @selector(release);
wRetSel = @selector(retain);
wRelImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRelSel]; wRelImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRelSel];
wRetImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRetSel]; wRetImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRetSel];
#endif #endif

View file

@ -44,7 +44,7 @@ static Class GSUString_class;
static Class GSMString_class; static Class GSMString_class;
static Class NXConstantString_class; static Class NXConstantString_class;
static NSCharacterSet *defaultSkipSet; static NSCharacterSet *defaultSkipSet;
static SEL memSel = @selector(characterIsMember:); static SEL memSel;
/* /*
* Hack for direct access to internals of an concrete string object. * Hack for direct access to internals of an concrete string object.
@ -74,6 +74,7 @@ typedef struct {
{ {
if (self == [NSScanner class]) if (self == [NSScanner class])
{ {
memSel = @selector(characterIsMember:);
defaultSkipSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; defaultSkipSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
IF_NO_GC(RETAIN(defaultSkipSet)); IF_NO_GC(RETAIN(defaultSkipSet));
NSString_class = [NSString class]; NSString_class = [NSString class];

View file

@ -124,11 +124,11 @@ typedef struct {
BOOL shouldUnique; // Do we do uniquing? BOOL shouldUnique; // Do we do uniquing?
} _NSSerializerInfo; } _NSSerializerInfo;
static SEL appSel = @selector(appendBytes:length:); static SEL appSel;
static SEL datSel = @selector(mutableBytes); static SEL datSel;
static SEL lenSel = @selector(length); static SEL lenSel;
static SEL serSel = @selector(serializeInt:); static SEL serSel;
static SEL setSel = @selector(setLength:); static SEL setSel;
static void static void
initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u) initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u)
@ -299,6 +299,11 @@ static BOOL shouldBeCompact = NO;
{ {
if (self == [NSSerializer class]) if (self == [NSSerializer class])
{ {
appSel = @selector(appendBytes:length:);
datSel = @selector(mutableBytes);
lenSel = @selector(length);
serSel = @selector(serializeInt:);
setSel = @selector(setLength:);
ArrayClass = [NSArray class]; ArrayClass = [NSArray class];
MutableArrayClass = [NSMutableArray class]; MutableArrayClass = [NSMutableArray class];
DataClass = [NSData class]; DataClass = [NSData class];
@ -381,15 +386,15 @@ typedef struct {
GSIArray_t array; GSIArray_t array;
} _NSDeserializerInfo; } _NSDeserializerInfo;
static SEL debSel = @selector(deserializeBytes:length:atCursor:); static SEL debSel;
static SEL deiSel = @selector(deserializeIntAtCursor:); static SEL deiSel;
static SEL csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:); static SEL csInitSel;
static SEL usInitSel = @selector(initWithCharactersNoCopy:length:freeWhenDone:); static SEL usInitSel;
static SEL dInitSel = @selector(initWithBytesNoCopy:length:); static SEL dInitSel;
static SEL iaInitSel = @selector(initWithObjects:count:); static SEL iaInitSel;
static SEL maInitSel = @selector(initWithObjects:count:); static SEL maInitSel;
static SEL idInitSel = @selector(initWithObjects:forKeys:count:); static SEL idInitSel;
static SEL mdInitSel = @selector(initWithObjects:forKeys:count:); static SEL mdInitSel;
static IMP csInitImp; static IMP csInitImp;
static IMP usInitImp; static IMP usInitImp;
static IMP dInitImp; static IMP dInitImp;
@ -674,6 +679,15 @@ deserializeFromInfo(_NSDeserializerInfo* info)
{ {
if (self == [NSDeserializer class]) if (self == [NSDeserializer class])
{ {
debSel = @selector(deserializeBytes:length:atCursor:);
deiSel = @selector(deserializeIntAtCursor:);
csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:);
usInitSel = @selector(initWithCharactersNoCopy:length:freeWhenDone:);
dInitSel = @selector(initWithBytesNoCopy:length:);
iaInitSel = @selector(initWithObjects:count:);
maInitSel = @selector(initWithObjects:count:);
idInitSel = @selector(initWithObjects:forKeys:count:);
mdInitSel = @selector(initWithObjects:forKeys:count:);
IACls = [NSGArray class]; IACls = [NSGArray class];
MACls = [NSGMutableArray class]; MACls = [NSGMutableArray class];
DCls = [NSDataMalloc class]; DCls = [NSDataMalloc class];

View file

@ -102,9 +102,9 @@ static id (*plSet)(id, SEL, id, id) = 0;
static id (*plAlloc)(Class, SEL, NSZone*) = 0; static id (*plAlloc)(Class, SEL, NSZone*) = 0;
static id (*plInit)(id, SEL, unichar*, unsigned) = 0; static id (*plInit)(id, SEL, unichar*, unsigned) = 0;
static SEL plSel = @selector(initWithCharacters:length:);
static SEL cMemberSel = @selector(characterIsMember:); static SEL plSel;
static SEL cMemberSel;
static NSCharacterSet *hexdigits = nil; static NSCharacterSet *hexdigits = nil;
static BOOL (*hexdigitsImp)(id, SEL, unichar) = 0; static BOOL (*hexdigitsImp)(id, SEL, unichar) = 0;
@ -278,8 +278,11 @@ handle_printf_atsign (FILE *stream,
{ {
if (self == [NSString class]) if (self == [NSString class])
{ {
plSel = @selector(initWithCharacters:length:);
cMemberSel = @selector(characterIsMember:);
_DefaultStringEncoding = GetDefEncoding(); _DefaultStringEncoding = GetDefEncoding();
NSStringClass = self; NSStringClass = self;
[self setVersion: 1];
NSMutableStringClass = [NSMutableString class]; NSMutableStringClass = [NSMutableString class];
NSDataClass = [NSData class]; NSDataClass = [NSData class];
GSStringClass = [GSString class]; GSStringClass = [GSString class];

View file

@ -196,9 +196,9 @@ typeCheck(char t1, char t2)
#define PREFIX "GNUstep archive" #define PREFIX "GNUstep archive"
static SEL desSel = @selector(deserializeDataAt:ofObjCType:atCursor:context:); static SEL desSel;
static SEL tagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:); static SEL tagSel;
static SEL dValSel = @selector(decodeValueOfObjCType:at:); static SEL dValSel;
@interface NSUnarchiverClassInfo : NSObject @interface NSUnarchiverClassInfo : NSObject
{ {
@ -298,6 +298,9 @@ mapClassName(NSUnarchiverObjectInfo *info)
{ {
if ([self class] == [NSUnarchiver class]) if ([self class] == [NSUnarchiver class])
{ {
desSel = @selector(deserializeDataAt:ofObjCType:atCursor:context:);
tagSel = @selector(deserializeTypeTag:andCrossRef:atCursor:);
dValSel = @selector(decodeValueOfObjCType:at:);
clsDict = [[NSMutableDictionary alloc] initWithCapacity: 200]; clsDict = [[NSMutableDictionary alloc] initWithCapacity: 200];
} }
} }

View file

@ -48,8 +48,9 @@
/* Wait for access */ /* Wait for access */
#define _MAX_COUNT 5 /* Max 10 sec. */ #define _MAX_COUNT 5 /* Max 10 sec. */
static SEL nextObjectSel = @selector(nextObject); static SEL nextObjectSel;
static SEL objectForKeySel = @selector(objectForKey:); static SEL objectForKeySel;
static SEL addSel;
/* User's Defaults database */ /* User's Defaults database */
static NSString *GNU_UserDefaultsPrefix = @"GNUstep"; static NSString *GNU_UserDefaultsPrefix = @"GNUstep";
@ -89,6 +90,9 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
{ {
if (self == [NSUserDefaults class]) if (self == [NSUserDefaults class])
{ {
nextObjectSel = @selector(nextObject);
objectForKeySel = @selector(objectForKey:);
addSel = @selector(addEntriesFromDictionary:);
/* /*
* Cache class info for more rapid testing of the types of defaults. * Cache class info for more rapid testing of the types of defaults.
*/ */
@ -954,11 +958,10 @@ static NSString *pathForUser(NSString *user)
NSMutableDictionary *dictRep; NSMutableDictionary *dictRep;
id obj; id obj;
id dict; id dict;
static SEL aSel = @selector(addEntriesFromDictionary:);
IMP nImp; IMP nImp;
IMP pImp; IMP pImp;
IMP tImp; IMP tImp;
IMP aImp; IMP addImp;
pImp = [_persDomains methodForSelector: objectForKeySel]; pImp = [_persDomains methodForSelector: objectForKeySel];
tImp = [_tempDomains methodForSelector: objectForKeySel]; tImp = [_tempDomains methodForSelector: objectForKeySel];
@ -968,13 +971,13 @@ static NSString *pathForUser(NSString *user)
dictRep = [NSMutableDictionaryClass allocWithZone: NSDefaultMallocZone()]; dictRep = [NSMutableDictionaryClass allocWithZone: NSDefaultMallocZone()];
dictRep = [dictRep initWithCapacity: 512]; dictRep = [dictRep initWithCapacity: 512];
aImp = [dictRep methodForSelector: aSel]; addImp = [dictRep methodForSelector: addSel];
while ((obj = (*nImp)(enumerator, nextObjectSel)) != nil) while ((obj = (*nImp)(enumerator, nextObjectSel)) != nil)
{ {
if ( (dict = (*pImp)(_persDomains, objectForKeySel, obj)) != nil if ( (dict = (*pImp)(_persDomains, objectForKeySel, obj)) != nil
|| (dict = (*tImp)(_tempDomains, objectForKeySel, obj)) != nil) || (dict = (*tImp)(_tempDomains, objectForKeySel, obj)) != nil)
(*aImp)(dictRep, aSel, dict); (*addImp)(dictRep, addSel, dict);
} }
_dictionaryRep = [dictRep copy]; _dictionaryRep = [dictRep copy];
RELEASE(dictRep); RELEASE(dictRep);