Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -399,52 +399,11 @@ Class superclass = [self superclass]; if ([self isSubclassOfClass: class]) return; -#if defined(OF_APPLE_RUNTIME) - Method *methodList; - unsigned i, count; - - methodList = class_copyMethodList(object_getClass(class), &count); - @try { - for (i = 0; i < count; i++) { - SEL selector = method_getName(methodList[i]); - - /* - * Don't replace methods implemented in receiving class. - */ - if ([self methodForSelector: selector] != - [superclass methodForSelector: selector]) - continue; - - [self replaceClassMethod: selector - withMethodFromClass: class]; - } - } @finally { - free(methodList); - } - - methodList = class_copyMethodList(class, &count); - @try { - for (i = 0; i < count; i++) { - SEL selector = method_getName(methodList[i]); - - /* - * Don't replace methods implemented in receiving class. - */ - if ([self instanceMethodForSelector: selector] != - [superclass instanceMethodForSelector: selector]) - continue; - - [self replaceInstanceMethod: selector - withMethodFromClass: class]; - } - } @finally { - free(methodList); - } -#elif defined(OF_OBJFW_RUNTIME) +#if defined(OF_OBJFW_RUNTIME) struct objc_method_list *methodlist; for (methodlist = object_getClass(class)->methodlist; methodlist != NULL; methodlist = methodlist->next) { int i; @@ -451,11 +410,12 @@ for (i = 0; i < methodlist->count; i++) { SEL selector = (SEL)&methodlist->methods[i].sel; /* - * Don't replace methods implemented in receiving class. + * Don't replace methods implemented in the receiving + * class. */ if ([self methodForSelector: selector] != [superclass methodForSelector: selector]) continue; @@ -470,19 +430,63 @@ for (i = 0; i < methodlist->count; i++) { SEL selector = (SEL)&methodlist->methods[i].sel; /* - * Don't replace methods implemented in receiving class. + * Don't replace methods implemented in the receiving + * class. + */ + if ([self instanceMethodForSelector: selector] != + [superclass instanceMethodForSelector: selector]) + continue; + + [self replaceInstanceMethod: selector + withMethodFromClass: class]; + } + } +#elif defined(OF_APPLE_RUNTIME) + Method *methodList; + unsigned i, count; + + methodList = class_copyMethodList(object_getClass(class), &count); + @try { + for (i = 0; i < count; i++) { + SEL selector = method_getName(methodList[i]); + + /* + * Don't replace methods implemented in the receiving + * class. + */ + if ([self methodForSelector: selector] != + [superclass methodForSelector: selector]) + continue; + + [self replaceClassMethod: selector + withMethodFromClass: class]; + } + } @finally { + free(methodList); + } + + methodList = class_copyMethodList(class, &count); + @try { + for (i = 0; i < count; i++) { + SEL selector = method_getName(methodList[i]); + + /* + * Don't replace methods implemented in the receiving + * class. */ if ([self instanceMethodForSelector: selector] != [superclass instanceMethodForSelector: selector]) continue; [self replaceInstanceMethod: selector withMethodFromClass: class]; } + } @finally { + free(methodList); } #endif [self inheritMethodsFromClass: [class superclass]]; }