Hi
If I ask the GNU ObjC runtime (gcc 4.5) objc_msg_lookup for an IMP of a class'
method, I get an address to a forwarding/error routine back, if the method is
not present (without gnustep-base linked in). From looking with gdb, there
seems to be no symbol attached to the address. To me that implies that there is
no way to see from the returned value, if it is a resolved method or not ?
When I link gnustep-base in, then objc_msg_lookup throws an
NSInvalidArgumentException, because of the unrecognized selector. So
objc_msg_lookup is not something I can use. Is there a method that is as
performant as objc_msg_lookup (using the cache), which does not raise ? I am
assuming class_get_instance_method is traversing the method chains.
Here's my test code and it's output:
#ifndef GNUSTEP
#include <objc/runtime.h>
#include <objc/objc-runtime.h>
#else
#include <objc/objc.h>
#endif
#include <stdio.h>
//
// apple: cc -g -arch i386 -o x x.m -lobjc
// gnu: gcc -DGNUSTEP -o x -g x.m -lobjc
//
@interface Test
@end
@implementation Test
- (id) xxx
{
}
#ifndef GNUSTEP
- (id) forward:(SEL) sel
:(marg_list) args
{
}
#endif
@end
#ifndef GNUSTEP
extern id _objc_msgForward( id, SEL, ...);
#define FWD _objc_msgForward
#define LOOKUP class_lookupMethod
#define GETCLS objc_getClass
#else
extern IMP *__objc_msg_forward2;
#define FWD __objc_msg_forward2
#define LOOKUP objc_msg_lookup
#define GETCLS objc_get_class
#endif
check( SEL sel)
{
IMP imp;
Class cls;
cls = GETCLS( "Test");
imp = LOOKUP( cls, sel);
printf( "%p\n", imp);
}
main()
{
check( @selector( xxx));
check( @selector( yyy));
printf( "(%p)\n", FWD);
}
Apple Output (32bit):
=====================
0x1cd0
0x98c37260
(0x98c37260)
GNUstep Output (no gnustep-base):
=================================
0x8048604
0xb7736660
((nil))
Ciao
Nat!
P.S.: Not caring about the new stuff just yet :)
------------------------------------------------------
Es ist eine so angenehme Empfindung sich mit etwas zu
beschäftigen was man nur halb kann, daß Niemand den
Dilettanten schelten sollte, wenn er sich mit einer
Kunst abgibt, die er nie lernen wird. -- JWG
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev