diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-20 12:30:37 +0100 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-20 12:30:37 +0100 |
commit | a28a7dbb793b69dc8a174bc124d16fc3532c388f (patch) | |
tree | 227854e211fbb5f1b40ebf7ebb427a41505e2057 /Objective-C | |
parent | 9140c528f4036484a8f0473190aaaddbe3c2b5d7 (diff) |
Objective-C layer: Add objcl_for_each_class_do.
darcs-hash:4314d5bd41bf313fc50049b5e839aa09e5d94d19
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/libobjcl.h | 10 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 42 |
2 files changed, 49 insertions, 3 deletions
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index b3e1a3a..c9b7345 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -88,11 +88,12 @@ objcl_find_selector (const char *selector_name); SEL objcl_intern_selector (const char *selector_name); -/* Return a null-terminated list of type information strings. - The first entry describes the type of the method's return value. */ +/* Return a freshly consed null-terminated list of type information + strings. The first entry describes the type of the method's return + value. */ char ** objcl_query_arglist_info (void *receiver, - const char *method_name); + SEL method_name); const char * @@ -217,3 +218,6 @@ objcl_class_set_backed_by_lisp_class (Class class, int backed_p); int objcl_object_backed_by_lisp_class_p (id object); + +int +objcl_for_each_class_do (void (*function) (Class)); diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 1e70a37..d3a8514 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -24,6 +24,11 @@ #import "Foundation/Foundation.h" +#ifdef GNUSTEP +#import "GNUstepBase/GSLock.h" +/* #import "GNUstepBase/GSObjCRuntime.h" */ +#endif + #include <stdarg.h> #include <string.h> #include <sys/mman.h> @@ -91,7 +96,11 @@ objcl_initialise_runtime (void) PyObjC_SetupRuntimeCompat (); #endif +#ifdef GNUSTEP + objcl_current_exception_lock = [[GSLazyRecursiveLock alloc] init]; +#else objcl_current_exception_lock = [[NSRecursiveLock alloc] init]; +#endif method_lists = [[NSMutableDictionary alloc] init]; method_list_lengths = [[NSMutableDictionary alloc] init]; lisp_backed_classes = [[NSMutableSet alloc] init]; @@ -911,3 +920,36 @@ objcl_object_backed_by_lisp_class_p (id object) { return objcl_class_backed_by_lisp_class_p ([object class]); } + + +int +objcl_for_each_class_do (void (*function) (Class)) +{ +#ifdef __NEXT_RUNTIME__ + int class_num; + + class_num = objc_getClassList (NULL, 0); + if (class_num) + { + int i; + Class class_list[class_num]; + + objc_getClassList (&class_list, class_num); + for (i = 0; i < class_num; i++) + { + function (class_list[i]); + } + } +#else + /* In order to build a list of classes, we can use GSClassList(). */ + void *iter = 0; + Class class; + + while ((class = objc_next_class (&iter))) + { + function (class); + }; +#endif + + return 0; +} |