From 14c51ca8d167043b877903ca06e6ba05fbd242bf Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Sun, 18 Nov 2007 15:08:03 +0000 Subject: [PATCH] Made testhookmangen easier for the compiler --HG-- branch : hookman_autogen extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/hookman_autogen%40566 --- sourcehook/test/msvc8/test.vcproj | 4 + sourcehook/test/testevents.h | 29 +- sourcehook/test/testhookmangen.cpp | 925 ++++++------ sourcehook/test/testhookmangen.h | 2110 +++------------------------- sourcehook/test/testhookmangen.hxx | 394 +----- 5 files changed, 759 insertions(+), 2703 deletions(-) diff --git a/sourcehook/test/msvc8/test.vcproj b/sourcehook/test/msvc8/test.vcproj index c8df00a..a0f1533 100644 --- a/sourcehook/test/msvc8/test.vcproj +++ b/sourcehook/test/msvc8/test.vcproj @@ -529,6 +529,10 @@ RelativePath="..\testevents.h" > + + diff --git a/sourcehook/test/testevents.h b/sourcehook/test/testevents.h index 24aa060..7a0175c 100644 --- a/sourcehook/test/testevents.h +++ b/sourcehook/test/testevents.h @@ -151,9 +151,9 @@ namespace p1_type m_Param1; \ name(p1_type param1) : m_Param1(param1) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1;\ } \ virtual void Dump() { \ @@ -166,9 +166,9 @@ namespace p2_type m_Param2; \ name(p1_type param1, p2_type param2) : m_Param1(param1), m_Param2(param2) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2;\ } \ virtual void Dump() { \ @@ -182,9 +182,9 @@ namespace p3_type m_Param3; \ name(p1_type param1, p2_type param2, p3_type param3) : m_Param1(param1), m_Param2(param2), m_Param3(param3) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3;\ } \ virtual void Dump() { \ @@ -192,6 +192,23 @@ namespace const char *GetName() { return #name; } \ } +#define MAKE_STATE_4(name, p1_type, p2_type, p3_type, p4_type) struct name : State { \ + p1_type m_Param1; \ + p2_type m_Param2; \ + p3_type m_Param3; \ + p4_type m_Param4; \ + name(p1_type param1, p2_type param2, p3_type param3, p4_type param4) : m_Param1(param1), m_Param2(param2), m_Param3(param3), m_Param4(param4) {} \ + virtual bool IsEqual(State *other) { \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ + return false; \ + name *other2 = static_cast(other); \ + return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3 && other2->m_Param4 == m_Param4;\ + } \ + virtual void Dump() { \ + std::cout << " " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << "; Param3=" << m_Param3 << "; Param4=" << m_Param4 << std::endl; } \ + const char *GetName() { return #name; } \ + } + #define CHECK_COND(c, err) if (!(c)) { error = err; return false; } #endif diff --git a/sourcehook/test/testhookmangen.cpp b/sourcehook/test/testhookmangen.cpp index a391482..4ac57a5 100644 --- a/sourcehook/test/testhookmangen.cpp +++ b/sourcehook/test/testhookmangen.cpp @@ -565,8 +565,488 @@ namespace ADD_STATE(State_Hello_Func79_PreHook); } }; + + bool Tests1(std::string &error) + { + THGM_DO_TEST_void(0, ()); + + THGM_DO_TEST_void(1, (100)); + + THGM_DO_TEST_void(2, (0x1F00)); + + THGM_DO_TEST_void(3, (0x1F000000)); + + THGM_DO_TEST_void(4, (0.5f)); + + THGM_DO_TEST_void(5, (5.5)); + + THGM_DO_TEST_void(6, (100, 0x1f00, 0x1f000000, 0.5f, 5.5)); + + return true; + } + + bool Tests2(std::string &error) + { + char a = 5; + double b = 233.33; + THGM_DO_TEST_void(7, (a, b)); + + POD<7> pod7 = MakeRet< POD<7> >::Do(78); + THGM_DO_TEST_void(8, (pod7)); + + POD<600> pod600 = MakeRet< POD<600> >::Do(34); + THGM_DO_TEST_void(9, (pod600)); + + THGM_DO_TEST_void(10, (pod600)); + + // Test11: Special: constructors/destructors + PtrBuf_Clear(); + Object<3> *obj3_real = new Object<3>(33); + Object<600> *obj600_real = new Object<600>(21); + + Object<3> & obj3 = *obj3_real; + Object<600> & obj600 = *obj600_real; + + CHECK_STATES((&g_States, + new State_ObjOCtor_Called(3), + new State_ObjOCtor_Called(600), + NULL), "Test11 Part0"); + + setuppi_11(); + SourceHook::HookManagerPubFunc myhookman11 = g_HMAGPtr->MakeHookMan(protoinfo_11, 0, 0); \ + CAutoReleaseHookMan arhm_11(myhookman11); \ + int hook1_11, hook2_11, hook3_11, hook4_11; + + TestClass11 *pTest11 = new TestClass11; + CAutoPtrDestruction apd11(pTest11); + + /* no hooks - no hooks */ + PtrBuf_Clear(); + pTest11->Func(obj3, obj600); + + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + new State_ObjCCtor_Called(3), + new State_Func11(pTest11, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + NULL), "Test" "11" " Part1"); + g_Inside_LeafFunc = false; + + /* hook1 - no hooks */ + THGM_ADD_HOOK(11, 1); + + PtrBuf_Clear(); + pTest11->Func(obj3, obj600); + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + new State_ObjCCtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Func11(pTest11, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjODtor_Called(3), + NULL), "Test" "11" " Part2"); + g_Inside_LeafFunc = false; + + THGM_REMOVE_HOOK(11, 1); + + /* hook1, hook2 - hook3, hook4 */ + THGM_ADD_HOOK(11, 1); + THGM_ADD_HOOK(11, 2); + THGM_ADD_HOOK(11, 3); + THGM_ADD_HOOK(11, 4); + PtrBuf_Clear(); + pTest11->Func(obj3, obj600); + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + new State_ObjCCtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(2, pTest11, 1, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(3, pTest11, 2, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(4, pTest11, 3, ParamState_m11 (obj3, obj600)), + new State_ObjODtor_Called(3), + + new State_ObjODtor_Called(3), + NULL), "Test" "11" " Part3"); + g_Inside_LeafFunc = false; + + /* hook1 - hook3, hook4 WITH RECALLS */ + THGM_REMOVE_HOOK(11, 2); + PtrBuf_Clear(); + TestClass11::ms_DoRecall = true; + pTest11->Func(obj3, obj600); + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + new State_ObjCCtor_Called(3), + + new State_ObjCCtor_Called(3), + new State_Deleg_11(1, pTest11, 0 /* first deleg ptr */, ParamState_m11 (obj3, obj600)), + + // recall ! + // second hookfunc -> new copy + new State_ObjCCtor_Called(3), + + // in second hookfunc now + // -> calls orig func + + new State_ObjCCtor_Called(3), + new State_Func11(pTest11, ParamState_m11 (obj3, obj600)(1)), + new State_ObjODtor_Called(3), + + // calls first posthook + new State_ObjCCtor_Called(3), + new State_Deleg_11(3, pTest11, 1 /* second deleg ptr */, ParamState_m11 (obj3, obj600)(1)), + + // recall! + // third hookfunc -> new copy + new State_ObjCCtor_Called(3), + + // calls second posthook + + new State_ObjCCtor_Called(3), + new State_Deleg_11(4, pTest11, 2 /* third deleg ptr */, ParamState_m11 (obj3, obj600)(2)), + + // recall! + // fourth hookfunc -> new copy + new State_ObjCCtor_Called(3), + + // has nothing to do though! + + // fourth hookfunc done -> ret + new State_ObjODtor_Called(3), + + // third hookfunc done -> ret + new State_ObjODtor_Called(3), + // ret from hookhandler which did the recall + new State_ObjODtor_Called(3), + + // second hookfunc done -> ret + new State_ObjODtor_Called(3), + // ret from hookhandler which did the recall + new State_ObjODtor_Called(3), + + // deleg1's instance + new State_ObjODtor_Called(3), + // first hookfunc done -> ret + new State_ObjODtor_Called(3), + NULL), "Test" "11" " Part4"); + g_Inside_LeafFunc = false; + + THGM_REMOVE_HOOK(11, 1); + THGM_REMOVE_HOOK(11, 3); + THGM_REMOVE_HOOK(11, 4); + + delete obj3_real; + delete obj600_real; + + CHECK_STATES((&g_States, + new State_ObjODtor_Called(3), + new State_ObjODtor_Called(600), + NULL), "Test11 Part100"); + + return true; + } + + bool Tests3(std::string &error) + { + THGM_DO_TEST(101, ()); + + THGM_DO_TEST(102, ()); + + THGM_DO_TEST(103, ()); + + THGM_DO_TEST(104, ()); + + THGM_DO_TEST(105, ()); + + // pod returns + THGM_DO_TEST(106, (5)); + THGM_DO_TEST(107, (5)); + THGM_DO_TEST(108, (5)); + THGM_DO_TEST(109, (5)); + + return true; + } + + bool Tests4(std::string &error) + { + // Test110: Special: constructors/destructors on return + PtrBuf_Clear(); + ObjRet13 *obj13_real = new ObjRet13; + ObjRet13 &obj13 = *obj13_real; + + CHECK_STATES((&g_States, + new State_ObjOCtor_Called(13), + NULL), "Test110 Part0"); + + setuppi_110(); + setupri_110(); + + SourceHook::HookManagerPubFunc myhookman110 = g_HMAGPtr->MakeHookMan(protoinfo_110, 0, 0); \ + CAutoReleaseHookMan arhm_110(myhookman110); \ + int hook1_110, hook2_110, hook3_110, hook4_110; + + TestClass110 *pTest110 = new TestClass110; + CAutoPtrDestruction apd110(pTest110); + + /* no hooks - no hooks */ + PtrBuf_Clear(); + obj13 = pTest110->Func(5); + + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + new State_Func110(pTest110, ParamState_m110 (5)), + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in our stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack + new State_ObjODtor_Called(13), // Func110: destruction of temporary object + NULL), "Test" "110" " Part1"); + g_Inside_LeafFunc = false; + + /* hook1 - no hooks */ + THGM_ADD_HOOK(110, 1); + + PtrBuf_Clear(); + obj13 = pTest110->Func(5); + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + // HookFunc: construct orig_ret/override_ret/plugin_ret objects + new State_ObjOCtor_Called(13), + new State_ObjOCtor_Called(13), + new State_ObjOCtor_Called(13), + + // Calling delegate + new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)), + + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + // Calling orig function Func110 + new State_Func110(pTest110, ParamState_m110 (5)), + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: orig_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + // hookfunc is returning: + new State_ObjCCtor_Called(13), // copy to temp object in our stack + + // hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret + new State_ObjODtor_Called(13), + new State_ObjODtor_Called(13), + new State_ObjODtor_Called(13), + + // we are in our function: assign + new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack + new State_ObjODtor_Called(13), // Func110: destruction of temporary object + + NULL), "Test" "11" " Part2"); + + CHECK_COND(obj13 == 0, "Test" "11" " Part 2.1"); + g_Inside_LeafFunc = false; + + THGM_REMOVE_HOOK(110, 1); + + /* hook1, hook2 - hook3, hook4 */ + THGM_ADD_HOOK(110, 1); + THGM_ADD_HOOK(110, 2); + THGM_ADD_HOOK(110, 3); + THGM_ADD_HOOK(110, 4); + + PtrBuf_Clear(); + obj13 = pTest110->Func(5); + g_Inside_LeafFunc = true; + CHECK_STATES((&g_States, + // HookFunc: construct orig_ret/override_ret/plugin_ret objects + new State_ObjOCtor_Called(13), + new State_ObjOCtor_Called(13), + new State_ObjOCtor_Called(13), + + // Calling delegate1 + new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)), + + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + + // Calling delegate2 + new State_Deleg_110(2, pTest110, 1, ParamState_m110 (5)), + + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + // hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret + new State_ObjAssignOp_Called(13), + + // SUPERCEDE -> orig function is not called + // instead: orig_ret = override_ret + new State_ObjAssignOp_Called(13), + + // Calling delegate3 + new State_Deleg_110(3, pTest110, 2, ParamState_m110 (5)), + + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + // Calling delegate4 + new State_Deleg_110(4, pTest110, 3, ParamState_m110 (5)), + + new State_ObjOCtor_Called(13), // MakeRet: Construction of x + new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // MakeRet: Destruction of x + + // back in hookfunc + new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack + new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack + + // hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret (yes really, we overwrite the old value!) + new State_ObjAssignOp_Called(13), + + // hookfunc is returning: + new State_ObjCCtor_Called(13), // copy to temp object in our stack + + // hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret + new State_ObjODtor_Called(13), + new State_ObjODtor_Called(13), + new State_ObjODtor_Called(13), + + // we are in our function: assign + new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack + new State_ObjODtor_Called(13), // Func110: destruction of temporary object + + NULL), "Test" "11" " Part3"); + + CHECK_COND(obj13 == 4, "Test" "11" " Part 3.1"); + g_Inside_LeafFunc = false; + + THGM_REMOVE_HOOK(110, 1); + THGM_REMOVE_HOOK(110, 2); + THGM_REMOVE_HOOK(110, 3); + THGM_REMOVE_HOOK(110, 4); + + delete obj13_real; + + CHECK_STATES((&g_States, + new State_ObjODtor_Called(13), + NULL), "Test110 Part100"); + + return true; + } + + bool Tests5(std::string &error) + { + // RefRet + THGM_DO_TEST(111, ()); + + // Vafmt + + THGM_DO_TEST_void(200, ("Hello %s%d%s", "BA", 1, "L!")); + + THGM_DO_TEST_void(201, (100, "Hello %s%d%s", "BA", 1, "L!")); + + THGM_DO_TEST_void(203, (0x1F000000, "Hello %s%d%s", "BA", 1, "L!")); + + THGM_DO_TEST_void(206, (100, 0x1f00, 0x1f000000, 0.5f, 5.5, "Hello %s%d%s", "BA", 1, "L!")); + + char a = 5; + double b = 233.33; + THGM_DO_TEST_void(207, (a, b, "Hello %s%d%s", "BA", 1, "L!")); + + POD<7> pod7 = MakeRet< POD<7> >::Do(78); + THGM_DO_TEST_void(208, (pod7, "Hello %s%d%s", "BA", 1, "L!")); + + POD<600> pod600 = MakeRet< POD<600> >::Do(34); + THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!")); + + // Test for lange vtable indices + Hello *pHello = new Hello; + SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall); + SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4); + SourceHook::HookManagerPubFunc helloHM_79 = g_HMAGPtr->MakeHookMan(helloPi, 0, 79); + + pHello->Func4(); + pHello->Func79(); + SH_CALL(pHello, &Hello::Func4)(); + SH_CALL(pHello, &Hello::Func79)(); + CHECK_STATES((&g_States, + new State_Hello_Func4_Called, + new State_Hello_Func79_Called, + new State_Hello_Func4_Called, + new State_Hello_Func79_Called, + NULL), "Test" "Hello" " Part1"); + + int helloHook4 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pHello), + 0, helloHM_4, new Hello_Func4_Deleg, false); + + int helloHook79 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pHello), + 0, helloHM_79, new Hello_Func79_Deleg, false); + + pHello->Func4(); + pHello->Func79(); + SH_CALL(pHello, &Hello::Func4)(); + SH_CALL(pHello, &Hello::Func79)(); + + CHECK_STATES((&g_States, + new State_Hello_Func4_PreHook, + new State_Hello_Func4_Called, + new State_Hello_Func79_PreHook, + new State_Hello_Func79_Called, + new State_Hello_Func4_Called, + new State_Hello_Func79_Called, + NULL), "Test" "Hello" " Part2"); + + g_SHPtr->RemoveHookByID(helloHook4); + g_SHPtr->RemoveHookByID(helloHook79); + + g_HMAGPtr->ReleaseHookMan(helloHM_4); + g_HMAGPtr->ReleaseHookMan(helloHM_79); + + return true; + } } + bool TestHookManGen(std::string &error) { GET_SHPTR(g_SHPtr); @@ -582,441 +1062,16 @@ bool TestHookManGen(std::string &error) new State_ObjOCtor_Called(111), NULL), "GlobCtors"); - THGM_DO_TEST_void(0, ()); - - THGM_DO_TEST_void(1, (100)); - - THGM_DO_TEST_void(2, (0x1F00)); - - THGM_DO_TEST_void(3, (0x1F000000)); - - THGM_DO_TEST_void(4, (0.5f)); - - THGM_DO_TEST_void(5, (5.5)); - - THGM_DO_TEST_void(6, (100, 0x1f00, 0x1f000000, 0.5f, 5.5)); - - char a = 5; - double b = 233.33; - THGM_DO_TEST_void(7, (a, b)); - - POD<7> pod7 = MakeRet< POD<7> >::Do(78); - THGM_DO_TEST_void(8, (pod7)); - - POD<600> pod600 = MakeRet< POD<600> >::Do(34); - THGM_DO_TEST_void(9, (pod600)); - - THGM_DO_TEST_void(10, (pod600)); - - // Test11: Special: constructors/destructors - PtrBuf_Clear(); - Object<3> obj3(33); - Object<600> obj600(21); - - CHECK_STATES((&g_States, - new State_ObjOCtor_Called(3), - new State_ObjOCtor_Called(600), - NULL), "Test11 Part0"); - - setuppi_11(); - SourceHook::HookManagerPubFunc myhookman11 = g_HMAGPtr->MakeHookMan(protoinfo_11, 0, 0); \ - CAutoReleaseHookMan arhm_11(myhookman11); \ - int hook1_11, hook2_11, hook3_11, hook4_11; - - TestClass11 *pTest11 = new TestClass11; - CAutoPtrDestruction apd11(pTest11); - - /* no hooks - no hooks */ - PtrBuf_Clear(); - pTest11->Func(obj3, obj600); - - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - new State_ObjCCtor_Called(3), - new State_Func11(pTest11, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - NULL), "Test" "11" " Part1"); - g_Inside_LeafFunc = false; - - /* hook1 - no hooks */ - THGM_ADD_HOOK(11, 1); - - PtrBuf_Clear(); - pTest11->Func(obj3, obj600); - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - new State_ObjCCtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg1_11(pTest11, 0, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Func11(pTest11, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjODtor_Called(3), - NULL), "Test" "11" " Part2"); - g_Inside_LeafFunc = false; - - THGM_REMOVE_HOOK(11, 1); - - /* hook1, hook2 - hook3, hook4 */ - THGM_ADD_HOOK(11, 1); - THGM_ADD_HOOK(11, 2); - THGM_ADD_HOOK(11, 3); - THGM_ADD_HOOK(11, 4); - PtrBuf_Clear(); - pTest11->Func(obj3, obj600); - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - new State_ObjCCtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg1_11(pTest11, 0, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg2_11(pTest11, 1, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg3_11(pTest11, 2, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg4_11(pTest11, 3, ParamState_m11 (obj3, obj600)), - new State_ObjODtor_Called(3), - - new State_ObjODtor_Called(3), - NULL), "Test" "11" " Part3"); - g_Inside_LeafFunc = false; - - /* hook1 - hook3, hook4 WITH RECALLS */ - THGM_REMOVE_HOOK(11, 2); - PtrBuf_Clear(); - TestClass11::ms_DoRecall = true; - pTest11->Func(obj3, obj600); - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - new State_ObjCCtor_Called(3), - - new State_ObjCCtor_Called(3), - new State_Deleg1_11(pTest11, 0 /* first deleg ptr */, ParamState_m11 (obj3, obj600)), - - // recall ! - // second hookfunc -> new copy - new State_ObjCCtor_Called(3), - - // in second hookfunc now - // -> calls orig func - - new State_ObjCCtor_Called(3), - new State_Func11(pTest11, ParamState_m11 (obj3, obj600)(1)), - new State_ObjODtor_Called(3), - - // calls first posthook - new State_ObjCCtor_Called(3), - new State_Deleg3_11(pTest11, 1 /* second deleg ptr */, ParamState_m11 (obj3, obj600)(1)), - - // recall! - // third hookfunc -> new copy - new State_ObjCCtor_Called(3), - - // calls second posthook - - new State_ObjCCtor_Called(3), - new State_Deleg4_11(pTest11, 2 /* third deleg ptr */, ParamState_m11 (obj3, obj600)(2)), - - // recall! - // fourth hookfunc -> new copy - new State_ObjCCtor_Called(3), - - // has nothing to do though! - - // fourth hookfunc done -> ret - new State_ObjODtor_Called(3), - - // third hookfunc done -> ret - new State_ObjODtor_Called(3), - // ret from hookhandler which did the recall - new State_ObjODtor_Called(3), - - // second hookfunc done -> ret - new State_ObjODtor_Called(3), - // ret from hookhandler which did the recall - new State_ObjODtor_Called(3), - - // deleg1's instance - new State_ObjODtor_Called(3), - // first hookfunc done -> ret - new State_ObjODtor_Called(3), - NULL), "Test" "11" " Part4"); - g_Inside_LeafFunc = false; - - THGM_REMOVE_HOOK(11, 1); - THGM_REMOVE_HOOK(11, 3); - THGM_REMOVE_HOOK(11, 4); - - THGM_DO_TEST(101, ()); - - THGM_DO_TEST(102, ()); - - THGM_DO_TEST(103, ()); - - THGM_DO_TEST(104, ()); - - THGM_DO_TEST(105, ()); - - // pod returns - THGM_DO_TEST(106, (5)); - THGM_DO_TEST(107, (5)); - THGM_DO_TEST(108, (5)); - THGM_DO_TEST(109, (5)); - - // Test110: Special: constructors/destructors on return - PtrBuf_Clear(); - ObjRet13 obj13; - - CHECK_STATES((&g_States, - new State_ObjOCtor_Called(13), - NULL), "Test110 Part0"); - - setuppi_110(); - setupri_110(); - - SourceHook::HookManagerPubFunc myhookman110 = g_HMAGPtr->MakeHookMan(protoinfo_110, 0, 0); \ - CAutoReleaseHookMan arhm_110(myhookman110); \ - int hook1_110, hook2_110, hook3_110, hook4_110; - - TestClass110 *pTest110 = new TestClass110; - CAutoPtrDestruction apd110(pTest110); - - /* no hooks - no hooks */ - PtrBuf_Clear(); - obj13 = pTest110->Func(5); - - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - new State_Func110(pTest110, ParamState_m110 (5)), - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in our stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack - new State_ObjODtor_Called(13), // Func110: destruction of temporary object - NULL), "Test" "110" " Part1"); - g_Inside_LeafFunc = false; - - /* hook1 - no hooks */ - THGM_ADD_HOOK(110, 1); - - PtrBuf_Clear(); - obj13 = pTest110->Func(5); - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - // HookFunc: construct orig_ret/override_ret/plugin_ret objects - new State_ObjOCtor_Called(13), - new State_ObjOCtor_Called(13), - new State_ObjOCtor_Called(13), - - // Calling delegate - new State_Deleg1_110(pTest110, 0, ParamState_m110 (5)), - - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - // Calling orig function Func110 - new State_Func110(pTest110, ParamState_m110 (5)), - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: orig_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - // hookfunc is returning: - new State_ObjCCtor_Called(13), // copy to temp object in our stack - - // hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret - new State_ObjODtor_Called(13), - new State_ObjODtor_Called(13), - new State_ObjODtor_Called(13), - - // we are in our function: assign - new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack - new State_ObjODtor_Called(13), // Func110: destruction of temporary object - - NULL), "Test" "11" " Part2"); - - CHECK_COND(obj13 == 0, "Test" "11" " Part 2.1"); - g_Inside_LeafFunc = false; - - THGM_REMOVE_HOOK(11, 1); - - /* hook1, hook2 - hook3, hook4 */ - THGM_ADD_HOOK(110, 1); - THGM_ADD_HOOK(110, 2); - THGM_ADD_HOOK(110, 3); - THGM_ADD_HOOK(110, 4); - - PtrBuf_Clear(); - obj13 = pTest110->Func(5); - g_Inside_LeafFunc = true; - CHECK_STATES((&g_States, - // HookFunc: construct orig_ret/override_ret/plugin_ret objects - new State_ObjOCtor_Called(13), - new State_ObjOCtor_Called(13), - new State_ObjOCtor_Called(13), - - // Calling delegate1 - new State_Deleg1_110(pTest110, 0, ParamState_m110 (5)), - - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - - // Calling delegate2 - new State_Deleg2_110(pTest110, 1, ParamState_m110 (5)), - - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - // hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret - new State_ObjAssignOp_Called(13), - - // SUPERCEDE -> orig function is not called - // instead: orig_ret = override_ret - new State_ObjAssignOp_Called(13), - - // Calling delegate3 - new State_Deleg3_110(pTest110, 2, ParamState_m110 (5)), - - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - // Calling delegate4 - new State_Deleg4_110(pTest110, 3, ParamState_m110 (5)), - - new State_ObjOCtor_Called(13), // MakeRet: Construction of x - new State_ObjCCtor_Called(13), // Return from MakeRet -> construct temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // MakeRet: Destruction of x - - // back in hookfunc - new State_ObjAssignOp_Called(13), // assign: plugin_ret = temporary object in HookFunc's stack - new State_ObjODtor_Called(13), // destruction of temporary object in HookFunc's stack - - // hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret (yes really, we overwrite the old value!) - new State_ObjAssignOp_Called(13), - - // hookfunc is returning: - new State_ObjCCtor_Called(13), // copy to temp object in our stack - - // hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret - new State_ObjODtor_Called(13), - new State_ObjODtor_Called(13), - new State_ObjODtor_Called(13), - - // we are in our function: assign - new State_ObjAssignOp_Called(13), // assign: obj13 = temporary object in our stack - new State_ObjODtor_Called(13), // Func110: destruction of temporary object - - NULL), "Test" "11" " Part3"); - - CHECK_COND(obj13 == 4, "Test" "11" " Part 3.1"); - g_Inside_LeafFunc = false; - - THGM_REMOVE_HOOK(110, 1); - THGM_REMOVE_HOOK(110, 2); - THGM_REMOVE_HOOK(110, 3); - THGM_REMOVE_HOOK(110, 4); - - - // RefRet - THGM_DO_TEST(111, ()); - - // Vafmt - - THGM_DO_TEST_void(200, ("Hello %s%d%s", "BA", 1, "L!")); - - THGM_DO_TEST_void(201, (100, "Hello %s%d%s", "BA", 1, "L!")); - - THGM_DO_TEST_void(203, (0x1F000000, "Hello %s%d%s", "BA", 1, "L!")); - - THGM_DO_TEST_void(206, (100, 0x1f00, 0x1f000000, 0.5f, 5.5, "Hello %s%d%s", "BA", 1, "L!")); - - a = 5; - b = 233.33; - THGM_DO_TEST_void(207, (a, b, "Hello %s%d%s", "BA", 1, "L!")); - - pod7 = MakeRet< POD<7> >::Do(78); - THGM_DO_TEST_void(208, (pod7, "Hello %s%d%s", "BA", 1, "L!")); - - THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!")); - - // Test for lange vtable indices - Hello *pHello = new Hello; - SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall); - SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4); - SourceHook::HookManagerPubFunc helloHM_79 = g_HMAGPtr->MakeHookMan(helloPi, 0, 79); - - pHello->Func4(); - pHello->Func79(); - SH_CALL(pHello, &Hello::Func4)(); - SH_CALL(pHello, &Hello::Func79)(); - CHECK_STATES((&g_States, - new State_Hello_Func4_Called, - new State_Hello_Func79_Called, - new State_Hello_Func4_Called, - new State_Hello_Func79_Called, - NULL), "Test" "Hello" " Part1"); - - int helloHook4 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pHello), - 0, helloHM_4, new Hello_Func4_Deleg, false); - - int helloHook79 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pHello), - 0, helloHM_79, new Hello_Func79_Deleg, false); - - pHello->Func4(); - pHello->Func79(); - SH_CALL(pHello, &Hello::Func4)(); - SH_CALL(pHello, &Hello::Func79)(); - - CHECK_STATES((&g_States, - new State_Hello_Func4_PreHook, - new State_Hello_Func4_Called, - new State_Hello_Func79_PreHook, - new State_Hello_Func79_Called, - new State_Hello_Func4_Called, - new State_Hello_Func79_Called, - NULL), "Test" "Hello" " Part2"); - - g_SHPtr->RemoveHookByID(helloHook4); - g_SHPtr->RemoveHookByID(helloHook79); - - g_HMAGPtr->ReleaseHookMan(helloHM_4); - g_HMAGPtr->ReleaseHookMan(helloHM_79); + if (!Tests1(error)) + return false; + if (!Tests2(error)) + return false; + if (!Tests3(error)) + return false; + if (!Tests4(error)) + return false; + if (!Tests5(error)) + return false; // Shutdown now! // If we don't SH will auto-shutdown _after_ genc's destructor is called diff --git a/sourcehook/test/testhookmangen.h b/sourcehook/test/testhookmangen.h index 32c12d5..835532f 100644 --- a/sourcehook/test/testhookmangen.h +++ b/sourcehook/test/testhookmangen.h @@ -507,10 +507,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState0<0 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -523,70 +520,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call() \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ()); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, ()); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -598,10 +550,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState0<0 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -616,70 +565,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call() \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, ()); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, ()); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -689,10 +593,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState1<0, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -713,169 +614,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, ("%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST0_vafmt(id, ret_type) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState0<0 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call() \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, ()); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI0(id) \ void setuppi_##id() \ { \ @@ -888,10 +650,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState1<0, param1 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -904,70 +663,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -979,10 +693,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState1<0, param1 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -997,70 +708,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -1070,10 +736,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState2<0, param1, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1094,169 +757,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST1_vafmt(id, ret_type, param1) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState1<0, param1 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI1(id, p1_type, p1_passtype, p1_flags) \ void setuppi_##id() \ { \ @@ -1276,10 +800,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState2<0, param1, param2 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1292,70 +813,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -1367,10 +843,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState2<0, param1, param2 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1385,70 +858,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1, param2 p2) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -1458,10 +886,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState3<0, param1, param2, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1482,169 +907,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST2_vafmt(id, ret_type, param1, param2) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState2<0, param1, param2 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI2(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags) \ void setuppi_##id() \ { \ @@ -1671,10 +957,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1687,70 +970,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -1762,10 +1000,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1780,70 +1015,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -1853,10 +1043,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState4<0, param1, param2, param3, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -1877,169 +1064,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST3_vafmt(id, ret_type, param1, param2, param3) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI3(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags, p3_type, p3_passtype, p3_flags) \ void setuppi_##id() \ { \ @@ -2073,10 +1121,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2089,70 +1134,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -2164,10 +1164,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2182,70 +1179,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -2255,10 +1207,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState5<0, param1, param2, param3, param4, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2279,169 +1228,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST4_vafmt(id, ret_type, param1, param2, param3, param4) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI4(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags, p3_type, p3_passtype, p3_flags, p4_type, p4_passtype, p4_flags) \ void setuppi_##id() \ { \ @@ -2482,10 +1292,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2498,70 +1305,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -2573,10 +1335,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2591,70 +1350,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -2664,10 +1378,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState6<0, param1, param2, param3, param4, param5, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2688,169 +1399,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST5_vafmt(id, ret_type, param1, param2, param3, param4, param5) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI5(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags, p3_type, p3_passtype, p3_flags, p4_type, p4_passtype, p4_flags, p5_type, p5_passtype, p5_flags) \ void setuppi_##id() \ { \ @@ -2898,10 +1470,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -2914,70 +1483,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -2989,10 +1513,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, typedef ret_type RetType##id; \ typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -3007,70 +1528,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -3080,10 +1556,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, struct TestClass##id; \ typedef ParamState7<0, param1, param2, param3, param4, param5, param6, std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -3104,169 +1577,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST6_vafmt(id, ret_type, param1, param2, param3, param4, param5, param6) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - Increment::type>::Incr(p1);Increment::type>::Incr(p2);Increment::type>::Incr(p3);Increment::type>::Incr(p4);Increment::type>::Incr(p5);Increment::type>::Incr(p6); \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI6(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags, p3_type, p3_passtype, p3_flags, p4_type, p4_passtype, p4_flags, p5_type, p5_passtype, p5_flags, p6_type, p6_passtype, p6_flags) \ void setuppi_##id() \ { \ @@ -3330,7 +1664,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, #define THGM_ADD_HOOK(id, num) \ CAT4(hook, num, _, id) = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pTest##id), \ - 0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate##num), num >= 3); + 0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate(num)), num >= 3); #define THGM_REMOVE_HOOK(id, num) \ g_SHPtr->RemoveHookByID(CAT4(hook, num, _, id)); @@ -3356,28 +1690,6 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, new State_Func##id(pTest##id, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part1"); \ - \ - /* hook1 - no hooks */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_CALLS_void(id, call_params); \ - CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part2"); \ - THGM_REMOVE_HOOK(id, 1); \ - \ - /* no hooks - hook3 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 3); \ - THGM_CALLS_void(id, call_params); \ - CHECK_STATES((&g_States, \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part3"); \ - THGM_REMOVE_HOOK(id, 3); \ \ /* hook1 - hook3 */ \ PtrBuf_Clear(); \ @@ -3385,9 +1697,9 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, THGM_ADD_HOOK(id, 3); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part4"); \ THGM_REMOVE_HOOK(id, 1); \ @@ -3400,26 +1712,19 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, THGM_ADD_HOOK(id, 3); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part5"); \ - THGM_REMOVE_HOOK(id, 1); \ - THGM_REMOVE_HOOK(id, 2); \ - THGM_REMOVE_HOOK(id, 3); \ /* hook1, hook2 - hook3, hook4 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_ADD_HOOK(id, 2); \ - THGM_ADD_HOOK(id, 3); \ THGM_ADD_HOOK(id, 4); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part6"); \ \ @@ -3429,10 +1734,10 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, THGM_REMOVE_HOOK(id, 2); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \ new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \ /* sh_call one */ \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part7"); \ @@ -3474,28 +1779,6 @@ T* ComparableRef(T& x) new State_Func##id(pTest##id, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part1"); \ - \ - /* hook1 - no hooks */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_CALLS(id, call_params, 0, 0, "Part2"); \ - CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part2"); \ - THGM_REMOVE_HOOK(id, 1); \ - \ - /* no hooks - hook3 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 3); \ - THGM_CALLS(id, call_params, 0, 0, "Part3"); \ - CHECK_STATES((&g_States, \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part3"); \ - THGM_REMOVE_HOOK(id, 3); \ \ /* hook1 - hook3 */ \ PtrBuf_Clear(); \ @@ -3503,9 +1786,9 @@ T* ComparableRef(T& x) THGM_ADD_HOOK(id, 3); \ THGM_CALLS(id, call_params, 0, 0, "Part4"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part4"); \ THGM_REMOVE_HOOK(id, 1); \ @@ -3518,26 +1801,19 @@ T* ComparableRef(T& x) THGM_ADD_HOOK(id, 3); \ THGM_CALLS(id, call_params, 2, 0, "Part5"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part5"); \ - THGM_REMOVE_HOOK(id, 1); \ - THGM_REMOVE_HOOK(id, 2); \ - THGM_REMOVE_HOOK(id, 3); \ /* hook1, hook2 - hook3, hook4 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_ADD_HOOK(id, 2); \ - THGM_ADD_HOOK(id, 3); \ THGM_ADD_HOOK(id, 4); \ THGM_CALLS(id, call_params, 4, 0, "Part6"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part6"); \ \ @@ -3547,10 +1823,10 @@ T* ComparableRef(T& x) THGM_REMOVE_HOOK(id, 2); \ THGM_CALLS(id, call_params, 4, 0, "Part7"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \ new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \ /* sh_call one */ \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part7"); \ diff --git a/sourcehook/test/testhookmangen.hxx b/sourcehook/test/testhookmangen.hxx index 8b94fd3..7941ef5 100644 --- a/sourcehook/test/testhookmangen.hxx +++ b/sourcehook/test/testhookmangen.hxx @@ -203,10 +203,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] struct TestClass##id; \ typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -219,70 +216,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -294,10 +246,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] typedef ret_type RetType##id; \ typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -312,70 +261,25 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] return MakeRet< ret_type >::Do(0); \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ + RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ } \ else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ @@ -385,10 +289,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] struct TestClass##id; \ typedef ParamState@($1+1)<0@[$2,1,$1:, param$2@], std::string > ParamState_m##id; \ MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ \ struct TestClass##id \ { \ @@ -409,169 +310,30 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] g_Inside_LeafFunc = false; \ } \ \ - struct Delegate1 : public MyDelegate \ + struct Delegate : public MyDelegate \ { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \ { \ g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \ + ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \ g_Inside_LeafFunc = false; \ if (ms_DoRecall) \ { \ @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ + RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ } \ else \ - RETURN_META(MRES_IGNORED); \ + RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \ } \ }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_IGNORED); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ - } \ - else \ - RETURN_META(MRES_SUPERCEDE); \ - }; \ - }; \ }; \ \ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt); - -#define THGM_MAKE_TEST$1_vafmt(id, ret_type@[$2,1,$1:, param$2@]) \ - struct TestClass##id; \ - typedef ret_type RetType##id; \ - typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \ - MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ - \ - struct TestClass##id \ - { \ - static bool ms_DoRecall; \ - \ - virtual ret_type Func(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Func##id(this, ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - \ - return MakeRet< ret_type >::Do(0); \ - } \ - \ - struct Delegate1 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \ - } \ - }; \ - struct Delegate2 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \ - } \ - }; \ - struct Delegate3 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \ - } \ - }; \ - struct Delegate4 : public MyDelegate \ - { \ - virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \ - { \ - g_Inside_LeafFunc = true; \ - ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \ - g_Inside_LeafFunc = false; \ - if (ms_DoRecall) \ - { \ - @[$2,1,$1:Increment::type>::Incr(p$2);@] \ - RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \ - } \ - else \ - RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \ - }; \ - }; \ - }; \ - \ - bool TestClass##id::ms_DoRecall = false; \ - SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall) - - #define THGM_SETUP_PI$1(id@[$2,1,$1:, p$2_type, p$2_passtype, p$2_flags@]) \ void setuppi_##id() \ { \ @@ -600,7 +362,7 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] #define THGM_ADD_HOOK(id, num) \ CAT4(hook, num, _, id) = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast(pTest##id), \ - 0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate##num), num >= 3); + 0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate(num)), num >= 3); #define THGM_REMOVE_HOOK(id, num) \ g_SHPtr->RemoveHookByID(CAT4(hook, num, _, id)); @@ -626,28 +388,6 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] new State_Func##id(pTest##id, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part1"); \ - \ - /* hook1 - no hooks */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_CALLS_void(id, call_params); \ - CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part2"); \ - THGM_REMOVE_HOOK(id, 1); \ - \ - /* no hooks - hook3 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 3); \ - THGM_CALLS_void(id, call_params); \ - CHECK_STATES((&g_States, \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part3"); \ - THGM_REMOVE_HOOK(id, 3); \ \ /* hook1 - hook3 */ \ PtrBuf_Clear(); \ @@ -655,9 +395,9 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] THGM_ADD_HOOK(id, 3); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part4"); \ THGM_REMOVE_HOOK(id, 1); \ @@ -670,26 +410,19 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] THGM_ADD_HOOK(id, 3); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part5"); \ - THGM_REMOVE_HOOK(id, 1); \ - THGM_REMOVE_HOOK(id, 2); \ - THGM_REMOVE_HOOK(id, 3); \ /* hook1, hook2 - hook3, hook4 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_ADD_HOOK(id, 2); \ - THGM_ADD_HOOK(id, 3); \ THGM_ADD_HOOK(id, 4); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part6"); \ \ @@ -699,10 +432,10 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] THGM_REMOVE_HOOK(id, 2); \ THGM_CALLS_void(id, call_params); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \ new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \ /* sh_call one */ \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part7"); \ @@ -744,28 +477,6 @@ T* ComparableRef(T& x) new State_Func##id(pTest##id, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part1"); \ - \ - /* hook1 - no hooks */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_CALLS(id, call_params, 0, 0, "Part2"); \ - CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part2"); \ - THGM_REMOVE_HOOK(id, 1); \ - \ - /* no hooks - hook3 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 3); \ - THGM_CALLS(id, call_params, 0, 0, "Part3"); \ - CHECK_STATES((&g_States, \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Func##id(pTest##id, ParamState_m##id call_params), \ - NULL), "Test" #id " Part3"); \ - THGM_REMOVE_HOOK(id, 3); \ \ /* hook1 - hook3 */ \ PtrBuf_Clear(); \ @@ -773,9 +484,9 @@ T* ComparableRef(T& x) THGM_ADD_HOOK(id, 3); \ THGM_CALLS(id, call_params, 0, 0, "Part4"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part4"); \ THGM_REMOVE_HOOK(id, 1); \ @@ -788,26 +499,19 @@ T* ComparableRef(T& x) THGM_ADD_HOOK(id, 3); \ THGM_CALLS(id, call_params, 2, 0, "Part5"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part5"); \ - THGM_REMOVE_HOOK(id, 1); \ - THGM_REMOVE_HOOK(id, 2); \ - THGM_REMOVE_HOOK(id, 3); \ /* hook1, hook2 - hook3, hook4 */ \ - PtrBuf_Clear(); \ - THGM_ADD_HOOK(id, 1); \ - THGM_ADD_HOOK(id, 2); \ - THGM_ADD_HOOK(id, 3); \ THGM_ADD_HOOK(id, 4); \ THGM_CALLS(id, call_params, 4, 0, "Part6"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \ - new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \ + new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part6"); \ \ @@ -817,10 +521,10 @@ T* ComparableRef(T& x) THGM_REMOVE_HOOK(id, 2); \ THGM_CALLS(id, call_params, 4, 0, "Part7"); \ CHECK_STATES((&g_States, \ - new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \ + new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \ new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \ - new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \ - new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \ + new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \ + new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \ /* sh_call one */ \ new State_Func##id(pTest##id, ParamState_m##id call_params), \ NULL), "Test" #id " Part7"); \