diff --git a/ChangeLog b/ChangeLog index 3e7b6db7e..575eee8ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2003-03-31 Stephane Corthesy + + * Source/Additions/GCArray.m: Replace retain/release by + RETAIN/RELEASE macros. + * Source/Additions/GCDictionary.m: Idem. + + * Source/Additions/GSCompatibility.h: Add NSBundle category. + * Source/Additions/GSCompatibility.m (GSEncodingName): New. + Add -[NSBundle pathForGNUstepResource:ofType:inDirectory:]. + + * Source/Additions/GSObjCRuntime.m: Include GNUstep.h. + (GSObjCMethodNames): Cast method_name to const char *. + 2003-03-31 Adam Fedor * Headers/gnustep/base/Foundation.h: Add GSCategories.h diff --git a/Source/Additions/GCArray.m b/Source/Additions/GCArray.m index 15f0eea0a..3d9847977 100644 --- a/Source/Additions/GCArray.m +++ b/Source/Additions/GCArray.m @@ -35,6 +35,7 @@ #include #include +#include @implementation GCArray @@ -79,7 +80,7 @@ static Class gcClass = 0; { if (_isGCObject[c] == NO) { - [_contents[c] release]; + DESTROY(_contents[c]); } } } @@ -87,7 +88,7 @@ static Class gcClass = 0; { while (c-- > 0) { - [_contents[c] release]; + DESTROY(_contents[c]); } } @@ -139,7 +140,7 @@ static Class gcClass = 0; _count = 0; while (_count < count) { - _contents[_count] = [objects[_count] retain]; + _contents[_count] = RETAIN(objects[_count]); if (_contents[_count] == nil) { [self release]; @@ -164,7 +165,7 @@ static Class gcClass = 0; _count = 0; while (_count < count) { - _contents[_count] = [[anotherArray objectAtIndex: _count] retain]; + _contents[_count] = RETAIN([anotherArray objectAtIndex: _count]); _isGCObject[_count] = [_contents[_count] isKindOfClass: gcClass]; _count++; } @@ -250,7 +251,7 @@ static Class gcClass = 0; { while (_count < count) { - _contents[_count] = [[anotherArray objectAtIndex: _count] retain]; + _contents[_count] = RETAIN([anotherArray objectAtIndex: _count]); _isGCObject[_count] = [_contents[_count] isKindOfClass: gcClass]; _count++; } @@ -279,7 +280,7 @@ static Class gcClass = 0; { while (_count < count) { - _contents[_count] = [objects[_count] retain]; + _contents[_count] = RETAIN(objects[_count]); if (_contents[_count] == nil) { [self release]; @@ -337,7 +338,7 @@ static Class gcClass = 0; _contents[i] = _contents[i - 1]; _isGCObject[i] = _isGCObject[i - 1]; } - _contents[index] = [anObject retain]; + _contents[index] = RETAIN(anObject); _isGCObject[index] = [anObject isKindOfClass: gcClass]; _count++; } @@ -375,7 +376,7 @@ static Class gcClass = 0; } for (i = range.location; i < NSMaxRange(range); i++) { - [_contents[i] release]; + RELEASE(_contents[i]); } for (i = NSMaxRange(range); i < _count; i++, range.location++) { @@ -399,9 +400,7 @@ static Class gcClass = 0; format: @"[%@-%@]: bad index %u", NSStringFromClass([self class]), NSStringFromSelector(_cmd), index]; } - [anObject retain]; - [_contents[index] release]; - _contents[index] = anObject; + ASSIGN(_contents[index], anObject); _isGCObject[index] = [anObject isKindOfClass: gcClass]; } diff --git a/Source/Additions/GCDictionary.m b/Source/Additions/GCDictionary.m index 44ab82439..2f9bf6067 100644 --- a/Source/Additions/GCDictionary.m +++ b/Source/Additions/GCDictionary.m @@ -61,7 +61,7 @@ typedef struct { - (void) dealloc { NSEndMapTableEnumeration(&enumerator); - [dict release]; + DESTROY(dict); [super dealloc]; } - (id) nextObject @@ -104,7 +104,7 @@ _GCRetainObjects(NSMapTable *table, const void *ptr) { GCInfo *objectStruct = (GCInfo*)ptr; - [objectStruct->object retain]; + RETAIN(objectStruct->object); } static void @@ -116,12 +116,12 @@ _GCReleaseObjects(NSMapTable *table, const void *ptr) { if (objectStruct->isGCObject == NO) { - [objectStruct->object release]; + DESTROY(objectStruct->object); } } else { - [objectStruct->object release]; + DESTROY(objectStruct->object); } NSZoneFree(NSDefaultMallocZone(), objectStruct); } @@ -316,7 +316,7 @@ static Class gcClass = 0; e = [_GCDictionaryKeyEnumerator alloc]; e->dict = [self retain]; e->enumerator = NSEnumerateMapTable(_map); - return [e autorelease]; + return AUTORELEASE(e); } - (NSEnumerator*) objectEnumerator @@ -326,7 +326,7 @@ static Class gcClass = 0; e = [_GCDictionaryObjectEnumerator alloc]; e->dict = [self retain]; e->enumerator = NSEnumerateMapTable(_map); - return [e autorelease]; + return AUTORELEASE(e); } - (id) mutableCopyWithZone: (NSZone*)zone diff --git a/Source/Additions/GSCompatibility.h b/Source/Additions/GSCompatibility.h index 10c4ed672..d2c24c164 100644 --- a/Source/Additions/GSCompatibility.h +++ b/Source/Additions/GSCompatibility.h @@ -163,6 +163,12 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock; - (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy; @end +@interface NSBundle(GSCompatibility) ++ (NSString *) pathForGNUstepResource: (NSString *)name + ofType: (NSString *)ext + inDirectory: (NSString *)bundlePath; +@end + @interface NSDistantObject (GSCompatibility) + (void) setDebug: (int)val; @end diff --git a/Source/Additions/GSCompatibility.m b/Source/Additions/GSCompatibility.m index efac5bd50..09f191a62 100644 --- a/Source/Additions/GSCompatibility.m +++ b/Source/Additions/GSCompatibility.m @@ -26,11 +26,18 @@ #include #include "GSCompatibility.h" #include "gnustep/base/GSCategories.h" +#include "gnustep/base/GCObject.h" /* FIXME: Need to initialize this */ NSRecursiveLock *gnustep_global_lock = NULL; NSString *GetEncodingName(NSStringEncoding availableEncodingValue) +{ + // Deprecated + return GSEncodingName(availableEncodingValue); +} + +NSString *GSEncodingName(NSStringEncoding availableEncodingValue) { return (NSString *)CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(availableEncodingValue)); } @@ -211,6 +218,47 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) } else { +} + +@end + +@implementation NSBundle(GSCompatibility) + +// In NSBundle.m ++ (NSString *) pathForGNUstepResource: (NSString *)name + ofType: (NSString *)ext + inDirectory: (NSString *)bundlePath +{ + NSString *path = nil; + NSString *bundle_path = nil; + NSArray *paths; + NSBundle *bundle; + NSEnumerator *enumerator; + + /* Gather up the paths */ + // Originally, looks up in GSLibrariesDirectory, i.e. "Libraries" + paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, + NSAllDomainsMask, YES); + + enumerator = [paths objectEnumerator]; + while ((path == nil) && (bundle_path = [enumerator nextObject])) + { + bundle = [self bundleWithPath: bundle_path]; + path = [bundle pathForResource: name + ofType: ext + inDirectory: bundlePath]; + } + + // New for OSX: looks in framework + if(path == nil){ + if([bundlePath hasPrefix:@"Resources/"]) + bundlePath = [bundlePath substringFromIndex:10]; + path = [[NSBundle bundleForClass:[GCObject class]] pathForResource: name + ofType: ext + inDirectory: bundlePath]; + } + + return path; return NO; } } diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index be5b192d2..25bde2fca 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -45,8 +45,10 @@ #include #endif #include +#include "gnustep/base/GNUstep.h" #include + @class NSNull; /** Deprecated ... use GSObjCFindVariable() */ @@ -151,7 +153,7 @@ GSObjCMethodNames(id obj) NSString *name; name = [[NSString alloc] initWithUTF8String: - method->method_name]; + (const char *)method->method_name]; [set addObject: name]; RELEASE(name); } @@ -831,8 +833,6 @@ GSObjCAddClassBehavior(Class receiver, Class behavior) #ifndef NeXT_Foundation_LIBRARY #include #include -#else -#include #endif /** Deprecated ... use GSObjCGetValue() */