From 84a87208ac15e72ca7b1b8492531a106bc53aa25 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Mon, 19 Nov 2007 13:39:44 +0000 Subject: [PATCH] Added test for an void (int, double, int) function (in case doubles are aligned on an 8-byte boundary and we don't know about it) Added tests for vafmt functions with non-void return types (basic, float, object) --HG-- branch : hookman_autogen extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/hookman_autogen%40567 --- sourcehook/test/testhookmangen.cpp | 34 +++ sourcehook/test/testhookmangen.h | 357 +++++++++++++++++++++++++++++ sourcehook/test/testhookmangen.hxx | 51 +++++ 3 files changed, 442 insertions(+) diff --git a/sourcehook/test/testhookmangen.cpp b/sourcehook/test/testhookmangen.cpp index 4ac57a5..2cc8953 100644 --- a/sourcehook/test/testhookmangen.cpp +++ b/sourcehook/test/testhookmangen.cpp @@ -422,6 +422,12 @@ namespace SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp); + THGM_MAKE_TEST3_void(150, int, double, int); + THGM_SETUP_PI3(150, + int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal, + double, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal, + int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal); + // vafmt tests THGM_MAKE_TEST0_vafmt_void(200); THGM_SETUP_PI0(200); @@ -453,6 +459,25 @@ namespace THGM_MAKE_TEST1_vafmt_void(210, POD<600> &); THGM_SETUP_PI1(210, POD<600> &, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByRef) + THGM_MAKE_TEST1_vafmt(211, int, int); + THGM_SETUP_PI1(211, + int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal + ); + THGM_SETUP_RI(211, int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal); + + THGM_MAKE_TEST1_vafmt(212, double, int); + THGM_SETUP_PI1(212, + int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal + ); + THGM_SETUP_RI(212, float, SourceHook::PassInfo::PassType_Float, SourceHook::PassInfo::PassFlag_ByVal); + + THGM_MAKE_TEST1_vafmt(213, PodRet8, int); + THGM_SETUP_PI1(213, + int, SourceHook::PassInfo::PassType_Basic, SourceHook::PassInfo::PassFlag_ByVal + ); + THGM_SETUP_RI(213, PodRet8, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal); + + MAKE_STATE(State_Hello_Func4_Called); MAKE_STATE(State_Hello_Func79_Called); @@ -971,6 +996,9 @@ namespace new State_ObjODtor_Called(13), NULL), "Test110 Part100"); + + THGM_DO_TEST_void(150, (5, 5.5, 6)); + return true; } @@ -999,6 +1027,12 @@ namespace POD<600> pod600 = MakeRet< POD<600> >::Do(34); THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!")); + + THGM_DO_TEST(211, (5, "Hello %s%d%s", "BA", 1, "L!")); + THGM_DO_TEST(212, (5, "Hello %s%d%s", "BA", 1, "L!")); + THGM_DO_TEST(213, (5, "Hello %s%d%s", "BA", 1, "L!")); + + // Test for lange vtable indices Hello *pHello = new Hello; SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall); diff --git a/sourcehook/test/testhookmangen.h b/sourcehook/test/testhookmangen.h index 835532f..d0faad5 100644 --- a/sourcehook/test/testhookmangen.h +++ b/sourcehook/test/testhookmangen.h @@ -638,6 +638,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 ParamState1<0, std::string > ParamState_m##id; \ + MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + \ + struct TestClass##id \ + { \ + static bool ms_DoRecall; \ + \ + virtual ret_type Func(const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + struct Delegate : public MyDelegate \ + { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ + virtual ret_type Call(const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, ("%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + bool TestClass##id::ms_DoRecall = false; \ + SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall); + #define THGM_SETUP_PI0(id) \ void setuppi_##id() \ { \ @@ -781,6 +832,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 ParamState2<0, param1, std::string > ParamState_m##id; \ + MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + \ + struct TestClass##id \ + { \ + static bool ms_DoRecall; \ + \ + virtual ret_type Func(param1 p1, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + struct Delegate : public MyDelegate \ + { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ + virtual ret_type Call(param1 p1, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ @@ -931,6 +1033,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 ParamState3<0, param1, param2, std::string > ParamState_m##id; \ + MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \ + \ + struct TestClass##id \ + { \ + static bool ms_DoRecall; \ + \ + virtual ret_type Func(param1 p1, param2 p2, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + struct Delegate : public MyDelegate \ + { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ + virtual ret_type Call(param1 p1, param2 p2, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ @@ -1088,6 +1241,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 ParamState4<0, param1, param2, param3, std::string > ParamState_m##id; \ + MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \ + MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, 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, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + struct Delegate : public MyDelegate \ + { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ + virtual ret_type Call(param1 p1, param2 p2, param3 p3, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ @@ -1252,6 +1456,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 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_4(State_Deleg_##id, int /*delegnumber*/, 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, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + 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, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ @@ -1423,6 +1678,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 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_4(State_Deleg_##id, int /*delegnumber*/, 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, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + 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, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ @@ -1601,6 +1907,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState6<0, p1, p2, p3, p4, 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 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_4(State_Deleg_##id, int /*delegnumber*/, 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, const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5, p6, std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + 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, const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \ diff --git a/sourcehook/test/testhookmangen.hxx b/sourcehook/test/testhookmangen.hxx index 7941ef5..cf6bd79 100644 --- a/sourcehook/test/testhookmangen.hxx +++ b/sourcehook/test/testhookmangen.hxx @@ -334,6 +334,57 @@ std::ostream& operator <<(std::ostream &os,const ParamState$1<0@[$2,1,$1:, p$2@] 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+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_4(State_Deleg_##id, int /*delegnumber*/, 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, @]const char *fmt, ...) \ + { \ + g_Inside_LeafFunc = true; \ + \ + char buf[9999]; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, 9998, fmt, ap); \ + buf[9998] = 0; \ + va_end(ap); \ + \ + ADD_STATE(State_Func##id(this, ParamState_m##id(@[$2,1,$1:p$2, @]std::string(buf)))); \ + \ + return MakeRet< ret_type >::Do(0); \ + } \ + \ + struct Delegate : public MyDelegate \ + { \ + int m_DelegNumber; \ + Delegate(int num) : m_DelegNumber(num) { } \ + \ + virtual ret_type Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \ + { \ + g_Inside_LeafFunc = true; \ + 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_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \ + } \ + else \ + RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \ + } \ + }; \ + }; \ + \ + 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() \ { \