diff --git a/runtime.c b/runtime.c index 683e6f8..50d62e8 100644 --- a/runtime.c +++ b/runtime.c @@ -344,21 +344,6 @@ const char *class_getIvarLayout(Class cls) return (char*)cls->ivars; } -IMP class_getMethodImplementation(Class cls, SEL name) -{ - CHECK_ARG(cls); - CHECK_ARG(name); - struct objc_object obj = { cls }; - return (IMP)objc_msg_lookup((id)&obj, name); -} - -IMP class_getMethodImplementation_stret(Class cls, SEL name) -{ - CHECK_ARG(cls); - CHECK_ARG(name); - struct objc_object obj = { cls }; - return (IMP)objc_msg_lookup((id)&obj, name); -} const char * class_getName(Class cls) { diff --git a/sendmsg2.c b/sendmsg2.c index 9cc5883..5adc473 100644 --- a/sendmsg2.c +++ b/sendmsg2.c @@ -293,6 +293,19 @@ BOOL class_respondsToSelector(Class cls, SEL selector) return NULL != objc_get_slot(cls, selector); } +IMP class_getMethodImplementation(Class cls, SEL name) +{ + if ((cls = Nil) || (name == NULL)) { return (IMP)0; } + Slot_t slot = objc_get_slot(cls, name); + return NULL != slot ? slot->method : __objc_msg_forward2(nil, name); +} + +IMP class_getMethodImplementation_stret(Class cls, SEL name) +{ + return class_getMethodImplementation(cls, name); +} + + //////////////////////////////////////////////////////////////////////////////// // Legacy compatibility //////////////////////////////////////////////////////////////////////////////// @@ -307,10 +320,8 @@ BOOL __objc_responds_to(id object, SEL sel) IMP get_imp(Class cls, SEL selector) { - Slot_t slot = objc_get_slot(cls, selector); - return NULL != slot ? slot->method : __objc_msg_forward2(nil, selector); + return class_getMethodImplementation(cls, selector); } - /** * Legacy message lookup function. Does not support fast proxies or safe IMP * caching.