diff --git a/AppKit/CoreGraphics.subproj/CGGeometry.m b/AppKit/CoreGraphics.subproj/CGGeometry.m index ad0d7394..38cc0729 100755 --- a/AppKit/CoreGraphics.subproj/CGGeometry.m +++ b/AppKit/CoreGraphics.subproj/CGGeometry.m @@ -8,6 +8,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import -CGRect CGRectZero={{0,0},{0,0}}; -CGPoint CGPointZero={0,0}; -CGSize CGSizeZero={0,0}; +const CGRect CGRectZero={{0,0},{0,0}}; +const CGPoint CGPointZero={0,0}; +const CGSize CGSizeZero={0,0}; diff --git a/AppKit/CoreGraphics.subproj/KGContext_builtin.m b/AppKit/CoreGraphics.subproj/KGContext_builtin.m index 407daa66..f25ef799 100644 --- a/AppKit/CoreGraphics.subproj/KGContext_builtin.m +++ b/AppKit/CoreGraphics.subproj/KGContext_builtin.m @@ -39,7 +39,7 @@ @implementation KGContext_builtin -BOOL _isAvailable=NO; +static BOOL _isAvailable=NO; +(void)initialize { _isAvailable=[[NSUserDefaults standardUserDefaults] boolForKey:@"CGEnableBuiltin"]; diff --git a/AppKit/CoreGraphics.subproj/KGImageSource.m b/AppKit/CoreGraphics.subproj/KGImageSource.m index 5fc6e03b..bbec692d 100644 --- a/AppKit/CoreGraphics.subproj/KGImageSource.m +++ b/AppKit/CoreGraphics.subproj/KGImageSource.m @@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation KGImageSource +(KGImageSource *)newImageSourceWithDataProvider:(KGDataProvider *)provider options:(NSDictionary *)options { - static NSString *classes[]={ + NSString *classes[]={ @"KGImageSource_PNG", @"KGImageSource_TIFF", @"KGImageSource_JPEG", diff --git a/AppKit/NSInterfacePart/NSInterfacePartAttributedString.m b/AppKit/NSInterfacePart/NSInterfacePartAttributedString.m index 4074e677..56864b03 100755 --- a/AppKit/NSInterfacePart/NSInterfacePartAttributedString.m +++ b/AppKit/NSInterfacePart/NSInterfacePartAttributedString.m @@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -// Original - Christopher Lloyd #import #import #import @@ -15,12 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSInterfacePartAttributedString -static NSMutableArray *_fontHolder; - -+(void)initialize { - _fontHolder=[NSMutableArray new]; -} - -initWithCharacter:(unichar)character fontName:(NSString *)fontName pointSize:(float)pointSize color:(NSColor *)color { NSString *string=[NSString stringWithCharacters:&character length:1]; NSFont *font=[NSFont fontWithName:fontName size:pointSize]; @@ -29,9 +21,6 @@ static NSMutableArray *_fontHolder; color,NSForegroundColorAttributeName, nil]; - if(![_fontHolder containsObject:font]) - [_fontHolder addObject:font]; - _attributedString=[[NSAttributedString alloc] initWithString:string attributes:attributes]; return self; diff --git a/AppKit/NSKeyValueBinding/NSObject+BindingSupport.m b/AppKit/NSKeyValueBinding/NSObject+BindingSupport.m index 81db5ed7..1d603771 100644 --- a/AppKit/NSKeyValueBinding/NSObject+BindingSupport.m +++ b/AppKit/NSKeyValueBinding/NSObject+BindingSupport.m @@ -14,8 +14,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -NSMutableDictionary *bindersForObjects=nil; -NSDictionary *defaultBindingOptions; +static NSMutableDictionary *bindersForObjects=nil; +static NSDictionary *defaultBindingOptions; #pragma mark - #pragma mark Binding Option Keys diff --git a/ApplicationServices/CGGeometry.h b/ApplicationServices/CGGeometry.h index c2859fc9..7a3c58e0 100755 --- a/ApplicationServices/CGGeometry.h +++ b/ApplicationServices/CGGeometry.h @@ -15,9 +15,9 @@ typedef NSPoint CGPoint; typedef NSSize CGSize; typedef NSRect CGRect; -COREGRAPHICS_EXPORT CGRect CGRectZero; -COREGRAPHICS_EXPORT CGPoint CGPointZero; -COREGRAPHICS_EXPORT CGSize CGSizeZero; +COREGRAPHICS_EXPORT const CGRect CGRectZero; +COREGRAPHICS_EXPORT const CGPoint CGPointZero; +COREGRAPHICS_EXPORT const CGSize CGSizeZero; static inline CGRect CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) { return NSMakeRect(x,y,width,height); diff --git a/CoreData/CoreData.xcodeproj/project.pbxproj b/CoreData/CoreData.xcodeproj/project.pbxproj index 8cab5acc..644c7d3e 100644 --- a/CoreData/CoreData.xcodeproj/project.pbxproj +++ b/CoreData/CoreData.xcodeproj/project.pbxproj @@ -95,6 +95,20 @@ remoteGlobalIDString = FED70FB70C3C09C7000CBE5B; remoteInfo = "Foundation-Darwin-ppc"; }; + FE6E110C0F4F8F6600C65544 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E2F48FA10DC80FAE00310CCE /* AppKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = C889770C0EA0BF3100D0A0A2 /* AppKit.framework */; + remoteInfo = "AppKit-Linux-i386"; + }; + FE6E110E0F4F8F6600C65544 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E2F48FA10DC80FAE00310CCE /* AppKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = C8A2E5730F07EA1F0054397C /* AppKit.framework */; + remoteInfo = "AppKit-Darwin-i386"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -252,6 +266,8 @@ isa = PBXGroup; children = ( E2F48FA60DC80FAE00310CCE /* AppKit.framework */, + FE6E110D0F4F8F6600C65544 /* AppKit.framework */, + FE6E110F0F4F8F6600C65544 /* AppKit.framework */, ); name = Products; sourceTree = ""; @@ -387,6 +403,20 @@ remoteRef = FE59F3170D54301D00D54A25 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + FE6E110D0F4F8F6600C65544 /* AppKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = AppKit.framework; + remoteRef = FE6E110C0F4F8F6600C65544 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + FE6E110F0F4F8F6600C65544 /* AppKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = AppKit.framework; + remoteRef = FE6E110E0F4F8F6600C65544 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ diff --git a/CoreData/NSEntityDescription.m b/CoreData/NSEntityDescription.m index 6bb16389..fd1d4306 100644 --- a/CoreData/NSEntityDescription.m +++ b/CoreData/NSEntityDescription.m @@ -128,7 +128,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI struct objc_method_list *newMethodList = malloc(sizeof(struct objc_method_list) + [newMethods count] * sizeof(struct objc_method)); - newMethodList->method_next = NULL; newMethodList->method_count = [newMethods count]; NSInteger i = 0; for(NSValue *methodValue in newMethods) { diff --git a/Foundation/NSBundle.h b/Foundation/NSBundle.h index 179843f7..754fa8ef 100755 --- a/Foundation/NSBundle.h +++ b/Foundation/NSBundle.h @@ -18,6 +18,7 @@ FOUNDATION_EXPORT NSString *NSLoadedClasses; NSString *_resourcePath; NSDictionary *_infoDictionary; NSString *_executablePath; + NSArray *_lookInDirectories; BOOL _isLoaded; } diff --git a/Foundation/NSBundle.m b/Foundation/NSBundle.m index adbdd725..89befc4c 100755 --- a/Foundation/NSBundle.m +++ b/Foundation/NSBundle.m @@ -389,18 +389,18 @@ static NSMapTable *pathToObject=NULL; return 0; } -static NSArray *_sharedLookInDirectoriesArray = nil; - -(NSArray *)lookInDirectories { - if (_sharedLookInDirectoriesArray == nil) + if (_lookInDirectories == nil) { + // FIXME: This should be based on language preference order, and tested for presence in bundle before adding + NSString *language = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]; if ([language isEqualToString:@"English"]) - _sharedLookInDirectoriesArray = [[NSArray arrayWithObjects:@"English.lproj", @"", nil] retain]; + _lookInDirectories = [[NSArray arrayWithObjects:@"English.lproj", @"", nil] retain]; else - _sharedLookInDirectoriesArray = [[NSArray arrayWithObjects:[language stringByAppendingPathExtension:@"lproj"], @"English.lproj", @"", nil] retain]; + _lookInDirectories = [[NSArray arrayWithObjects:[language stringByAppendingPathExtension:@"lproj"], @"English.lproj", @"", nil] retain]; } - return _sharedLookInDirectoriesArray; + return _lookInDirectories; } -(NSString *)pathForResourceFile:(NSString *)file inDirectory:(NSString *)directory { diff --git a/Foundation/NSClassDescription.m b/Foundation/NSClassDescription.m index 62dc1558..02b8d709 100644 --- a/Foundation/NSClassDescription.m +++ b/Foundation/NSClassDescription.m @@ -19,8 +19,10 @@ static NSMutableDictionary* classDescriptionCache = nil; + (NSClassDescription*) classDescriptionForClass: (Class) class { - // @synchronized(self) { // should be in, but bus error in gcc - id result = [classDescriptionCache objectForKey: + id result; + + @synchronized(self) { + result = [classDescriptionCache objectForKey: NSStringFromClass(class)]; if (!result) { [[NSNotificationCenter defaultCenter] postNotificationName: @@ -28,28 +30,28 @@ NSClassDescriptionNeededForClassNotification object: class]; } result = [classDescriptionCache objectForKey: NSStringFromClass(class)]; - //} + } return result; } + (void)invalidateClassDescriptionCache { - // @synchronized(self) { // should be in, but bus error in gcc + @synchronized(self) { [classDescriptionCache release]; classDescriptionCache = nil; - //} + } } + (void) registerClassDescription: (NSClassDescription*)description forClass: (Class) class { - // @synchronized(self) { // should be in, but bus error in gcc + @synchronized(self) { if (!classDescriptionCache) { classDescriptionCache = [[NSMutableDictionary alloc] init]; } [classDescriptionCache setObject: description forKey: NSStringFromClass(class)]; - //} + } } -(NSArray *)attributeKeys { diff --git a/Foundation/NSDebug.m b/Foundation/NSDebug.m index 5c81e8ab..0ba9d7fe 100755 --- a/Foundation/NSDebug.m +++ b/Foundation/NSDebug.m @@ -9,13 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -#if 0 -#warning !!!!!!!!!!!!!!!!ZOMBIES ENABLED!!!!!!!!!!!!!!!! -BOOL NSZombieEnabled=YES; -#else BOOL NSZombieEnabled=NO; -#endif - BOOL NSDebugEnabled=NO; const char* _NSPrintForDebugger(id object) { diff --git a/Foundation/NSIndexPath.m b/Foundation/NSIndexPath.m index ea5e9f1b..cbacba96 100644 --- a/Foundation/NSIndexPath.m +++ b/Foundation/NSIndexPath.m @@ -15,16 +15,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSIndexPath -#define PATH_CACHE_SIZE 512 // adjust, if not suitable in praxis - -static NSMutableSet* pathCache = nil; - -+ (void) initialize { - if (pathCache == nil) { - pathCache = [[NSMutableSet alloc] init]; - } -} - + (NSIndexPath*) indexPathWithIndex: (unsigned int) index { return [[[self alloc] initWithIndexes: &index length: 1] autorelease]; } @@ -49,26 +39,9 @@ static NSMutableSet* pathCache = nil; _hash = _hash*2 + _indexes[i]; } _hash = 2*_hash + _length; - - id cachedInstance = [pathCache member: self]; - _indexes = NULL; // make sure, free() is not called - - if (cachedInstance) { - [self release]; - return cachedInstance; - } - - // copy indexes only, if no cached instance exists: - _indexes = malloc(length*sizeof(unsigned int)); + _indexes = malloc(length*sizeof(unsigned int)); memcpy(_indexes, indexes, length*sizeof(unsigned int)); - - // Make sure, pathCache does not grow larger than 1024 elements. Should be do that? - if ([pathCache count] >= PATH_CACHE_SIZE) { - [pathCache removeObject: [pathCache anyObject]]; - } - - [pathCache addObject: self]; - } + } return self; } diff --git a/Foundation/NSLock/NSSynchronization.m b/Foundation/NSLock/NSSynchronization.m index e0f73259..7bbd2f9e 100644 --- a/Foundation/NSLock/NSSynchronization.m +++ b/Foundation/NSLock/NSSynchronization.m @@ -26,7 +26,7 @@ typedef struct LockChain struct LockChain *next; } LockChain; -LockChain *allLocks[NUM_CHAINS]={0}; +static LockChain *allLocks[NUM_CHAINS]={0}; void _NSInitializeSynchronizedDirective() { diff --git a/Foundation/NSMethodSignature.h b/Foundation/NSMethodSignature.h index 0b42a057..d4e78e42 100755 --- a/Foundation/NSMethodSignature.h +++ b/Foundation/NSMethodSignature.h @@ -11,7 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @class NSString,NSMutableArray; @interface NSMethodSignature : NSObject { - const char *_typesCString; + char *_typesCString; NSString *_returnType; NSMutableArray *_types; void* _closure; diff --git a/Foundation/NSMethodSignature.m b/Foundation/NSMethodSignature.m index 40a1d074..6690ee07 100755 --- a/Foundation/NSMethodSignature.m +++ b/Foundation/NSMethodSignature.m @@ -16,48 +16,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSMethodSignature -static unsigned stringHash(NSMapTable *table,const void *data){ - const char *s=data; - - if(s!=NULL) - return NSStringHashZeroTerminatedASCII(s); - - return 0; -} - -static BOOL stringIsEqual(NSMapTable *tabl,const void *data1,const void *data2){ - if (data1 == data2) - return YES; - - if (!data1) - return ! strlen ((char *) data2); - - if (!data2) - return ! strlen ((char *) data1); - - if (((char *) data1)[0] != ((char *) data2)[0]) - return NO; - - return (strcmp ((char *) data1, (char *) data2)) ? NO : YES; -} - -static NSMapTableKeyCallBacks keyCallBacks = { - stringHash,stringIsEqual,NULL,NULL,NULL,NULL -}; - -static NSMapTable *_cache=NULL; - -+(void)initialize { - if(self==[NSMethodSignature class]) - _cache=NSCreateMapTable(keyCallBacks,NSObjectMapValueCallBacks,0); -} - -initWithTypes:(const char *)types { - const char *next=types,*last=types; + const char *next,*last; unsigned size,align; BOOL first=YES; - _typesCString=types; + // not guaranteed that types is static + _typesCString=NSZoneMalloc(NULL,strlen(types)+1); + strcpy(_typesCString,types); + next=last=_typesCString; _returnType=nil; _types=[[NSMutableArray allocWithZone:NULL] init]; @@ -84,6 +51,7 @@ static NSMapTable *_cache=NULL; } -(void)dealloc { + NSZoneFree(NULL,_typesCString); [_returnType release]; [_types release]; if([self respondsToSelector:@selector(_deallocateClosure)]) @@ -91,32 +59,8 @@ static NSMapTable *_cache=NULL; [super dealloc]; } -NSMethodSignature *NSMethodSignatureWithTypes(const char *types) { - NSMethodSignature *entry; - char *typesCopy; - - if(_cache==NULL) - [NSMethodSignature class]; // initialize - - entry=NSMapGet(_cache,types); - - if(entry==nil){ - entry=[[NSMethodSignature allocWithZone:NULL] initWithTypes:types]; - - // not guaranteed that types is static - typesCopy=NSZoneMalloc(NULL,strlen(types)+1); - strcpy(typesCopy,types); - - NSMapInsert(_cache,typesCopy,entry); - - [entry release]; - } - - return entry; -} - +(NSMethodSignature *)signatureWithObjCTypes:(const char *)types { - return NSMethodSignatureWithTypes(types); + return [[[NSMethodSignature allocWithZone:NULL] initWithTypes:types] autorelease]; } -(NSString *)description { @@ -124,7 +68,7 @@ NSMethodSignature *NSMethodSignatureWithTypes(const char *types) { } -(unsigned)hash { - return stringHash(NULL,_typesCString); + return NSStringHashZeroTerminatedASCII(_typesCString); } -(BOOL)isEqual:otherObject { diff --git a/Foundation/NSObject/NSObject.m b/Foundation/NSObject/NSObject.m index daeb4de3..8d91ba8e 100755 --- a/Foundation/NSObject/NSObject.m +++ b/Foundation/NSObject/NSObject.m @@ -19,8 +19,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types); - @interface NSInvocation(private) +(NSInvocation *)invocationWithMethodSignature:(NSMethodSignature *)signature arguments:(void *)arguments; @end @@ -86,7 +84,7 @@ extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types); +(NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)selector { const char *types=OBJCTypesForSelector(self,selector); - return (types==NULL)?(NSMethodSignature *)nil:NSMethodSignatureWithTypes(types); + return (types==NULL)?(NSMethodSignature *)nil:[NSMethodSignature signatureWithObjCTypes:types]; } +(BOOL)resolveClassMethod:(SEL)selector { @@ -184,7 +182,7 @@ extern NSMethodSignature *NSMethodSignatureWithTypes(const char *types); -(NSMethodSignature *)methodSignatureForSelector:(SEL)selector { const char *types=OBJCTypesForSelector(isa,selector); - return (types==NULL)?(NSMethodSignature *)nil:NSMethodSignatureWithTypes(types); + return (types==NULL)?(NSMethodSignature *)nil:[NSMethodSignature signatureWithObjCTypes:types]; } -(void)forwardInvocation:(NSInvocation *)invocation { diff --git a/Foundation/NSProcessInfo.h b/Foundation/NSProcessInfo.h index ab983394..745d49c2 100755 --- a/Foundation/NSProcessInfo.h +++ b/Foundation/NSProcessInfo.h @@ -8,7 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import -@class NSArray,NSDictionary; +@class NSArray,NSDictionary,NSLock; enum { NSWindowsNTOperatingSystem=1, @@ -22,6 +22,8 @@ enum { NSArray *_arguments; NSString *_hostName; NSString *_processName; + NSInteger _counter; + NSLock *_counterLock; } +(NSProcessInfo *)processInfo; diff --git a/Foundation/NSProcessInfo.m b/Foundation/NSProcessInfo.m index 84e8c18e..44221813 100755 --- a/Foundation/NSProcessInfo.m +++ b/Foundation/NSProcessInfo.m @@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -// Original - Christopher Lloyd #import #import #import @@ -23,20 +21,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI int NSProcessInfoArgc=0; const char * const *NSProcessInfoArgv=NULL; -static NSLock *_counterLock=nil; - -+(void)initialize { - if(self==[NSProcessInfo class]) - _counterLock=[NSLock new]; -} - --(int)incrementCounter { - static int counter=0; +-(NSInteger)incrementCounter { int result; [_counterLock lock]; - counter++; - result=counter; + _counter++; + result=_counter; [_counterLock unlock]; return result; @@ -51,6 +41,8 @@ static NSLock *_counterLock=nil; _arguments=nil; _hostName=nil; _processName=nil; + _counter=0; + _counterLock=[NSLock new]; return self; } diff --git a/Foundation/NSPropertyList/NSPropertyListReader_vintage.h b/Foundation/NSPropertyList/NSPropertyListReader_vintage.h index 7fb80e57..1436d431 100755 --- a/Foundation/NSPropertyList/NSPropertyListReader_vintage.h +++ b/Foundation/NSPropertyList/NSPropertyListReader_vintage.h @@ -26,6 +26,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI unsigned _index; unsigned _lineNumber; + + Class _stringClass; + Class _dictionaryClass; + Class _arrayClass; } +(NSObject *)propertyListFromData:(NSData *)data; diff --git a/Foundation/NSPropertyList/NSPropertyListReader_vintage.m b/Foundation/NSPropertyList/NSPropertyListReader_vintage.m index 2a9b2bf7..701aa767 100755 --- a/Foundation/NSPropertyList/NSPropertyListReader_vintage.m +++ b/Foundation/NSPropertyList/NSPropertyListReader_vintage.m @@ -15,21 +15,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -static Class NSStringClass=nil; -static Class NSMutableDictionaryClass=nil; -static Class NSMutableArrayClass=nil; - @implementation NSPropertyListReader_vintage -+(void)initialize { - if(self==[NSPropertyListReader_vintage class]) - { - NSStringClass=[NSString class]; - NSMutableDictionaryClass=[NSMutableDictionary class]; - NSMutableArrayClass=[NSMutableArray class]; - } -} - -initWithData:(NSData *)data { _data=[data retain]; _length=[_data length]; @@ -46,6 +33,10 @@ static Class NSMutableArrayClass=nil; _index=0; _lineNumber=1; + _stringClass=[NSString class]; + _dictionaryClass=[NSMutableDictionary class]; + _arrayClass=[NSMutableArray class]; + return self; } @@ -128,7 +119,7 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c -(id)convertValue:(id)value { - if(![value isKindOfClass:NSStringClass]) + if(![value isKindOfClass:_stringClass]) return value; id scanner=[NSScanner scannerWithString:value]; @@ -220,17 +211,17 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c object=popObject(self); key=popObject(self); - if(![key isKindOfClass:NSStringClass]){ + if(![key isKindOfClass:_stringClass]){ [key release]; [object release]; - return [self internalError:NSStringClass]; + return [self internalError:_stringClass]; } dictionary=topObject(self); - if(![dictionary isKindOfClass:NSMutableDictionaryClass]){ + if(![dictionary isKindOfClass:_dictionaryClass]){ [key release]; [object release]; - return [self internalError:NSMutableDictionaryClass]; + return [self internalError:_dictionaryClass]; } [dictionary setObject:[self convertValue:object] forKey:key]; [key release]; @@ -241,8 +232,8 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c if(expect!=EXPECT_KEY) return [self parseError:expect:code info:info]; - if(![topObject(self) isKindOfClass:NSMutableDictionaryClass]) - return [self internalError:NSMutableDictionaryClass]; + if(![topObject(self) isKindOfClass:_dictionaryClass]) + return [self internalError:_dictionaryClass]; expect=(_stackSize==1)?EXPECT_EOF:EXPECT_SEPARATOR; } @@ -263,9 +254,9 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c object=popObject(self); array=topObject(self); - if(![array isKindOfClass:NSMutableArrayClass]){ + if(![array isKindOfClass:_arrayClass]){ [object release]; - return [self internalError:NSMutableArrayClass]; + return [self internalError:_arrayClass]; } [array addObject:[self convertValue:object]]; @@ -285,9 +276,9 @@ static inline void appendCharacter(NSPropertyListReader_vintage *self,unsigned c object=popObject(self); array=topObject(self); - if(![array isKindOfClass:NSMutableArrayClass]){ + if(![array isKindOfClass:_arrayClass]){ [object release]; - return [self internalError:NSMutableArrayClass]; + return [self internalError:_arrayClass]; } if(object!=nil){ diff --git a/Foundation/NSZone/NSZone.m b/Foundation/NSZone/NSZone.m index b1c1f954..b0fb442f 100755 --- a/Foundation/NSZone/NSZone.m +++ b/Foundation/NSZone/NSZone.m @@ -52,7 +52,7 @@ typedef struct { RefCountBucket **buckets; } RefCountTable; -OSSpinLock RefCountLock=0; +static OSSpinLock RefCountLock=0; static inline RefCountTable *CreateRefCountTable() { RefCountTable *table; diff --git a/Foundation/objc/ObjCClass.m b/Foundation/objc/ObjCClass.m index 6cf109c7..0d29d3ed 100755 --- a/Foundation/objc/ObjCClass.m +++ b/Foundation/objc/ObjCClass.m @@ -5,8 +5,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -// Original - David Young , Christopher Lloyd #import #import #import "Protocol.h" @@ -128,23 +126,23 @@ static void OBJCRegisterSelectorsInClass(Class class) { } } -static void OBJCInitializeCacheEntry(OBJCMethodCacheEntry *entry){ - static struct objc_method empty={ - 0,NULL,NULL - }; - +static inline void OBJCInitializeCacheEntryOffset(OBJCMethodCacheEntry *entry){ entry->offsetToNextEntry=-((long)entry); - entry->method=∅ } static void OBJCCreateCacheForClass(Class class){ if(class->cache==NULL){ + static struct objc_method empty={ + 0,NULL,NULL + }; int i; class->cache=NSZoneCalloc(NULL,1,sizeof(OBJCMethodCache)); for(i=0;icache->table+i); + OBJCMethodCacheEntry *entry=class->cache->table+i; + OBJCInitializeCacheEntryOffset(entry); + entry->method=∅ } } } @@ -360,7 +358,7 @@ id OBJCMessageNil(id object,SEL message,...){ static OBJCMethodCacheEntry *allocateCacheEntry(){ OBJCMethodCacheEntry *result=NSZoneCalloc(NULL,1,sizeof(OBJCMethodCacheEntry)); - OBJCInitializeCacheEntry(result); + OBJCInitializeCacheEntryOffset(result); return result; } diff --git a/Foundation/objc/ObjCSelector.m b/Foundation/objc/ObjCSelector.m index 94d5f7e0..79c0509b 100755 --- a/Foundation/objc/ObjCSelector.m +++ b/Foundation/objc/ObjCSelector.m @@ -16,11 +16,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #define INITIAL_SELECTOR_TABLE_SIZE 4096 // Big System has about 3700 selectors -int selectorCount=0; - static OBJCHashTable *nameToNumber=NULL; - SEL OBJCRegisterSelectorName(const char *name){ SEL result; @@ -30,7 +27,6 @@ SEL OBJCRegisterSelectorName(const char *name){ result=(SEL)OBJCHashValueForKey(nameToNumber,name); if(result==OBJCNilSelector){ - selectorCount++; result=(SEL)OBJCHashInsertValueForKey(nameToNumber,name, (char*)name); } diff --git a/Foundation/objc/objc_forward_ffi.m b/Foundation/objc/objc_forward_ffi.m index ba68e9ff..e6f1fa7b 100644 --- a/Foundation/objc/objc_forward_ffi.m +++ b/Foundation/objc/objc_forward_ffi.m @@ -290,7 +290,6 @@ invocation_closure(ffi_cif* cif, void* result, void** args, void* userdata) @implementation NSMethodSignature (FFIClosure) -(void)_deallocateClosure { - NSLog(@"deallocate closure"); if(((ffi_cif*)_closureInfo)->arg_types) NSZoneFree(NULL, ((ffi_cif*)_closureInfo)->arg_types); if(_closureInfo) diff --git a/Foundation/platform_darwin/DarwinMemoryFunctions.m b/Foundation/platform_darwin/DarwinMemoryFunctions.m index e2e34529..4561cf6a 100755 --- a/Foundation/platform_darwin/DarwinMemoryFunctions.m +++ b/Foundation/platform_darwin/DarwinMemoryFunctions.m @@ -10,12 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import NSUInteger NSPageSize(void) { - static size_t pageSize = 0; - - if (pageSize == 0) - pageSize = getpagesize(); - - return pageSize; + return getpagesize(); } NSUInteger NSRealMemoryAvailable(void) diff --git a/Foundation/platform_linux/NSMemoryFunctions_linux.m b/Foundation/platform_linux/NSMemoryFunctions_linux.m index 66ad6401..189cea44 100755 --- a/Foundation/platform_linux/NSMemoryFunctions_linux.m +++ b/Foundation/platform_linux/NSMemoryFunctions_linux.m @@ -5,20 +5,13 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -// Original - David Young #import #import #import // on Linux, page size is a compiled constant in the kernel unsigned NSPageSize(void) { - static size_t pageSize = 0; - - if (pageSize == 0) - pageSize = getpagesize(); - - return pageSize; + return getpagesize(); } unsigned NSRealMemoryAvailable(void) diff --git a/Foundation/platform_solaris/SolarisMemoryFunctions.m b/Foundation/platform_solaris/SolarisMemoryFunctions.m index 1636880c..94e6568d 100755 --- a/Foundation/platform_solaris/SolarisMemoryFunctions.m +++ b/Foundation/platform_solaris/SolarisMemoryFunctions.m @@ -6,22 +6,12 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// Original - David Young #import #import #import -/* - The page size is a system page size and need not be the same - as the underlying hardware page size. - */ unsigned NSPageSize(void) { - static size_t pageSize = 0; - - if (pageSize == 0) - pageSize = getpagesize(); - - return pageSize; + return getpagesize(); } unsigned NSRealMemoryAvailable(void)