From c93a74f1befea75be769fb47968e67568139954d Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Tue, 18 Sep 2007 00:50:47 +0200 Subject: Objective-C layer: Add functions for dealing with classes and metaclasses. darcs-hash:9ce15bb5fff3fb127cf4f6b72e70fa58c1cc2345 --- Objective-C/libobjcl.m | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'Objective-C/libobjcl.m') 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 +} -- cgit v1.2.3