diff options
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/libobjcl.h | 12 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 55 |
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 +} |