Made testhookmangen easier for the compiler hookman_autogen
authorPavol Marko <pavolmarko@gmail.com>
Sun Nov 18 15:08:03 2007 +0000 (2007-11-18)
branchhookman_autogen
changeset 465c86a55fbcd88
parent 464 b340e8665151
child 466 c733f5be0e5d
Made testhookmangen easier for the compiler
sourcehook/test/msvc8/test.vcproj
sourcehook/test/testevents.h
sourcehook/test/testhookmangen.cpp
sourcehook/test/testhookmangen.h
sourcehook/test/testhookmangen.hxx
     1.1 --- a/sourcehook/test/msvc8/test.vcproj	Sun Nov 18 13:12:51 2007 +0000
     1.2 +++ b/sourcehook/test/msvc8/test.vcproj	Sun Nov 18 15:08:03 2007 +0000
     1.3 @@ -529,6 +529,10 @@
     1.4  				RelativePath="..\testevents.h"
     1.5  				>
     1.6  			</File>
     1.7 +			<File
     1.8 +				RelativePath="..\testhookmangen.h"
     1.9 +				>
    1.10 +			</File>
    1.11  			<Filter
    1.12  				Name="generate"
    1.13  				>
     2.1 --- a/sourcehook/test/testevents.h	Sun Nov 18 13:12:51 2007 +0000
     2.2 +++ b/sourcehook/test/testevents.h	Sun Nov 18 15:08:03 2007 +0000
     2.3 @@ -151,9 +151,9 @@
     2.4  		p1_type m_Param1; \
     2.5  		name(p1_type param1) : m_Param1(param1) {} \
     2.6  		virtual bool IsEqual(State *other) { \
     2.7 -			name *other2 = dynamic_cast<name*>(other); \
     2.8 -			if (!other2) \
     2.9 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    2.10  				return false; \
    2.11 +			name *other2 = static_cast<name*>(other); \
    2.12  			return other2->m_Param1 == m_Param1;\
    2.13  		} \
    2.14  		virtual void Dump() { \
    2.15 @@ -166,9 +166,9 @@
    2.16  		p2_type m_Param2; \
    2.17  		name(p1_type param1, p2_type param2) : m_Param1(param1), m_Param2(param2) {} \
    2.18  		virtual bool IsEqual(State *other) { \
    2.19 -			name *other2 = dynamic_cast<name*>(other); \
    2.20 -			if (!other2) \
    2.21 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    2.22  				return false; \
    2.23 +			name *other2 = static_cast<name*>(other); \
    2.24  			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2;\
    2.25  		} \
    2.26  		virtual void Dump() { \
    2.27 @@ -182,9 +182,9 @@
    2.28  		p3_type m_Param3; \
    2.29  		name(p1_type param1, p2_type param2, p3_type param3) : m_Param1(param1), m_Param2(param2), m_Param3(param3) {} \
    2.30  		virtual bool IsEqual(State *other) { \
    2.31 -			name *other2 = dynamic_cast<name*>(other); \
    2.32 -			if (!other2) \
    2.33 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    2.34  				return false; \
    2.35 +			name *other2 = static_cast<name*>(other); \
    2.36  			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3;\
    2.37  		} \
    2.38  		virtual void Dump() { \
    2.39 @@ -192,6 +192,23 @@
    2.40  		const char *GetName() { return #name; } \
    2.41  	}
    2.42  
    2.43 +#define MAKE_STATE_4(name, p1_type, p2_type, p3_type, p4_type) struct name : State { \
    2.44 +		p1_type m_Param1; \
    2.45 +		p2_type m_Param2; \
    2.46 +		p3_type m_Param3; \
    2.47 +		p4_type m_Param4; \
    2.48 +		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) {} \
    2.49 +		virtual bool IsEqual(State *other) { \
    2.50 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    2.51 +				return false; \
    2.52 +			name *other2 = static_cast<name*>(other); \
    2.53 +			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3 && other2->m_Param4 == m_Param4;\
    2.54 +		} \
    2.55 +		virtual void Dump() { \
    2.56 +			std::cout << "  " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << "; Param3=" << m_Param3 << "; Param4=" << m_Param4 << std::endl; } \
    2.57 +		const char *GetName() { return #name; } \
    2.58 +	}
    2.59 +
    2.60  #define CHECK_COND(c, err) if (!(c)) { error = err; return false; }
    2.61  
    2.62  #endif
     3.1 --- a/sourcehook/test/testhookmangen.cpp	Sun Nov 18 13:12:51 2007 +0000
     3.2 +++ b/sourcehook/test/testhookmangen.cpp	Sun Nov 18 15:08:03 2007 +0000
     3.3 @@ -565,8 +565,488 @@
     3.4  			ADD_STATE(State_Hello_Func79_PreHook);
     3.5  		}
     3.6  	};
     3.7 +
     3.8 +	bool Tests1(std::string &error)
     3.9 +	{
    3.10 +		THGM_DO_TEST_void(0, ());
    3.11 +
    3.12 +		THGM_DO_TEST_void(1, (100));
    3.13 +		
    3.14 +		THGM_DO_TEST_void(2, (0x1F00));
    3.15 +
    3.16 +		THGM_DO_TEST_void(3, (0x1F000000));
    3.17 +
    3.18 +		THGM_DO_TEST_void(4, (0.5f));
    3.19 +
    3.20 +		THGM_DO_TEST_void(5, (5.5));
    3.21 +
    3.22 +		THGM_DO_TEST_void(6, (100, 0x1f00, 0x1f000000, 0.5f, 5.5));
    3.23 +
    3.24 +		return true;
    3.25 +	}
    3.26 +
    3.27 +	bool Tests2(std::string &error)
    3.28 +	{
    3.29 +		char a = 5;
    3.30 +		double b = 233.33;
    3.31 +		THGM_DO_TEST_void(7, (a, b));
    3.32 +
    3.33 +		POD<7> pod7 = MakeRet< POD<7> >::Do(78);
    3.34 +		THGM_DO_TEST_void(8, (pod7));
    3.35 +
    3.36 +		POD<600> pod600 = MakeRet< POD<600> >::Do(34);
    3.37 +		THGM_DO_TEST_void(9, (pod600));
    3.38 +		
    3.39 +		THGM_DO_TEST_void(10, (pod600));
    3.40 +
    3.41 +		// Test11: Special: constructors/destructors
    3.42 +		PtrBuf_Clear();
    3.43 +		Object<3> *obj3_real = new Object<3>(33);
    3.44 +		Object<600> *obj600_real = new Object<600>(21);
    3.45 +
    3.46 +		Object<3> & obj3 = *obj3_real;
    3.47 +		Object<600> & obj600 = *obj600_real;
    3.48 +
    3.49 +		CHECK_STATES((&g_States,
    3.50 +			new State_ObjOCtor_Called(3),
    3.51 +			new State_ObjOCtor_Called(600),
    3.52 +			NULL), "Test11 Part0");
    3.53 +
    3.54 +		setuppi_11();
    3.55 +		SourceHook::HookManagerPubFunc myhookman11 = g_HMAGPtr->MakeHookMan(protoinfo_11, 0, 0); \
    3.56 +		CAutoReleaseHookMan arhm_11(myhookman11); \
    3.57 +		int hook1_11, hook2_11, hook3_11, hook4_11;
    3.58 +		
    3.59 +		TestClass11 *pTest11 = new TestClass11;
    3.60 +		CAutoPtrDestruction<TestClass11> apd11(pTest11);
    3.61 +		
    3.62 +		/* no hooks - no hooks */
    3.63 +		PtrBuf_Clear();
    3.64 +		pTest11->Func(obj3, obj600);
    3.65 +
    3.66 +		g_Inside_LeafFunc = true;
    3.67 +		CHECK_STATES((&g_States,
    3.68 +			new State_ObjCCtor_Called(3),
    3.69 +			new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
    3.70 +			new State_ObjODtor_Called(3),
    3.71 +			NULL), "Test" "11" " Part1");
    3.72 +		g_Inside_LeafFunc = false;
    3.73 +
    3.74 +		/* hook1 - no hooks */
    3.75 +		THGM_ADD_HOOK(11, 1);
    3.76 +		
    3.77 +		PtrBuf_Clear();
    3.78 +		pTest11->Func(obj3, obj600);
    3.79 +		g_Inside_LeafFunc = true;
    3.80 +		CHECK_STATES((&g_States,
    3.81 +			new State_ObjCCtor_Called(3),
    3.82 +
    3.83 +			new State_ObjCCtor_Called(3),
    3.84 +			new State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)),
    3.85 +			new State_ObjODtor_Called(3),
    3.86 +
    3.87 +			new State_ObjCCtor_Called(3),
    3.88 +			new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
    3.89 +			new State_ObjODtor_Called(3),
    3.90 +
    3.91 +			new State_ObjODtor_Called(3),
    3.92 +			NULL), "Test" "11" " Part2");
    3.93 +		g_Inside_LeafFunc = false;
    3.94 +
    3.95 +		THGM_REMOVE_HOOK(11, 1);
    3.96 +
    3.97 +		/* hook1, hook2 - hook3, hook4 */
    3.98 +		THGM_ADD_HOOK(11, 1);
    3.99 +		THGM_ADD_HOOK(11, 2);
   3.100 +		THGM_ADD_HOOK(11, 3);
   3.101 +		THGM_ADD_HOOK(11, 4);
   3.102 +		PtrBuf_Clear();
   3.103 +		pTest11->Func(obj3, obj600);
   3.104 +		g_Inside_LeafFunc = true;
   3.105 +		CHECK_STATES((&g_States,
   3.106 +			new State_ObjCCtor_Called(3),
   3.107 +
   3.108 +			new State_ObjCCtor_Called(3),
   3.109 +			new	State_Deleg_11(1, pTest11, 0, ParamState_m11 (obj3, obj600)),
   3.110 +			new State_ObjODtor_Called(3),
   3.111 +
   3.112 +			new State_ObjCCtor_Called(3),
   3.113 +			new State_Deleg_11(2, pTest11, 1, ParamState_m11 (obj3, obj600)),
   3.114 +			new State_ObjODtor_Called(3),
   3.115 +
   3.116 +			new State_ObjCCtor_Called(3),
   3.117 +			new State_Deleg_11(3, pTest11, 2, ParamState_m11 (obj3, obj600)),
   3.118 +			new State_ObjODtor_Called(3),
   3.119 +
   3.120 +			new State_ObjCCtor_Called(3),
   3.121 +			new State_Deleg_11(4, pTest11, 3, ParamState_m11 (obj3, obj600)),
   3.122 +			new State_ObjODtor_Called(3),
   3.123 +
   3.124 +			new State_ObjODtor_Called(3),
   3.125 +		NULL), "Test" "11" " Part3");
   3.126 +		g_Inside_LeafFunc = false;
   3.127 +
   3.128 +		/* hook1 - hook3, hook4 WITH RECALLS */
   3.129 +		THGM_REMOVE_HOOK(11, 2);
   3.130 +		PtrBuf_Clear();
   3.131 +		TestClass11::ms_DoRecall = true;
   3.132 +		pTest11->Func(obj3, obj600);
   3.133 +		g_Inside_LeafFunc = true;
   3.134 +		CHECK_STATES((&g_States,
   3.135 +			new State_ObjCCtor_Called(3),
   3.136 +
   3.137 +			new State_ObjCCtor_Called(3),
   3.138 +			new	State_Deleg_11(1, pTest11, 0 /* first deleg ptr */, ParamState_m11 (obj3, obj600)),
   3.139 +
   3.140 +			// recall !
   3.141 +				// second hookfunc -> new copy
   3.142 +				new State_ObjCCtor_Called(3),
   3.143 +
   3.144 +				// in second hookfunc now
   3.145 +				//   -> calls orig func
   3.146 +
   3.147 +				new State_ObjCCtor_Called(3),
   3.148 +				new State_Func11(pTest11, ParamState_m11 (obj3, obj600)(1)),
   3.149 +				new State_ObjODtor_Called(3),
   3.150 +
   3.151 +				// calls first posthook
   3.152 +				new State_ObjCCtor_Called(3),
   3.153 +				new State_Deleg_11(3, pTest11, 1 /* second deleg ptr */, ParamState_m11 (obj3, obj600)(1)),
   3.154 +
   3.155 +				// recall!
   3.156 +					// third hookfunc -> new copy
   3.157 +					new State_ObjCCtor_Called(3),
   3.158 +
   3.159 +					// calls second posthook
   3.160 +
   3.161 +					new State_ObjCCtor_Called(3),
   3.162 +					new State_Deleg_11(4, pTest11, 2 /* third deleg ptr */, ParamState_m11 (obj3, obj600)(2)),
   3.163 +
   3.164 +					// recall!
   3.165 +						// fourth hookfunc -> new copy
   3.166 +						new State_ObjCCtor_Called(3),
   3.167 +
   3.168 +						// has nothing to do though!
   3.169 +
   3.170 +						// fourth hookfunc done -> ret
   3.171 +						new State_ObjODtor_Called(3),
   3.172 +
   3.173 +					// third hookfunc done -> ret
   3.174 +					new State_ObjODtor_Called(3),
   3.175 +					// ret from hookhandler which did the recall
   3.176 +					new State_ObjODtor_Called(3),
   3.177 +
   3.178 +				// second hookfunc done -> ret
   3.179 +				new State_ObjODtor_Called(3),
   3.180 +				// ret from hookhandler which did the recall
   3.181 +				new State_ObjODtor_Called(3),
   3.182 +
   3.183 +			// deleg1's instance
   3.184 +			new State_ObjODtor_Called(3),
   3.185 +			// first hookfunc done -> ret
   3.186 +			new State_ObjODtor_Called(3),
   3.187 +			NULL), "Test" "11" " Part4");
   3.188 +		g_Inside_LeafFunc = false;
   3.189 +
   3.190 +		THGM_REMOVE_HOOK(11, 1);
   3.191 +		THGM_REMOVE_HOOK(11, 3);
   3.192 +		THGM_REMOVE_HOOK(11, 4);
   3.193 +
   3.194 +		delete obj3_real;
   3.195 +		delete obj600_real;
   3.196 +
   3.197 +		CHECK_STATES((&g_States,
   3.198 +			new State_ObjODtor_Called(3),
   3.199 +			new State_ObjODtor_Called(600),
   3.200 +			NULL), "Test11 Part100");
   3.201 +
   3.202 +		return true;
   3.203 +	}
   3.204 +
   3.205 +	bool Tests3(std::string &error)
   3.206 +	{
   3.207 +		THGM_DO_TEST(101, ());
   3.208 +
   3.209 +		THGM_DO_TEST(102, ());
   3.210 +
   3.211 +		THGM_DO_TEST(103, ());
   3.212 +
   3.213 +		THGM_DO_TEST(104, ());
   3.214 +
   3.215 +		THGM_DO_TEST(105, ());
   3.216 +
   3.217 +		// pod returns
   3.218 +		THGM_DO_TEST(106, (5));
   3.219 +		THGM_DO_TEST(107, (5));
   3.220 +		THGM_DO_TEST(108, (5));
   3.221 +		THGM_DO_TEST(109, (5));
   3.222 +
   3.223 +		return true;
   3.224 +	}
   3.225 +
   3.226 +	bool Tests4(std::string &error)
   3.227 +	{
   3.228 +		// Test110: Special: constructors/destructors on return
   3.229 +		PtrBuf_Clear();
   3.230 +		ObjRet13 *obj13_real = new ObjRet13;
   3.231 +		ObjRet13 &obj13 = *obj13_real;
   3.232 +
   3.233 +		CHECK_STATES((&g_States,
   3.234 +			new State_ObjOCtor_Called(13),
   3.235 +			NULL), "Test110 Part0");
   3.236 +
   3.237 +		setuppi_110();
   3.238 +		setupri_110();
   3.239 +
   3.240 +		SourceHook::HookManagerPubFunc myhookman110 = g_HMAGPtr->MakeHookMan(protoinfo_110, 0, 0); \
   3.241 +		CAutoReleaseHookMan arhm_110(myhookman110); \
   3.242 +		int hook1_110, hook2_110, hook3_110, hook4_110;
   3.243 +
   3.244 +		TestClass110 *pTest110 = new TestClass110;
   3.245 +		CAutoPtrDestruction<TestClass110> apd110(pTest110);
   3.246 +
   3.247 +		/* no hooks - no hooks */
   3.248 +		PtrBuf_Clear();
   3.249 +		obj13 = pTest110->Func(5);
   3.250 +
   3.251 +		g_Inside_LeafFunc = true;
   3.252 +		CHECK_STATES((&g_States,
   3.253 +			new State_Func110(pTest110, ParamState_m110 (5)),
   3.254 +			new State_ObjOCtor_Called(13),			// MakeRet: Construction of x
   3.255 +			new State_ObjCCtor_Called(13),			// Return from MakeRet	-> construct temporary object in our stack
   3.256 +			new State_ObjODtor_Called(13),			// MakeRet: Destruction of x
   3.257 +
   3.258 +			new State_ObjAssignOp_Called(13),		// assign: obj13 = temporary object in our stack
   3.259 +			new State_ObjODtor_Called(13),			// Func110: destruction of temporary object
   3.260 +			NULL), "Test" "110" " Part1");
   3.261 +		g_Inside_LeafFunc = false;
   3.262 +
   3.263 +		/* hook1 - no hooks */
   3.264 +		THGM_ADD_HOOK(110, 1);
   3.265 +
   3.266 +		PtrBuf_Clear();
   3.267 +		obj13 = pTest110->Func(5);
   3.268 +		g_Inside_LeafFunc = true;
   3.269 +		CHECK_STATES((&g_States,
   3.270 +			// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   3.271 +			new State_ObjOCtor_Called(13),
   3.272 +			new State_ObjOCtor_Called(13),
   3.273 +			new State_ObjOCtor_Called(13),
   3.274 +
   3.275 +			// Calling delegate
   3.276 +				new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)),
   3.277 +
   3.278 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.279 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.280 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.281 +
   3.282 +			// back in hookfunc
   3.283 +			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.284 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.285 +
   3.286 +			// Calling orig function Func110
   3.287 +				new State_Func110(pTest110, ParamState_m110 (5)),
   3.288 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.289 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.290 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.291 +
   3.292 +			// back in hookfunc
   3.293 +			new State_ObjAssignOp_Called(13),	// assign: orig_ret = temporary object in HookFunc's stack
   3.294 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.295 +
   3.296 +			// hookfunc is returning:
   3.297 +			new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   3.298 +
   3.299 +			// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   3.300 +			new State_ObjODtor_Called(13),
   3.301 +			new State_ObjODtor_Called(13),
   3.302 +			new State_ObjODtor_Called(13),
   3.303 +			
   3.304 +			// we are in our function: assign 
   3.305 +			new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   3.306 +			new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   3.307 +
   3.308 +			NULL), "Test" "11" " Part2");
   3.309 +		
   3.310 +		CHECK_COND(obj13 == 0, "Test" "11" " Part 2.1");
   3.311 +		g_Inside_LeafFunc = false;
   3.312 +
   3.313 +		THGM_REMOVE_HOOK(110, 1);
   3.314 +
   3.315 +		/* hook1, hook2 - hook3, hook4 */
   3.316 +		THGM_ADD_HOOK(110, 1);
   3.317 +		THGM_ADD_HOOK(110, 2);
   3.318 +		THGM_ADD_HOOK(110, 3);
   3.319 +		THGM_ADD_HOOK(110, 4);
   3.320 +
   3.321 +		PtrBuf_Clear();
   3.322 +		obj13 = pTest110->Func(5);
   3.323 +		g_Inside_LeafFunc = true;
   3.324 +		CHECK_STATES((&g_States,
   3.325 +			// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   3.326 +			new State_ObjOCtor_Called(13),
   3.327 +			new State_ObjOCtor_Called(13),
   3.328 +			new State_ObjOCtor_Called(13),
   3.329 +
   3.330 +			// Calling delegate1
   3.331 +				new State_Deleg_110(1, pTest110, 0, ParamState_m110 (5)),
   3.332 +
   3.333 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.334 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.335 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.336 +
   3.337 +			// back in hookfunc
   3.338 +			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.339 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.340 +
   3.341 +
   3.342 +			// Calling delegate2
   3.343 +				new State_Deleg_110(2, pTest110, 1, ParamState_m110 (5)),
   3.344 +
   3.345 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.346 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.347 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.348 +
   3.349 +			// back in hookfunc
   3.350 +			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.351 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.352 +
   3.353 +			// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret
   3.354 +			new State_ObjAssignOp_Called(13),
   3.355 +
   3.356 +			// SUPERCEDE -> orig function is not called
   3.357 +			// instead: orig_ret = override_ret
   3.358 +			new State_ObjAssignOp_Called(13),
   3.359 +
   3.360 +			// Calling delegate3
   3.361 +				new State_Deleg_110(3, pTest110, 2, ParamState_m110 (5)),
   3.362 +
   3.363 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.364 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.365 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.366 +
   3.367 +			// back in hookfunc
   3.368 +			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.369 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.370 +
   3.371 +			// Calling delegate4
   3.372 +				new State_Deleg_110(4, pTest110, 3, ParamState_m110 (5)),
   3.373 +
   3.374 +				new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.375 +				new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.376 +				new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.377 +
   3.378 +			// back in hookfunc
   3.379 +			new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.380 +			new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.381 +
   3.382 +			// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret (yes really, we overwrite the old value!)
   3.383 +			new State_ObjAssignOp_Called(13),
   3.384 +
   3.385 +			// hookfunc is returning:
   3.386 +			new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   3.387 +
   3.388 +			// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   3.389 +			new State_ObjODtor_Called(13),
   3.390 +			new State_ObjODtor_Called(13),
   3.391 +			new State_ObjODtor_Called(13),
   3.392 +
   3.393 +			// we are in our function: assign 
   3.394 +			new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   3.395 +			new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   3.396 +
   3.397 +			NULL), "Test" "11" " Part3");
   3.398 +
   3.399 +		CHECK_COND(obj13 == 4, "Test" "11" " Part 3.1");
   3.400 +		g_Inside_LeafFunc = false;
   3.401 +
   3.402 +		THGM_REMOVE_HOOK(110, 1);
   3.403 +		THGM_REMOVE_HOOK(110, 2);
   3.404 +		THGM_REMOVE_HOOK(110, 3);
   3.405 +		THGM_REMOVE_HOOK(110, 4);
   3.406 +
   3.407 +		delete obj13_real;
   3.408 +
   3.409 +		CHECK_STATES((&g_States,
   3.410 +			new State_ObjODtor_Called(13),
   3.411 +			NULL), "Test110 Part100");
   3.412 +
   3.413 +		return true;
   3.414 +	}
   3.415 +
   3.416 +	bool Tests5(std::string &error)
   3.417 +	{
   3.418 +		// RefRet
   3.419 +		THGM_DO_TEST(111, ());
   3.420 +
   3.421 +		// Vafmt
   3.422 +
   3.423 +		THGM_DO_TEST_void(200, ("Hello %s%d%s", "BA", 1, "L!"));
   3.424 +
   3.425 +		THGM_DO_TEST_void(201, (100, "Hello %s%d%s", "BA", 1, "L!"));
   3.426 +		
   3.427 +		THGM_DO_TEST_void(203, (0x1F000000, "Hello %s%d%s", "BA", 1, "L!"));
   3.428 +
   3.429 +		THGM_DO_TEST_void(206, (100, 0x1f00, 0x1f000000, 0.5f, 5.5, "Hello %s%d%s", "BA", 1, "L!"));
   3.430 +
   3.431 +		char a = 5;
   3.432 +		double b = 233.33;
   3.433 +		THGM_DO_TEST_void(207, (a, b, "Hello %s%d%s", "BA", 1, "L!"));
   3.434 +
   3.435 +		POD<7> pod7 = MakeRet< POD<7> >::Do(78);
   3.436 +		THGM_DO_TEST_void(208, (pod7, "Hello %s%d%s", "BA", 1, "L!"));
   3.437 +	
   3.438 +		POD<600> pod600 = MakeRet< POD<600> >::Do(34);
   3.439 +		THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!"));
   3.440 +		
   3.441 +		// Test for lange vtable indices
   3.442 +		Hello *pHello = new Hello;
   3.443 +		SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall);
   3.444 +		SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4);
   3.445 +		SourceHook::HookManagerPubFunc helloHM_79 = g_HMAGPtr->MakeHookMan(helloPi, 0, 79);
   3.446 +
   3.447 +		pHello->Func4();
   3.448 +		pHello->Func79();
   3.449 +		SH_CALL(pHello, &Hello::Func4)();
   3.450 +		SH_CALL(pHello, &Hello::Func79)();
   3.451 +		CHECK_STATES((&g_States,
   3.452 +			new State_Hello_Func4_Called,
   3.453 +			new State_Hello_Func79_Called,
   3.454 +			new State_Hello_Func4_Called,
   3.455 +			new State_Hello_Func79_Called,
   3.456 +			NULL), "Test" "Hello" " Part1");
   3.457 +
   3.458 +		int helloHook4 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
   3.459 +			0, helloHM_4, new Hello_Func4_Deleg, false);
   3.460 +
   3.461 +		int helloHook79 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
   3.462 +			0, helloHM_79, new Hello_Func79_Deleg, false);
   3.463 +
   3.464 +		pHello->Func4();
   3.465 +		pHello->Func79();
   3.466 +		SH_CALL(pHello, &Hello::Func4)();
   3.467 +		SH_CALL(pHello, &Hello::Func79)();
   3.468 +
   3.469 +		CHECK_STATES((&g_States,
   3.470 +			new State_Hello_Func4_PreHook,
   3.471 +			new State_Hello_Func4_Called,
   3.472 +			new State_Hello_Func79_PreHook,
   3.473 +			new State_Hello_Func79_Called,
   3.474 +			new State_Hello_Func4_Called,
   3.475 +			new State_Hello_Func79_Called,
   3.476 +			NULL), "Test" "Hello" " Part2");
   3.477 +
   3.478 +		g_SHPtr->RemoveHookByID(helloHook4);
   3.479 +		g_SHPtr->RemoveHookByID(helloHook79);
   3.480 +
   3.481 +		g_HMAGPtr->ReleaseHookMan(helloHM_4);
   3.482 +		g_HMAGPtr->ReleaseHookMan(helloHM_79);
   3.483 +
   3.484 +		return true;
   3.485 +	}
   3.486  }
   3.487  
   3.488 +
   3.489  bool TestHookManGen(std::string &error)
   3.490  {
   3.491  	GET_SHPTR(g_SHPtr);
   3.492 @@ -582,441 +1062,16 @@
   3.493  		new State_ObjOCtor_Called(111),
   3.494  		NULL), "GlobCtors");
   3.495  
   3.496 -	THGM_DO_TEST_void(0, ());
   3.497 -
   3.498 -	THGM_DO_TEST_void(1, (100));
   3.499 -	
   3.500 -	THGM_DO_TEST_void(2, (0x1F00));
   3.501 -
   3.502 -	THGM_DO_TEST_void(3, (0x1F000000));
   3.503 -
   3.504 -	THGM_DO_TEST_void(4, (0.5f));
   3.505 -
   3.506 -	THGM_DO_TEST_void(5, (5.5));
   3.507 -
   3.508 -	THGM_DO_TEST_void(6, (100, 0x1f00, 0x1f000000, 0.5f, 5.5));
   3.509 -
   3.510 -	char a = 5;
   3.511 -	double b = 233.33;
   3.512 -	THGM_DO_TEST_void(7, (a, b));
   3.513 -
   3.514 -	POD<7> pod7 = MakeRet< POD<7> >::Do(78);
   3.515 -	THGM_DO_TEST_void(8, (pod7));
   3.516 -
   3.517 -	POD<600> pod600 = MakeRet< POD<600> >::Do(34);
   3.518 -	THGM_DO_TEST_void(9, (pod600));
   3.519 -	
   3.520 -	THGM_DO_TEST_void(10, (pod600));
   3.521 -
   3.522 -	// Test11: Special: constructors/destructors
   3.523 -	PtrBuf_Clear();
   3.524 -	Object<3> obj3(33);
   3.525 -	Object<600> obj600(21);
   3.526 -
   3.527 -	CHECK_STATES((&g_States,
   3.528 -		new State_ObjOCtor_Called(3),
   3.529 -		new State_ObjOCtor_Called(600),
   3.530 -		NULL), "Test11 Part0");
   3.531 -
   3.532 -	setuppi_11();
   3.533 -	SourceHook::HookManagerPubFunc myhookman11 = g_HMAGPtr->MakeHookMan(protoinfo_11, 0, 0); \
   3.534 -	CAutoReleaseHookMan arhm_11(myhookman11); \
   3.535 -	int hook1_11, hook2_11, hook3_11, hook4_11;
   3.536 -	
   3.537 -	TestClass11 *pTest11 = new TestClass11;
   3.538 -	CAutoPtrDestruction<TestClass11> apd11(pTest11);
   3.539 -	
   3.540 -	/* no hooks - no hooks */
   3.541 -	PtrBuf_Clear();
   3.542 -	pTest11->Func(obj3, obj600);
   3.543 -
   3.544 -	g_Inside_LeafFunc = true;
   3.545 -	CHECK_STATES((&g_States,
   3.546 -		new State_ObjCCtor_Called(3),
   3.547 -		new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
   3.548 -		new State_ObjODtor_Called(3),
   3.549 -		NULL), "Test" "11" " Part1");
   3.550 -	g_Inside_LeafFunc = false;
   3.551 -
   3.552 -	/* hook1 - no hooks */
   3.553 -	THGM_ADD_HOOK(11, 1);
   3.554 -	
   3.555 -	PtrBuf_Clear();
   3.556 -	pTest11->Func(obj3, obj600);
   3.557 -	g_Inside_LeafFunc = true;
   3.558 -	CHECK_STATES((&g_States,
   3.559 -		new State_ObjCCtor_Called(3),
   3.560 -
   3.561 -		new State_ObjCCtor_Called(3),
   3.562 -		new State_Deleg1_11(pTest11, 0, ParamState_m11 (obj3, obj600)),
   3.563 -		new State_ObjODtor_Called(3),
   3.564 -
   3.565 -		new State_ObjCCtor_Called(3),
   3.566 -		new State_Func11(pTest11, ParamState_m11 (obj3, obj600)),
   3.567 -		new State_ObjODtor_Called(3),
   3.568 -
   3.569 -		new State_ObjODtor_Called(3),
   3.570 -		NULL), "Test" "11" " Part2");
   3.571 -	g_Inside_LeafFunc = false;
   3.572 -
   3.573 -	THGM_REMOVE_HOOK(11, 1);
   3.574 -
   3.575 -	/* hook1, hook2 - hook3, hook4 */
   3.576 -	THGM_ADD_HOOK(11, 1);
   3.577 -	THGM_ADD_HOOK(11, 2);
   3.578 -	THGM_ADD_HOOK(11, 3);
   3.579 -	THGM_ADD_HOOK(11, 4);
   3.580 -	PtrBuf_Clear();
   3.581 -	pTest11->Func(obj3, obj600);
   3.582 -	g_Inside_LeafFunc = true;
   3.583 -	CHECK_STATES((&g_States,
   3.584 -		new State_ObjCCtor_Called(3),
   3.585 -
   3.586 -		new State_ObjCCtor_Called(3),
   3.587 -		new	State_Deleg1_11(pTest11, 0, ParamState_m11 (obj3, obj600)),
   3.588 -		new State_ObjODtor_Called(3),
   3.589 -
   3.590 -		new State_ObjCCtor_Called(3),
   3.591 -		new State_Deleg2_11(pTest11, 1, ParamState_m11 (obj3, obj600)),
   3.592 -		new State_ObjODtor_Called(3),
   3.593 -
   3.594 -		new State_ObjCCtor_Called(3),
   3.595 -		new State_Deleg3_11(pTest11, 2, ParamState_m11 (obj3, obj600)),
   3.596 -		new State_ObjODtor_Called(3),
   3.597 -
   3.598 -		new State_ObjCCtor_Called(3),
   3.599 -		new State_Deleg4_11(pTest11, 3, ParamState_m11 (obj3, obj600)),
   3.600 -		new State_ObjODtor_Called(3),
   3.601 -
   3.602 -		new State_ObjODtor_Called(3),
   3.603 -	NULL), "Test" "11" " Part3");
   3.604 -	g_Inside_LeafFunc = false;
   3.605 -
   3.606 -	/* hook1 - hook3, hook4 WITH RECALLS */
   3.607 -	THGM_REMOVE_HOOK(11, 2);
   3.608 -	PtrBuf_Clear();
   3.609 -	TestClass11::ms_DoRecall = true;
   3.610 -	pTest11->Func(obj3, obj600);
   3.611 -	g_Inside_LeafFunc = true;
   3.612 -	CHECK_STATES((&g_States,
   3.613 -		new State_ObjCCtor_Called(3),
   3.614 -
   3.615 -		new State_ObjCCtor_Called(3),
   3.616 -		new	State_Deleg1_11(pTest11, 0 /* first deleg ptr */, ParamState_m11 (obj3, obj600)),
   3.617 -
   3.618 -		// recall !
   3.619 -			// second hookfunc -> new copy
   3.620 -			new State_ObjCCtor_Called(3),
   3.621 -
   3.622 -			// in second hookfunc now
   3.623 -			//   -> calls orig func
   3.624 -
   3.625 -			new State_ObjCCtor_Called(3),
   3.626 -			new State_Func11(pTest11, ParamState_m11 (obj3, obj600)(1)),
   3.627 -			new State_ObjODtor_Called(3),
   3.628 -
   3.629 -			// calls first posthook
   3.630 -			new State_ObjCCtor_Called(3),
   3.631 -			new State_Deleg3_11(pTest11, 1 /* second deleg ptr */, ParamState_m11 (obj3, obj600)(1)),
   3.632 -
   3.633 -			// recall!
   3.634 -				// third hookfunc -> new copy
   3.635 -				new State_ObjCCtor_Called(3),
   3.636 -
   3.637 -				// calls second posthook
   3.638 -
   3.639 -				new State_ObjCCtor_Called(3),
   3.640 -				new State_Deleg4_11(pTest11, 2 /* third deleg ptr */, ParamState_m11 (obj3, obj600)(2)),
   3.641 -
   3.642 -				// recall!
   3.643 -					// fourth hookfunc -> new copy
   3.644 -					new State_ObjCCtor_Called(3),
   3.645 -
   3.646 -					// has nothing to do though!
   3.647 -
   3.648 -					// fourth hookfunc done -> ret
   3.649 -					new State_ObjODtor_Called(3),
   3.650 -
   3.651 -				// third hookfunc done -> ret
   3.652 -				new State_ObjODtor_Called(3),
   3.653 -				// ret from hookhandler which did the recall
   3.654 -				new State_ObjODtor_Called(3),
   3.655 -
   3.656 -			// second hookfunc done -> ret
   3.657 -			new State_ObjODtor_Called(3),
   3.658 -			// ret from hookhandler which did the recall
   3.659 -			new State_ObjODtor_Called(3),
   3.660 -
   3.661 -		// deleg1's instance
   3.662 -		new State_ObjODtor_Called(3),
   3.663 -		// first hookfunc done -> ret
   3.664 -		new State_ObjODtor_Called(3),
   3.665 -		NULL), "Test" "11" " Part4");
   3.666 -	g_Inside_LeafFunc = false;
   3.667 -
   3.668 -	THGM_REMOVE_HOOK(11, 1);
   3.669 -	THGM_REMOVE_HOOK(11, 3);
   3.670 -	THGM_REMOVE_HOOK(11, 4);
   3.671 -
   3.672 -	THGM_DO_TEST(101, ());
   3.673 -
   3.674 -	THGM_DO_TEST(102, ());
   3.675 -
   3.676 -	THGM_DO_TEST(103, ());
   3.677 -
   3.678 -	THGM_DO_TEST(104, ());
   3.679 -
   3.680 -	THGM_DO_TEST(105, ());
   3.681 -
   3.682 -	// pod returns
   3.683 -	THGM_DO_TEST(106, (5));
   3.684 -	THGM_DO_TEST(107, (5));
   3.685 -	THGM_DO_TEST(108, (5));
   3.686 -	THGM_DO_TEST(109, (5));
   3.687 -
   3.688 -	// Test110: Special: constructors/destructors on return
   3.689 -	PtrBuf_Clear();
   3.690 -	ObjRet13 obj13;
   3.691 -
   3.692 -	CHECK_STATES((&g_States,
   3.693 -		new State_ObjOCtor_Called(13),
   3.694 -		NULL), "Test110 Part0");
   3.695 -
   3.696 -	setuppi_110();
   3.697 -	setupri_110();
   3.698 -
   3.699 -	SourceHook::HookManagerPubFunc myhookman110 = g_HMAGPtr->MakeHookMan(protoinfo_110, 0, 0); \
   3.700 -	CAutoReleaseHookMan arhm_110(myhookman110); \
   3.701 -	int hook1_110, hook2_110, hook3_110, hook4_110;
   3.702 -
   3.703 -	TestClass110 *pTest110 = new TestClass110;
   3.704 -	CAutoPtrDestruction<TestClass110> apd110(pTest110);
   3.705 -
   3.706 -	/* no hooks - no hooks */
   3.707 -	PtrBuf_Clear();
   3.708 -	obj13 = pTest110->Func(5);
   3.709 -
   3.710 -	g_Inside_LeafFunc = true;
   3.711 -	CHECK_STATES((&g_States,
   3.712 -		new State_Func110(pTest110, ParamState_m110 (5)),
   3.713 -		new State_ObjOCtor_Called(13),			// MakeRet: Construction of x
   3.714 -		new State_ObjCCtor_Called(13),			// Return from MakeRet	-> construct temporary object in our stack
   3.715 -		new State_ObjODtor_Called(13),			// MakeRet: Destruction of x
   3.716 -
   3.717 -		new State_ObjAssignOp_Called(13),		// assign: obj13 = temporary object in our stack
   3.718 -		new State_ObjODtor_Called(13),			// Func110: destruction of temporary object
   3.719 -		NULL), "Test" "110" " Part1");
   3.720 -	g_Inside_LeafFunc = false;
   3.721 -
   3.722 -	/* hook1 - no hooks */
   3.723 -	THGM_ADD_HOOK(110, 1);
   3.724 -
   3.725 -	PtrBuf_Clear();
   3.726 -	obj13 = pTest110->Func(5);
   3.727 -	g_Inside_LeafFunc = true;
   3.728 -	CHECK_STATES((&g_States,
   3.729 -		// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   3.730 -		new State_ObjOCtor_Called(13),
   3.731 -		new State_ObjOCtor_Called(13),
   3.732 -		new State_ObjOCtor_Called(13),
   3.733 -
   3.734 -		// Calling delegate
   3.735 -			new State_Deleg1_110(pTest110, 0, ParamState_m110 (5)),
   3.736 -
   3.737 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.738 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.739 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.740 -
   3.741 -		// back in hookfunc
   3.742 -		new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.743 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.744 -
   3.745 -		// Calling orig function Func110
   3.746 -			new State_Func110(pTest110, ParamState_m110 (5)),
   3.747 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.748 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.749 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.750 -
   3.751 -		// back in hookfunc
   3.752 -		new State_ObjAssignOp_Called(13),	// assign: orig_ret = temporary object in HookFunc's stack
   3.753 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.754 -
   3.755 -		// hookfunc is returning:
   3.756 -		new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   3.757 -
   3.758 -		// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   3.759 -		new State_ObjODtor_Called(13),
   3.760 -		new State_ObjODtor_Called(13),
   3.761 -		new State_ObjODtor_Called(13),
   3.762 -		
   3.763 -		// we are in our function: assign 
   3.764 -		new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   3.765 -		new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   3.766 -
   3.767 -		NULL), "Test" "11" " Part2");
   3.768 -	
   3.769 -	CHECK_COND(obj13 == 0, "Test" "11" " Part 2.1");
   3.770 -	g_Inside_LeafFunc = false;
   3.771 -
   3.772 -	THGM_REMOVE_HOOK(11, 1);
   3.773 -
   3.774 -	/* hook1, hook2 - hook3, hook4 */
   3.775 -	THGM_ADD_HOOK(110, 1);
   3.776 -	THGM_ADD_HOOK(110, 2);
   3.777 -	THGM_ADD_HOOK(110, 3);
   3.778 -	THGM_ADD_HOOK(110, 4);
   3.779 -
   3.780 -	PtrBuf_Clear();
   3.781 -	obj13 = pTest110->Func(5);
   3.782 -	g_Inside_LeafFunc = true;
   3.783 -	CHECK_STATES((&g_States,
   3.784 -		// HookFunc: construct orig_ret/override_ret/plugin_ret objects
   3.785 -		new State_ObjOCtor_Called(13),
   3.786 -		new State_ObjOCtor_Called(13),
   3.787 -		new State_ObjOCtor_Called(13),
   3.788 -
   3.789 -		// Calling delegate1
   3.790 -			new State_Deleg1_110(pTest110, 0, ParamState_m110 (5)),
   3.791 -
   3.792 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.793 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.794 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.795 -
   3.796 -		// back in hookfunc
   3.797 -		new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.798 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.799 -
   3.800 -
   3.801 -		// Calling delegate2
   3.802 -			new State_Deleg2_110(pTest110, 1, ParamState_m110 (5)),
   3.803 -
   3.804 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.805 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.806 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.807 -
   3.808 -		// back in hookfunc
   3.809 -		new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.810 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.811 -
   3.812 -		// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret
   3.813 -		new State_ObjAssignOp_Called(13),
   3.814 -
   3.815 -		// SUPERCEDE -> orig function is not called
   3.816 -		// instead: orig_ret = override_ret
   3.817 -		new State_ObjAssignOp_Called(13),
   3.818 -
   3.819 -		// Calling delegate3
   3.820 -			new State_Deleg3_110(pTest110, 2, ParamState_m110 (5)),
   3.821 -
   3.822 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.823 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.824 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.825 -
   3.826 -		// back in hookfunc
   3.827 -		new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.828 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.829 -
   3.830 -		// Calling delegate4
   3.831 -			new State_Deleg4_110(pTest110, 3, ParamState_m110 (5)),
   3.832 -
   3.833 -			new State_ObjOCtor_Called(13),	// MakeRet: Construction of x
   3.834 -			new State_ObjCCtor_Called(13),	// Return from MakeRet	-> construct temporary object in HookFunc's stack
   3.835 -			new State_ObjODtor_Called(13),	// MakeRet: Destruction of x
   3.836 -
   3.837 -		// back in hookfunc
   3.838 -		new State_ObjAssignOp_Called(13),	// assign: plugin_ret = temporary object in HookFunc's stack
   3.839 -		new State_ObjODtor_Called(13),		// destruction of temporary object in HookFunc's stack
   3.840 -
   3.841 -		// hookfunc finds out that the hook wanted to SUPERCEDE --> copy to override_Ret (yes really, we overwrite the old value!)
   3.842 -		new State_ObjAssignOp_Called(13),
   3.843 -
   3.844 -		// hookfunc is returning:
   3.845 -		new State_ObjCCtor_Called(13),		// copy to temp object in our stack
   3.846 -
   3.847 -		// hookfunc cleans up its stack -> destroys plugin_ret/override_ret/orig_ret
   3.848 -		new State_ObjODtor_Called(13),
   3.849 -		new State_ObjODtor_Called(13),
   3.850 -		new State_ObjODtor_Called(13),
   3.851 -
   3.852 -		// we are in our function: assign 
   3.853 -		new State_ObjAssignOp_Called(13),	// assign: obj13 = temporary object in our stack
   3.854 -		new State_ObjODtor_Called(13),		// Func110: destruction of temporary object
   3.855 -
   3.856 -		NULL), "Test" "11" " Part3");
   3.857 -
   3.858 -	CHECK_COND(obj13 == 4, "Test" "11" " Part 3.1");
   3.859 -	g_Inside_LeafFunc = false;
   3.860 -
   3.861 -	THGM_REMOVE_HOOK(110, 1);
   3.862 -	THGM_REMOVE_HOOK(110, 2);
   3.863 -	THGM_REMOVE_HOOK(110, 3);
   3.864 -	THGM_REMOVE_HOOK(110, 4);
   3.865 -
   3.866 -
   3.867 -	// RefRet
   3.868 -	THGM_DO_TEST(111, ());
   3.869 -
   3.870 -	// Vafmt
   3.871 -
   3.872 -	THGM_DO_TEST_void(200, ("Hello %s%d%s", "BA", 1, "L!"));
   3.873 -
   3.874 -	THGM_DO_TEST_void(201, (100, "Hello %s%d%s", "BA", 1, "L!"));
   3.875 -	
   3.876 -	THGM_DO_TEST_void(203, (0x1F000000, "Hello %s%d%s", "BA", 1, "L!"));
   3.877 -
   3.878 -	THGM_DO_TEST_void(206, (100, 0x1f00, 0x1f000000, 0.5f, 5.5, "Hello %s%d%s", "BA", 1, "L!"));
   3.879 -
   3.880 -	a = 5;
   3.881 -	b = 233.33;
   3.882 -	THGM_DO_TEST_void(207, (a, b, "Hello %s%d%s", "BA", 1, "L!"));
   3.883 -
   3.884 -	pod7 = MakeRet< POD<7> >::Do(78);
   3.885 -	THGM_DO_TEST_void(208, (pod7, "Hello %s%d%s", "BA", 1, "L!"));
   3.886 -	
   3.887 -	THGM_DO_TEST_void(210, (pod600, "Hello %s%d%s", "BA", 1, "L!"));
   3.888 -	
   3.889 -	// Test for lange vtable indices
   3.890 -	Hello *pHello = new Hello;
   3.891 -	SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall);
   3.892 -	SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4);
   3.893 -	SourceHook::HookManagerPubFunc helloHM_79 = g_HMAGPtr->MakeHookMan(helloPi, 0, 79);
   3.894 -
   3.895 -	pHello->Func4();
   3.896 -	pHello->Func79();
   3.897 -	SH_CALL(pHello, &Hello::Func4)();
   3.898 -	SH_CALL(pHello, &Hello::Func79)();
   3.899 -	CHECK_STATES((&g_States,
   3.900 -		new State_Hello_Func4_Called,
   3.901 -		new State_Hello_Func79_Called,
   3.902 -		new State_Hello_Func4_Called,
   3.903 -		new State_Hello_Func79_Called,
   3.904 -		NULL), "Test" "Hello" " Part1");
   3.905 -
   3.906 -	int helloHook4 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
   3.907 -		0, helloHM_4, new Hello_Func4_Deleg, false);
   3.908 -
   3.909 -	int helloHook79 = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pHello),
   3.910 -		0, helloHM_79, new Hello_Func79_Deleg, false);
   3.911 -
   3.912 -	pHello->Func4();
   3.913 -	pHello->Func79();
   3.914 -	SH_CALL(pHello, &Hello::Func4)();
   3.915 -	SH_CALL(pHello, &Hello::Func79)();
   3.916 -
   3.917 -	CHECK_STATES((&g_States,
   3.918 -		new State_Hello_Func4_PreHook,
   3.919 -		new State_Hello_Func4_Called,
   3.920 -		new State_Hello_Func79_PreHook,
   3.921 -		new State_Hello_Func79_Called,
   3.922 -		new State_Hello_Func4_Called,
   3.923 -		new State_Hello_Func79_Called,
   3.924 -		NULL), "Test" "Hello" " Part2");
   3.925 -
   3.926 -	g_SHPtr->RemoveHookByID(helloHook4);
   3.927 -	g_SHPtr->RemoveHookByID(helloHook79);
   3.928 -
   3.929 -	g_HMAGPtr->ReleaseHookMan(helloHM_4);
   3.930 -	g_HMAGPtr->ReleaseHookMan(helloHM_79);
   3.931 +	if (!Tests1(error))
   3.932 +		return false;
   3.933 +	if (!Tests2(error))
   3.934 +		return false;
   3.935 +	if (!Tests3(error))
   3.936 +		return false;
   3.937 +	if (!Tests4(error))
   3.938 +		return false;
   3.939 +	if (!Tests5(error))
   3.940 +		return false;
   3.941  
   3.942  	// Shutdown now!
   3.943  	// If we don't SH will auto-shutdown _after_ genc's destructor is called
     4.1 --- a/sourcehook/test/testhookmangen.h	Sun Nov 18 13:12:51 2007 +0000
     4.2 +++ b/sourcehook/test/testhookmangen.h	Sun Nov 18 15:08:03 2007 +0000
     4.3 @@ -507,10 +507,7 @@
     4.4  	struct TestClass##id; \
     4.5  	typedef ParamState0<0 > ParamState_m##id; \
     4.6  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
     4.7 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
     4.8 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
     4.9 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    4.10 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    4.11 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    4.12  	\
    4.13  	struct TestClass##id \
    4.14  	{ \
    4.15 @@ -523,70 +520,25 @@
    4.16  			g_Inside_LeafFunc = false; \
    4.17  		} \
    4.18  		\
    4.19 -		struct Delegate1 : public MyDelegate \
    4.20 +		struct Delegate : public MyDelegate \
    4.21  		{ \
    4.22 +			int m_DelegNumber; \
    4.23 +			Delegate(int num) : m_DelegNumber(num) { } \
    4.24 +			\
    4.25  			virtual void Call() \
    4.26  			{ \
    4.27  				g_Inside_LeafFunc = true; \
    4.28 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
    4.29 -				g_Inside_LeafFunc = false; \
    4.30 -				if (ms_DoRecall) \
    4.31 -				{ \
    4.32 -					 \
    4.33 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ()); \
    4.34 -				} \
    4.35 -				else \
    4.36 -					RETURN_META(MRES_IGNORED); \
    4.37 -			} \
    4.38 -		}; \
    4.39 -		struct Delegate2 : public MyDelegate \
    4.40 -		{ \
    4.41 -			virtual void Call() \
    4.42 -			{ \
    4.43 -				g_Inside_LeafFunc = true; \
    4.44 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
    4.45 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
    4.46  				g_Inside_LeafFunc = false; \
    4.47  				if (ms_DoRecall) \
    4.48  				{ \
    4.49  					 \
    4.50 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, ()); \
    4.51 -				} \
    4.52 -				else \
    4.53 -					RETURN_META(MRES_SUPERCEDE); \
    4.54 -			} \
    4.55 -		}; \
    4.56 -		struct Delegate3 : public MyDelegate \
    4.57 -		{ \
    4.58 -			virtual void Call() \
    4.59 -			{ \
    4.60 -				g_Inside_LeafFunc = true; \
    4.61 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
    4.62 -				g_Inside_LeafFunc = false; \
    4.63 -				if (ms_DoRecall) \
    4.64 -				{ \
    4.65 -					 \
    4.66 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ()); \
    4.67 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, ()); \
    4.68  				} \
    4.69  				else \
    4.70 -					RETURN_META(MRES_IGNORED); \
    4.71 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
    4.72  			} \
    4.73  		}; \
    4.74 -		struct Delegate4 : public MyDelegate \
    4.75 -		{ \
    4.76 -			virtual void Call() \
    4.77 -			{ \
    4.78 -				g_Inside_LeafFunc = true; \
    4.79 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
    4.80 -				g_Inside_LeafFunc = false; \
    4.81 -				if (ms_DoRecall) \
    4.82 -				{ \
    4.83 -					 \
    4.84 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, ()); \
    4.85 -				} \
    4.86 -				else \
    4.87 -					RETURN_META(MRES_SUPERCEDE); \
    4.88 -			}; \
    4.89 -		}; \
    4.90  	}; \
    4.91  	\
    4.92  	bool TestClass##id::ms_DoRecall = false; \
    4.93 @@ -598,10 +550,7 @@
    4.94  	typedef ret_type RetType##id; \
    4.95  	typedef ParamState0<0 > ParamState_m##id; \
    4.96  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
    4.97 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    4.98 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    4.99 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.100 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.101 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.102  	\
   4.103  	struct TestClass##id \
   4.104  	{ \
   4.105 @@ -616,70 +565,25 @@
   4.106  			return MakeRet< ret_type >::Do(0); \
   4.107  		} \
   4.108  		\
   4.109 -		struct Delegate1 : public MyDelegate \
   4.110 +		struct Delegate : public MyDelegate \
   4.111  		{ \
   4.112 +			int m_DelegNumber; \
   4.113 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.114 +			\
   4.115  			virtual ret_type Call() \
   4.116  			{ \
   4.117  				g_Inside_LeafFunc = true; \
   4.118 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.119 -				g_Inside_LeafFunc = false; \
   4.120 -				if (ms_DoRecall) \
   4.121 -				{ \
   4.122 -					 \
   4.123 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, ()); \
   4.124 -				} \
   4.125 -				else \
   4.126 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   4.127 -			} \
   4.128 -		}; \
   4.129 -		struct Delegate2 : public MyDelegate \
   4.130 -		{ \
   4.131 -			virtual ret_type Call() \
   4.132 -			{ \
   4.133 -				g_Inside_LeafFunc = true; \
   4.134 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.135 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.136  				g_Inside_LeafFunc = false; \
   4.137  				if (ms_DoRecall) \
   4.138  				{ \
   4.139  					 \
   4.140 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, ()); \
   4.141 -				} \
   4.142 -				else \
   4.143 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   4.144 -			} \
   4.145 -		}; \
   4.146 -		struct Delegate3 : public MyDelegate \
   4.147 -		{ \
   4.148 -			virtual ret_type Call() \
   4.149 -			{ \
   4.150 -				g_Inside_LeafFunc = true; \
   4.151 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.152 -				g_Inside_LeafFunc = false; \
   4.153 -				if (ms_DoRecall) \
   4.154 -				{ \
   4.155 -					 \
   4.156 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, ()); \
   4.157 +					RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, ()); \
   4.158  				} \
   4.159  				else \
   4.160 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   4.161 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
   4.162  			} \
   4.163  		}; \
   4.164 -		struct Delegate4 : public MyDelegate \
   4.165 -		{ \
   4.166 -			virtual ret_type Call() \
   4.167 -			{ \
   4.168 -				g_Inside_LeafFunc = true; \
   4.169 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.170 -				g_Inside_LeafFunc = false; \
   4.171 -				if (ms_DoRecall) \
   4.172 -				{ \
   4.173 -					 \
   4.174 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, ()); \
   4.175 -				} \
   4.176 -				else \
   4.177 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   4.178 -			}; \
   4.179 -		}; \
   4.180  	}; \
   4.181  	\
   4.182  	bool TestClass##id::ms_DoRecall = false; \
   4.183 @@ -689,10 +593,7 @@
   4.184  	struct TestClass##id; \
   4.185  	typedef ParamState1<0, std::string > ParamState_m##id; \
   4.186  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.187 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.188 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.189 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.190 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.191 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.192  	\
   4.193  	struct TestClass##id \
   4.194  	{ \
   4.195 @@ -713,169 +614,30 @@
   4.196  			g_Inside_LeafFunc = false; \
   4.197  		} \
   4.198  		\
   4.199 -		struct Delegate1 : public MyDelegate \
   4.200 +		struct Delegate : public MyDelegate \
   4.201  		{ \
   4.202 +			int m_DelegNumber; \
   4.203 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.204 +			\
   4.205  			virtual void Call(const char *buf) \
   4.206  			{ \
   4.207  				g_Inside_LeafFunc = true; \
   4.208 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \
   4.209 -				g_Inside_LeafFunc = false; \
   4.210 -				if (ms_DoRecall) \
   4.211 -				{ \
   4.212 -					 \
   4.213 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \
   4.214 -				} \
   4.215 -				else \
   4.216 -					RETURN_META(MRES_IGNORED); \
   4.217 -			} \
   4.218 -		}; \
   4.219 -		struct Delegate2 : public MyDelegate \
   4.220 -		{ \
   4.221 -			virtual void Call(const char *buf) \
   4.222 -			{ \
   4.223 -				g_Inside_LeafFunc = true; \
   4.224 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \
   4.225 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \
   4.226  				g_Inside_LeafFunc = false; \
   4.227  				if (ms_DoRecall) \
   4.228  				{ \
   4.229  					 \
   4.230 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \
   4.231 -				} \
   4.232 -				else \
   4.233 -					RETURN_META(MRES_SUPERCEDE); \
   4.234 -			} \
   4.235 -		}; \
   4.236 -		struct Delegate3 : public MyDelegate \
   4.237 -		{ \
   4.238 -			virtual void Call(const char *buf) \
   4.239 -			{ \
   4.240 -				g_Inside_LeafFunc = true; \
   4.241 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \
   4.242 -				g_Inside_LeafFunc = false; \
   4.243 -				if (ms_DoRecall) \
   4.244 -				{ \
   4.245 -					 \
   4.246 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \
   4.247 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, ("%s!", buf)); \
   4.248  				} \
   4.249  				else \
   4.250 -					RETURN_META(MRES_IGNORED); \
   4.251 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   4.252  			} \
   4.253  		}; \
   4.254 -		struct Delegate4 : public MyDelegate \
   4.255 -		{ \
   4.256 -			virtual void Call(const char *buf) \
   4.257 -			{ \
   4.258 -				g_Inside_LeafFunc = true; \
   4.259 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(buf))); \
   4.260 -				g_Inside_LeafFunc = false; \
   4.261 -				if (ms_DoRecall) \
   4.262 -				{ \
   4.263 -					 \
   4.264 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, ("%s!", buf)); \
   4.265 -				} \
   4.266 -				else \
   4.267 -					RETURN_META(MRES_SUPERCEDE); \
   4.268 -			}; \
   4.269 -		}; \
   4.270  	}; \
   4.271  	\
   4.272  	bool TestClass##id::ms_DoRecall = false; \
   4.273  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
   4.274  
   4.275 -
   4.276 -#define THGM_MAKE_TEST0_vafmt(id, ret_type) \
   4.277 -	struct TestClass##id; \
   4.278 -	typedef ret_type RetType##id; \
   4.279 -	typedef ParamState0<0 > ParamState_m##id; \
   4.280 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.281 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.282 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.283 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.284 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.285 -	\
   4.286 -	struct TestClass##id \
   4.287 -	{ \
   4.288 -		static bool ms_DoRecall; \
   4.289 -		\
   4.290 -		virtual ret_type Func() \
   4.291 -		{ \
   4.292 -			g_Inside_LeafFunc = true; \
   4.293 -			ADD_STATE(State_Func##id(this, ParamState_m##id())); \
   4.294 -			g_Inside_LeafFunc = false; \
   4.295 -			\
   4.296 -			return MakeRet< ret_type >::Do(0); \
   4.297 -		} \
   4.298 -		\
   4.299 -		struct Delegate1 : public MyDelegate \
   4.300 -		{ \
   4.301 -			virtual ret_type Call() \
   4.302 -			{ \
   4.303 -				g_Inside_LeafFunc = true; \
   4.304 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.305 -				g_Inside_LeafFunc = false; \
   4.306 -				if (ms_DoRecall) \
   4.307 -				{ \
   4.308 -					 \
   4.309 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, ()); \
   4.310 -				} \
   4.311 -				else \
   4.312 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   4.313 -			} \
   4.314 -		}; \
   4.315 -		struct Delegate2 : public MyDelegate \
   4.316 -		{ \
   4.317 -			virtual ret_type Call() \
   4.318 -			{ \
   4.319 -				g_Inside_LeafFunc = true; \
   4.320 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.321 -				g_Inside_LeafFunc = false; \
   4.322 -				if (ms_DoRecall) \
   4.323 -				{ \
   4.324 -					 \
   4.325 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, ()); \
   4.326 -				} \
   4.327 -				else \
   4.328 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   4.329 -			} \
   4.330 -		}; \
   4.331 -		struct Delegate3 : public MyDelegate \
   4.332 -		{ \
   4.333 -			virtual ret_type Call() \
   4.334 -			{ \
   4.335 -				g_Inside_LeafFunc = true; \
   4.336 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.337 -				g_Inside_LeafFunc = false; \
   4.338 -				if (ms_DoRecall) \
   4.339 -				{ \
   4.340 -					 \
   4.341 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, ()); \
   4.342 -				} \
   4.343 -				else \
   4.344 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   4.345 -			} \
   4.346 -		}; \
   4.347 -		struct Delegate4 : public MyDelegate \
   4.348 -		{ \
   4.349 -			virtual ret_type Call() \
   4.350 -			{ \
   4.351 -				g_Inside_LeafFunc = true; \
   4.352 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id())); \
   4.353 -				g_Inside_LeafFunc = false; \
   4.354 -				if (ms_DoRecall) \
   4.355 -				{ \
   4.356 -					 \
   4.357 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, ()); \
   4.358 -				} \
   4.359 -				else \
   4.360 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   4.361 -			}; \
   4.362 -		}; \
   4.363 -	}; \
   4.364 -	\
   4.365 -	bool TestClass##id::ms_DoRecall = false; \
   4.366 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
   4.367 -
   4.368 -
   4.369  #define THGM_SETUP_PI0(id) \
   4.370  	void setuppi_##id() \
   4.371  	{ \
   4.372 @@ -888,10 +650,7 @@
   4.373  	struct TestClass##id; \
   4.374  	typedef ParamState1<0, param1 > ParamState_m##id; \
   4.375  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.376 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.377 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.378 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.379 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.380 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.381  	\
   4.382  	struct TestClass##id \
   4.383  	{ \
   4.384 @@ -904,70 +663,25 @@
   4.385  			g_Inside_LeafFunc = false; \
   4.386  		} \
   4.387  		\
   4.388 -		struct Delegate1 : public MyDelegate \
   4.389 +		struct Delegate : public MyDelegate \
   4.390  		{ \
   4.391 +			int m_DelegNumber; \
   4.392 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.393 +			\
   4.394  			virtual void Call(param1 p1) \
   4.395  			{ \
   4.396  				g_Inside_LeafFunc = true; \
   4.397 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.398 -				g_Inside_LeafFunc = false; \
   4.399 -				if (ms_DoRecall) \
   4.400 -				{ \
   4.401 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.402 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1)); \
   4.403 -				} \
   4.404 -				else \
   4.405 -					RETURN_META(MRES_IGNORED); \
   4.406 -			} \
   4.407 -		}; \
   4.408 -		struct Delegate2 : public MyDelegate \
   4.409 -		{ \
   4.410 -			virtual void Call(param1 p1) \
   4.411 -			{ \
   4.412 -				g_Inside_LeafFunc = true; \
   4.413 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.414 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.415  				g_Inside_LeafFunc = false; \
   4.416  				if (ms_DoRecall) \
   4.417  				{ \
   4.418  					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.419 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \
   4.420 -				} \
   4.421 -				else \
   4.422 -					RETURN_META(MRES_SUPERCEDE); \
   4.423 -			} \
   4.424 -		}; \
   4.425 -		struct Delegate3 : public MyDelegate \
   4.426 -		{ \
   4.427 -			virtual void Call(param1 p1) \
   4.428 -			{ \
   4.429 -				g_Inside_LeafFunc = true; \
   4.430 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.431 -				g_Inside_LeafFunc = false; \
   4.432 -				if (ms_DoRecall) \
   4.433 -				{ \
   4.434 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.435 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1)); \
   4.436 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \
   4.437  				} \
   4.438  				else \
   4.439 -					RETURN_META(MRES_IGNORED); \
   4.440 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   4.441  			} \
   4.442  		}; \
   4.443 -		struct Delegate4 : public MyDelegate \
   4.444 -		{ \
   4.445 -			virtual void Call(param1 p1) \
   4.446 -			{ \
   4.447 -				g_Inside_LeafFunc = true; \
   4.448 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.449 -				g_Inside_LeafFunc = false; \
   4.450 -				if (ms_DoRecall) \
   4.451 -				{ \
   4.452 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.453 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1)); \
   4.454 -				} \
   4.455 -				else \
   4.456 -					RETURN_META(MRES_SUPERCEDE); \
   4.457 -			}; \
   4.458 -		}; \
   4.459  	}; \
   4.460  	\
   4.461  	bool TestClass##id::ms_DoRecall = false; \
   4.462 @@ -979,10 +693,7 @@
   4.463  	typedef ret_type RetType##id; \
   4.464  	typedef ParamState1<0, param1 > ParamState_m##id; \
   4.465  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.466 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.467 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.468 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.469 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.470 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.471  	\
   4.472  	struct TestClass##id \
   4.473  	{ \
   4.474 @@ -997,70 +708,25 @@
   4.475  			return MakeRet< ret_type >::Do(0); \
   4.476  		} \
   4.477  		\
   4.478 -		struct Delegate1 : public MyDelegate \
   4.479 +		struct Delegate : public MyDelegate \
   4.480  		{ \
   4.481 +			int m_DelegNumber; \
   4.482 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.483 +			\
   4.484  			virtual ret_type Call(param1 p1) \
   4.485  			{ \
   4.486  				g_Inside_LeafFunc = true; \
   4.487 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.488 -				g_Inside_LeafFunc = false; \
   4.489 -				if (ms_DoRecall) \
   4.490 -				{ \
   4.491 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.492 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1)); \
   4.493 -				} \
   4.494 -				else \
   4.495 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   4.496 -			} \
   4.497 -		}; \
   4.498 -		struct Delegate2 : public MyDelegate \
   4.499 -		{ \
   4.500 -			virtual ret_type Call(param1 p1) \
   4.501 -			{ \
   4.502 -				g_Inside_LeafFunc = true; \
   4.503 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.504 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.505  				g_Inside_LeafFunc = false; \
   4.506  				if (ms_DoRecall) \
   4.507  				{ \
   4.508  					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.509 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1)); \
   4.510 -				} \
   4.511 -				else \
   4.512 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   4.513 -			} \
   4.514 -		}; \
   4.515 -		struct Delegate3 : public MyDelegate \
   4.516 -		{ \
   4.517 -			virtual ret_type Call(param1 p1) \
   4.518 -			{ \
   4.519 -				g_Inside_LeafFunc = true; \
   4.520 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.521 -				g_Inside_LeafFunc = false; \
   4.522 -				if (ms_DoRecall) \
   4.523 -				{ \
   4.524 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.525 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1)); \
   4.526 +					RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1)); \
   4.527  				} \
   4.528  				else \
   4.529 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   4.530 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
   4.531  			} \
   4.532  		}; \
   4.533 -		struct Delegate4 : public MyDelegate \
   4.534 -		{ \
   4.535 -			virtual ret_type Call(param1 p1) \
   4.536 -			{ \
   4.537 -				g_Inside_LeafFunc = true; \
   4.538 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.539 -				g_Inside_LeafFunc = false; \
   4.540 -				if (ms_DoRecall) \
   4.541 -				{ \
   4.542 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.543 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1)); \
   4.544 -				} \
   4.545 -				else \
   4.546 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   4.547 -			}; \
   4.548 -		}; \
   4.549  	}; \
   4.550  	\
   4.551  	bool TestClass##id::ms_DoRecall = false; \
   4.552 @@ -1070,10 +736,7 @@
   4.553  	struct TestClass##id; \
   4.554  	typedef ParamState2<0, param1, std::string > ParamState_m##id; \
   4.555  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.556 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.557 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.558 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.559 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.560 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.561  	\
   4.562  	struct TestClass##id \
   4.563  	{ \
   4.564 @@ -1094,169 +757,30 @@
   4.565  			g_Inside_LeafFunc = false; \
   4.566  		} \
   4.567  		\
   4.568 -		struct Delegate1 : public MyDelegate \
   4.569 +		struct Delegate : public MyDelegate \
   4.570  		{ \
   4.571 +			int m_DelegNumber; \
   4.572 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.573 +			\
   4.574  			virtual void Call(param1 p1, const char *buf) \
   4.575  			{ \
   4.576  				g_Inside_LeafFunc = true; \
   4.577 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \
   4.578 -				g_Inside_LeafFunc = false; \
   4.579 -				if (ms_DoRecall) \
   4.580 -				{ \
   4.581 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.582 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \
   4.583 -				} \
   4.584 -				else \
   4.585 -					RETURN_META(MRES_IGNORED); \
   4.586 -			} \
   4.587 -		}; \
   4.588 -		struct Delegate2 : public MyDelegate \
   4.589 -		{ \
   4.590 -			virtual void Call(param1 p1, const char *buf) \
   4.591 -			{ \
   4.592 -				g_Inside_LeafFunc = true; \
   4.593 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \
   4.594 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \
   4.595  				g_Inside_LeafFunc = false; \
   4.596  				if (ms_DoRecall) \
   4.597  				{ \
   4.598  					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.599 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \
   4.600 -				} \
   4.601 -				else \
   4.602 -					RETURN_META(MRES_SUPERCEDE); \
   4.603 -			} \
   4.604 -		}; \
   4.605 -		struct Delegate3 : public MyDelegate \
   4.606 -		{ \
   4.607 -			virtual void Call(param1 p1, const char *buf) \
   4.608 -			{ \
   4.609 -				g_Inside_LeafFunc = true; \
   4.610 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \
   4.611 -				g_Inside_LeafFunc = false; \
   4.612 -				if (ms_DoRecall) \
   4.613 -				{ \
   4.614 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.615 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \
   4.616 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, "%s!", buf)); \
   4.617  				} \
   4.618  				else \
   4.619 -					RETURN_META(MRES_IGNORED); \
   4.620 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   4.621  			} \
   4.622  		}; \
   4.623 -		struct Delegate4 : public MyDelegate \
   4.624 -		{ \
   4.625 -			virtual void Call(param1 p1, const char *buf) \
   4.626 -			{ \
   4.627 -				g_Inside_LeafFunc = true; \
   4.628 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, buf))); \
   4.629 -				g_Inside_LeafFunc = false; \
   4.630 -				if (ms_DoRecall) \
   4.631 -				{ \
   4.632 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.633 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, "%s!", buf)); \
   4.634 -				} \
   4.635 -				else \
   4.636 -					RETURN_META(MRES_SUPERCEDE); \
   4.637 -			}; \
   4.638 -		}; \
   4.639  	}; \
   4.640  	\
   4.641  	bool TestClass##id::ms_DoRecall = false; \
   4.642  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
   4.643  
   4.644 -
   4.645 -#define THGM_MAKE_TEST1_vafmt(id, ret_type, param1) \
   4.646 -	struct TestClass##id; \
   4.647 -	typedef ret_type RetType##id; \
   4.648 -	typedef ParamState1<0, param1 > ParamState_m##id; \
   4.649 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.650 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.651 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.652 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.653 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.654 -	\
   4.655 -	struct TestClass##id \
   4.656 -	{ \
   4.657 -		static bool ms_DoRecall; \
   4.658 -		\
   4.659 -		virtual ret_type Func(param1 p1) \
   4.660 -		{ \
   4.661 -			g_Inside_LeafFunc = true; \
   4.662 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1))); \
   4.663 -			g_Inside_LeafFunc = false; \
   4.664 -			\
   4.665 -			return MakeRet< ret_type >::Do(0); \
   4.666 -		} \
   4.667 -		\
   4.668 -		struct Delegate1 : public MyDelegate \
   4.669 -		{ \
   4.670 -			virtual ret_type Call(param1 p1) \
   4.671 -			{ \
   4.672 -				g_Inside_LeafFunc = true; \
   4.673 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.674 -				g_Inside_LeafFunc = false; \
   4.675 -				if (ms_DoRecall) \
   4.676 -				{ \
   4.677 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.678 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1)); \
   4.679 -				} \
   4.680 -				else \
   4.681 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   4.682 -			} \
   4.683 -		}; \
   4.684 -		struct Delegate2 : public MyDelegate \
   4.685 -		{ \
   4.686 -			virtual ret_type Call(param1 p1) \
   4.687 -			{ \
   4.688 -				g_Inside_LeafFunc = true; \
   4.689 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.690 -				g_Inside_LeafFunc = false; \
   4.691 -				if (ms_DoRecall) \
   4.692 -				{ \
   4.693 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.694 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1)); \
   4.695 -				} \
   4.696 -				else \
   4.697 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   4.698 -			} \
   4.699 -		}; \
   4.700 -		struct Delegate3 : public MyDelegate \
   4.701 -		{ \
   4.702 -			virtual ret_type Call(param1 p1) \
   4.703 -			{ \
   4.704 -				g_Inside_LeafFunc = true; \
   4.705 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.706 -				g_Inside_LeafFunc = false; \
   4.707 -				if (ms_DoRecall) \
   4.708 -				{ \
   4.709 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.710 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1)); \
   4.711 -				} \
   4.712 -				else \
   4.713 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   4.714 -			} \
   4.715 -		}; \
   4.716 -		struct Delegate4 : public MyDelegate \
   4.717 -		{ \
   4.718 -			virtual ret_type Call(param1 p1) \
   4.719 -			{ \
   4.720 -				g_Inside_LeafFunc = true; \
   4.721 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1))); \
   4.722 -				g_Inside_LeafFunc = false; \
   4.723 -				if (ms_DoRecall) \
   4.724 -				{ \
   4.725 -					Increment<StripRef< param1 >::type>::Incr(p1); \
   4.726 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1)); \
   4.727 -				} \
   4.728 -				else \
   4.729 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   4.730 -			}; \
   4.731 -		}; \
   4.732 -	}; \
   4.733 -	\
   4.734 -	bool TestClass##id::ms_DoRecall = false; \
   4.735 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
   4.736 -
   4.737 -
   4.738  #define THGM_SETUP_PI1(id, p1_type, p1_passtype, p1_flags) \
   4.739  	void setuppi_##id() \
   4.740  	{ \
   4.741 @@ -1276,10 +800,7 @@
   4.742  	struct TestClass##id; \
   4.743  	typedef ParamState2<0, param1, param2 > ParamState_m##id; \
   4.744  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.745 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.746 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.747 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.748 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.749 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.750  	\
   4.751  	struct TestClass##id \
   4.752  	{ \
   4.753 @@ -1292,70 +813,25 @@
   4.754  			g_Inside_LeafFunc = false; \
   4.755  		} \
   4.756  		\
   4.757 -		struct Delegate1 : public MyDelegate \
   4.758 +		struct Delegate : public MyDelegate \
   4.759  		{ \
   4.760 +			int m_DelegNumber; \
   4.761 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.762 +			\
   4.763  			virtual void Call(param1 p1, param2 p2) \
   4.764  			{ \
   4.765  				g_Inside_LeafFunc = true; \
   4.766 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.767 -				g_Inside_LeafFunc = false; \
   4.768 -				if (ms_DoRecall) \
   4.769 -				{ \
   4.770 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.771 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2)); \
   4.772 -				} \
   4.773 -				else \
   4.774 -					RETURN_META(MRES_IGNORED); \
   4.775 -			} \
   4.776 -		}; \
   4.777 -		struct Delegate2 : public MyDelegate \
   4.778 -		{ \
   4.779 -			virtual void Call(param1 p1, param2 p2) \
   4.780 -			{ \
   4.781 -				g_Inside_LeafFunc = true; \
   4.782 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.783 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.784  				g_Inside_LeafFunc = false; \
   4.785  				if (ms_DoRecall) \
   4.786  				{ \
   4.787  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.788 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \
   4.789 -				} \
   4.790 -				else \
   4.791 -					RETURN_META(MRES_SUPERCEDE); \
   4.792 -			} \
   4.793 -		}; \
   4.794 -		struct Delegate3 : public MyDelegate \
   4.795 -		{ \
   4.796 -			virtual void Call(param1 p1, param2 p2) \
   4.797 -			{ \
   4.798 -				g_Inside_LeafFunc = true; \
   4.799 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.800 -				g_Inside_LeafFunc = false; \
   4.801 -				if (ms_DoRecall) \
   4.802 -				{ \
   4.803 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.804 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2)); \
   4.805 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \
   4.806  				} \
   4.807  				else \
   4.808 -					RETURN_META(MRES_IGNORED); \
   4.809 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   4.810  			} \
   4.811  		}; \
   4.812 -		struct Delegate4 : public MyDelegate \
   4.813 -		{ \
   4.814 -			virtual void Call(param1 p1, param2 p2) \
   4.815 -			{ \
   4.816 -				g_Inside_LeafFunc = true; \
   4.817 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.818 -				g_Inside_LeafFunc = false; \
   4.819 -				if (ms_DoRecall) \
   4.820 -				{ \
   4.821 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.822 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2)); \
   4.823 -				} \
   4.824 -				else \
   4.825 -					RETURN_META(MRES_SUPERCEDE); \
   4.826 -			}; \
   4.827 -		}; \
   4.828  	}; \
   4.829  	\
   4.830  	bool TestClass##id::ms_DoRecall = false; \
   4.831 @@ -1367,10 +843,7 @@
   4.832  	typedef ret_type RetType##id; \
   4.833  	typedef ParamState2<0, param1, param2 > ParamState_m##id; \
   4.834  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.835 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.836 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.837 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.838 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.839 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.840  	\
   4.841  	struct TestClass##id \
   4.842  	{ \
   4.843 @@ -1385,70 +858,25 @@
   4.844  			return MakeRet< ret_type >::Do(0); \
   4.845  		} \
   4.846  		\
   4.847 -		struct Delegate1 : public MyDelegate \
   4.848 +		struct Delegate : public MyDelegate \
   4.849  		{ \
   4.850 +			int m_DelegNumber; \
   4.851 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.852 +			\
   4.853  			virtual ret_type Call(param1 p1, param2 p2) \
   4.854  			{ \
   4.855  				g_Inside_LeafFunc = true; \
   4.856 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.857 -				g_Inside_LeafFunc = false; \
   4.858 -				if (ms_DoRecall) \
   4.859 -				{ \
   4.860 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.861 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2)); \
   4.862 -				} \
   4.863 -				else \
   4.864 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   4.865 -			} \
   4.866 -		}; \
   4.867 -		struct Delegate2 : public MyDelegate \
   4.868 -		{ \
   4.869 -			virtual ret_type Call(param1 p1, param2 p2) \
   4.870 -			{ \
   4.871 -				g_Inside_LeafFunc = true; \
   4.872 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.873 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.874  				g_Inside_LeafFunc = false; \
   4.875  				if (ms_DoRecall) \
   4.876  				{ \
   4.877  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.878 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2)); \
   4.879 -				} \
   4.880 -				else \
   4.881 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   4.882 -			} \
   4.883 -		}; \
   4.884 -		struct Delegate3 : public MyDelegate \
   4.885 -		{ \
   4.886 -			virtual ret_type Call(param1 p1, param2 p2) \
   4.887 -			{ \
   4.888 -				g_Inside_LeafFunc = true; \
   4.889 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.890 -				g_Inside_LeafFunc = false; \
   4.891 -				if (ms_DoRecall) \
   4.892 -				{ \
   4.893 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.894 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2)); \
   4.895 +					RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2)); \
   4.896  				} \
   4.897  				else \
   4.898 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   4.899 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
   4.900  			} \
   4.901  		}; \
   4.902 -		struct Delegate4 : public MyDelegate \
   4.903 -		{ \
   4.904 -			virtual ret_type Call(param1 p1, param2 p2) \
   4.905 -			{ \
   4.906 -				g_Inside_LeafFunc = true; \
   4.907 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
   4.908 -				g_Inside_LeafFunc = false; \
   4.909 -				if (ms_DoRecall) \
   4.910 -				{ \
   4.911 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.912 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2)); \
   4.913 -				} \
   4.914 -				else \
   4.915 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   4.916 -			}; \
   4.917 -		}; \
   4.918  	}; \
   4.919  	\
   4.920  	bool TestClass##id::ms_DoRecall = false; \
   4.921 @@ -1458,10 +886,7 @@
   4.922  	struct TestClass##id; \
   4.923  	typedef ParamState3<0, param1, param2, std::string > ParamState_m##id; \
   4.924  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   4.925 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.926 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.927 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.928 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.929 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   4.930  	\
   4.931  	struct TestClass##id \
   4.932  	{ \
   4.933 @@ -1482,169 +907,30 @@
   4.934  			g_Inside_LeafFunc = false; \
   4.935  		} \
   4.936  		\
   4.937 -		struct Delegate1 : public MyDelegate \
   4.938 +		struct Delegate : public MyDelegate \
   4.939  		{ \
   4.940 +			int m_DelegNumber; \
   4.941 +			Delegate(int num) : m_DelegNumber(num) { } \
   4.942 +			\
   4.943  			virtual void Call(param1 p1, param2 p2, const char *buf) \
   4.944  			{ \
   4.945  				g_Inside_LeafFunc = true; \
   4.946 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \
   4.947 -				g_Inside_LeafFunc = false; \
   4.948 -				if (ms_DoRecall) \
   4.949 -				{ \
   4.950 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.951 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \
   4.952 -				} \
   4.953 -				else \
   4.954 -					RETURN_META(MRES_IGNORED); \
   4.955 -			} \
   4.956 -		}; \
   4.957 -		struct Delegate2 : public MyDelegate \
   4.958 -		{ \
   4.959 -			virtual void Call(param1 p1, param2 p2, const char *buf) \
   4.960 -			{ \
   4.961 -				g_Inside_LeafFunc = true; \
   4.962 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \
   4.963 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \
   4.964  				g_Inside_LeafFunc = false; \
   4.965  				if (ms_DoRecall) \
   4.966  				{ \
   4.967  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.968 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \
   4.969 -				} \
   4.970 -				else \
   4.971 -					RETURN_META(MRES_SUPERCEDE); \
   4.972 -			} \
   4.973 -		}; \
   4.974 -		struct Delegate3 : public MyDelegate \
   4.975 -		{ \
   4.976 -			virtual void Call(param1 p1, param2 p2, const char *buf) \
   4.977 -			{ \
   4.978 -				g_Inside_LeafFunc = true; \
   4.979 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \
   4.980 -				g_Inside_LeafFunc = false; \
   4.981 -				if (ms_DoRecall) \
   4.982 -				{ \
   4.983 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
   4.984 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \
   4.985 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, "%s!", buf)); \
   4.986  				} \
   4.987  				else \
   4.988 -					RETURN_META(MRES_IGNORED); \
   4.989 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   4.990  			} \
   4.991  		}; \
   4.992 -		struct Delegate4 : public MyDelegate \
   4.993 -		{ \
   4.994 -			virtual void Call(param1 p1, param2 p2, const char *buf) \
   4.995 -			{ \
   4.996 -				g_Inside_LeafFunc = true; \
   4.997 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, buf))); \
   4.998 -				g_Inside_LeafFunc = false; \
   4.999 -				if (ms_DoRecall) \
  4.1000 -				{ \
  4.1001 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
  4.1002 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, "%s!", buf)); \
  4.1003 -				} \
  4.1004 -				else \
  4.1005 -					RETURN_META(MRES_SUPERCEDE); \
  4.1006 -			}; \
  4.1007 -		}; \
  4.1008  	}; \
  4.1009  	\
  4.1010  	bool TestClass##id::ms_DoRecall = false; \
  4.1011  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
  4.1012  
  4.1013 -
  4.1014 -#define THGM_MAKE_TEST2_vafmt(id, ret_type, param1, param2) \
  4.1015 -	struct TestClass##id; \
  4.1016 -	typedef ret_type RetType##id; \
  4.1017 -	typedef ParamState2<0, param1, param2 > ParamState_m##id; \
  4.1018 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1019 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1020 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1021 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1022 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1023 -	\
  4.1024 -	struct TestClass##id \
  4.1025 -	{ \
  4.1026 -		static bool ms_DoRecall; \
  4.1027 -		\
  4.1028 -		virtual ret_type Func(param1 p1, param2 p2) \
  4.1029 -		{ \
  4.1030 -			g_Inside_LeafFunc = true; \
  4.1031 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2))); \
  4.1032 -			g_Inside_LeafFunc = false; \
  4.1033 -			\
  4.1034 -			return MakeRet< ret_type >::Do(0); \
  4.1035 -		} \
  4.1036 -		\
  4.1037 -		struct Delegate1 : public MyDelegate \
  4.1038 -		{ \
  4.1039 -			virtual ret_type Call(param1 p1, param2 p2) \
  4.1040 -			{ \
  4.1041 -				g_Inside_LeafFunc = true; \
  4.1042 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
  4.1043 -				g_Inside_LeafFunc = false; \
  4.1044 -				if (ms_DoRecall) \
  4.1045 -				{ \
  4.1046 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
  4.1047 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2)); \
  4.1048 -				} \
  4.1049 -				else \
  4.1050 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1051 -			} \
  4.1052 -		}; \
  4.1053 -		struct Delegate2 : public MyDelegate \
  4.1054 -		{ \
  4.1055 -			virtual ret_type Call(param1 p1, param2 p2) \
  4.1056 -			{ \
  4.1057 -				g_Inside_LeafFunc = true; \
  4.1058 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
  4.1059 -				g_Inside_LeafFunc = false; \
  4.1060 -				if (ms_DoRecall) \
  4.1061 -				{ \
  4.1062 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
  4.1063 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2)); \
  4.1064 -				} \
  4.1065 -				else \
  4.1066 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1067 -			} \
  4.1068 -		}; \
  4.1069 -		struct Delegate3 : public MyDelegate \
  4.1070 -		{ \
  4.1071 -			virtual ret_type Call(param1 p1, param2 p2) \
  4.1072 -			{ \
  4.1073 -				g_Inside_LeafFunc = true; \
  4.1074 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
  4.1075 -				g_Inside_LeafFunc = false; \
  4.1076 -				if (ms_DoRecall) \
  4.1077 -				{ \
  4.1078 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
  4.1079 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2)); \
  4.1080 -				} \
  4.1081 -				else \
  4.1082 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.1083 -			} \
  4.1084 -		}; \
  4.1085 -		struct Delegate4 : public MyDelegate \
  4.1086 -		{ \
  4.1087 -			virtual ret_type Call(param1 p1, param2 p2) \
  4.1088 -			{ \
  4.1089 -				g_Inside_LeafFunc = true; \
  4.1090 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2))); \
  4.1091 -				g_Inside_LeafFunc = false; \
  4.1092 -				if (ms_DoRecall) \
  4.1093 -				{ \
  4.1094 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2); \
  4.1095 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2)); \
  4.1096 -				} \
  4.1097 -				else \
  4.1098 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.1099 -			}; \
  4.1100 -		}; \
  4.1101 -	}; \
  4.1102 -	\
  4.1103 -	bool TestClass##id::ms_DoRecall = false; \
  4.1104 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
  4.1105 -
  4.1106 -
  4.1107  #define THGM_SETUP_PI2(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags) \
  4.1108  	void setuppi_##id() \
  4.1109  	{ \
  4.1110 @@ -1671,10 +957,7 @@
  4.1111  	struct TestClass##id; \
  4.1112  	typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \
  4.1113  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1114 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1115 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1116 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1117 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1118 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1119  	\
  4.1120  	struct TestClass##id \
  4.1121  	{ \
  4.1122 @@ -1687,70 +970,25 @@
  4.1123  			g_Inside_LeafFunc = false; \
  4.1124  		} \
  4.1125  		\
  4.1126 -		struct Delegate1 : public MyDelegate \
  4.1127 +		struct Delegate : public MyDelegate \
  4.1128  		{ \
  4.1129 +			int m_DelegNumber; \
  4.1130 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1131 +			\
  4.1132  			virtual void Call(param1 p1, param2 p2, param3 p3) \
  4.1133  			{ \
  4.1134  				g_Inside_LeafFunc = true; \
  4.1135 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1136 -				g_Inside_LeafFunc = false; \
  4.1137 -				if (ms_DoRecall) \
  4.1138 -				{ \
  4.1139 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1140 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3)); \
  4.1141 -				} \
  4.1142 -				else \
  4.1143 -					RETURN_META(MRES_IGNORED); \
  4.1144 -			} \
  4.1145 -		}; \
  4.1146 -		struct Delegate2 : public MyDelegate \
  4.1147 -		{ \
  4.1148 -			virtual void Call(param1 p1, param2 p2, param3 p3) \
  4.1149 -			{ \
  4.1150 -				g_Inside_LeafFunc = true; \
  4.1151 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1152 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1153  				g_Inside_LeafFunc = false; \
  4.1154  				if (ms_DoRecall) \
  4.1155  				{ \
  4.1156  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1157 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \
  4.1158 -				} \
  4.1159 -				else \
  4.1160 -					RETURN_META(MRES_SUPERCEDE); \
  4.1161 -			} \
  4.1162 -		}; \
  4.1163 -		struct Delegate3 : public MyDelegate \
  4.1164 -		{ \
  4.1165 -			virtual void Call(param1 p1, param2 p2, param3 p3) \
  4.1166 -			{ \
  4.1167 -				g_Inside_LeafFunc = true; \
  4.1168 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1169 -				g_Inside_LeafFunc = false; \
  4.1170 -				if (ms_DoRecall) \
  4.1171 -				{ \
  4.1172 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1173 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3)); \
  4.1174 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \
  4.1175  				} \
  4.1176  				else \
  4.1177 -					RETURN_META(MRES_IGNORED); \
  4.1178 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.1179  			} \
  4.1180  		}; \
  4.1181 -		struct Delegate4 : public MyDelegate \
  4.1182 -		{ \
  4.1183 -			virtual void Call(param1 p1, param2 p2, param3 p3) \
  4.1184 -			{ \
  4.1185 -				g_Inside_LeafFunc = true; \
  4.1186 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1187 -				g_Inside_LeafFunc = false; \
  4.1188 -				if (ms_DoRecall) \
  4.1189 -				{ \
  4.1190 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1191 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3)); \
  4.1192 -				} \
  4.1193 -				else \
  4.1194 -					RETURN_META(MRES_SUPERCEDE); \
  4.1195 -			}; \
  4.1196 -		}; \
  4.1197  	}; \
  4.1198  	\
  4.1199  	bool TestClass##id::ms_DoRecall = false; \
  4.1200 @@ -1762,10 +1000,7 @@
  4.1201  	typedef ret_type RetType##id; \
  4.1202  	typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \
  4.1203  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1204 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1205 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1206 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1207 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1208 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1209  	\
  4.1210  	struct TestClass##id \
  4.1211  	{ \
  4.1212 @@ -1780,70 +1015,25 @@
  4.1213  			return MakeRet< ret_type >::Do(0); \
  4.1214  		} \
  4.1215  		\
  4.1216 -		struct Delegate1 : public MyDelegate \
  4.1217 +		struct Delegate : public MyDelegate \
  4.1218  		{ \
  4.1219 +			int m_DelegNumber; \
  4.1220 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1221 +			\
  4.1222  			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1223  			{ \
  4.1224  				g_Inside_LeafFunc = true; \
  4.1225 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1226 -				g_Inside_LeafFunc = false; \
  4.1227 -				if (ms_DoRecall) \
  4.1228 -				{ \
  4.1229 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1230 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3)); \
  4.1231 -				} \
  4.1232 -				else \
  4.1233 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1234 -			} \
  4.1235 -		}; \
  4.1236 -		struct Delegate2 : public MyDelegate \
  4.1237 -		{ \
  4.1238 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1239 -			{ \
  4.1240 -				g_Inside_LeafFunc = true; \
  4.1241 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1242 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1243  				g_Inside_LeafFunc = false; \
  4.1244  				if (ms_DoRecall) \
  4.1245  				{ \
  4.1246  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1247 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3)); \
  4.1248 -				} \
  4.1249 -				else \
  4.1250 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1251 -			} \
  4.1252 -		}; \
  4.1253 -		struct Delegate3 : public MyDelegate \
  4.1254 -		{ \
  4.1255 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1256 -			{ \
  4.1257 -				g_Inside_LeafFunc = true; \
  4.1258 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1259 -				g_Inside_LeafFunc = false; \
  4.1260 -				if (ms_DoRecall) \
  4.1261 -				{ \
  4.1262 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1263 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3)); \
  4.1264 +					RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3)); \
  4.1265  				} \
  4.1266  				else \
  4.1267 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.1268 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
  4.1269  			} \
  4.1270  		}; \
  4.1271 -		struct Delegate4 : public MyDelegate \
  4.1272 -		{ \
  4.1273 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1274 -			{ \
  4.1275 -				g_Inside_LeafFunc = true; \
  4.1276 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1277 -				g_Inside_LeafFunc = false; \
  4.1278 -				if (ms_DoRecall) \
  4.1279 -				{ \
  4.1280 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1281 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3)); \
  4.1282 -				} \
  4.1283 -				else \
  4.1284 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.1285 -			}; \
  4.1286 -		}; \
  4.1287  	}; \
  4.1288  	\
  4.1289  	bool TestClass##id::ms_DoRecall = false; \
  4.1290 @@ -1853,10 +1043,7 @@
  4.1291  	struct TestClass##id; \
  4.1292  	typedef ParamState4<0, param1, param2, param3, std::string > ParamState_m##id; \
  4.1293  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1294 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1295 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1296 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1297 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1298 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1299  	\
  4.1300  	struct TestClass##id \
  4.1301  	{ \
  4.1302 @@ -1877,169 +1064,30 @@
  4.1303  			g_Inside_LeafFunc = false; \
  4.1304  		} \
  4.1305  		\
  4.1306 -		struct Delegate1 : public MyDelegate \
  4.1307 +		struct Delegate : public MyDelegate \
  4.1308  		{ \
  4.1309 +			int m_DelegNumber; \
  4.1310 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1311 +			\
  4.1312  			virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \
  4.1313  			{ \
  4.1314  				g_Inside_LeafFunc = true; \
  4.1315 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \
  4.1316 -				g_Inside_LeafFunc = false; \
  4.1317 -				if (ms_DoRecall) \
  4.1318 -				{ \
  4.1319 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1320 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \
  4.1321 -				} \
  4.1322 -				else \
  4.1323 -					RETURN_META(MRES_IGNORED); \
  4.1324 -			} \
  4.1325 -		}; \
  4.1326 -		struct Delegate2 : public MyDelegate \
  4.1327 -		{ \
  4.1328 -			virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \
  4.1329 -			{ \
  4.1330 -				g_Inside_LeafFunc = true; \
  4.1331 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \
  4.1332 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \
  4.1333  				g_Inside_LeafFunc = false; \
  4.1334  				if (ms_DoRecall) \
  4.1335  				{ \
  4.1336  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1337 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \
  4.1338 -				} \
  4.1339 -				else \
  4.1340 -					RETURN_META(MRES_SUPERCEDE); \
  4.1341 -			} \
  4.1342 -		}; \
  4.1343 -		struct Delegate3 : public MyDelegate \
  4.1344 -		{ \
  4.1345 -			virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \
  4.1346 -			{ \
  4.1347 -				g_Inside_LeafFunc = true; \
  4.1348 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \
  4.1349 -				g_Inside_LeafFunc = false; \
  4.1350 -				if (ms_DoRecall) \
  4.1351 -				{ \
  4.1352 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1353 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \
  4.1354 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \
  4.1355  				} \
  4.1356  				else \
  4.1357 -					RETURN_META(MRES_IGNORED); \
  4.1358 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.1359  			} \
  4.1360  		}; \
  4.1361 -		struct Delegate4 : public MyDelegate \
  4.1362 -		{ \
  4.1363 -			virtual void Call(param1 p1, param2 p2, param3 p3, const char *buf) \
  4.1364 -			{ \
  4.1365 -				g_Inside_LeafFunc = true; \
  4.1366 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, buf))); \
  4.1367 -				g_Inside_LeafFunc = false; \
  4.1368 -				if (ms_DoRecall) \
  4.1369 -				{ \
  4.1370 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1371 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, "%s!", buf)); \
  4.1372 -				} \
  4.1373 -				else \
  4.1374 -					RETURN_META(MRES_SUPERCEDE); \
  4.1375 -			}; \
  4.1376 -		}; \
  4.1377  	}; \
  4.1378  	\
  4.1379  	bool TestClass##id::ms_DoRecall = false; \
  4.1380  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
  4.1381  
  4.1382 -
  4.1383 -#define THGM_MAKE_TEST3_vafmt(id, ret_type, param1, param2, param3) \
  4.1384 -	struct TestClass##id; \
  4.1385 -	typedef ret_type RetType##id; \
  4.1386 -	typedef ParamState3<0, param1, param2, param3 > ParamState_m##id; \
  4.1387 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1388 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1389 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1390 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1391 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1392 -	\
  4.1393 -	struct TestClass##id \
  4.1394 -	{ \
  4.1395 -		static bool ms_DoRecall; \
  4.1396 -		\
  4.1397 -		virtual ret_type Func(param1 p1, param2 p2, param3 p3) \
  4.1398 -		{ \
  4.1399 -			g_Inside_LeafFunc = true; \
  4.1400 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3))); \
  4.1401 -			g_Inside_LeafFunc = false; \
  4.1402 -			\
  4.1403 -			return MakeRet< ret_type >::Do(0); \
  4.1404 -		} \
  4.1405 -		\
  4.1406 -		struct Delegate1 : public MyDelegate \
  4.1407 -		{ \
  4.1408 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1409 -			{ \
  4.1410 -				g_Inside_LeafFunc = true; \
  4.1411 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1412 -				g_Inside_LeafFunc = false; \
  4.1413 -				if (ms_DoRecall) \
  4.1414 -				{ \
  4.1415 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1416 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3)); \
  4.1417 -				} \
  4.1418 -				else \
  4.1419 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1420 -			} \
  4.1421 -		}; \
  4.1422 -		struct Delegate2 : public MyDelegate \
  4.1423 -		{ \
  4.1424 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1425 -			{ \
  4.1426 -				g_Inside_LeafFunc = true; \
  4.1427 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1428 -				g_Inside_LeafFunc = false; \
  4.1429 -				if (ms_DoRecall) \
  4.1430 -				{ \
  4.1431 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1432 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3)); \
  4.1433 -				} \
  4.1434 -				else \
  4.1435 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1436 -			} \
  4.1437 -		}; \
  4.1438 -		struct Delegate3 : public MyDelegate \
  4.1439 -		{ \
  4.1440 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1441 -			{ \
  4.1442 -				g_Inside_LeafFunc = true; \
  4.1443 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1444 -				g_Inside_LeafFunc = false; \
  4.1445 -				if (ms_DoRecall) \
  4.1446 -				{ \
  4.1447 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1448 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3)); \
  4.1449 -				} \
  4.1450 -				else \
  4.1451 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.1452 -			} \
  4.1453 -		}; \
  4.1454 -		struct Delegate4 : public MyDelegate \
  4.1455 -		{ \
  4.1456 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3) \
  4.1457 -			{ \
  4.1458 -				g_Inside_LeafFunc = true; \
  4.1459 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3))); \
  4.1460 -				g_Inside_LeafFunc = false; \
  4.1461 -				if (ms_DoRecall) \
  4.1462 -				{ \
  4.1463 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3); \
  4.1464 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3)); \
  4.1465 -				} \
  4.1466 -				else \
  4.1467 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.1468 -			}; \
  4.1469 -		}; \
  4.1470 -	}; \
  4.1471 -	\
  4.1472 -	bool TestClass##id::ms_DoRecall = false; \
  4.1473 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
  4.1474 -
  4.1475 -
  4.1476  #define THGM_SETUP_PI3(id, p1_type, p1_passtype, p1_flags, p2_type, p2_passtype, p2_flags, p3_type, p3_passtype, p3_flags) \
  4.1477  	void setuppi_##id() \
  4.1478  	{ \
  4.1479 @@ -2073,10 +1121,7 @@
  4.1480  	struct TestClass##id; \
  4.1481  	typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \
  4.1482  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1483 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1484 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1485 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1486 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1487 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1488  	\
  4.1489  	struct TestClass##id \
  4.1490  	{ \
  4.1491 @@ -2089,70 +1134,25 @@
  4.1492  			g_Inside_LeafFunc = false; \
  4.1493  		} \
  4.1494  		\
  4.1495 -		struct Delegate1 : public MyDelegate \
  4.1496 +		struct Delegate : public MyDelegate \
  4.1497  		{ \
  4.1498 +			int m_DelegNumber; \
  4.1499 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1500 +			\
  4.1501  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1502  			{ \
  4.1503  				g_Inside_LeafFunc = true; \
  4.1504 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1505 -				g_Inside_LeafFunc = false; \
  4.1506 -				if (ms_DoRecall) \
  4.1507 -				{ \
  4.1508 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1509 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1510 -				} \
  4.1511 -				else \
  4.1512 -					RETURN_META(MRES_IGNORED); \
  4.1513 -			} \
  4.1514 -		}; \
  4.1515 -		struct Delegate2 : public MyDelegate \
  4.1516 -		{ \
  4.1517 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1518 -			{ \
  4.1519 -				g_Inside_LeafFunc = true; \
  4.1520 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1521 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1522  				g_Inside_LeafFunc = false; \
  4.1523  				if (ms_DoRecall) \
  4.1524  				{ \
  4.1525  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1526 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1527 -				} \
  4.1528 -				else \
  4.1529 -					RETURN_META(MRES_SUPERCEDE); \
  4.1530 -			} \
  4.1531 -		}; \
  4.1532 -		struct Delegate3 : public MyDelegate \
  4.1533 -		{ \
  4.1534 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1535 -			{ \
  4.1536 -				g_Inside_LeafFunc = true; \
  4.1537 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1538 -				g_Inside_LeafFunc = false; \
  4.1539 -				if (ms_DoRecall) \
  4.1540 -				{ \
  4.1541 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1542 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1543 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1544  				} \
  4.1545  				else \
  4.1546 -					RETURN_META(MRES_IGNORED); \
  4.1547 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.1548  			} \
  4.1549  		}; \
  4.1550 -		struct Delegate4 : public MyDelegate \
  4.1551 -		{ \
  4.1552 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1553 -			{ \
  4.1554 -				g_Inside_LeafFunc = true; \
  4.1555 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1556 -				g_Inside_LeafFunc = false; \
  4.1557 -				if (ms_DoRecall) \
  4.1558 -				{ \
  4.1559 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1560 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1561 -				} \
  4.1562 -				else \
  4.1563 -					RETURN_META(MRES_SUPERCEDE); \
  4.1564 -			}; \
  4.1565 -		}; \
  4.1566  	}; \
  4.1567  	\
  4.1568  	bool TestClass##id::ms_DoRecall = false; \
  4.1569 @@ -2164,10 +1164,7 @@
  4.1570  	typedef ret_type RetType##id; \
  4.1571  	typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \
  4.1572  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1573 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1574 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1575 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1576 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1577 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1578  	\
  4.1579  	struct TestClass##id \
  4.1580  	{ \
  4.1581 @@ -2182,70 +1179,25 @@
  4.1582  			return MakeRet< ret_type >::Do(0); \
  4.1583  		} \
  4.1584  		\
  4.1585 -		struct Delegate1 : public MyDelegate \
  4.1586 +		struct Delegate : public MyDelegate \
  4.1587  		{ \
  4.1588 +			int m_DelegNumber; \
  4.1589 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1590 +			\
  4.1591  			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1592  			{ \
  4.1593  				g_Inside_LeafFunc = true; \
  4.1594 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1595 -				g_Inside_LeafFunc = false; \
  4.1596 -				if (ms_DoRecall) \
  4.1597 -				{ \
  4.1598 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1599 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1600 -				} \
  4.1601 -				else \
  4.1602 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1603 -			} \
  4.1604 -		}; \
  4.1605 -		struct Delegate2 : public MyDelegate \
  4.1606 -		{ \
  4.1607 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1608 -			{ \
  4.1609 -				g_Inside_LeafFunc = true; \
  4.1610 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1611 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1612  				g_Inside_LeafFunc = false; \
  4.1613  				if (ms_DoRecall) \
  4.1614  				{ \
  4.1615  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1616 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1617 -				} \
  4.1618 -				else \
  4.1619 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1620 -			} \
  4.1621 -		}; \
  4.1622 -		struct Delegate3 : public MyDelegate \
  4.1623 -		{ \
  4.1624 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1625 -			{ \
  4.1626 -				g_Inside_LeafFunc = true; \
  4.1627 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1628 -				g_Inside_LeafFunc = false; \
  4.1629 -				if (ms_DoRecall) \
  4.1630 -				{ \
  4.1631 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1632 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1633 +					RETURN_META_VALUE_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1634  				} \
  4.1635  				else \
  4.1636 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.1637 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
  4.1638  			} \
  4.1639  		}; \
  4.1640 -		struct Delegate4 : public MyDelegate \
  4.1641 -		{ \
  4.1642 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1643 -			{ \
  4.1644 -				g_Inside_LeafFunc = true; \
  4.1645 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1646 -				g_Inside_LeafFunc = false; \
  4.1647 -				if (ms_DoRecall) \
  4.1648 -				{ \
  4.1649 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1650 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1651 -				} \
  4.1652 -				else \
  4.1653 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.1654 -			}; \
  4.1655 -		}; \
  4.1656  	}; \
  4.1657  	\
  4.1658  	bool TestClass##id::ms_DoRecall = false; \
  4.1659 @@ -2255,10 +1207,7 @@
  4.1660  	struct TestClass##id; \
  4.1661  	typedef ParamState5<0, param1, param2, param3, param4, std::string > ParamState_m##id; \
  4.1662  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1663 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1664 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1665 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1666 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1667 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1668  	\
  4.1669  	struct TestClass##id \
  4.1670  	{ \
  4.1671 @@ -2279,169 +1228,30 @@
  4.1672  			g_Inside_LeafFunc = false; \
  4.1673  		} \
  4.1674  		\
  4.1675 -		struct Delegate1 : public MyDelegate \
  4.1676 +		struct Delegate : public MyDelegate \
  4.1677  		{ \
  4.1678 +			int m_DelegNumber; \
  4.1679 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1680 +			\
  4.1681  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \
  4.1682  			{ \
  4.1683  				g_Inside_LeafFunc = true; \
  4.1684 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \
  4.1685 -				g_Inside_LeafFunc = false; \
  4.1686 -				if (ms_DoRecall) \
  4.1687 -				{ \
  4.1688 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1689 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \
  4.1690 -				} \
  4.1691 -				else \
  4.1692 -					RETURN_META(MRES_IGNORED); \
  4.1693 -			} \
  4.1694 -		}; \
  4.1695 -		struct Delegate2 : public MyDelegate \
  4.1696 -		{ \
  4.1697 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \
  4.1698 -			{ \
  4.1699 -				g_Inside_LeafFunc = true; \
  4.1700 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \
  4.1701 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \
  4.1702  				g_Inside_LeafFunc = false; \
  4.1703  				if (ms_DoRecall) \
  4.1704  				{ \
  4.1705  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1706 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \
  4.1707 -				} \
  4.1708 -				else \
  4.1709 -					RETURN_META(MRES_SUPERCEDE); \
  4.1710 -			} \
  4.1711 -		}; \
  4.1712 -		struct Delegate3 : public MyDelegate \
  4.1713 -		{ \
  4.1714 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \
  4.1715 -			{ \
  4.1716 -				g_Inside_LeafFunc = true; \
  4.1717 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \
  4.1718 -				g_Inside_LeafFunc = false; \
  4.1719 -				if (ms_DoRecall) \
  4.1720 -				{ \
  4.1721 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1722 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \
  4.1723 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \
  4.1724  				} \
  4.1725  				else \
  4.1726 -					RETURN_META(MRES_IGNORED); \
  4.1727 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.1728  			} \
  4.1729  		}; \
  4.1730 -		struct Delegate4 : public MyDelegate \
  4.1731 -		{ \
  4.1732 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, const char *buf) \
  4.1733 -			{ \
  4.1734 -				g_Inside_LeafFunc = true; \
  4.1735 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, buf))); \
  4.1736 -				g_Inside_LeafFunc = false; \
  4.1737 -				if (ms_DoRecall) \
  4.1738 -				{ \
  4.1739 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1740 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, "%s!", buf)); \
  4.1741 -				} \
  4.1742 -				else \
  4.1743 -					RETURN_META(MRES_SUPERCEDE); \
  4.1744 -			}; \
  4.1745 -		}; \
  4.1746  	}; \
  4.1747  	\
  4.1748  	bool TestClass##id::ms_DoRecall = false; \
  4.1749  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
  4.1750  
  4.1751 -
  4.1752 -#define THGM_MAKE_TEST4_vafmt(id, ret_type, param1, param2, param3, param4) \
  4.1753 -	struct TestClass##id; \
  4.1754 -	typedef ret_type RetType##id; \
  4.1755 -	typedef ParamState4<0, param1, param2, param3, param4 > ParamState_m##id; \
  4.1756 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1757 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1758 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1759 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1760 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1761 -	\
  4.1762 -	struct TestClass##id \
  4.1763 -	{ \
  4.1764 -		static bool ms_DoRecall; \
  4.1765 -		\
  4.1766 -		virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1767 -		{ \
  4.1768 -			g_Inside_LeafFunc = true; \
  4.1769 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4))); \
  4.1770 -			g_Inside_LeafFunc = false; \
  4.1771 -			\
  4.1772 -			return MakeRet< ret_type >::Do(0); \
  4.1773 -		} \
  4.1774 -		\
  4.1775 -		struct Delegate1 : public MyDelegate \
  4.1776 -		{ \
  4.1777 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1778 -			{ \
  4.1779 -				g_Inside_LeafFunc = true; \
  4.1780 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1781 -				g_Inside_LeafFunc = false; \
  4.1782 -				if (ms_DoRecall) \
  4.1783 -				{ \
  4.1784 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1785 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1786 -				} \
  4.1787 -				else \
  4.1788 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1789 -			} \
  4.1790 -		}; \
  4.1791 -		struct Delegate2 : public MyDelegate \
  4.1792 -		{ \
  4.1793 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1794 -			{ \
  4.1795 -				g_Inside_LeafFunc = true; \
  4.1796 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1797 -				g_Inside_LeafFunc = false; \
  4.1798 -				if (ms_DoRecall) \
  4.1799 -				{ \
  4.1800 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1801 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1802 -				} \
  4.1803 -				else \
  4.1804 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1805 -			} \
  4.1806 -		}; \
  4.1807 -		struct Delegate3 : public MyDelegate \
  4.1808 -		{ \
  4.1809 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1810 -			{ \
  4.1811 -				g_Inside_LeafFunc = true; \
  4.1812 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1813 -				g_Inside_LeafFunc = false; \
  4.1814 -				if (ms_DoRecall) \
  4.1815 -				{ \
  4.1816 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1817 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1818 -				} \
  4.1819 -				else \
  4.1820 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.1821 -			} \
  4.1822 -		}; \
  4.1823 -		struct Delegate4 : public MyDelegate \
  4.1824 -		{ \
  4.1825 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4) \
  4.1826 -			{ \
  4.1827 -				g_Inside_LeafFunc = true; \
  4.1828 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4))); \
  4.1829 -				g_Inside_LeafFunc = false; \
  4.1830 -				if (ms_DoRecall) \
  4.1831 -				{ \
  4.1832 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4); \
  4.1833 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4)); \
  4.1834 -				} \
  4.1835 -				else \
  4.1836 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.1837 -			}; \
  4.1838 -		}; \
  4.1839 -	}; \
  4.1840 -	\
  4.1841 -	bool TestClass##id::ms_DoRecall = false; \
  4.1842 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
  4.1843 -
  4.1844 -
  4.1845  #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) \
  4.1846  	void setuppi_##id() \
  4.1847  	{ \
  4.1848 @@ -2482,10 +1292,7 @@
  4.1849  	struct TestClass##id; \
  4.1850  	typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \
  4.1851  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1852 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1853 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1854 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1855 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1856 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1857  	\
  4.1858  	struct TestClass##id \
  4.1859  	{ \
  4.1860 @@ -2498,70 +1305,25 @@
  4.1861  			g_Inside_LeafFunc = false; \
  4.1862  		} \
  4.1863  		\
  4.1864 -		struct Delegate1 : public MyDelegate \
  4.1865 +		struct Delegate : public MyDelegate \
  4.1866  		{ \
  4.1867 +			int m_DelegNumber; \
  4.1868 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1869 +			\
  4.1870  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1871  			{ \
  4.1872  				g_Inside_LeafFunc = true; \
  4.1873 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1874 -				g_Inside_LeafFunc = false; \
  4.1875 -				if (ms_DoRecall) \
  4.1876 -				{ \
  4.1877 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1878 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1879 -				} \
  4.1880 -				else \
  4.1881 -					RETURN_META(MRES_IGNORED); \
  4.1882 -			} \
  4.1883 -		}; \
  4.1884 -		struct Delegate2 : public MyDelegate \
  4.1885 -		{ \
  4.1886 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1887 -			{ \
  4.1888 -				g_Inside_LeafFunc = true; \
  4.1889 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1890 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1891  				g_Inside_LeafFunc = false; \
  4.1892  				if (ms_DoRecall) \
  4.1893  				{ \
  4.1894  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1895 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1896 -				} \
  4.1897 -				else \
  4.1898 -					RETURN_META(MRES_SUPERCEDE); \
  4.1899 -			} \
  4.1900 -		}; \
  4.1901 -		struct Delegate3 : public MyDelegate \
  4.1902 -		{ \
  4.1903 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1904 -			{ \
  4.1905 -				g_Inside_LeafFunc = true; \
  4.1906 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1907 -				g_Inside_LeafFunc = false; \
  4.1908 -				if (ms_DoRecall) \
  4.1909 -				{ \
  4.1910 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1911 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1912 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1913  				} \
  4.1914  				else \
  4.1915 -					RETURN_META(MRES_IGNORED); \
  4.1916 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.1917  			} \
  4.1918  		}; \
  4.1919 -		struct Delegate4 : public MyDelegate \
  4.1920 -		{ \
  4.1921 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1922 -			{ \
  4.1923 -				g_Inside_LeafFunc = true; \
  4.1924 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1925 -				g_Inside_LeafFunc = false; \
  4.1926 -				if (ms_DoRecall) \
  4.1927 -				{ \
  4.1928 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1929 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1930 -				} \
  4.1931 -				else \
  4.1932 -					RETURN_META(MRES_SUPERCEDE); \
  4.1933 -			}; \
  4.1934 -		}; \
  4.1935  	}; \
  4.1936  	\
  4.1937  	bool TestClass##id::ms_DoRecall = false; \
  4.1938 @@ -2573,10 +1335,7 @@
  4.1939  	typedef ret_type RetType##id; \
  4.1940  	typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \
  4.1941  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.1942 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1943 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1944 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1945 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1946 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.1947  	\
  4.1948  	struct TestClass##id \
  4.1949  	{ \
  4.1950 @@ -2591,70 +1350,25 @@
  4.1951  			return MakeRet< ret_type >::Do(0); \
  4.1952  		} \
  4.1953  		\
  4.1954 -		struct Delegate1 : public MyDelegate \
  4.1955 +		struct Delegate : public MyDelegate \
  4.1956  		{ \
  4.1957 +			int m_DelegNumber; \
  4.1958 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.1959 +			\
  4.1960  			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1961  			{ \
  4.1962  				g_Inside_LeafFunc = true; \
  4.1963 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1964 -				g_Inside_LeafFunc = false; \
  4.1965 -				if (ms_DoRecall) \
  4.1966 -				{ \
  4.1967 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1968 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1969 -				} \
  4.1970 -				else \
  4.1971 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.1972 -			} \
  4.1973 -		}; \
  4.1974 -		struct Delegate2 : public MyDelegate \
  4.1975 -		{ \
  4.1976 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1977 -			{ \
  4.1978 -				g_Inside_LeafFunc = true; \
  4.1979 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1980 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1981  				g_Inside_LeafFunc = false; \
  4.1982  				if (ms_DoRecall) \
  4.1983  				{ \
  4.1984  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.1985 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.1986 -				} \
  4.1987 -				else \
  4.1988 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.1989 -			} \
  4.1990 -		}; \
  4.1991 -		struct Delegate3 : public MyDelegate \
  4.1992 -		{ \
  4.1993 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.1994 -			{ \
  4.1995 -				g_Inside_LeafFunc = true; \
  4.1996 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.1997 -				g_Inside_LeafFunc = false; \
  4.1998 -				if (ms_DoRecall) \
  4.1999 -				{ \
  4.2000 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2001 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2002 +					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)); \
  4.2003  				} \
  4.2004  				else \
  4.2005 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.2006 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
  4.2007  			} \
  4.2008  		}; \
  4.2009 -		struct Delegate4 : public MyDelegate \
  4.2010 -		{ \
  4.2011 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2012 -			{ \
  4.2013 -				g_Inside_LeafFunc = true; \
  4.2014 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2015 -				g_Inside_LeafFunc = false; \
  4.2016 -				if (ms_DoRecall) \
  4.2017 -				{ \
  4.2018 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2019 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2020 -				} \
  4.2021 -				else \
  4.2022 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.2023 -			}; \
  4.2024 -		}; \
  4.2025  	}; \
  4.2026  	\
  4.2027  	bool TestClass##id::ms_DoRecall = false; \
  4.2028 @@ -2664,10 +1378,7 @@
  4.2029  	struct TestClass##id; \
  4.2030  	typedef ParamState6<0, param1, param2, param3, param4, param5, std::string > ParamState_m##id; \
  4.2031  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2032 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2033 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2034 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2035 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2036 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2037  	\
  4.2038  	struct TestClass##id \
  4.2039  	{ \
  4.2040 @@ -2688,169 +1399,30 @@
  4.2041  			g_Inside_LeafFunc = false; \
  4.2042  		} \
  4.2043  		\
  4.2044 -		struct Delegate1 : public MyDelegate \
  4.2045 +		struct Delegate : public MyDelegate \
  4.2046  		{ \
  4.2047 +			int m_DelegNumber; \
  4.2048 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.2049 +			\
  4.2050  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \
  4.2051  			{ \
  4.2052  				g_Inside_LeafFunc = true; \
  4.2053 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \
  4.2054 -				g_Inside_LeafFunc = false; \
  4.2055 -				if (ms_DoRecall) \
  4.2056 -				{ \
  4.2057 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2058 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \
  4.2059 -				} \
  4.2060 -				else \
  4.2061 -					RETURN_META(MRES_IGNORED); \
  4.2062 -			} \
  4.2063 -		}; \
  4.2064 -		struct Delegate2 : public MyDelegate \
  4.2065 -		{ \
  4.2066 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \
  4.2067 -			{ \
  4.2068 -				g_Inside_LeafFunc = true; \
  4.2069 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \
  4.2070 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \
  4.2071  				g_Inside_LeafFunc = false; \
  4.2072  				if (ms_DoRecall) \
  4.2073  				{ \
  4.2074  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2075 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \
  4.2076 -				} \
  4.2077 -				else \
  4.2078 -					RETURN_META(MRES_SUPERCEDE); \
  4.2079 -			} \
  4.2080 -		}; \
  4.2081 -		struct Delegate3 : public MyDelegate \
  4.2082 -		{ \
  4.2083 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \
  4.2084 -			{ \
  4.2085 -				g_Inside_LeafFunc = true; \
  4.2086 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \
  4.2087 -				g_Inside_LeafFunc = false; \
  4.2088 -				if (ms_DoRecall) \
  4.2089 -				{ \
  4.2090 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2091 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \
  4.2092 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \
  4.2093  				} \
  4.2094  				else \
  4.2095 -					RETURN_META(MRES_IGNORED); \
  4.2096 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.2097  			} \
  4.2098  		}; \
  4.2099 -		struct Delegate4 : public MyDelegate \
  4.2100 -		{ \
  4.2101 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, const char *buf) \
  4.2102 -			{ \
  4.2103 -				g_Inside_LeafFunc = true; \
  4.2104 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, buf))); \
  4.2105 -				g_Inside_LeafFunc = false; \
  4.2106 -				if (ms_DoRecall) \
  4.2107 -				{ \
  4.2108 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2109 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, "%s!", buf)); \
  4.2110 -				} \
  4.2111 -				else \
  4.2112 -					RETURN_META(MRES_SUPERCEDE); \
  4.2113 -			}; \
  4.2114 -		}; \
  4.2115  	}; \
  4.2116  	\
  4.2117  	bool TestClass##id::ms_DoRecall = false; \
  4.2118  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
  4.2119  
  4.2120 -
  4.2121 -#define THGM_MAKE_TEST5_vafmt(id, ret_type, param1, param2, param3, param4, param5) \
  4.2122 -	struct TestClass##id; \
  4.2123 -	typedef ret_type RetType##id; \
  4.2124 -	typedef ParamState5<0, param1, param2, param3, param4, param5 > ParamState_m##id; \
  4.2125 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2126 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2127 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2128 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2129 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2130 -	\
  4.2131 -	struct TestClass##id \
  4.2132 -	{ \
  4.2133 -		static bool ms_DoRecall; \
  4.2134 -		\
  4.2135 -		virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2136 -		{ \
  4.2137 -			g_Inside_LeafFunc = true; \
  4.2138 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2139 -			g_Inside_LeafFunc = false; \
  4.2140 -			\
  4.2141 -			return MakeRet< ret_type >::Do(0); \
  4.2142 -		} \
  4.2143 -		\
  4.2144 -		struct Delegate1 : public MyDelegate \
  4.2145 -		{ \
  4.2146 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2147 -			{ \
  4.2148 -				g_Inside_LeafFunc = true; \
  4.2149 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2150 -				g_Inside_LeafFunc = false; \
  4.2151 -				if (ms_DoRecall) \
  4.2152 -				{ \
  4.2153 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2154 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2155 -				} \
  4.2156 -				else \
  4.2157 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.2158 -			} \
  4.2159 -		}; \
  4.2160 -		struct Delegate2 : public MyDelegate \
  4.2161 -		{ \
  4.2162 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2163 -			{ \
  4.2164 -				g_Inside_LeafFunc = true; \
  4.2165 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2166 -				g_Inside_LeafFunc = false; \
  4.2167 -				if (ms_DoRecall) \
  4.2168 -				{ \
  4.2169 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2170 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2171 -				} \
  4.2172 -				else \
  4.2173 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.2174 -			} \
  4.2175 -		}; \
  4.2176 -		struct Delegate3 : public MyDelegate \
  4.2177 -		{ \
  4.2178 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2179 -			{ \
  4.2180 -				g_Inside_LeafFunc = true; \
  4.2181 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2182 -				g_Inside_LeafFunc = false; \
  4.2183 -				if (ms_DoRecall) \
  4.2184 -				{ \
  4.2185 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2186 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2187 -				} \
  4.2188 -				else \
  4.2189 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.2190 -			} \
  4.2191 -		}; \
  4.2192 -		struct Delegate4 : public MyDelegate \
  4.2193 -		{ \
  4.2194 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
  4.2195 -			{ \
  4.2196 -				g_Inside_LeafFunc = true; \
  4.2197 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5))); \
  4.2198 -				g_Inside_LeafFunc = false; \
  4.2199 -				if (ms_DoRecall) \
  4.2200 -				{ \
  4.2201 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5); \
  4.2202 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5)); \
  4.2203 -				} \
  4.2204 -				else \
  4.2205 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.2206 -			}; \
  4.2207 -		}; \
  4.2208 -	}; \
  4.2209 -	\
  4.2210 -	bool TestClass##id::ms_DoRecall = false; \
  4.2211 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
  4.2212 -
  4.2213 -
  4.2214  #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) \
  4.2215  	void setuppi_##id() \
  4.2216  	{ \
  4.2217 @@ -2898,10 +1470,7 @@
  4.2218  	struct TestClass##id; \
  4.2219  	typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \
  4.2220  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2221 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2222 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2223 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2224 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2225 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2226  	\
  4.2227  	struct TestClass##id \
  4.2228  	{ \
  4.2229 @@ -2914,70 +1483,25 @@
  4.2230  			g_Inside_LeafFunc = false; \
  4.2231  		} \
  4.2232  		\
  4.2233 -		struct Delegate1 : public MyDelegate \
  4.2234 +		struct Delegate : public MyDelegate \
  4.2235  		{ \
  4.2236 +			int m_DelegNumber; \
  4.2237 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.2238 +			\
  4.2239  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2240  			{ \
  4.2241  				g_Inside_LeafFunc = true; \
  4.2242 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2243 -				g_Inside_LeafFunc = false; \
  4.2244 -				if (ms_DoRecall) \
  4.2245 -				{ \
  4.2246 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2247 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2248 -				} \
  4.2249 -				else \
  4.2250 -					RETURN_META(MRES_IGNORED); \
  4.2251 -			} \
  4.2252 -		}; \
  4.2253 -		struct Delegate2 : public MyDelegate \
  4.2254 -		{ \
  4.2255 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2256 -			{ \
  4.2257 -				g_Inside_LeafFunc = true; \
  4.2258 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2259 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2260  				g_Inside_LeafFunc = false; \
  4.2261  				if (ms_DoRecall) \
  4.2262  				{ \
  4.2263  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2264 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2265 -				} \
  4.2266 -				else \
  4.2267 -					RETURN_META(MRES_SUPERCEDE); \
  4.2268 -			} \
  4.2269 -		}; \
  4.2270 -		struct Delegate3 : public MyDelegate \
  4.2271 -		{ \
  4.2272 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2273 -			{ \
  4.2274 -				g_Inside_LeafFunc = true; \
  4.2275 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2276 -				g_Inside_LeafFunc = false; \
  4.2277 -				if (ms_DoRecall) \
  4.2278 -				{ \
  4.2279 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2280 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2281 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2282  				} \
  4.2283  				else \
  4.2284 -					RETURN_META(MRES_IGNORED); \
  4.2285 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.2286  			} \
  4.2287  		}; \
  4.2288 -		struct Delegate4 : public MyDelegate \
  4.2289 -		{ \
  4.2290 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2291 -			{ \
  4.2292 -				g_Inside_LeafFunc = true; \
  4.2293 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2294 -				g_Inside_LeafFunc = false; \
  4.2295 -				if (ms_DoRecall) \
  4.2296 -				{ \
  4.2297 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2298 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2299 -				} \
  4.2300 -				else \
  4.2301 -					RETURN_META(MRES_SUPERCEDE); \
  4.2302 -			}; \
  4.2303 -		}; \
  4.2304  	}; \
  4.2305  	\
  4.2306  	bool TestClass##id::ms_DoRecall = false; \
  4.2307 @@ -2989,10 +1513,7 @@
  4.2308  	typedef ret_type RetType##id; \
  4.2309  	typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \
  4.2310  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2311 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2312 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2313 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2314 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2315 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2316  	\
  4.2317  	struct TestClass##id \
  4.2318  	{ \
  4.2319 @@ -3007,70 +1528,25 @@
  4.2320  			return MakeRet< ret_type >::Do(0); \
  4.2321  		} \
  4.2322  		\
  4.2323 -		struct Delegate1 : public MyDelegate \
  4.2324 +		struct Delegate : public MyDelegate \
  4.2325  		{ \
  4.2326 +			int m_DelegNumber; \
  4.2327 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.2328 +			\
  4.2329  			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2330  			{ \
  4.2331  				g_Inside_LeafFunc = true; \
  4.2332 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2333 -				g_Inside_LeafFunc = false; \
  4.2334 -				if (ms_DoRecall) \
  4.2335 -				{ \
  4.2336 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2337 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2338 -				} \
  4.2339 -				else \
  4.2340 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.2341 -			} \
  4.2342 -		}; \
  4.2343 -		struct Delegate2 : public MyDelegate \
  4.2344 -		{ \
  4.2345 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2346 -			{ \
  4.2347 -				g_Inside_LeafFunc = true; \
  4.2348 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2349 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2350  				g_Inside_LeafFunc = false; \
  4.2351  				if (ms_DoRecall) \
  4.2352  				{ \
  4.2353  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2354 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2355 -				} \
  4.2356 -				else \
  4.2357 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.2358 -			} \
  4.2359 -		}; \
  4.2360 -		struct Delegate3 : public MyDelegate \
  4.2361 -		{ \
  4.2362 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2363 -			{ \
  4.2364 -				g_Inside_LeafFunc = true; \
  4.2365 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2366 -				g_Inside_LeafFunc = false; \
  4.2367 -				if (ms_DoRecall) \
  4.2368 -				{ \
  4.2369 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2370 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2371 +					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)); \
  4.2372  				} \
  4.2373  				else \
  4.2374 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.2375 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
  4.2376  			} \
  4.2377  		}; \
  4.2378 -		struct Delegate4 : public MyDelegate \
  4.2379 -		{ \
  4.2380 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2381 -			{ \
  4.2382 -				g_Inside_LeafFunc = true; \
  4.2383 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2384 -				g_Inside_LeafFunc = false; \
  4.2385 -				if (ms_DoRecall) \
  4.2386 -				{ \
  4.2387 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2388 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2389 -				} \
  4.2390 -				else \
  4.2391 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.2392 -			}; \
  4.2393 -		}; \
  4.2394  	}; \
  4.2395  	\
  4.2396  	bool TestClass##id::ms_DoRecall = false; \
  4.2397 @@ -3080,10 +1556,7 @@
  4.2398  	struct TestClass##id; \
  4.2399  	typedef ParamState7<0, param1, param2, param3, param4, param5, param6, std::string > ParamState_m##id; \
  4.2400  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2401 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2402 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2403 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2404 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2405 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2406  	\
  4.2407  	struct TestClass##id \
  4.2408  	{ \
  4.2409 @@ -3104,169 +1577,30 @@
  4.2410  			g_Inside_LeafFunc = false; \
  4.2411  		} \
  4.2412  		\
  4.2413 -		struct Delegate1 : public MyDelegate \
  4.2414 +		struct Delegate : public MyDelegate \
  4.2415  		{ \
  4.2416 +			int m_DelegNumber; \
  4.2417 +			Delegate(int num) : m_DelegNumber(num) { } \
  4.2418 +			\
  4.2419  			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \
  4.2420  			{ \
  4.2421  				g_Inside_LeafFunc = true; \
  4.2422 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \
  4.2423 -				g_Inside_LeafFunc = false; \
  4.2424 -				if (ms_DoRecall) \
  4.2425 -				{ \
  4.2426 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2427 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \
  4.2428 -				} \
  4.2429 -				else \
  4.2430 -					RETURN_META(MRES_IGNORED); \
  4.2431 -			} \
  4.2432 -		}; \
  4.2433 -		struct Delegate2 : public MyDelegate \
  4.2434 -		{ \
  4.2435 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \
  4.2436 -			{ \
  4.2437 -				g_Inside_LeafFunc = true; \
  4.2438 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \
  4.2439 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \
  4.2440  				g_Inside_LeafFunc = false; \
  4.2441  				if (ms_DoRecall) \
  4.2442  				{ \
  4.2443  					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2444 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \
  4.2445 -				} \
  4.2446 -				else \
  4.2447 -					RETURN_META(MRES_SUPERCEDE); \
  4.2448 -			} \
  4.2449 -		}; \
  4.2450 -		struct Delegate3 : public MyDelegate \
  4.2451 -		{ \
  4.2452 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \
  4.2453 -			{ \
  4.2454 -				g_Inside_LeafFunc = true; \
  4.2455 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \
  4.2456 -				g_Inside_LeafFunc = false; \
  4.2457 -				if (ms_DoRecall) \
  4.2458 -				{ \
  4.2459 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2460 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \
  4.2461 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \
  4.2462  				} \
  4.2463  				else \
  4.2464 -					RETURN_META(MRES_IGNORED); \
  4.2465 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
  4.2466  			} \
  4.2467  		}; \
  4.2468 -		struct Delegate4 : public MyDelegate \
  4.2469 -		{ \
  4.2470 -			virtual void Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, const char *buf) \
  4.2471 -			{ \
  4.2472 -				g_Inside_LeafFunc = true; \
  4.2473 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6, buf))); \
  4.2474 -				g_Inside_LeafFunc = false; \
  4.2475 -				if (ms_DoRecall) \
  4.2476 -				{ \
  4.2477 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2478 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (p1, p2, p3, p4, p5, p6, "%s!", buf)); \
  4.2479 -				} \
  4.2480 -				else \
  4.2481 -					RETURN_META(MRES_SUPERCEDE); \
  4.2482 -			}; \
  4.2483 -		}; \
  4.2484  	}; \
  4.2485  	\
  4.2486  	bool TestClass##id::ms_DoRecall = false; \
  4.2487  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
  4.2488  
  4.2489 -
  4.2490 -#define THGM_MAKE_TEST6_vafmt(id, ret_type, param1, param2, param3, param4, param5, param6) \
  4.2491 -	struct TestClass##id; \
  4.2492 -	typedef ret_type RetType##id; \
  4.2493 -	typedef ParamState6<0, param1, param2, param3, param4, param5, param6 > ParamState_m##id; \
  4.2494 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
  4.2495 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2496 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2497 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2498 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
  4.2499 -	\
  4.2500 -	struct TestClass##id \
  4.2501 -	{ \
  4.2502 -		static bool ms_DoRecall; \
  4.2503 -		\
  4.2504 -		virtual ret_type Func(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2505 -		{ \
  4.2506 -			g_Inside_LeafFunc = true; \
  4.2507 -			ADD_STATE(State_Func##id(this, ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2508 -			g_Inside_LeafFunc = false; \
  4.2509 -			\
  4.2510 -			return MakeRet< ret_type >::Do(0); \
  4.2511 -		} \
  4.2512 -		\
  4.2513 -		struct Delegate1 : public MyDelegate \
  4.2514 -		{ \
  4.2515 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2516 -			{ \
  4.2517 -				g_Inside_LeafFunc = true; \
  4.2518 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2519 -				g_Inside_LeafFunc = false; \
  4.2520 -				if (ms_DoRecall) \
  4.2521 -				{ \
  4.2522 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2523 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2524 -				} \
  4.2525 -				else \
  4.2526 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
  4.2527 -			} \
  4.2528 -		}; \
  4.2529 -		struct Delegate2 : public MyDelegate \
  4.2530 -		{ \
  4.2531 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2532 -			{ \
  4.2533 -				g_Inside_LeafFunc = true; \
  4.2534 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2535 -				g_Inside_LeafFunc = false; \
  4.2536 -				if (ms_DoRecall) \
  4.2537 -				{ \
  4.2538 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2539 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2540 -				} \
  4.2541 -				else \
  4.2542 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
  4.2543 -			} \
  4.2544 -		}; \
  4.2545 -		struct Delegate3 : public MyDelegate \
  4.2546 -		{ \
  4.2547 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2548 -			{ \
  4.2549 -				g_Inside_LeafFunc = true; \
  4.2550 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2551 -				g_Inside_LeafFunc = false; \
  4.2552 -				if (ms_DoRecall) \
  4.2553 -				{ \
  4.2554 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2555 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2556 -				} \
  4.2557 -				else \
  4.2558 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
  4.2559 -			} \
  4.2560 -		}; \
  4.2561 -		struct Delegate4 : public MyDelegate \
  4.2562 -		{ \
  4.2563 -			virtual ret_type Call(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
  4.2564 -			{ \
  4.2565 -				g_Inside_LeafFunc = true; \
  4.2566 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(p1, p2, p3, p4, p5, p6))); \
  4.2567 -				g_Inside_LeafFunc = false; \
  4.2568 -				if (ms_DoRecall) \
  4.2569 -				{ \
  4.2570 -					Increment<StripRef< param1 >::type>::Incr(p1);Increment<StripRef< param2 >::type>::Incr(p2);Increment<StripRef< param3 >::type>::Incr(p3);Increment<StripRef< param4 >::type>::Incr(p4);Increment<StripRef< param5 >::type>::Incr(p5);Increment<StripRef< param6 >::type>::Incr(p6); \
  4.2571 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (p1, p2, p3, p4, p5, p6)); \
  4.2572 -				} \
  4.2573 -				else \
  4.2574 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
  4.2575 -			}; \
  4.2576 -		}; \
  4.2577 -	}; \
  4.2578 -	\
  4.2579 -	bool TestClass##id::ms_DoRecall = false; \
  4.2580 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
  4.2581 -
  4.2582 -
  4.2583  #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) \
  4.2584  	void setuppi_##id() \
  4.2585  	{ \
  4.2586 @@ -3330,7 +1664,7 @@
  4.2587  	
  4.2588  #define THGM_ADD_HOOK(id, num) \
  4.2589  	CAT4(hook, num, _, id) = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pTest##id), \
  4.2590 -		0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate##num), num >= 3);
  4.2591 +		0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate(num)), num >= 3);
  4.2592  
  4.2593  #define THGM_REMOVE_HOOK(id, num) \
  4.2594  	g_SHPtr->RemoveHookByID(CAT4(hook, num, _, id));
  4.2595 @@ -3357,37 +1691,15 @@
  4.2596  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2597  		NULL), "Test" #id " Part1"); \
  4.2598  	\
  4.2599 -			/* hook1 - no hooks */ \
  4.2600 -	PtrBuf_Clear(); \
  4.2601 -	THGM_ADD_HOOK(id, 1); \
  4.2602 -	THGM_CALLS_void(id, call_params); \
  4.2603 -	CHECK_STATES((&g_States, \
  4.2604 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2605 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2606 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2607 -		NULL), "Test" #id " Part2"); \
  4.2608 -	THGM_REMOVE_HOOK(id, 1); \
  4.2609 -	\
  4.2610 -			/* no hooks - hook3 */ \
  4.2611 -	PtrBuf_Clear(); \
  4.2612 -	THGM_ADD_HOOK(id, 3); \
  4.2613 -	THGM_CALLS_void(id, call_params); \
  4.2614 -	CHECK_STATES((&g_States, \
  4.2615 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2616 -		new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2617 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2618 -		NULL), "Test" #id " Part3"); \
  4.2619 -	THGM_REMOVE_HOOK(id, 3); \
  4.2620 -	\
  4.2621  			/* hook1 - hook3 */ \
  4.2622  	PtrBuf_Clear(); \
  4.2623  	THGM_ADD_HOOK(id, 1); \
  4.2624  	THGM_ADD_HOOK(id, 3); \
  4.2625  	THGM_CALLS_void(id, call_params); \
  4.2626  	CHECK_STATES((&g_States, \
  4.2627 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2628 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2629  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2630 -		new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2631 +		new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \
  4.2632  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2633  		NULL), "Test" #id " Part4"); \
  4.2634  	THGM_REMOVE_HOOK(id, 1); \
  4.2635 @@ -3400,26 +1712,19 @@
  4.2636  	THGM_ADD_HOOK(id, 3); \
  4.2637  	THGM_CALLS_void(id, call_params); \
  4.2638  	CHECK_STATES((&g_States, \
  4.2639 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2640 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2641 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
  4.2642 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2643 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
  4.2644 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
  4.2645  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2646  		NULL), "Test" #id " Part5"); \
  4.2647 -	THGM_REMOVE_HOOK(id, 1); \
  4.2648 -	THGM_REMOVE_HOOK(id, 2); \
  4.2649 -	THGM_REMOVE_HOOK(id, 3); \
  4.2650  			/* hook1, hook2 - hook3, hook4 */ \
  4.2651 -	PtrBuf_Clear(); \
  4.2652 -	THGM_ADD_HOOK(id, 1); \
  4.2653 -	THGM_ADD_HOOK(id, 2); \
  4.2654 -	THGM_ADD_HOOK(id, 3); \
  4.2655  	THGM_ADD_HOOK(id, 4); \
  4.2656  	THGM_CALLS_void(id, call_params); \
  4.2657  	CHECK_STATES((&g_States, \
  4.2658 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2659 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2660 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
  4.2661 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
  4.2662 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2663 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
  4.2664 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
  4.2665 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \
  4.2666  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2667  		NULL), "Test" #id " Part6"); \
  4.2668  		\
  4.2669 @@ -3429,10 +1734,10 @@
  4.2670  	THGM_REMOVE_HOOK(id, 2); \
  4.2671  	THGM_CALLS_void(id, call_params); \
  4.2672  	CHECK_STATES((&g_States, \
  4.2673 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
  4.2674 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \
  4.2675  		new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
  4.2676 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
  4.2677 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
  4.2678 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \
  4.2679 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \
  4.2680  		/* sh_call one */ \
  4.2681  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2682  		NULL), "Test" #id " Part7"); \
  4.2683 @@ -3475,37 +1780,15 @@
  4.2684  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2685  		NULL), "Test" #id " Part1"); \
  4.2686  	\
  4.2687 -			/* hook1 - no hooks */ \
  4.2688 -	PtrBuf_Clear(); \
  4.2689 -	THGM_ADD_HOOK(id, 1); \
  4.2690 -	THGM_CALLS(id, call_params, 0, 0, "Part2"); \
  4.2691 -	CHECK_STATES((&g_States, \
  4.2692 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2693 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2694 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2695 -		NULL), "Test" #id " Part2"); \
  4.2696 -	THGM_REMOVE_HOOK(id, 1); \
  4.2697 -	\
  4.2698 -			/* no hooks - hook3 */ \
  4.2699 -	PtrBuf_Clear(); \
  4.2700 -	THGM_ADD_HOOK(id, 3); \
  4.2701 -	THGM_CALLS(id, call_params, 0, 0, "Part3"); \
  4.2702 -	CHECK_STATES((&g_States, \
  4.2703 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2704 -		new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2705 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2706 -		NULL), "Test" #id " Part3"); \
  4.2707 -	THGM_REMOVE_HOOK(id, 3); \
  4.2708 -	\
  4.2709  			/* hook1 - hook3 */ \
  4.2710  	PtrBuf_Clear(); \
  4.2711  	THGM_ADD_HOOK(id, 1); \
  4.2712  	THGM_ADD_HOOK(id, 3); \
  4.2713  	THGM_CALLS(id, call_params, 0, 0, "Part4"); \
  4.2714  	CHECK_STATES((&g_States, \
  4.2715 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2716 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2717  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2718 -		new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2719 +		new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \
  4.2720  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2721  		NULL), "Test" #id " Part4"); \
  4.2722  	THGM_REMOVE_HOOK(id, 1); \
  4.2723 @@ -3518,26 +1801,19 @@
  4.2724  	THGM_ADD_HOOK(id, 3); \
  4.2725  	THGM_CALLS(id, call_params, 2, 0, "Part5"); \
  4.2726  	CHECK_STATES((&g_States, \
  4.2727 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2728 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2729 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
  4.2730 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2731 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
  4.2732 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
  4.2733  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2734  		NULL), "Test" #id " Part5"); \
  4.2735 -	THGM_REMOVE_HOOK(id, 1); \
  4.2736 -	THGM_REMOVE_HOOK(id, 2); \
  4.2737 -	THGM_REMOVE_HOOK(id, 3); \
  4.2738  			/* hook1, hook2 - hook3, hook4 */ \
  4.2739 -	PtrBuf_Clear(); \
  4.2740 -	THGM_ADD_HOOK(id, 1); \
  4.2741 -	THGM_ADD_HOOK(id, 2); \
  4.2742 -	THGM_ADD_HOOK(id, 3); \
  4.2743  	THGM_ADD_HOOK(id, 4); \
  4.2744  	THGM_CALLS(id, call_params, 4, 0, "Part6"); \
  4.2745  	CHECK_STATES((&g_States, \
  4.2746 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
  4.2747 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
  4.2748 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
  4.2749 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
  4.2750 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
  4.2751 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
  4.2752 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
  4.2753 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \
  4.2754  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2755  		NULL), "Test" #id " Part6"); \
  4.2756  		\
  4.2757 @@ -3547,10 +1823,10 @@
  4.2758  	THGM_REMOVE_HOOK(id, 2); \
  4.2759  	THGM_CALLS(id, call_params, 4, 0, "Part7"); \
  4.2760  	CHECK_STATES((&g_States, \
  4.2761 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
  4.2762 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \
  4.2763  		new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
  4.2764 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
  4.2765 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
  4.2766 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \
  4.2767 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \
  4.2768  		/* sh_call one */ \
  4.2769  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
  4.2770  		NULL), "Test" #id " Part7"); \
     5.1 --- a/sourcehook/test/testhookmangen.hxx	Sun Nov 18 13:12:51 2007 +0000
     5.2 +++ b/sourcehook/test/testhookmangen.hxx	Sun Nov 18 15:08:03 2007 +0000
     5.3 @@ -203,10 +203,7 @@
     5.4  	struct TestClass##id; \
     5.5  	typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \
     5.6  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
     5.7 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
     5.8 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
     5.9 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    5.10 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    5.11 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    5.12  	\
    5.13  	struct TestClass##id \
    5.14  	{ \
    5.15 @@ -219,70 +216,25 @@
    5.16  			g_Inside_LeafFunc = false; \
    5.17  		} \
    5.18  		\
    5.19 -		struct Delegate1 : public MyDelegate \
    5.20 +		struct Delegate : public MyDelegate \
    5.21  		{ \
    5.22 +			int m_DelegNumber; \
    5.23 +			Delegate(int num) : m_DelegNumber(num) { } \
    5.24 +			\
    5.25  			virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
    5.26  			{ \
    5.27  				g_Inside_LeafFunc = true; \
    5.28 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
    5.29 -				g_Inside_LeafFunc = false; \
    5.30 -				if (ms_DoRecall) \
    5.31 -				{ \
    5.32 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
    5.33 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
    5.34 -				} \
    5.35 -				else \
    5.36 -					RETURN_META(MRES_IGNORED); \
    5.37 -			} \
    5.38 -		}; \
    5.39 -		struct Delegate2 : public MyDelegate \
    5.40 -		{ \
    5.41 -			virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
    5.42 -			{ \
    5.43 -				g_Inside_LeafFunc = true; \
    5.44 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
    5.45 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
    5.46  				g_Inside_LeafFunc = false; \
    5.47  				if (ms_DoRecall) \
    5.48  				{ \
    5.49  					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
    5.50 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
    5.51 -				} \
    5.52 -				else \
    5.53 -					RETURN_META(MRES_SUPERCEDE); \
    5.54 -			} \
    5.55 -		}; \
    5.56 -		struct Delegate3 : public MyDelegate \
    5.57 -		{ \
    5.58 -			virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
    5.59 -			{ \
    5.60 -				g_Inside_LeafFunc = true; \
    5.61 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
    5.62 -				g_Inside_LeafFunc = false; \
    5.63 -				if (ms_DoRecall) \
    5.64 -				{ \
    5.65 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
    5.66 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
    5.67 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
    5.68  				} \
    5.69  				else \
    5.70 -					RETURN_META(MRES_IGNORED); \
    5.71 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
    5.72  			} \
    5.73  		}; \
    5.74 -		struct Delegate4 : public MyDelegate \
    5.75 -		{ \
    5.76 -			virtual void Call(@[$2,1,$1|, :param$2 p$2@]) \
    5.77 -			{ \
    5.78 -				g_Inside_LeafFunc = true; \
    5.79 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
    5.80 -				g_Inside_LeafFunc = false; \
    5.81 -				if (ms_DoRecall) \
    5.82 -				{ \
    5.83 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
    5.84 -					RETURN_META_NEWPARAMS(MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
    5.85 -				} \
    5.86 -				else \
    5.87 -					RETURN_META(MRES_SUPERCEDE); \
    5.88 -			}; \
    5.89 -		}; \
    5.90  	}; \
    5.91  	\
    5.92  	bool TestClass##id::ms_DoRecall = false; \
    5.93 @@ -294,10 +246,7 @@
    5.94  	typedef ret_type RetType##id; \
    5.95  	typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \
    5.96  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
    5.97 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    5.98 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
    5.99 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.100 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.101 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.102  	\
   5.103  	struct TestClass##id \
   5.104  	{ \
   5.105 @@ -312,70 +261,25 @@
   5.106  			return MakeRet< ret_type >::Do(0); \
   5.107  		} \
   5.108  		\
   5.109 -		struct Delegate1 : public MyDelegate \
   5.110 +		struct Delegate : public MyDelegate \
   5.111  		{ \
   5.112 +			int m_DelegNumber; \
   5.113 +			Delegate(int num) : m_DelegNumber(num) { } \
   5.114 +			\
   5.115  			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.116  			{ \
   5.117  				g_Inside_LeafFunc = true; \
   5.118 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.119 -				g_Inside_LeafFunc = false; \
   5.120 -				if (ms_DoRecall) \
   5.121 -				{ \
   5.122 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.123 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.124 -				} \
   5.125 -				else \
   5.126 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   5.127 -			} \
   5.128 -		}; \
   5.129 -		struct Delegate2 : public MyDelegate \
   5.130 -		{ \
   5.131 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.132 -			{ \
   5.133 -				g_Inside_LeafFunc = true; \
   5.134 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.135 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.136  				g_Inside_LeafFunc = false; \
   5.137  				if (ms_DoRecall) \
   5.138  				{ \
   5.139  					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.140 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.141 -				} \
   5.142 -				else \
   5.143 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   5.144 -			} \
   5.145 -		}; \
   5.146 -		struct Delegate3 : public MyDelegate \
   5.147 -		{ \
   5.148 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.149 -			{ \
   5.150 -				g_Inside_LeafFunc = true; \
   5.151 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.152 -				g_Inside_LeafFunc = false; \
   5.153 -				if (ms_DoRecall) \
   5.154 -				{ \
   5.155 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.156 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.157 +					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@])); \
   5.158  				} \
   5.159  				else \
   5.160 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   5.161 +					RETURN_META_VALUE((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, MakeRet< ret_type >::Do(m_DelegNumber)); \
   5.162  			} \
   5.163  		}; \
   5.164 -		struct Delegate4 : public MyDelegate \
   5.165 -		{ \
   5.166 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.167 -			{ \
   5.168 -				g_Inside_LeafFunc = true; \
   5.169 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.170 -				g_Inside_LeafFunc = false; \
   5.171 -				if (ms_DoRecall) \
   5.172 -				{ \
   5.173 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.174 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.175 -				} \
   5.176 -				else \
   5.177 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   5.178 -			}; \
   5.179 -		}; \
   5.180  	}; \
   5.181  	\
   5.182  	bool TestClass##id::ms_DoRecall = false; \
   5.183 @@ -385,10 +289,7 @@
   5.184  	struct TestClass##id; \
   5.185  	typedef ParamState@($1+1)<0@[$2,1,$1:, param$2@], std::string > ParamState_m##id; \
   5.186  	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   5.187 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.188 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.189 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.190 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.191 +	MAKE_STATE_4(State_Deleg_##id, int /*delegnumber*/, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.192  	\
   5.193  	struct TestClass##id \
   5.194  	{ \
   5.195 @@ -409,169 +310,30 @@
   5.196  			g_Inside_LeafFunc = false; \
   5.197  		} \
   5.198  		\
   5.199 -		struct Delegate1 : public MyDelegate \
   5.200 +		struct Delegate : public MyDelegate \
   5.201  		{ \
   5.202 +			int m_DelegNumber; \
   5.203 +			Delegate(int num) : m_DelegNumber(num) { } \
   5.204 +			\
   5.205  			virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \
   5.206  			{ \
   5.207  				g_Inside_LeafFunc = true; \
   5.208 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \
   5.209 -				g_Inside_LeafFunc = false; \
   5.210 -				if (ms_DoRecall) \
   5.211 -				{ \
   5.212 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.213 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \
   5.214 -				} \
   5.215 -				else \
   5.216 -					RETURN_META(MRES_IGNORED); \
   5.217 -			} \
   5.218 -		}; \
   5.219 -		struct Delegate2 : public MyDelegate \
   5.220 -		{ \
   5.221 -			virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \
   5.222 -			{ \
   5.223 -				g_Inside_LeafFunc = true; \
   5.224 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \
   5.225 +				ADD_STATE(State_Deleg_##id(m_DelegNumber, META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \
   5.226  				g_Inside_LeafFunc = false; \
   5.227  				if (ms_DoRecall) \
   5.228  				{ \
   5.229  					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.230 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \
   5.231 -				} \
   5.232 -				else \
   5.233 -					RETURN_META(MRES_SUPERCEDE); \
   5.234 -			} \
   5.235 -		}; \
   5.236 -		struct Delegate3 : public MyDelegate \
   5.237 -		{ \
   5.238 -			virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \
   5.239 -			{ \
   5.240 -				g_Inside_LeafFunc = true; \
   5.241 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \
   5.242 -				g_Inside_LeafFunc = false; \
   5.243 -				if (ms_DoRecall) \
   5.244 -				{ \
   5.245 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.246 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \
   5.247 +					RETURN_META_NEWPARAMS((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \
   5.248  				} \
   5.249  				else \
   5.250 -					RETURN_META(MRES_IGNORED); \
   5.251 +					RETURN_META((m_DelegNumber & 1) ? MRES_IGNORED : MRES_SUPERCEDE); \
   5.252  			} \
   5.253  		}; \
   5.254 -		struct Delegate4 : public MyDelegate \
   5.255 -		{ \
   5.256 -			virtual void Call(@[$2,1,$1:param$2 p$2, @]const char *buf) \
   5.257 -			{ \
   5.258 -				g_Inside_LeafFunc = true; \
   5.259 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1:p$2, @]buf))); \
   5.260 -				g_Inside_LeafFunc = false; \
   5.261 -				if (ms_DoRecall) \
   5.262 -				{ \
   5.263 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.264 -					RETURN_META_NEWPARAMS(MRES_IGNORED, &TestClass##id::Func, (@[$2,1,$1:p$2, @]"%s!", buf)); \
   5.265 -				} \
   5.266 -				else \
   5.267 -					RETURN_META(MRES_SUPERCEDE); \
   5.268 -			}; \
   5.269 -		}; \
   5.270  	}; \
   5.271  	\
   5.272  	bool TestClass##id::ms_DoRecall = false; \
   5.273  	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall | SourceHook::ProtoInfo::CallConv_HasVafmt);
   5.274  
   5.275 -
   5.276 -#define THGM_MAKE_TEST$1_vafmt(id, ret_type@[$2,1,$1:, param$2@]) \
   5.277 -	struct TestClass##id; \
   5.278 -	typedef ret_type RetType##id; \
   5.279 -	typedef ParamState$1<0@[$2,1,$1:, param$2@] > ParamState_m##id; \
   5.280 -	MAKE_STATE_2(State_Func##id, TestClass##id* /*thisptr*/, ParamState_m##id ); \
   5.281 -	MAKE_STATE_3(State_Deleg1_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.282 -	MAKE_STATE_3(State_Deleg2_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.283 -	MAKE_STATE_3(State_Deleg3_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.284 -	MAKE_STATE_3(State_Deleg4_##id, TestClass##id* /*ifptr*/, int /*deleg thisptr*/, ParamState_m##id ); \
   5.285 -	\
   5.286 -	struct TestClass##id \
   5.287 -	{ \
   5.288 -		static bool ms_DoRecall; \
   5.289 -		\
   5.290 -		virtual ret_type Func(@[$2,1,$1|, :param$2 p$2@]) \
   5.291 -		{ \
   5.292 -			g_Inside_LeafFunc = true; \
   5.293 -			ADD_STATE(State_Func##id(this, ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.294 -			g_Inside_LeafFunc = false; \
   5.295 -			\
   5.296 -			return MakeRet< ret_type >::Do(0); \
   5.297 -		} \
   5.298 -		\
   5.299 -		struct Delegate1 : public MyDelegate \
   5.300 -		{ \
   5.301 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.302 -			{ \
   5.303 -				g_Inside_LeafFunc = true; \
   5.304 -				ADD_STATE(State_Deleg1_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.305 -				g_Inside_LeafFunc = false; \
   5.306 -				if (ms_DoRecall) \
   5.307 -				{ \
   5.308 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.309 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(1), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.310 -				} \
   5.311 -				else \
   5.312 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(1)); \
   5.313 -			} \
   5.314 -		}; \
   5.315 -		struct Delegate2 : public MyDelegate \
   5.316 -		{ \
   5.317 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.318 -			{ \
   5.319 -				g_Inside_LeafFunc = true; \
   5.320 -				ADD_STATE(State_Deleg2_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.321 -				g_Inside_LeafFunc = false; \
   5.322 -				if (ms_DoRecall) \
   5.323 -				{ \
   5.324 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.325 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.326 -				} \
   5.327 -				else \
   5.328 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(2)); \
   5.329 -			} \
   5.330 -		}; \
   5.331 -		struct Delegate3 : public MyDelegate \
   5.332 -		{ \
   5.333 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.334 -			{ \
   5.335 -				g_Inside_LeafFunc = true; \
   5.336 -				ADD_STATE(State_Deleg3_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.337 -				g_Inside_LeafFunc = false; \
   5.338 -				if (ms_DoRecall) \
   5.339 -				{ \
   5.340 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.341 -					RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, MakeRet< ret_type >::Do(3), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.342 -				} \
   5.343 -				else \
   5.344 -					RETURN_META_VALUE(MRES_IGNORED, MakeRet< ret_type >::Do(3)); \
   5.345 -			} \
   5.346 -		}; \
   5.347 -		struct Delegate4 : public MyDelegate \
   5.348 -		{ \
   5.349 -			virtual ret_type Call(@[$2,1,$1|, :param$2 p$2@]) \
   5.350 -			{ \
   5.351 -				g_Inside_LeafFunc = true; \
   5.352 -				ADD_STATE(State_Deleg4_##id(META_IFACEPTR(TestClass##id), PtrBuf(this), ParamState_m##id(@[$2,1,$1|, :p$2@]))); \
   5.353 -				g_Inside_LeafFunc = false; \
   5.354 -				if (ms_DoRecall) \
   5.355 -				{ \
   5.356 -					@[$2,1,$1:Increment<StripRef< param$2 >::type>::Incr(p$2);@] \
   5.357 -					RETURN_META_VALUE_NEWPARAMS(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4), &TestClass##id::Func, (@[$2,1,$1|, :p$2@])); \
   5.358 -				} \
   5.359 -				else \
   5.360 -					RETURN_META_VALUE(MRES_SUPERCEDE, MakeRet< ret_type >::Do(4)); \
   5.361 -			}; \
   5.362 -		}; \
   5.363 -	}; \
   5.364 -	\
   5.365 -	bool TestClass##id::ms_DoRecall = false; \
   5.366 -	SourceHook::CProtoInfoBuilder protoinfo_##id(SourceHook::ProtoInfo::CallConv_ThisCall)
   5.367 -
   5.368 -
   5.369  #define THGM_SETUP_PI$1(id@[$2,1,$1:, p$2_type, p$2_passtype, p$2_flags@]) \
   5.370  	void setuppi_##id() \
   5.371  	{ \
   5.372 @@ -600,7 +362,7 @@
   5.373  	
   5.374  #define THGM_ADD_HOOK(id, num) \
   5.375  	CAT4(hook, num, _, id) = g_SHPtr->AddHook(g_PLID, SourceHook::ISourceHook::Hook_Normal, reinterpret_cast<void*>(pTest##id), \
   5.376 -		0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate##num), num >= 3);
   5.377 +		0, myhookman##id, PtrBufPtr(new TestClass##id::Delegate(num)), num >= 3);
   5.378  
   5.379  #define THGM_REMOVE_HOOK(id, num) \
   5.380  	g_SHPtr->RemoveHookByID(CAT4(hook, num, _, id));
   5.381 @@ -627,37 +389,15 @@
   5.382  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.383  		NULL), "Test" #id " Part1"); \
   5.384  	\
   5.385 -			/* hook1 - no hooks */ \
   5.386 -	PtrBuf_Clear(); \
   5.387 -	THGM_ADD_HOOK(id, 1); \
   5.388 -	THGM_CALLS_void(id, call_params); \
   5.389 -	CHECK_STATES((&g_States, \
   5.390 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.391 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.392 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.393 -		NULL), "Test" #id " Part2"); \
   5.394 -	THGM_REMOVE_HOOK(id, 1); \
   5.395 -	\
   5.396 -			/* no hooks - hook3 */ \
   5.397 -	PtrBuf_Clear(); \
   5.398 -	THGM_ADD_HOOK(id, 3); \
   5.399 -	THGM_CALLS_void(id, call_params); \
   5.400 -	CHECK_STATES((&g_States, \
   5.401 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.402 -		new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.403 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.404 -		NULL), "Test" #id " Part3"); \
   5.405 -	THGM_REMOVE_HOOK(id, 3); \
   5.406 -	\
   5.407  			/* hook1 - hook3 */ \
   5.408  	PtrBuf_Clear(); \
   5.409  	THGM_ADD_HOOK(id, 1); \
   5.410  	THGM_ADD_HOOK(id, 3); \
   5.411  	THGM_CALLS_void(id, call_params); \
   5.412  	CHECK_STATES((&g_States, \
   5.413 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.414 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.415  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.416 -		new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.417 +		new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \
   5.418  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.419  		NULL), "Test" #id " Part4"); \
   5.420  	THGM_REMOVE_HOOK(id, 1); \
   5.421 @@ -670,26 +410,19 @@
   5.422  	THGM_ADD_HOOK(id, 3); \
   5.423  	THGM_CALLS_void(id, call_params); \
   5.424  	CHECK_STATES((&g_States, \
   5.425 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.426 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.427 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
   5.428 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.429 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
   5.430 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
   5.431  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.432  		NULL), "Test" #id " Part5"); \
   5.433 -	THGM_REMOVE_HOOK(id, 1); \
   5.434 -	THGM_REMOVE_HOOK(id, 2); \
   5.435 -	THGM_REMOVE_HOOK(id, 3); \
   5.436  			/* hook1, hook2 - hook3, hook4 */ \
   5.437 -	PtrBuf_Clear(); \
   5.438 -	THGM_ADD_HOOK(id, 1); \
   5.439 -	THGM_ADD_HOOK(id, 2); \
   5.440 -	THGM_ADD_HOOK(id, 3); \
   5.441  	THGM_ADD_HOOK(id, 4); \
   5.442  	THGM_CALLS_void(id, call_params); \
   5.443  	CHECK_STATES((&g_States, \
   5.444 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.445 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.446 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
   5.447 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
   5.448 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.449 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
   5.450 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
   5.451 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \
   5.452  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.453  		NULL), "Test" #id " Part6"); \
   5.454  		\
   5.455 @@ -699,10 +432,10 @@
   5.456  	THGM_REMOVE_HOOK(id, 2); \
   5.457  	THGM_CALLS_void(id, call_params); \
   5.458  	CHECK_STATES((&g_States, \
   5.459 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
   5.460 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \
   5.461  		new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
   5.462 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
   5.463 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
   5.464 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \
   5.465 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \
   5.466  		/* sh_call one */ \
   5.467  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.468  		NULL), "Test" #id " Part7"); \
   5.469 @@ -745,37 +478,15 @@
   5.470  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.471  		NULL), "Test" #id " Part1"); \
   5.472  	\
   5.473 -			/* hook1 - no hooks */ \
   5.474 -	PtrBuf_Clear(); \
   5.475 -	THGM_ADD_HOOK(id, 1); \
   5.476 -	THGM_CALLS(id, call_params, 0, 0, "Part2"); \
   5.477 -	CHECK_STATES((&g_States, \
   5.478 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.479 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.480 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.481 -		NULL), "Test" #id " Part2"); \
   5.482 -	THGM_REMOVE_HOOK(id, 1); \
   5.483 -	\
   5.484 -			/* no hooks - hook3 */ \
   5.485 -	PtrBuf_Clear(); \
   5.486 -	THGM_ADD_HOOK(id, 3); \
   5.487 -	THGM_CALLS(id, call_params, 0, 0, "Part3"); \
   5.488 -	CHECK_STATES((&g_States, \
   5.489 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.490 -		new State_Deleg3_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.491 -		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.492 -		NULL), "Test" #id " Part3"); \
   5.493 -	THGM_REMOVE_HOOK(id, 3); \
   5.494 -	\
   5.495  			/* hook1 - hook3 */ \
   5.496  	PtrBuf_Clear(); \
   5.497  	THGM_ADD_HOOK(id, 1); \
   5.498  	THGM_ADD_HOOK(id, 3); \
   5.499  	THGM_CALLS(id, call_params, 0, 0, "Part4"); \
   5.500  	CHECK_STATES((&g_States, \
   5.501 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.502 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.503  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.504 -		new State_Deleg3_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.505 +		new State_Deleg_##id(3, pTest##id, 1, ParamState_m##id call_params), \
   5.506  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.507  		NULL), "Test" #id " Part4"); \
   5.508  	THGM_REMOVE_HOOK(id, 1); \
   5.509 @@ -788,26 +499,19 @@
   5.510  	THGM_ADD_HOOK(id, 3); \
   5.511  	THGM_CALLS(id, call_params, 2, 0, "Part5"); \
   5.512  	CHECK_STATES((&g_States, \
   5.513 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.514 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.515 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
   5.516 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.517 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
   5.518 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
   5.519  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.520  		NULL), "Test" #id " Part5"); \
   5.521 -	THGM_REMOVE_HOOK(id, 1); \
   5.522 -	THGM_REMOVE_HOOK(id, 2); \
   5.523 -	THGM_REMOVE_HOOK(id, 3); \
   5.524  			/* hook1, hook2 - hook3, hook4 */ \
   5.525 -	PtrBuf_Clear(); \
   5.526 -	THGM_ADD_HOOK(id, 1); \
   5.527 -	THGM_ADD_HOOK(id, 2); \
   5.528 -	THGM_ADD_HOOK(id, 3); \
   5.529  	THGM_ADD_HOOK(id, 4); \
   5.530  	THGM_CALLS(id, call_params, 4, 0, "Part6"); \
   5.531  	CHECK_STATES((&g_States, \
   5.532 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params), \
   5.533 -		new State_Deleg2_##id(pTest##id, 1, ParamState_m##id call_params), \
   5.534 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params), \
   5.535 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params), \
   5.536 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params), \
   5.537 +		new State_Deleg_##id(2, pTest##id, 1, ParamState_m##id call_params), \
   5.538 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params), \
   5.539 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params), \
   5.540  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.541  		NULL), "Test" #id " Part6"); \
   5.542  		\
   5.543 @@ -817,10 +521,10 @@
   5.544  	THGM_REMOVE_HOOK(id, 2); \
   5.545  	THGM_CALLS(id, call_params, 4, 0, "Part7"); \
   5.546  	CHECK_STATES((&g_States, \
   5.547 -		new State_Deleg1_##id(pTest##id, 0, ParamState_m##id call_params(0)), \
   5.548 +		new State_Deleg_##id(1, pTest##id, 0, ParamState_m##id call_params(0)), \
   5.549  		new State_Func##id(pTest##id, ParamState_m##id call_params(1)), \
   5.550 -		new State_Deleg3_##id(pTest##id, 2, ParamState_m##id call_params(1)), \
   5.551 -		new State_Deleg4_##id(pTest##id, 3, ParamState_m##id call_params(2)), \
   5.552 +		new State_Deleg_##id(3, pTest##id, 2, ParamState_m##id call_params(1)), \
   5.553 +		new State_Deleg_##id(4, pTest##id, 3, ParamState_m##id call_params(2)), \
   5.554  		/* sh_call one */ \
   5.555  		new State_Func##id(pTest##id, ParamState_m##id call_params), \
   5.556  		NULL), "Test" #id " Part7"); \