summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lisp/libobjcl.lisp9
-rw-r--r--Objective-C/libobjcl.h3
-rw-r--r--Objective-C/libobjcl.m12
3 files changed, 24 insertions, 0 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index 16a300f..19f5a29 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -52,6 +52,9 @@
(defcfun ("objcl_class_name" %objcl-class-name) :string
(class :pointer))
+(defcfun ("objcl_class_superclass" %objcl-class-superclass) :pointer
+ (obj :pointer))
+
(defcfun ("objcl_find_selector" %objcl-find-selector) :pointer
(selector-name :string))
@@ -577,6 +580,12 @@ separating parts by hyphens works nicely in all of the `:INVERT`,
(find-objc-meta-class-by-name
(%objcl-class-name (%objcl-object-get-class (pointer-to obj)))))
+(defun objcl-class-superclass (class)
+ (let ((superclass-ptr (%objcl-class-superclass (pointer-to class))))
+ (if superclass-ptr
+ (make-pointer-wrapper t :pointer superclass-ptr)
+ nil)))
+
(defun objc-class-of (obj)
(cond ((object-is-meta-class-p obj)
(error "Tried to get the class of meta class ~S." obj))
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h
index 9008c9e..968cf14 100644
--- a/Objective-C/libobjcl.h
+++ b/Objective-C/libobjcl.h
@@ -71,6 +71,9 @@ objcl_query_arglist_info (void *receiver,
const char *
objcl_class_name (Class class);
+Class
+objcl_class_superclass (Class class);
+
const char *
objcl_selector_name (SEL selector);
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m
index 3fc2300..5161a52 100644
--- a/Objective-C/libobjcl.m
+++ b/Objective-C/libobjcl.m
@@ -20,6 +20,7 @@
#import "libobjcl.h"
#import "PyObjC/libffi_support.h"
#import "PyObjC/objc_support.h"
+#import "PyObjC/objc-runtime-compat.h"
#import <Foundation/Foundation.h>
#include <stdarg.h>
@@ -207,6 +208,17 @@ objcl_class_name (Class class)
}
+Class
+objcl_class_superclass (Class class)
+{
+#ifdef __NEXT_RUNTIME__
+ return class_getSuperclass (class);
+#else
+ return class_get_super_class (class);
+#endif
+}
+
+
const char *
objcl_selector_name (SEL selector)
{