Fix class_getMethodImplementation() semantics for Apple compatibility (returns forwarding selector IMP, doesn't actually do the forwarding).

main
theraven 15 years ago
parent 5574585b0f
commit 4a3326f2fd

@ -344,21 +344,6 @@ const char *class_getIvarLayout(Class cls)
return (char*)cls->ivars; 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) const char * class_getName(Class cls)
{ {

@ -293,6 +293,19 @@ BOOL class_respondsToSelector(Class cls, SEL selector)
return NULL != objc_get_slot(cls, 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 // Legacy compatibility
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -307,10 +320,8 @@ BOOL __objc_responds_to(id object, SEL sel)
IMP get_imp(Class cls, SEL selector) IMP get_imp(Class cls, SEL selector)
{ {
Slot_t slot = objc_get_slot(cls, selector); return class_getMethodImplementation(cls, selector);
return NULL != slot ? slot->method : __objc_msg_forward2(nil, selector);
} }
/** /**
* Legacy message lookup function. Does not support fast proxies or safe IMP * Legacy message lookup function. Does not support fast proxies or safe IMP
* caching. * caching.

Loading…
Cancel
Save