summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-09-14 03:26:32 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-09-14 03:26:32 +0200
commit9197694fe9fd4eaa6e2c11f0acc92ef60ab6110a (patch)
tree538b277e6d2e120fe47562940ead66be723f9fbb /Objective-C
parenta4654002da82a9eebf728f856c9d501756553eb1 (diff)
New C function: objcl_get_method_implementation.
darcs-hash:de2f77980605c7aec911673edb0f0f29d0467fce
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/libobjcl.h4
-rw-r--r--Objective-C/libobjcl.m33
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
+}