summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-09-18 00:50:47 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-09-18 00:50:47 +0200
commitc93a74f1befea75be769fb47968e67568139954d (patch)
tree3774752500b8e615f98c10e6245544a7247aeaf2 /Objective-C
parentf98c79811e81eff07f967f28c108b76a4a7d1343 (diff)
Objective-C layer: Add functions for dealing with classes and metaclasses.
darcs-hash:9ce15bb5fff3fb127cf4f6b72e70fa58c1cc2345
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/libobjcl.h12
-rw-r--r--Objective-C/libobjcl.m55
2 files changed, 67 insertions, 0 deletions
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h
index d2f5e76..27ffd01 100644
--- a/Objective-C/libobjcl.h
+++ b/Objective-C/libobjcl.h
@@ -79,3 +79,15 @@ objcl_selector_name (OBJCL_OBJ_DATA class);
IMP
objcl_get_method_implementation (OBJCL_OBJ_DATA object,
OBJCL_OBJ_DATA selector);
+
+BOOL
+objcl_object_is_class (id obj);
+
+BOOL
+objcl_object_is_meta_class (id obj);
+
+Class
+objcl_object_get_class (id obj);
+
+Class
+objcl_object_get_meta_class (id obj);
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m
index 25fc11f..bc89a32 100644
--- a/Objective-C/libobjcl.m
+++ b/Objective-C/libobjcl.m
@@ -447,3 +447,58 @@ objcl_get_method_implementation (OBJCL_OBJ_DATA object,
return objc_msg_lookup (obj, selector->data.sel_val);
#endif
}
+
+
+BOOL
+objcl_object_is_class (id obj)
+{
+#ifdef __NEXT_RUNTIME__
+ return [obj class] == obj
+#else
+ /* return CLS_ISCLASS (obj); */
+ return object_is_class (obj);
+#endif
+}
+
+
+BOOL
+objcl_object_is_meta_class (id obj)
+{
+#ifdef __NEXT_RUNTIME__
+ /* FIXME: What to do here? */
+ return [[obj class] metaClass] == obj;
+#else
+ /* return CLS_ISMETA (ptr); */
+ if (objcl_object_is_class (obj))
+ return class_is_meta_class (obj);
+ else
+ return object_is_meta_class (obj);
+#endif
+}
+
+
+Class
+objcl_object_get_class (id obj)
+{
+#ifdef __NEXT_RUNTIME__
+ /* XXX? return obj->isa; */
+ return [obj class];
+#else
+ return object_get_class (obj);
+#endif
+}
+
+
+Class
+objcl_object_get_meta_class (id obj)
+{
+#ifdef __NEXT_RUNTIME__
+ /* FIXME: What to do here? */
+ return [[obj class] metaClass];
+#else
+ if (objcl_object_is_class (obj))
+ return class_get_meta_class (obj);
+ else
+ return object_get_meta_class (obj);
+#endif
+}