Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -38,11 +38,11 @@ #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "macros.h" -#if (defined(OF_APPLE_RUNTIME) && __OBJC2__) +#if defined(OF_APPLE_RUNTIME) && __OBJC2__ # import #elif defined(OF_OBJFW_RUNTIME) # import "runtime.h" #endif @@ -92,11 +92,11 @@ #ifdef NEED_OBJC_PROPERTIES_INIT extern BOOL objc_properties_init(); #endif -#if (defined(OF_APPLE_RUNTIME) && __OBJC2__) +#if defined(OF_APPLE_RUNTIME) && __OBJC2__ static void uncaught_exception_handler(id exception) { fprintf(stderr, "\nUnhandled exception:\n%s\n", [[exception description] UTF8String]); @@ -148,11 +148,11 @@ stderr); abort(); } #endif -#if (defined(OF_APPLE_RUNTIME) && __OBJC2__) +#if defined(OF_APPLE_RUNTIME) && __OBJC2__ objc_setUncaughtExceptionHandler(uncaught_exception_handler); #endif #ifdef HAVE_OBJC_ENUMERATIONMUTATION objc_setEnumerationMutationHandler(enumeration_mutation_handler); @@ -387,12 +387,50 @@ withMethodFromClass: class]; } } @finally { free(methodList); } -#else - /* FIXME */ +#elif defined(OF_OBJFW_RUNTIME) + struct objc_method_list *methodlist; + + for (methodlist = class->isa->methodlist; + methodlist != NULL; methodlist = methodlist->next) { + int i; + + for (i = 0; i < methodlist->count; i++) { + SEL selector = &methodlist->methods[i].sel; + + /* + * Don't replace methods implemented in receiving class. + */ + if ([self methodForSelector: selector] != + [superclass methodForSelector: selector]) + continue; + + [self replaceClassMethod: selector + withMethodFromClass: class]; + } + } + + for (methodlist = class->methodlist; methodlist != NULL; + methodlist = methodlist->next) { + int i; + + for (i = 0; i < methodlist->count; i++) { + SEL selector = &methodlist->methods[i].sel; + + /* + * Don't replace methods implemented in receiving class. + */ + if ([self instanceMethodForSelector: selector] != + [superclass instanceMethodForSelector: selector]) + continue; + + [self replaceInstanceMethod: selector + withMethodFromClass: class]; + } + } #endif [self inheritMethodsFromClass: [class superclass]]; }