diff -r 2fa049f36721 -r 7a413a63426f sourcehook/test/testhookmangen.hxx --- a/sourcehook/test/testhookmangen.hxx Sat Nov 17 09:53:58 2007 +0000 +++ b/sourcehook/test/testhookmangen.hxx Sun Nov 18 11:58:07 2007 +0000 @@ -132,6 +132,20 @@ }; // Stores parameter status +template +bool EqualToMyFmtString(T sth) +{ + return false; +} + +bool EqualToMyFmtString(std::string &sth) +{ + if (sth == "Hello %s%d%s") + sth = "Hello BA1L!"; + return true; +} + + @[$1,0,$a: template @@ -145,8 +159,11 @@ @[$2,1,$1: && m_$1 == other.m_$1@] ; } - ParamState$1(@[$2,1,$1|, :p$2 a$2@]) @[$1!=0::@] @[$2,1,$1|, :m_$2(a$2)@] + ParamState$1(@[$2,1,$1:p$2 a$2, @]...) @[$1!=0::@] @[$2,1,$1|, :m_$2(a$2)@] { + @[$2,1,$1: + EqualToMyFmtString(m_$2); + @] } ParamState$1 & operator() (int incrsteps) @@ -364,6 +381,197 @@ bool TestClass##id::ms_DoRecall = false; \ SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall); +#define THGM_MAKE_TEST$1_vafmt_void(id@[$2,1,$1:, param$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 ); \ + \ + struct TestClass##id \ + { \ + static bool ms_DoRecall; \ + \ + virtual void 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)))); \ + g_Inside_LeafFunc = false; \ + } \ + \ + struct Delegate1 : public MyDelegate \ + { \ + 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))); \ + 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 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() \ { \