summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-02-20 12:30:37 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-02-20 12:30:37 +0100
commita28a7dbb793b69dc8a174bc124d16fc3532c388f (patch)
tree227854e211fbb5f1b40ebf7ebb427a41505e2057
parent9140c528f4036484a8f0473190aaaddbe3c2b5d7 (diff)
Objective-C layer: Add objcl_for_each_class_do.
darcs-hash:4314d5bd41bf313fc50049b5e839aa09e5d94d19
-rw-r--r--Lisp/libobjcl.lisp4
-rw-r--r--Objective-C/libobjcl.h10
-rw-r--r--Objective-C/libobjcl.m42
3 files changed, 53 insertions, 3 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index 6296c46..a42300e 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -189,6 +189,10 @@
:int
(instance :pointer))
+(defcfun ("objcl_for_each_class_do" %objcl-for-each-class-do)
+ :int
+ (function :pointer))
+
(defcvar *objcl-current-exception-lock* :pointer)
(defcvar *objcl-current-exception* :pointer)
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;
+}