Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -41,11 +41,10 @@ #import "macros.h" #if defined(OF_OBJFW_RUNTIME) # import #elif defined(OF_OLD_GNU_RUNTIME) -# import # import #endif #ifdef _WIN32 # include @@ -74,10 +73,14 @@ #endif #define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN)) + +#ifdef OF_OLD_GNU_RUNTIME +extern void __objc_update_dispatch_table_for_class(Class); +#endif static struct { Class isa; } alloc_failed_exception; static Class autoreleasePool = Nil; @@ -124,42 +127,10 @@ void _references_to_categories_of_OFObject(void) { _OFObject_Serialization_reference = 1; } -#ifdef OF_OLD_GNU_RUNTIME -/* - * The old GNU runtime is missing functions for changing methods at runtime. It - * does not even offer a function to update the dtable, so we have to do even - * that manually. A well designed runtime would not even allow us to touch the - * dtable, but the old GNU runtime is that crappy that it even forces us to - * touch it... - */ -static void -update_dtable(Class class) -{ - MethodList_t iter; - Class subclass; - - for (subclass = class->subclass_list; subclass != Nil; - subclass = subclass->sibling_class) - update_dtable(subclass); - - for (iter = class->methods; iter != NULL; iter = iter->method_next) { - Method_t methods = iter->method_list; - int i; - - for (i = 0; i < iter->method_count; i++) - if (sarray_get_safe(class->dtable, - (sidx)methods[i].method_name->sel_id) != NULL) - sarray_at_put_safe(class->dtable, - (sidx)methods[i].method_name->sel_id, - methods[i].method_imp); - } -} -#endif - @implementation OFObject + (void)load { #ifdef NEED_OBJC_SYNC_INIT if (!objc_sync_init()) { @@ -391,11 +362,12 @@ IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; - update_dtable((Class)self->class_pointer); + __objc_update_dispatch_table_for_class( + (Class)self->class_pointer); return oldImp; } } @@ -465,11 +437,11 @@ IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; - update_dtable(self); + __objc_update_dispatch_table_for_class(self); return oldImp; } } @@ -537,11 +509,11 @@ methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self)->methods = methodList; - update_dtable(self); + __objc_update_dispatch_table_for_class(self); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; @@ -580,11 +552,11 @@ methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self->class_pointer)->methods = methodList; - update_dtable((Class)self->class_pointer); + __objc_update_dispatch_table_for_class((Class)self->class_pointer); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd];