From d907d3d250c9a0f43b3497dcf5fa354be4ffc83f Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Wed, 5 Mar 2008 02:13:26 +0100 Subject: Add function COLLECT-METHODS. darcs-hash:4c78479b2d67157304f041d700fceb34a3ed7721 --- Objective-C/libobjcl.m | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index d32a37c..0b1719f 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -1053,6 +1053,54 @@ objcl_for_each_class_do (void (*function) (Class)) } +void ** +objcl_class_methods (Class class, unsigned int *count) +{ +#ifdef __NEXT_RUNTIME__ + return (void **) class_copyMethodList (class, count); +#else + size_t buflen = 0; + void **buf = NULL; + MethodList_t list = class->methods; + + *count = 0; + + while (list) + { + int i; + unsigned int position = *count; + *count += list->method_count; + + if (buflen < *count) + { + buflen = *count; + buf = realloc (buf, buflen * sizeof (void *)); + } + + for (i = 0; i < list->method_count; i++) + { + buf[position + i] = &list->method_list[i]; + } + + list = list->method_next; + } + + return buf; +#endif +} + + +SEL +objcl_method_selector (void *method) +{ +#ifdef __NEXT_RUNTIME__ + return method_getName ((Method) method); +#else + return ((Method_t) method)->method_name; +#endif +} + + /* The function objcl_test_foo is a general-purpose debugging tool that can be adapted as needed. */ @interface MLKTestStringHelper -- cgit v1.2.3