1.1 --- a/sourcehook/test/testmanual.cpp Sat May 13 18:23:25 2006 +0000
1.2 +++ b/sourcehook/test/testmanual.cpp Sun May 14 18:29:35 2006 +0000
1.3 @@ -64,6 +64,11 @@
1.4 SH_DECL_MANUALHOOK0(TheWall_Func3, 2, 0, 0, short);
1.5 SH_DECL_MANUALHOOK1(TheWall_Func4, 3, 0, 0, short, int);
1.6
1.7 + typedef void (SourceHook::EmptyClass::*MFP_Func1)();
1.8 + typedef void (SourceHook::EmptyClass::*MFP_Func2)(int);
1.9 + typedef short (SourceHook::EmptyClass::*MFP_Func3)();
1.10 + typedef short (SourceHook::EmptyClass::*MFP_Func4)(int);
1.11 +
1.12 void Handler_Func1()
1.13 {
1.14 ADD_STATE(State_Func1H_Called(META_IFACEPTR(void)));
1.15 @@ -101,6 +106,8 @@
1.16 TheWall inst;
1.17 TheWall *p = &inst;
1.18
1.19 + SourceHook::ManualCallClass *cc = SH_GET_MCALLCLASS(p, sizeof(void*));
1.20 +
1.21 // 1)
1.22 // Call each function
1.23 p->Func1();
1.24 @@ -117,8 +124,34 @@
1.25 new State_Return(4),
1.26 NULL), "Part 1");
1.27
1.28 + // 1.1)
1.29 + // Now call each function through the manual call class, using the hook decl and manually
1.30 + SH_MCALL(cc, TheWall_Func1)();
1.31 + SH_MCALL2(cc, MFP_Func1(), 0, 0, 0)();
1.32 + SH_MCALL(cc, TheWall_Func2)(200);
1.33 + SH_MCALL2(cc, MFP_Func2(), 1, 0, 0)(200);
1.34 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func3)()));
1.35 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func3(), 2, 0, 0)()));
1.36 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func4)(400)));
1.37 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func4(), 3, 0, 0)(400)));
1.38 +
1.39 + CHECK_STATES((&g_States,
1.40 + new State_Func1_Called(p),
1.41 + new State_Func1_Called(p),
1.42 + new State_Func2_Called(p, 200),
1.43 + new State_Func2_Called(p, 200),
1.44 + new State_Func3_Called(p),
1.45 + new State_Return(3),
1.46 + new State_Func3_Called(p),
1.47 + new State_Return(3),
1.48 + new State_Func4_Called(p, 400),
1.49 + new State_Return(4),
1.50 + new State_Func4_Called(p, 400),
1.51 + new State_Return(4),
1.52 + NULL), "Part 1.1");
1.53 +
1.54 // 2)
1.55 - // Hook each function normally, call them, unhook them
1.56 + // Hook each function normally, call them
1.57 SH_ADD_HOOK_STATICFUNC(TheWall, Func1, p, Handler_Func1, false);
1.58 SH_ADD_HOOK_STATICFUNC(TheWall, Func2, p, Handler_Func2, false);
1.59 SH_ADD_HOOK_STATICFUNC(TheWall, Func3, p, Handler_Func3, false);
1.60 @@ -142,13 +175,41 @@
1.61 new State_Return(4),
1.62 NULL), "Part 2");
1.63
1.64 + // Call them through the mcallclass
1.65 + // 2.1)
1.66 + // Now call each function through the manual call class, using the hook decl and manually
1.67 + SH_MCALL(cc, TheWall_Func1)();
1.68 + SH_MCALL2(cc, MFP_Func1(), 0, 0, 0)();
1.69 + SH_MCALL(cc, TheWall_Func2)(200);
1.70 + SH_MCALL2(cc, MFP_Func2(), 1, 0, 0)(200);
1.71 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func3)()));
1.72 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func3(), 2, 0, 0)()));
1.73 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func4)(400)));
1.74 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func4(), 3, 0, 0)(400)));
1.75 +
1.76 + CHECK_STATES((&g_States,
1.77 + new State_Func1_Called(p),
1.78 + new State_Func1_Called(p),
1.79 + new State_Func2_Called(p, 200),
1.80 + new State_Func2_Called(p, 200),
1.81 + new State_Func3_Called(p),
1.82 + new State_Return(3),
1.83 + new State_Func3_Called(p),
1.84 + new State_Return(3),
1.85 + new State_Func4_Called(p, 400),
1.86 + new State_Return(4),
1.87 + new State_Func4_Called(p, 400),
1.88 + new State_Return(4),
1.89 + NULL), "Part 2.1");
1.90 +
1.91 + // Unhook them
1.92 SH_REMOVE_HOOK_STATICFUNC(TheWall, Func1, p, Handler_Func1, false);
1.93 SH_REMOVE_HOOK_STATICFUNC(TheWall, Func2, p, Handler_Func2, false);
1.94 SH_REMOVE_HOOK_STATICFUNC(TheWall, Func3, p, Handler_Func3, false);
1.95 SH_REMOVE_HOOK_STATICFUNC(TheWall, Func4, p, Handler_Func4, false);
1.96
1.97 // 3)
1.98 - // Hook each function manually, call them, unhook them
1.99 + // Hook each function manually, call them
1.100
1.101 SH_ADD_MANUALHOOK_STATICFUNC(TheWall_Func1, p, Handler_Func1, false);
1.102 SH_ADD_MANUALHOOK_STATICFUNC(TheWall_Func2, p, Handler_Func2, false);
1.103 @@ -173,6 +234,36 @@
1.104 new State_Return(4),
1.105 NULL), "Part 3");
1.106
1.107 + // Now through the mcallclass
1.108 +
1.109 + // Call them through the mcallclass
1.110 + // 3.1)
1.111 + // Now call each function through the manual call class, using the hook decl and manually
1.112 + SH_MCALL(cc, TheWall_Func1)();
1.113 + SH_MCALL2(cc, MFP_Func1(), 0, 0, 0)();
1.114 + SH_MCALL(cc, TheWall_Func2)(200);
1.115 + SH_MCALL2(cc, MFP_Func2(), 1, 0, 0)(200);
1.116 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func3)()));
1.117 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func3(), 2, 0, 0)()));
1.118 + ADD_STATE(State_Return(SH_MCALL(cc, TheWall_Func4)(400)));
1.119 + ADD_STATE(State_Return(SH_MCALL2(cc, MFP_Func4(), 3, 0, 0)(400)));
1.120 +
1.121 + CHECK_STATES((&g_States,
1.122 + new State_Func1_Called(p),
1.123 + new State_Func1_Called(p),
1.124 + new State_Func2_Called(p, 200),
1.125 + new State_Func2_Called(p, 200),
1.126 + new State_Func3_Called(p),
1.127 + new State_Return(3),
1.128 + new State_Func3_Called(p),
1.129 + new State_Return(3),
1.130 + new State_Func4_Called(p, 400),
1.131 + new State_Return(4),
1.132 + new State_Func4_Called(p, 400),
1.133 + new State_Return(4),
1.134 + NULL), "Part 3.1");
1.135 +
1.136 + // Unhook them
1.137 SH_REMOVE_MANUALHOOK_STATICFUNC(TheWall_Func1, p, Handler_Func1, false);
1.138 SH_REMOVE_MANUALHOOK_STATICFUNC(TheWall_Func2, p, Handler_Func2, false);
1.139 SH_REMOVE_MANUALHOOK_STATICFUNC(TheWall_Func3, p, Handler_Func3, false);