2 template <class T> struct StripRef
7 template <class T> struct StripRef<T&>
12 // Address of constructor/destructor
18 void NormalConstructor()
23 void CopyConstructor(const T &other)
30 reinterpret_cast<T*>(this)->~T();
33 const T& AssignOp(const T &other)
35 return (*reinterpret_cast<T*>(this) = other);
41 void *FindFuncAddr(T mfp)
53 template <class T> struct MyRefCarrier
58 template <class T> struct MyRefCarrier<T&>
64 type() : m_StoredRef(NULL)
67 type(T& ref) : m_StoredRef(&ref)
82 bool operator== (const typename MyRefCarrier<T&>::type &other)
84 return m_StoredRef == other.m_StoredRef;
87 friend std::ostream& operator <<(std::ostream &os,const typename MyRefCarrier<T&>::type &obj)
89 os << *obj.m_StoredRef;
95 #if SH_COMP==SH_COMP_GCC
96 #define NO_OPTIMIZE __attribute__((noinline))
101 // Return value maker
112 struct MakeRet< POD<SIZE> >
114 static POD<SIZE> Do(int a)
117 memset(reinterpret_cast<void*>(x.x), a, SIZE);
122 // Stores parameter status
125 template<int dummy@[$2,1,$1:, class p$2@]>
128 @[$2,1,$1:typename MyRefCarrier<p$2>::type m_$2; @]
130 bool operator==(const ParamState$1<dummy@[$2,1,$1:, p$2@]> &other)
133 @[$2,1,$1: && m_$1 == other.m_$1@]
136 ParamState$1(@[$2,1,$1|, :p$2 a$2@]) @[$1!=0::@] @[$2,1,$1|, :m_$2(a$2)@]
140 ParamState$1<dummy@[$2,1,$1:, p$2@]> & operator() (int incrsteps)
144 for (i = 0; i < incrsteps; ++i)
145 Increment<typename StripRef< p$2 >::type >::Incr(m_$2);
152 @[$1!=0:template<@[$2,1,$1|, :class p$2@]>@]
153 std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@]> &obj)
155 @[$1!=0:os@] @[$2,1,$1:<< obj.m_$2@];
161 #define CAT2(a, b) a##b
162 #define CAT3(a, b, c) a##b##c
163 #define CAT4(a, b, c, d) a##b##c##d
166 // hook2: pre supercede
167 // hook3: post ignore
168 // hook4: post supercede
173 #define THGM_MAKE_TEST$1_void(id@[$2,1,$1:, param$2@]) \
174 struct TestClass##id; \
175 typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \
176 MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
177 MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
178 MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
179 MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
180 MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
182 struct TestClass##id \
184 static bool ms_DoRecall; \
186 virtual void Func(@[$2,1,$1|, :param$2 p$2@]) \
188 g_Inside_LeafFunc = true; \
189 ADD_STATE(State_Func##id(this, ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
190 g_Inside_LeafFunc = false; \
193 struct Delegate1 : public MyDelegate \
195 virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
197 g_Inside_LeafFunc = true; \
198 ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
199 g_Inside_LeafFunc = false; \
202 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
203 RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
206 RETURN_META(MRES_IGNORED); \
209 struct Delegate2 : public MyDelegate \
211 virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
213 g_Inside_LeafFunc = true; \
214 ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
215 g_Inside_LeafFunc = false; \
218 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
219 RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
222 RETURN_META(MRES_SUPERCEDE); \
225 struct Delegate3 : public MyDelegate \
227 virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
229 g_Inside_LeafFunc = true; \
230 ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
231 g_Inside_LeafFunc = false; \
234 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
235 RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
238 RETURN_META(MRES_IGNORED); \
241 struct Delegate4 : public MyDelegate \
243 virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
245 g_Inside_LeafFunc = true; \
246 ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
247 g_Inside_LeafFunc = false; \
250 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
251 RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
254 RETURN_META(MRES_SUPERCEDE); \
259 bool TestClass##id::ms_DoRecall = false; \
261 SourceHook::PassInfo paraminfos_##id[$1+1]; \
262 SourceHook::PassInfo::V2Info paraminfos2_##id[$1+1]; \
263 SourceHook::ProtoInfo protoinfo_##id = { $1, {0, 0, 0}, paraminfos_##id, \
264 SourceHook::ProtoInfo::CallConv_ThisCall, __SH_EPI, paraminfos2_##id }; \
266 SourceHook::Impl::GenContext *g_Genc##id = NULL; \
267 CAutoPtrDestruction<SourceHook::Impl::GenContext> g_Genc_ad##id(NULL);
270 #define THGM_MAKE_TEST$1(id, ret_type@[$2,1,$1:, param$2@]) \
271 struct TestClass##id; \
272 typedef ret_type RetType##id; \
273 typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \
274 MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
275 MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
276 MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
277 MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
278 MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
280 struct TestClass##id \
282 static bool ms_DoRecall; \
284 virtual ret_type Func(@[$2,1,$1|, :param$2 p$2@]) \
286 g_Inside_LeafFunc = true; \
287 ADD_STATE(State_Func##id(this, ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
288 g_Inside_LeafFunc = false; \
290 return MakeRet< ret_type >::Do(0); \
293 struct Delegate1 : public MyDelegate \
295 virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
297 g_Inside_LeafFunc = true; \
298 ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
299 g_Inside_LeafFunc = false; \
302 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
303 RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
306 RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
309 struct Delegate2 : public MyDelegate \
311 virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
313 g_Inside_LeafFunc = true; \
314 ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
315 g_Inside_LeafFunc = false; \
318 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
319 RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
322 RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
325 struct Delegate3 : public MyDelegate \
327 virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
329 g_Inside_LeafFunc = true; \
330 ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
331 g_Inside_LeafFunc = false; \
334 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
335 RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
338 RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
341 struct Delegate4 : public MyDelegate \
343 virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
345 g_Inside_LeafFunc = true; \
346 ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
347 g_Inside_LeafFunc = false; \
350 @[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
351 RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
354 RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
359 bool TestClass##id::ms_DoRecall = false; \
361 SourceHook::PassInfo paraminfos_##id[$1+1]; \
362 SourceHook::PassInfo::V2Info paraminfos2_##id[$1+1]; \
363 SourceHook::ProtoInfo protoinfo_##id = { $1, {0, 0, 0}, paraminfos_##id, \
364 SourceHook::ProtoInfo::CallConv_ThisCall, __SH_EPI, paraminfos2_##id }; \
366 SourceHook::Impl::GenContext *g_Genc##id = NULL; \
367 CAutoPtrDestruction<SourceHook::Impl::GenContext> g_Genc_ad##id(NULL);
369 #define THGM_SETUP_PI$1(id@[$2,1,$1:, p$2_type, p$2_passtype, p$2_flags@]) \
370 void setuppi_##id() \
372 paraminfos_##id[0].size = 1; paraminfos_##id[0].type = 0; paraminfos_##id[0].flags = 0; \
374 @[$2,1,$1: paraminfos_##id[$2].size = sizeof(p$2_type); paraminfos_##id[$2].type = p$2_passtype; paraminfos_##id[$2].flags = p$2_flags; @] \
376 @[$2,1,$1: paraminfos2_##id[$2].pNormalCtor = (paraminfos_##id[$2].flags & SourceHook::PassInfo::PassFlag_OCtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< p$2_type >::type>::NormalConstructor) : NULL; @] \
377 @[$2,1,$1: paraminfos2_##id[$2].pCopyCtor = (paraminfos_##id[$2].flags & SourceHook::PassInfo::PassFlag_CCtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< p$2_type >::type>::CopyConstructor) : NULL; @] \
378 @[$2,1,$1: paraminfos2_##id[$2].pDtor = (paraminfos_##id[$2].flags & SourceHook::PassInfo::PassFlag_ODtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< p$2_type >::type>::Destructor) : NULL; @] \
379 @[$2,1,$1: paraminfos2_##id[$2].pAssignOperator = (paraminfos_##id[$2].flags & SourceHook::PassInfo::PassFlag_AssignOp) ? FindFuncAddr(&Ctor_Thunk<StripRef< p$2_type >::type>::AssignOp) : NULL; @] \
384 #define THGM_SETUP_RI(id, ret_type, ret_passtype, ret_flags) \
385 void setupri_##id() \
387 protoinfo_##id.retPassInfo.size = sizeof(ret_type); \
388 protoinfo_##id.retPassInfo.type = ret_passtype; \
389 protoinfo_##id.retPassInfo.flags = ret_flags; \
391 protoinfo_##id.retPassInfo2.pNormalCtor = (protoinfo_##id.retPassInfo.flags & SourceHook::PassInfo::PassFlag_OCtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< ret_type >::type>::NormalConstructor) : NULL; \
392 protoinfo_##id.retPassInfo2.pCopyCtor = (protoinfo_##id.retPassInfo.flags & SourceHook::PassInfo::PassFlag_CCtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< ret_type >::type>::CopyConstructor) : NULL; \
393 protoinfo_##id.retPassInfo2.pDtor = (protoinfo_##id.retPassInfo.flags & SourceHook::PassInfo::PassFlag_ODtor) ? FindFuncAddr(&Ctor_Thunk<StripRef< ret_type >::type>::Destructor) : NULL; \
394 protoinfo_##id.retPassInfo2.pAssignOperator = (protoinfo_##id.retPassInfo.flags & SourceHook::PassInfo::PassFlag_AssignOp) ? FindFuncAddr(&Ctor_Thunk<StripRef< ret_type >::type>::AssignOp) : NULL; \
397 #define THGM_ADD_HOOK(id, num) \
398 CAT4(hook, num, _, id) = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pTest##id), \
399 0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate##num), num >= 3);
401 #define THGM_REMOVE_HOOK(id, num) \
402 g_SHPtr->RemoveHookByID(CAT4(hook, num, _, id));
404 #define THGM_CALLS_void(id, call_params) \
405 pTest##id->Func call_params; \
406 SH_CALL(pTest##id, &TestClass##id::Func) call_params;
408 #define THGM_DO_TEST_void(id, call_params) \
410 g_Genc##id = new SourceHook::Impl::GenContext(&protoinfo_##id, 0, 0, g_SHPtr); \
411 g_Genc_ad##id.set(g_Genc##id); \
412 SourceHook::HookManagerPubFunc myhookman##id = g_Genc##id->Generate(); \
413 int hook1_##id, hook2_##id, hook3_##id, hook4_##id; \
415 TestClass##id::ms_DoRecall = false; \
416 TestClass##id *pTest##id = new TestClass##id; \
417 CAutoPtrDestruction<TestClass##id> apd##id(pTest##id); \
419 /* no hooks - no hooks */ \
421 THGM_CALLS_void(id, call_params); \
422 CHECK_STATES((&g_States, \
423 new State_Func##id(pTest##id, ParamState_m##id call_params), \
424 new State_Func##id(pTest##id, ParamState_m##id call_params), \
425 NULL), "Test" #id " Part1"); \
427 /* hook1 - no hooks */ \
429 THGM_ADD_HOOK(id, 1); \
430 THGM_CALLS_void(id, call_params); \
431 CHECK_STATES((&g_States, \
432 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
433 new State_Func##id(pTest##id, ParamState_m##id call_params), \
434 new State_Func##id(pTest##id, ParamState_m##id call_params), \
435 NULL), "Test" #id " Part2"); \
436 THGM_REMOVE_HOOK(id, 1); \
438 /* no hooks - hook3 */ \
440 THGM_ADD_HOOK(id, 3); \
441 THGM_CALLS_void(id, call_params); \
442 CHECK_STATES((&g_States, \
443 new State_Func##id(pTest##id, ParamState_m##id call_params), \
444 new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
445 new State_Func##id(pTest##id, ParamState_m##id call_params), \
446 NULL), "Test" #id " Part3"); \
447 THGM_REMOVE_HOOK(id, 3); \
449 /* hook1 - hook3 */ \
451 THGM_ADD_HOOK(id, 1); \
452 THGM_ADD_HOOK(id, 3); \
453 THGM_CALLS_void(id, call_params); \
454 CHECK_STATES((&g_States, \
455 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
456 new State_Func##id(pTest##id, ParamState_m##id call_params), \
457 new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
458 new State_Func##id(pTest##id, ParamState_m##id call_params), \
459 NULL), "Test" #id " Part4"); \
460 THGM_REMOVE_HOOK(id, 1); \
461 THGM_REMOVE_HOOK(id, 3); \
463 /* hook1, hook2 - hook3 */ \
465 THGM_ADD_HOOK(id, 1); \
466 THGM_ADD_HOOK(id, 2); \
467 THGM_ADD_HOOK(id, 3); \
468 THGM_CALLS_void(id, call_params); \
469 CHECK_STATES((&g_States, \
470 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
471 new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
472 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
473 new State_Func##id(pTest##id, ParamState_m##id call_params), \
474 NULL), "Test" #id " Part5"); \
475 THGM_REMOVE_HOOK(id, 1); \
476 THGM_REMOVE_HOOK(id, 2); \
477 THGM_REMOVE_HOOK(id, 3); \
478 /* hook1, hook2 - hook3, hook4 */ \
480 THGM_ADD_HOOK(id, 1); \
481 THGM_ADD_HOOK(id, 2); \
482 THGM_ADD_HOOK(id, 3); \
483 THGM_ADD_HOOK(id, 4); \
484 THGM_CALLS_void(id, call_params); \
485 CHECK_STATES((&g_States, \
486 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
487 new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
488 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
489 new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
490 new State_Func##id(pTest##id, ParamState_m##id call_params), \
491 NULL), "Test" #id " Part6"); \
493 /* hook1 - hook3, hook4, with recalls! */ \
495 TestClass##id::ms_DoRecall = true; \
496 THGM_REMOVE_HOOK(id, 2); \
497 THGM_CALLS_void(id, call_params); \
498 CHECK_STATES((&g_States, \
499 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
500 new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
501 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
502 new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
504 new State_Func##id(pTest##id, ParamState_m##id call_params), \
505 NULL), "Test" #id " Part7"); \
506 THGM_REMOVE_HOOK(id, 1); \
507 THGM_REMOVE_HOOK(id, 3); \
508 THGM_REMOVE_HOOK(id, 4);
517 T* ComparableRef(T& x)
522 #define THGM_CALLS(id, call_params, exp_ret_norm, exp_ret_shcall, err) \
523 CHECK_COND(ComparableRef<RetType##id>(pTest##id->Func call_params) == ComparableRef<RetType##id>(MakeRet< RetType##id >::Do(exp_ret_norm)), err " /retcallnorm"); \
524 CHECK_COND(ComparableRef<RetType##id>(SH_CALL(pTest##id, &TestClass##id::Func) call_params) == ComparableRef<RetType##id>(MakeRet< RetType##id >::Do(exp_ret_shcall)), err " /retcallshcall");
526 #define THGM_DO_TEST(id, call_params) \
529 g_Genc##id = new SourceHook::Impl::GenContext(&protoinfo_##id, 0, 0, g_SHPtr); \
530 g_Genc_ad##id.set(g_Genc##id); \
531 SourceHook::HookManagerPubFunc myhookman##id = g_Genc##id->Generate(); \
532 int hook1_##id, hook2_##id, hook3_##id, hook4_##id; \
534 TestClass##id::ms_DoRecall = false; \
535 TestClass##id *pTest##id = new TestClass##id; \
536 CAutoPtrDestruction<TestClass##id> apd##id(pTest##id); \
538 /* no hooks - no hooks */ \
540 THGM_CALLS(id, call_params, 0, 0, "Part1"); \
541 CHECK_STATES((&g_States, \
542 new State_Func##id(pTest##id, ParamState_m##id call_params), \
543 new State_Func##id(pTest##id, ParamState_m##id call_params), \
544 NULL), "Test" #id " Part1"); \
546 /* hook1 - no hooks */ \
548 THGM_ADD_HOOK(id, 1); \
549 THGM_CALLS(id, call_params, 0, 0, "Part2"); \
550 CHECK_STATES((&g_States, \
551 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
552 new State_Func##id(pTest##id, ParamState_m##id call_params), \
553 new State_Func##id(pTest##id, ParamState_m##id call_params), \
554 NULL), "Test" #id " Part2"); \
555 THGM_REMOVE_HOOK(id, 1); \
557 /* no hooks - hook3 */ \
559 THGM_ADD_HOOK(id, 3); \
560 THGM_CALLS(id, call_params, 0, 0, "Part3"); \
561 CHECK_STATES((&g_States, \
562 new State_Func##id(pTest##id, ParamState_m##id call_params), \
563 new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
564 new State_Func##id(pTest##id, ParamState_m##id call_params), \
565 NULL), "Test" #id " Part3"); \
566 THGM_REMOVE_HOOK(id, 3); \
568 /* hook1 - hook3 */ \
570 THGM_ADD_HOOK(id, 1); \
571 THGM_ADD_HOOK(id, 3); \
572 THGM_CALLS(id, call_params, 0, 0, "Part4"); \
573 CHECK_STATES((&g_States, \
574 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
575 new State_Func##id(pTest##id, ParamState_m##id call_params), \
576 new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
577 new State_Func##id(pTest##id, ParamState_m##id call_params), \
578 NULL), "Test" #id " Part4"); \
579 THGM_REMOVE_HOOK(id, 1); \
580 THGM_REMOVE_HOOK(id, 3); \
582 /* hook1, hook2 - hook3 */ \
584 THGM_ADD_HOOK(id, 1); \
585 THGM_ADD_HOOK(id, 2); \
586 THGM_ADD_HOOK(id, 3); \
587 THGM_CALLS(id, call_params, 2, 0, "Part5"); \
588 CHECK_STATES((&g_States, \
589 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
590 new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
591 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
592 new State_Func##id(pTest##id, ParamState_m##id call_params), \
593 NULL), "Test" #id " Part5"); \
594 THGM_REMOVE_HOOK(id, 1); \
595 THGM_REMOVE_HOOK(id, 2); \
596 THGM_REMOVE_HOOK(id, 3); \
597 /* hook1, hook2 - hook3, hook4 */ \
599 THGM_ADD_HOOK(id, 1); \
600 THGM_ADD_HOOK(id, 2); \
601 THGM_ADD_HOOK(id, 3); \
602 THGM_ADD_HOOK(id, 4); \
603 THGM_CALLS(id, call_params, 4, 0, "Part6"); \
604 CHECK_STATES((&g_States, \
605 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
606 new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
607 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
608 new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
609 new State_Func##id(pTest##id, ParamState_m##id call_params), \
610 NULL), "Test" #id " Part6"); \
612 /* hook1 - hook3, hook4, with recalls! */ \
614 TestClass##id::ms_DoRecall = true; \
615 THGM_REMOVE_HOOK(id, 2); \
616 THGM_CALLS(id, call_params, 4, 0, "Part7"); \
617 CHECK_STATES((&g_States, \
618 new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
619 new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
620 new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
621 new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
623 new State_Func##id(pTest##id, ParamState_m##id call_params), \
624 NULL), "Test" #id " Part7"); \
625 THGM_REMOVE_HOOK(id, 1); \
626 THGM_REMOVE_HOOK(id, 3); \
627 THGM_REMOVE_HOOK(id, 4);