mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
* 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 *. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16309 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ff1c0e236e
commit
2f182f82b2
6 changed files with 86 additions and 20 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2003-03-31 Stephane Corthesy <stephane@sente.ch>
|
||||
|
||||
* 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 <fedor@gnu.org>
|
||||
|
||||
* Headers/gnustep/base/Foundation.h: Add GSCategories.h
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <gnustep/base/GSObjCRuntime.h>
|
||||
#include <gnustep/base/GCObject.h>
|
||||
#include <gnustep/base/GNUstep.h>
|
||||
|
||||
@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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,11 +26,18 @@
|
|||
#include <objc/objc-class.h>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,10 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
#include <gnustep/base/GSObjCRuntime.h>
|
||||
#include "gnustep/base/GNUstep.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@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 <Foundation/NSValue.h>
|
||||
#include <Foundation/NSKeyValueCoding.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
/** Deprecated ... use GSObjCGetValue() */
|
||||
|
|
Loading…
Reference in a new issue