Various GSObjCRuntime usage cleanups.

See ChangeLog for details.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17533 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2003-08-24 23:07:41 +00:00
parent 71aead6c7c
commit fda10c748a
17 changed files with 292 additions and 147 deletions

View file

@ -542,8 +542,8 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
[NSException
raise: NSGenericException
format: @"method %s not implemented in %s(%s)",
aSel ? sel_get_name(aSel) : "(null)",
object_get_class_name(self),
aSel ? GSNameFromSelector(aSel) : "(null)",
GSClassNameFromObject(self),
GSObjCIsInstance(self) ? "instance" : "class"];
return nil;
}
@ -553,9 +553,9 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
[NSException
raise: NSGenericException
format: @"%s(%s) should not implement %s",
object_get_class_name(self),
GSClassNameFromObject(self),
GSObjCIsInstance(self) ? "instance" : "class",
aSel ? sel_get_name(aSel) : "(null)"];
aSel ? GSNameFromSelector(aSel) : "(null)"];
return nil;
}
@ -563,9 +563,9 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
{
[NSException raise: NSGenericException
format: @"subclass %s(%s) should override %s",
object_get_class_name(self),
GSClassNameFromObject(self),
GSObjCIsInstance(self) ? "instance" : "class",
aSel ? sel_get_name(aSel) : "(null)"];
aSel ? GSNameFromSelector(aSel) : "(null)"];
return nil;
}

View file

@ -112,7 +112,7 @@
if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
[NSException raise: NSRangeException \
format: @"in %s, range { %u, %u } extends beyond size (%u)", \
sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
GSNameFromSelector(_cmd), RANGE.location, RANGE.length, SIZE]
/* Taken from base/Headers/Foundation/NSString.h */
typedef enum _NSGNUstepStringEncoding

View file

@ -419,17 +419,17 @@ BOOL GSDebugSet(NSString *level)
+ (id) notImplemented:(SEL)selector
{
[NSException raise: NSGenericException
format: @"method %s not implemented in %s(class)",
selector ? sel_get_name(selector) : "(null)",
object_get_class_name(self)];
return nil;
[NSException raise: NSGenericException
format: @"method %s not implemented in %s(class)",
selector ? GSNameFromSelector(selector) : "(null)",
GSClassNameFromObject(self)];
return nil;
}
// In NSObject.m, category GNU
- (BOOL) isInstance
{
return GSObjCIsInstance(self);
return GSObjCIsInstance(self);
}
@end

View file

@ -172,7 +172,7 @@ GSObjCMethodNames(id obj)
NSString *name;
name = [[NSString alloc] initWithUTF8String:
sel_get_name(methods->method_list[i].method_name)];
GSNameFromSelector(methods->method_list[i].method_name)];
[set addObject: name];
RELEASE(name);
}
@ -505,7 +505,7 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
if (behavior_debug)
{
fprintf(stderr, " processing method [%s] ... ",
sel_get_name(method->method_name));
GSNameFromSelector(method->method_name));
}
if (!search_for_method_in_class(class,method->method_name)
@ -610,7 +610,7 @@ GSObjCAddMethods (Class class, struct objc_method_list *methods)
while (counter >= 0)
{
struct objc_method *method = &(mlist->method_list[counter]);
const char *name = sel_get_name(method->method_name);
const char *name = GSNameFromSelector(method->method_name);
if (behavior_debug)
{

View file

@ -212,14 +212,13 @@ gs_method_for_receiver_and_selector (id receiver, SEL sel)
{
if (receiver)
{
if (object_is_instance (receiver))
if (GSObjCIsInstance(receiver))
{
return GSGetInstanceMethod (object_get_class
(receiver), sel);
return GSGetInstanceMethod(GSObjCClass(receiver), sel);
}
else if (object_is_class (receiver))
else if (GSObjCIsClass(receiver))
{
return GSGetClassMethod (receiver, sel);
return GSGetClassMethod(receiver, sel);
}
}
@ -248,7 +247,7 @@ gs_find_best_typed_sel (SEL sel)
{
if (!sel_get_type (sel))
{
const char *name = sel_get_name (sel);
const char *name = GSNameFromSelector(sel);
if (name)
{
@ -679,14 +678,14 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
s.self = _target;
if (GSObjCIsInstance(_target))
s.class = class_get_super_class(GSObjCClass(_target));
s.class = GSObjCSuper(GSObjCClass(_target));
else
s.class = class_get_super_class((Class)_target);
s.class = GSObjCSuper((Class)_target);
imp = objc_msg_lookup_super(&s, _selector);
}
else
{
imp = method_get_imp(object_is_instance(_target) ?
imp = method_get_imp(GSObjCIsInstance(_target) ?
GSGetInstanceMethod(
((struct objc_class*)_target)->class_pointer, _selector)
: GSGetClassMethod(
@ -801,9 +800,13 @@ GSInvocationCallback (void *callback_data, va_alist args)
if (!fwdInvMethod)
{
NSCAssert2 (0, @"GSFFCallInvocation: Class '%s' does not respond"
@" to forwardInvocation: for '%s'",
object_get_class_name (obj), sel_get_name(selector));
[NSException raise: NSInvalidArgumentException
format: @"GSFFCallInvocation: Class '%s(%s)'"
@" does not respond"
@" to forwardInvocation: for '%s'",
GSClassNameFromObject(obj),
GSObjCIsInstance(obj) ? "instance" : "class",
selector ? GSNameFromSelector(selector) : "(null)"];
}
sig = nil;
@ -831,7 +834,7 @@ GSInvocationCallback (void *callback_data, va_alist args)
if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0)
{
const char *runtimeName = sel_get_name (selector);
const char *runtimeName = GSNameFromSelector(selector);
selector = sel_get_typed_uid (runtimeName, receiverTypes);
if (selector == 0)
@ -864,9 +867,9 @@ GSInvocationCallback (void *callback_data, va_alist args)
{
[NSException raise: NSInvalidArgumentException
format: @"%s(%s) does not recognize %s",
object_get_class_name(obj),
GSClassNameFromObject(obj),
GSObjCIsInstance(obj) ? "instance" : "class",
selector ? sel_get_name(selector) : "(null)"];
selector ? GSNameFromSelector(selector) : "(null)"];
}
invocation = [[GSFFCallInvocation alloc] initWithMethodSignature: sig];

View file

@ -59,15 +59,13 @@ gs_method_for_receiver_and_selector (id receiver, SEL sel)
{
if (receiver)
{
if (object_is_instance (receiver))
if (GSObjCIsInstance(receiver))
{
return GSGetInstanceMethod (object_get_class
(receiver), sel);
return GSGetInstanceMethod(GSObjCClass(receiver), sel);
}
else if (object_is_class (receiver))
else if (GSObjCIsClass(receiver))
{
return GSGetClassMethod (object_get_class
(receiver), sel);
return GSGetClassMethod(receiver, sel);
}
}
@ -96,7 +94,7 @@ gs_find_best_typed_sel (SEL sel)
{
if (!sel_get_type (sel))
{
const char *name = sel_get_name (sel);
const char *name = GSNameFromSelector(sel);
if (name)
{
@ -325,14 +323,14 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
s.self = _target;
if (GSObjCIsInstance(_target))
s.class = class_get_super_class(GSObjCClass(_target));
s.class = GSObjCSuper(GSObjCClass(_target));
else
s.class = class_get_super_class((Class)_target);
s.class = GSObjCSuper((Class)_target);
imp = objc_msg_lookup_super(&s, _selector);
}
else
{
imp = method_get_imp(object_is_instance(_target) ?
imp = method_get_imp(GSObjCIsInstance(_target) ?
GSGetInstanceMethod(
((struct objc_class*)_target)->class_pointer, _selector)
: GSGetClassMethod(
@ -420,9 +418,12 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
if (!fwdInvMethod)
{
NSCAssert2 (0, @"GSFFIInvocation: Class '%s' does not respond"
@" to forwardInvocation: for '%s'",
object_get_class_name (obj), sel_get_name(selector));
[NSException raise: NSInvalidArgumentException
format: @"GSFFIInvocation: Class '%s'(%s) does not respond"
@" to forwardInvocation: for '%s'",
GSClassNameFromObject(obj),
GSObjCIsInstance(obj) ? "instance" : "class",
selector ? GSNameFromSelector(selector) : "(null)"];
}
sig = nil;
@ -446,7 +447,7 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0)
{
const char *runtimeName = sel_get_name (selector);
const char *runtimeName = GSNameFromSelector(selector);
selector = sel_get_typed_uid (runtimeName, receiverTypes);
if (selector == 0)
@ -479,9 +480,9 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
{
[NSException raise: NSInvalidArgumentException
format: @"%s(%s) does not recognize %s",
object_get_class_name(obj),
GSClassNameFromObject(obj),
GSObjCIsInstance(obj) ? "instance" : "class",
selector ? sel_get_name(selector) : "(null)"];
selector ? GSNameFromSelector(selector) : "(null)"];
}
invocation = [[GSFFIInvocation alloc] initWithCallback: cif

View file

@ -1832,7 +1832,7 @@ static void retEncoder (DOContext *ctxt)
type = [[object methodSignatureForSelector: sel] methodType];
if (type)
{
sel_register_typed_name(sel_get_name(sel), type);
sel_register_typed_name(GSNameFromSelector(sel), type);
}
}
#endif
@ -1885,7 +1885,7 @@ static void retEncoder (DOContext *ctxt)
[self _sendOutRmc: ctxt.encoder type: METHOD_REQUEST];
ctxt.encoder = nil;
NSDebugMLLog(@"NSConnection", @"Sent message (%s) to 0x%x",
sel_get_name(sel), (gsaddr)self);
GSNameFromSelector(sel), (gsaddr)self);
if (needsResponse == NO)
{
@ -1952,7 +1952,7 @@ static void retEncoder (DOContext *ctxt)
type = [[object methodSignatureForSelector: [inv selector]] methodType];
if (type)
{
sel_register_typed_name(sel_get_name([inv selector]), type);
sel_register_typed_name(GSNameFromSelector([inv selector]), type);
}
}
NSParameterAssert(type);

View file

@ -1007,7 +1007,7 @@ static inline BOOL class_is_kind_of (Class self, Class aClassObject)
{
Class class;
for (class = self; class!=Nil; class = class_get_super_class(class))
for (class = self; class!=Nil; class = GSObjCSuper(class))
if (class==aClassObject)
return YES;
return NO;
@ -1040,7 +1040,7 @@ static inline BOOL class_is_kind_of (Class self, Class aClassObject)
- (id) forward: (SEL)aSel :(arglist_t)frame
{
if (debug_proxy)
NSLog(@"NSDistantObject forwarding %s\n", sel_get_name(aSel));
NSLog(@"NSDistantObject forwarding %s\n", GSNameFromSelector(aSel));
if (![_connection isValid])
[NSException

View file

@ -558,14 +558,14 @@ _arg_addr(NSInvocation *inv, int index)
s.receiver = _target;
#endif
if (GSObjCIsInstance(_target))
s.class = class_get_super_class(GSObjCClass(_target));
s.class = GSObjCSuper(GSObjCClass(_target));
else
s.class = class_get_super_class((Class)_target);
s.class = GSObjCSuper((Class)_target);
imp = objc_msg_lookup_super(&s, _selector);
}
else
{
imp = method_get_imp(object_is_instance(_target) ?
imp = method_get_imp(GSObjCIsInstance(_target) ?
GSGetInstanceMethod(
((struct objc_class*)_target)->class_pointer, _selector)
: GSGetClassMethod(
@ -608,14 +608,14 @@ _arg_addr(NSInvocation *inv, int index)
*/
char buffer[1024];
sprintf (buffer, "<%s %p selector: %s target: %s>", \
(char*)object_get_class_name(self), \
snprintf (buffer, 1024, "<%s %p selector: %s target: %s>", \
GSClassNameFromObject(self), \
self, \
_selector ? [NSStringFromSelector(_selector) cString] : "nil", \
_target ? [NSStringFromClass([_target class]) cString] : "nil" \
_selector ? GSNameFromSelector(_selector) : "nil", \
_target ? GSNameFromClass([_target class]) : "nil" \
);
return [NSString stringWithCString:buffer];
return [NSString stringWithCString: buffer];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
@ -761,12 +761,12 @@ _arg_addr(NSInvocation *inv, int index)
types = sel_get_type(aSelector);
if (types == 0)
{
types = sel_get_type(sel_get_any_typed_uid(sel_get_name(aSelector)));
types = sel_get_type(sel_get_any_typed_uid(GSNameFromSelector(aSelector)));
}
if (types == 0)
{
NSLog(@"Couldn't find encoding type for selector %s.",
sel_get_name(aSelector));
GSNameFromSelector(aSelector));
RELEASE(self);
return nil;
}

View file

@ -701,7 +701,7 @@ GSDescriptionForInstanceMethod(pcl self, SEL aSel)
{
int i;
struct objc_protocol_list *p_list;
const char *name = sel_get_name (aSel);
const char *name = GSNameFromSelector(aSel);
struct objc_method_description *result;
if (self->instance_methods != 0)
@ -732,7 +732,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
{
int i;
struct objc_protocol_list *p_list;
const char *name = sel_get_name (aSel);
const char *name = GSNameFromSelector(aSel);
struct objc_method_description *result;
if (self->class_methods != 0)
@ -1184,7 +1184,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
*/
+ (Class) superclass
{
return class_get_super_class (self);
return GSObjCSuper(self);
}
/**
@ -1404,7 +1404,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
- (NSString*) description
{
return [NSString stringWithFormat: @"<%s: %lx>",
object_get_class_name(self), (unsigned long)self];
GSClassNameFromObject(self), (unsigned long)self];
}
/**
@ -1437,9 +1437,9 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
{
[NSException raise: NSInvalidArgumentException
format: @"%s(%s) does not recognize %s",
object_get_class_name(self),
GSClassNameFromObject(self),
GSObjCIsInstance(self) ? "instance" : "class",
aSelector ? sel_get_name(aSelector) : "(null)"];
aSelector ? GSNameFromSelector(aSelector) : "(null)"];
}
- (retval_t) forward: (SEL)aSel : (arglist_t)argFrame
@ -1681,7 +1681,8 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
if (!msg)
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
format: @"invalid selector passed to %s",
GSNameFromSelector(_cmd)];
return nil;
}
return (*msg)(self, aSelector);
@ -1705,7 +1706,8 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
if (!msg)
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
format: @"invalid selector passed to %s",
GSNameFromSelector(_cmd)];
return nil;
}
@ -1732,7 +1734,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
if (!msg)
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
format: @"invalid selector passed to %s", GSNameFromSelector(_cmd)];
return nil;
}
@ -1906,7 +1908,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
if (aVersion < 0)
[NSException raise: NSInvalidArgumentException
format: @"%s +setVersion: may not set a negative version",
object_get_class_name(self)];
GSClassNameFromObject(self)];
class_set_version(self, aVersion);
return self;
}
@ -1921,11 +1923,11 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
- (id) error: (const char *)aString, ...
{
#define FMT "error: %s (%s)\n%s\n"
char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self))
char fmt[(strlen((char*)FMT)+strlen((char*)GSClassNameFromObject(self))
+((aString!=NULL)?strlen((char*)aString):0)+8)];
va_list ap;
sprintf(fmt, FMT, object_get_class_name(self),
sprintf(fmt, FMT, GSClassNameFromObject(self),
GSObjCIsInstance(self)?"instance":"class",
(aString!=NULL)?aString:"");
va_start(ap, aString);
@ -1939,7 +1941,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
/*
- (const char *) name
{
return object_get_class_name(self);
return GSClassNameFromObject(self);
}
*/
@ -2015,9 +2017,9 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
{
[NSException raise: NSGenericException
format: @"%s(%s) does not recognize %s",
object_get_class_name(self),
GSClassNameFromObject(self),
GSObjCIsInstance(self) ? "instance" : "class",
aSel ? sel_get_name(aSel) : "(null)"];
aSel ? GSNameFromSelector(aSel) : "(null)"];
return nil;
}
@ -2124,7 +2126,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
- (BOOL) isClass
{
return object_is_class(self);
return GSObjCIsClass(self);
}
- (BOOL) isInstance
@ -2271,7 +2273,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
- (NSString*) description
{
return [NSString stringWithFormat: @"<%s: %lx>",
object_get_class_name(self), (unsigned long)self];
GSClassNameFromObject(self), (unsigned long)self];
}
- (BOOL) isProxy
{

View file

@ -94,7 +94,7 @@ extern BOOL __objc_responds_to(id, SEL);
*/
+ (NSString*) description
{
return [NSString stringWithFormat: @"<%s>", object_get_class_name(self)];
return [NSString stringWithFormat: @"<%s>", GSClassNameFromObject(self)];
}
/**
@ -185,7 +185,7 @@ extern BOOL __objc_responds_to(id, SEL);
*/
+ (Class) superclass
{
return class_get_super_class (self);
return GSObjCSuper(self);
}
/**
@ -249,7 +249,7 @@ extern BOOL __objc_responds_to(id, SEL);
- (NSString*) description
{
return [NSString stringWithFormat: @"<%s %lx>",
object_get_class_name(self), (unsigned long)self];
GSClassNameFromObject(self), (unsigned long)self];
}
/**
@ -272,7 +272,7 @@ extern BOOL __objc_responds_to(id, SEL);
{
[NSException raise: NSInvalidArgumentException
format: @"NSProxy should not implement '%s'",
sel_get_name(_cmd)];
GSNameFromSelector(_cmd)];
}
/**
@ -289,8 +289,8 @@ extern BOOL __objc_responds_to(id, SEL);
- (id) init
{
[NSException raise: NSGenericException
format: @"subclass %s should override %s", object_get_class_name(self),
sel_get_name(_cmd)];
format: @"subclass %s should override %s", GSClassNameFromObject(self),
GSNameFromSelector(_cmd)];
return self;
}
@ -355,7 +355,7 @@ extern BOOL __objc_responds_to(id, SEL);
- (id) notImplemented: (SEL)aSel
{
[NSException raise: NSGenericException
format: @"NSProxy notImplemented %s", sel_get_name(aSel)];
format: @"NSProxy notImplemented %s", GSNameFromSelector(aSel)];
return self;
}
@ -394,7 +394,7 @@ extern BOOL __objc_responds_to(id, SEL);
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s",
sel_get_name(_cmd)];
GSNameFromSelector(_cmd)];
return nil;
}
return (*msg)(self, aSelector);
@ -409,7 +409,7 @@ extern BOOL __objc_responds_to(id, SEL);
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s",
sel_get_name(_cmd)];
GSNameFromSelector(_cmd)];
return nil;
}
return (*msg)(self, aSelector, anObject);
@ -425,7 +425,7 @@ extern BOOL __objc_responds_to(id, SEL);
{
[NSException raise: NSGenericException
format: @"invalid selector passed to %s",
sel_get_name(_cmd)];
GSNameFromSelector(_cmd)];
return nil;
}
return (*msg)(self, aSelector, anObject, anotherObject);