@@ -15,10 +15,16 @@ */ #ifndef __OBJFW_RUNTIME_H__ #define __OBJFW_RUNTIME_H__ #include + +#if defined(__has_feature) && __has_feature(objc_arc) +# define OBJC_BRIDGE __bridge +#else +# define OBJC_BRIDGE +#endif typedef struct objc_class *Class; typedef struct objc_object *id; typedef const struct objc_selector *SEL; typedef signed char BOOL; @@ -183,19 +189,19 @@ extern id _objc_rootAutorelease(id); static inline Class object_getClass(id obj_) { - struct objc_object *obj = (struct objc_object*)obj_; + struct objc_object *obj = (OBJC_BRIDGE struct objc_object*)obj_; return obj->isa; } static inline Class object_setClass(id obj_, Class cls) { - struct objc_object *obj = (struct objc_object*)obj_; + struct objc_object *obj = (OBJC_BRIDGE struct objc_object*)obj_; Class old = obj->isa; obj->isa = cls; return old; @@ -204,7 +210,9 @@ static inline const char* object_getClassName(id obj) { return class_getName(object_getClass(obj)); } + +#undef OBJC_BRIDGE #endif