implement dummy _frameLengthForSelector on Object

This commit is contained in:
Glenn Ganz 2013-08-15 10:10:14 +02:00
parent 56f52f6da1
commit d7eb69606d
4 changed files with 71 additions and 15 deletions

View File

@ -121,25 +121,26 @@ id objc_msgForward(id object, SEL message, ...)
IMP imp = method->method_imp;
#endif
frameLength = imp(object, @selector(_frameLengthForSelector:), message);
frame = __builtin_alloca(frameLength);
if (frameLength > 0) { // Object (Protocol) returns 0 frameLength
frame = __builtin_alloca(frameLength);
va_start(arguments, message);
frame[0] = object;
frame[1] = message;
for (i = 2; i < frameLength / sizeof(unsigned); i++) {
frame[i] = va_arg(arguments, unsigned);
}
va_start(arguments, message);
frame[0] = object;
frame[1] = message;
for (i = 2; i < frameLength / sizeof(unsigned); i++) {
frame[i] = va_arg(arguments, unsigned);
}
if ((method = class_getInstanceMethod(class, @selector(forwardSelector:arguments:))) != NULL) {
if ((method = class_getInstanceMethod(class, @selector(forwardSelector:arguments:))) != NULL) {
#if defined(GCC_RUNTIME_3) || defined(APPLE_RUNTIME_4)
imp = method_getImplementation(method);
imp = method_getImplementation(method);
#else
imp = method->method_imp;
imp = method->method_imp;
#endif
return imp(object, @selector(forwardSelector:arguments:), message, frame);
} else {
OBJCRaiseException("OBJCDoesNotRecognizeSelector", "%c[%s %s(%d)]", class_isMetaClass(class) ? '+' : '-', class->name, sel_getName(message), message);
return nil;
return imp(object, @selector(forwardSelector:arguments:), message, frame);
} else {
OBJCRaiseException("OBJCDoesNotRecognizeSelector", "%c[%s %s(%d)]", class_isMetaClass(class) ? '+' : '-', class->name, sel_getName(message), message);
return nil;
}
}
}

View File

@ -67,6 +67,56 @@ int backtrace(void** array, int size)
_NS_FRAME_ADDRESS_BACKTRACE(48);
_NS_FRAME_ADDRESS_BACKTRACE(49);
_NS_FRAME_ADDRESS_BACKTRACE(50);
_NS_FRAME_ADDRESS_BACKTRACE(51);
_NS_FRAME_ADDRESS_BACKTRACE(52);
_NS_FRAME_ADDRESS_BACKTRACE(53);
_NS_FRAME_ADDRESS_BACKTRACE(54);
_NS_FRAME_ADDRESS_BACKTRACE(55);
_NS_FRAME_ADDRESS_BACKTRACE(56);
_NS_FRAME_ADDRESS_BACKTRACE(57);
_NS_FRAME_ADDRESS_BACKTRACE(58);
_NS_FRAME_ADDRESS_BACKTRACE(59);
_NS_FRAME_ADDRESS_BACKTRACE(60);
_NS_FRAME_ADDRESS_BACKTRACE(61);
_NS_FRAME_ADDRESS_BACKTRACE(62);
_NS_FRAME_ADDRESS_BACKTRACE(63);
_NS_FRAME_ADDRESS_BACKTRACE(64);
_NS_FRAME_ADDRESS_BACKTRACE(65);
_NS_FRAME_ADDRESS_BACKTRACE(66);
_NS_FRAME_ADDRESS_BACKTRACE(67);
_NS_FRAME_ADDRESS_BACKTRACE(68);
_NS_FRAME_ADDRESS_BACKTRACE(69);
_NS_FRAME_ADDRESS_BACKTRACE(70);
_NS_FRAME_ADDRESS_BACKTRACE(71);
_NS_FRAME_ADDRESS_BACKTRACE(72);
_NS_FRAME_ADDRESS_BACKTRACE(73);
_NS_FRAME_ADDRESS_BACKTRACE(74);
_NS_FRAME_ADDRESS_BACKTRACE(75);
_NS_FRAME_ADDRESS_BACKTRACE(76);
_NS_FRAME_ADDRESS_BACKTRACE(77);
_NS_FRAME_ADDRESS_BACKTRACE(78);
_NS_FRAME_ADDRESS_BACKTRACE(79);
_NS_FRAME_ADDRESS_BACKTRACE(80);
_NS_FRAME_ADDRESS_BACKTRACE(81);
_NS_FRAME_ADDRESS_BACKTRACE(82);
_NS_FRAME_ADDRESS_BACKTRACE(83);
_NS_FRAME_ADDRESS_BACKTRACE(84);
_NS_FRAME_ADDRESS_BACKTRACE(85);
_NS_FRAME_ADDRESS_BACKTRACE(86);
_NS_FRAME_ADDRESS_BACKTRACE(87);
_NS_FRAME_ADDRESS_BACKTRACE(88);
_NS_FRAME_ADDRESS_BACKTRACE(89);
_NS_FRAME_ADDRESS_BACKTRACE(90);
_NS_FRAME_ADDRESS_BACKTRACE(91);
_NS_FRAME_ADDRESS_BACKTRACE(92);
_NS_FRAME_ADDRESS_BACKTRACE(93);
_NS_FRAME_ADDRESS_BACKTRACE(94);
_NS_FRAME_ADDRESS_BACKTRACE(95);
_NS_FRAME_ADDRESS_BACKTRACE(96);
_NS_FRAME_ADDRESS_BACKTRACE(97);
_NS_FRAME_ADDRESS_BACKTRACE(98);
_NS_FRAME_ADDRESS_BACKTRACE(99);
default: return size;
}

View File

@ -19,5 +19,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return nil;
}
-(unsigned int)_frameLengthForSelector:(SEL)selector {
return 0;
}
@end

View File

@ -10,4 +10,5 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <objc/objc-class.h>
OBJC_EXPORT SEL sel_registerNameNoCopy(const char *name);
BOOL sel_isMapped(SEL selector);