From 9197694fe9fd4eaa6e2c11f0acc92ef60ab6110a Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Fri, 14 Sep 2007 03:26:32 +0200 Subject: New C function: objcl_get_method_implementation. darcs-hash:de2f77980605c7aec911673edb0f0f29d0467fce --- Objective-C/libobjcl.h | 4 ++++ Objective-C/libobjcl.m | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index 270fa78..cb47440 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -60,3 +60,7 @@ objcl_class_name (OBJCL_OBJ_DATA class); const char * objcl_selector_name (OBJCL_OBJ_DATA class); + +IMP +objcl_get_method_implementation (OBJCL_OBJ_DATA object, + OBJCL_OBJ_DATA selector); diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 2e24f71..833a4fb 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -333,3 +333,36 @@ objcl_selector_name (OBJCL_OBJ_DATA selector) return name; } + + +IMP +objcl_get_method_implementation (OBJCL_OBJ_DATA object, + OBJCL_OBJ_DATA selector) +{ + id obj; + + if (strcmp (selector->type, @encode (SEL)) != 0) + return NULL; + + switch (object->type[0]) + { + case '#': + obj = object->data.class_val; + break; + case '@': + obj = object->data.id_val; + break; + case 'E': + obj = (id) object->data.exc_val; + break; + default: + return NULL; + } + +#ifdef __NEXT_RUNTIME__ + return class_getInstanceMethod ([obj class], + selector->data.sel_val)->method_imp; +#else + return objc_msg_lookup (obj, selector->data.sel_val); +#endif +} -- cgit v1.2.3