Update for new runtime api

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-02-20 08:32:54 +00:00
parent 050f3f7190
commit d32eb0e985
7 changed files with 46 additions and 29 deletions

View file

@ -1,3 +1,14 @@
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPortCoder.m:
* Source/common.h:
* Source/NSObject.m:
* Source/NSAutoreleasePool.m:
* Source/NSProxy.m:
* Source/NSSerializer.m:
Replace all calls to get_imp() with the new runtime API
class_getMethodImplementation().
2011-02-20 Richard Frith-Macdonald <rfm@gnu.org> 2011-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDistributedNotificationCenter.m: * Source/NSDistributedNotificationCenter.m:

View file

@ -433,13 +433,14 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
{ {
/* If anObject was an instance, c is it's class. /* If anObject was an instance, c is it's class.
* If anObject was a class, c is its metaclass. * If anObject was a class, c is its metaclass.
* Either way, get_imp() should get the appropriate pointer. * Either way, we should get the appropriate pointer.
* If anObject is a proxy to something, * If anObject is a proxy to something,
* the +instanceMethodForSelector: and -methodForSelector: * the +instanceMethodForSelector: and -methodForSelector:
* methods may not exist, but get_imp() will return the * methods may not exist, but this will return the
* address of the forwarding method if necessary. * address of the forwarding method if necessary.
*/ */
imps[hash] = get_imp(c, @selector(release)); imps[hash]
= class_getMethodImplementation(c, @selector(release));
classes[hash] = c; classes[hash] = c;
} }
(imps[hash])(anObject, @selector(release)); (imps[hash])(anObject, @selector(release));

View file

@ -586,7 +586,7 @@ GSFinalize(void* object, void* data)
static BOOL static BOOL
GSIsFinalizable(Class c) GSIsFinalizable(Class c)
{ {
if (get_imp(c, finalize_sel) != finalize_imp) if (class_getMethodImplementation(c, finalize_sel) != finalize_imp)
return YES; return YES;
return NO; return NO;
} }
@ -927,7 +927,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
#if GS_WITH_GC #if GS_WITH_GC
finalize_sel = @selector(finalize); finalize_sel = @selector(finalize);
finalize_imp = get_imp(self, finalize_sel); finalize_imp = class_getMethodImplementation(self, finalize_sel);
#endif #endif
#if (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) #if (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__)
@ -1376,9 +1376,10 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
/* /*
* Since 'self' is an class, get_imp() will get the instance method. * Since 'self' is an class, class_getMethodImplementation() will get
* the instance method.
*/ */
return get_imp((Class)self, aSelector); return class_getMethodImplementation((Class)self, aSelector);
} }
/** /**
@ -1393,11 +1394,11 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
/* /*
* If 'self' is an instance, object_getClass() will get the class, * If 'self' is an instance, object_getClass() will get the class,
* and get_imp() will get the instance method. * and class_getMethodImplementation() will get the instance method.
* If 'self' is a class, object_getClass() will get the meta-class, * If 'self' is a class, object_getClass() will get the meta-class,
* and get_imp() will get the class method. * and class_getMethodImplementation() will get the class method.
*/ */
return get_imp(object_getClass(self), aSelector); return class_getMethodImplementation(object_getClass(self), aSelector);
} }
/** /**
@ -1767,7 +1768,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
msg = get_imp(object_getClass(self), aSelector); msg = class_getMethodImplementation(object_getClass(self), aSelector);
if (!msg) if (!msg)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
@ -1792,7 +1793,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
msg = get_imp(object_getClass(self), aSelector); msg = class_getMethodImplementation(object_getClass(self), aSelector);
if (!msg) if (!msg)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
@ -1820,7 +1821,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
msg = get_imp(object_getClass(self), aSelector); msg = class_getMethodImplementation(object_getClass(self), aSelector);
if (!msg) if (!msg)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException

View file

@ -2044,10 +2044,10 @@ static IMP _xRefImp; /* Serialize a crossref. */
{ {
proxyClass = [NSDistantObject class]; proxyClass = [NSDistantObject class];
/* /*
* use get_imp() because NSDistantObject doesn't implement * Use class_getMethodImplementation() because NSDistantObject
* methodForSelector: * doesn't implement methodForSelector:
*/ */
proxyImp = get_imp(object_getClass((id)proxyClass), proxyImp = class_getMethodImplementation(object_getClass((id)proxyClass),
@selector(proxyWithLocal:connection:)); @selector(proxyWithLocal:connection:));
} }

View file

@ -102,9 +102,10 @@ extern BOOL __objc_responds_to(id, SEL);
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
/* /*
* Since 'self' is an class, get_imp() will get the instance method. * Since 'self' is an class, class_getMethodImplementation() will get
* the instance method.
*/ */
return get_imp((Class)self, aSelector); return class_getMethodImplementation((Class)self, aSelector);
} }
/** /**
@ -137,7 +138,7 @@ extern BOOL __objc_responds_to(id, SEL);
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; format: @"%@ null selector given", NSStringFromSelector(_cmd)];
return get_imp(object_getClass((id)self), aSelector); return class_getMethodImplementation(object_getClass((id)self), aSelector);
} }
/** /**
@ -475,10 +476,10 @@ extern BOOL __objc_responds_to(id, SEL);
{ {
proxyClass = [NSDistantObject class]; proxyClass = [NSDistantObject class];
/* /*
* use get_imp() because NSDistantObject doesn't implement * use class_getMethodImplementation() because NSDistantObject
* methodForSelector: * doesn't implement methodForSelector:
*/ */
proxyImp = get_imp(object_getClass((id)proxyClass), proxyImp = class_getMethodImplementation(object_getClass((id)proxyClass),
@selector(proxyWithLocal:connection:)); @selector(proxyWithLocal:connection:));
} }

View file

@ -144,11 +144,16 @@ initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u)
c = object_getClass(d); c = object_getClass(d);
info->data = d; info->data = d;
info->appImp = (void (*)(NSData*,SEL,const void*,unsigned))get_imp(c, appSel); info->appImp = (void (*)(NSData*,SEL,const void*,unsigned))
info->datImp = (void* (*)(NSMutableData*,SEL))get_imp(c, datSel); class_getMethodImplementation(c, appSel);
info->lenImp = (unsigned int (*)(NSData*,SEL))get_imp(c, lenSel); info->datImp = (void* (*)(NSMutableData*,SEL))
info->serImp = (void (*)(NSMutableData*,SEL,int))get_imp(c, serSel); class_getMethodImplementation(c, datSel);
info->setImp = (void (*)(NSMutableData*,SEL,unsigned))get_imp(c, setSel); info->lenImp = (unsigned int (*)(NSData*,SEL))
class_getMethodImplementation(c, lenSel);
info->serImp = (void (*)(NSMutableData*,SEL,int))
class_getMethodImplementation(c, serSel);
info->setImp = (void (*)(NSMutableData*,SEL,unsigned))
class_getMethodImplementation(c, setSel);
info->shouldUnique = u; info->shouldUnique = u;
(*info->appImp)(d, appSel, &info->shouldUnique, 1); (*info->appImp)(d, appSel, &info->shouldUnique, 1);
if (u) if (u)

View file

@ -51,5 +51,3 @@
#import "Foundation/NSBundle.h" #import "Foundation/NSBundle.h"
#import "GNUstepBase/NSBundle+GNUstepBase.h" #import "GNUstepBase/NSBundle+GNUstepBase.h"
// Semi-private GNU[step] runtime function.
IMP get_imp(Class, SEL);