From d7eb69606d1d3db6a96fe5643c1ccf7b470e1374 Mon Sep 17 00:00:00 2001 From: Glenn Ganz Date: Thu, 15 Aug 2013 10:10:14 +0200 Subject: [PATCH] implement dummy _frameLengthForSelector on Object --- Foundation/NSObject/forwarding.m | 31 ++++++------ .../NSBacktraceFunctions_win32.m | 50 +++++++++++++++++++ objc/Object.m | 4 ++ objc/objc_sel.h | 1 + 4 files changed, 71 insertions(+), 15 deletions(-) diff --git a/Foundation/NSObject/forwarding.m b/Foundation/NSObject/forwarding.m index 4eb820bb..432821df 100644 --- a/Foundation/NSObject/forwarding.m +++ b/Foundation/NSObject/forwarding.m @@ -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; + } } } diff --git a/Foundation/platform_windows/NSBacktraceFunctions_win32.m b/Foundation/platform_windows/NSBacktraceFunctions_win32.m index 1a9c5d07..03e7d3c3 100644 --- a/Foundation/platform_windows/NSBacktraceFunctions_win32.m +++ b/Foundation/platform_windows/NSBacktraceFunctions_win32.m @@ -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; } diff --git a/objc/Object.m b/objc/Object.m index edfa5060..eddf8f1f 100755 --- a/objc/Object.m +++ b/objc/Object.m @@ -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 diff --git a/objc/objc_sel.h b/objc/objc_sel.h index 091138d7..fbbcae1c 100755 --- a/objc/objc_sel.h +++ b/objc/objc_sel.h @@ -10,4 +10,5 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import OBJC_EXPORT SEL sel_registerNameNoCopy(const char *name); +BOOL sel_isMapped(SEL selector);