diff options
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/libobjcl.h | 4 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 33 |
2 files changed, 37 insertions, 0 deletions
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 +} |