diff --git a/Test/objc_msgSend.m b/Test/objc_msgSend.m index 6d6803c..3703365 100644 --- a/Test/objc_msgSend.m +++ b/Test/objc_msgSend.m @@ -4,6 +4,7 @@ #include #include #include "../objc/runtime.h" +#include "../objc/hooks.h" //#define assert(x) if (!(x)) { printf("Failed %d\n", __LINE__); } @@ -23,7 +24,31 @@ Class TestCls; __attribute__((objc_root_class)) #endif #endif -@interface Test { id isa; }@end +@interface Test { id isa; } @end +@interface Test (Dynamic) ++ (void)manyArgs: (int)a0 + : (int) a1 + : (int) a2 + : (int) a3 + : (int) a4 + : (int) a5 + : (int) a6 + : (int) a7 + : (int) a8 + : (int) a9 + : (int) a10 + : (float) f0 + : (float) f1 + : (float) f2 + : (float) f3 + : (float) f4 + : (float) f5 + : (float) f6 + : (float) f7 + : (float) f8 + : (float) f9 + : (float) f10; +@end @implementation Test - foo { @@ -70,8 +95,65 @@ __attribute__((objc_root_class)) } + nothing { return 0; } @end + +int forwardcalls; +void fwd(int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, + int a10, + float f0, + float f1, + float f2, + float f3, + float f4, + float f5, + float f6, + float f7, + float f8, + float f9, + float f10) +{ + forwardcalls++; + assert(a0 == 0); + assert(a1 == 0); + assert(a2 == 0); + assert(a3 == 0); + assert(a4 == 0); + assert(a5 == 0); + assert(a6 == 0); + assert(a7 == 0); + assert(a8 == 0); + assert(a9 == 0); + assert(a10 == 10); + assert(f0 == 0); + assert(f1 == 0); + assert(f2 == 0); + assert(f3 == 0); + assert(f4 == 0); + assert(f5 == 0); + assert(f6 == 0); + assert(f7 == 0); + assert(f8 == 0); + assert(f9 == 0); + assert(f10 == 10); +} + +IMP forward(id o, SEL s) +{ + assert(o == objc_getClass("Test")); + return (IMP)fwd; +} + int main(void) { + __objc_msg_forward2 = forward; TestCls = objc_getClass("Test"); int exceptionThrown = 0; @try { @@ -114,6 +196,7 @@ int main(void) assert(0 == [f dzero]); assert(0 == [f ldzero]); assert(0 == [f fzero]); + [TestCls manyArgs: 0 : 1 : 2 : 3: 4: 5: 6: 7: 8: 9: 10 : 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10]; #ifdef BENCHMARK clock_t c1, c2; c1 = clock();