correct ISO for scoping
authorPavol Marko <pavolmarko@gmail.com>
Sun Oct 14 12:28:28 2007 +0000 (2007-10-14)
changeset 4209c0613cb6f50
parent 419 862e6dddd0ee
child 421 573b9a092a5f
correct ISO for scoping
sourcehook/sourcehook.cpp
sourcehook/test/testvphooks.cpp
     1.1 --- a/sourcehook/sourcehook.cpp	Sun Oct 14 12:15:09 2007 +0000
     1.2 +++ b/sourcehook/sourcehook.cpp	Sun Oct 14 12:28:28 2007 +0000
     1.3 @@ -749,7 +749,8 @@
     1.4  					oldctx->m_State = CHookContext::State_Dead;
     1.5  
     1.6  					List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList();
     1.7 -					for (List<CVfnPtr*>::iterator vfnptr_iter = vfnptr_list.begin();
     1.8 +					List<CVfnPtr*>::iterator vfnptr_iter;
     1.9 +					for (vfnptr_iter = vfnptr_list.begin();
    1.10  						vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter)
    1.11  					{
    1.12  						if (**vfnptr_iter == vfnptr)
    1.13 @@ -805,7 +806,8 @@
    1.14  			pCtx->pIface = NULL;
    1.15  
    1.16  			List<CVfnPtr*> &vfnptr_list = static_cast<CHookManager*>(hi)->GetVfnPtrList();
    1.17 -			for (List<CVfnPtr*>::iterator vfnptr_iter = vfnptr_list.begin();
    1.18 +			List<CVfnPtr*>::iterator vfnptr_iter; 
    1.19 +			for (vfnptr_iter = vfnptr_list.begin();
    1.20  				vfnptr_iter != vfnptr_list.end(); ++vfnptr_iter)
    1.21  			{
    1.22  				if (**vfnptr_iter == vfnptr)
     2.1 --- a/sourcehook/test/testvphooks.cpp	Sun Oct 14 12:15:09 2007 +0000
     2.2 +++ b/sourcehook/test/testvphooks.cpp	Sun Oct 14 12:28:28 2007 +0000
     2.3 @@ -30,76 +30,76 @@
     2.4  	MAKE_STATE_2(State_Func3_Post, IBase *, int);
     2.5  
     2.6  	class IBase
     2.7 -	{
     2.8 -	public:
     2.9 -		virtual void Func1() = 0;
    2.10 -		virtual void Func2() = 0;
    2.11 -		virtual void Func3(int x) = 0;
    2.12 +	{
    2.13 +	public:
    2.14 +		virtual void Func1() = 0;
    2.15 +		virtual void Func2() = 0;
    2.16 +		virtual void Func3(int x) = 0;
    2.17  	};
    2.18  
    2.19  	class CDerived1 : public IBase
    2.20 -	{
    2.21 -	public:
    2.22 -		virtual void Func1()
    2.23 -		{
    2.24 -			ADD_STATE(State_D1_Func1(this));
    2.25 -		}
    2.26 -		virtual void Func2()
    2.27 -		{
    2.28 -			ADD_STATE(State_D1_Func2(this));
    2.29 -		}
    2.30 -		virtual void Func3(int x)
    2.31 -		{
    2.32 -			ADD_STATE(State_D1_Func3(this, x));
    2.33 -		}
    2.34 +	{
    2.35 +	public:
    2.36 +		virtual void Func1()
    2.37 +		{
    2.38 +			ADD_STATE(State_D1_Func1(this));
    2.39 +		}
    2.40 +		virtual void Func2()
    2.41 +		{
    2.42 +			ADD_STATE(State_D1_Func2(this));
    2.43 +		}
    2.44 +		virtual void Func3(int x)
    2.45 +		{
    2.46 +			ADD_STATE(State_D1_Func3(this, x));
    2.47 +		}
    2.48  	};
    2.49  
    2.50  	class CDerived2 : public IBase
    2.51 -	{
    2.52 -	public:
    2.53 -		virtual void Func1()
    2.54 -		{
    2.55 -			ADD_STATE(State_D2_Func1(this));
    2.56 -		}
    2.57 -		virtual void Func2()
    2.58 -		{
    2.59 -			ADD_STATE(State_D2_Func2(this));
    2.60 -		}
    2.61 -		virtual void Func3(int x)
    2.62 -		{
    2.63 -			ADD_STATE(State_D2_Func3(this, x));
    2.64 -		}
    2.65 +	{
    2.66 +	public:
    2.67 +		virtual void Func1()
    2.68 +		{
    2.69 +			ADD_STATE(State_D2_Func1(this));
    2.70 +		}
    2.71 +		virtual void Func2()
    2.72 +		{
    2.73 +			ADD_STATE(State_D2_Func2(this));
    2.74 +		}
    2.75 +		virtual void Func3(int x)
    2.76 +		{
    2.77 +			ADD_STATE(State_D2_Func3(this, x));
    2.78 +		}
    2.79  	};
    2.80  
    2.81  	void Handler_Func1_Pre()
    2.82 -	{
    2.83 -		ADD_STATE(State_Func1_Pre(META_IFACEPTR(IBase)));
    2.84 +	{
    2.85 +		ADD_STATE(State_Func1_Pre(META_IFACEPTR(IBase)));
    2.86  	}
    2.87  	void Handler_Func1_Post()
    2.88 -	{
    2.89 -		ADD_STATE(State_Func1_Post(META_IFACEPTR(IBase)));
    2.90 +	{
    2.91 +		ADD_STATE(State_Func1_Post(META_IFACEPTR(IBase)));
    2.92  	}
    2.93  	int g_F2_Pre_HookToRemove = 0;
    2.94  	void Handler_Func2_Pre()
    2.95 -	{
    2.96 -		ADD_STATE(State_Func2_Pre(META_IFACEPTR(IBase)));
    2.97 -		SH_REMOVE_HOOK_ID(g_F2_Pre_HookToRemove);
    2.98 +	{
    2.99 +		ADD_STATE(State_Func2_Pre(META_IFACEPTR(IBase)));
   2.100 +		SH_REMOVE_HOOK_ID(g_F2_Pre_HookToRemove);
   2.101  	}
   2.102  	void Handler_Func2_Post()
   2.103 -	{
   2.104 -		ADD_STATE(State_Func2_Post(META_IFACEPTR(IBase)));
   2.105 +	{
   2.106 +		ADD_STATE(State_Func2_Post(META_IFACEPTR(IBase)));
   2.107  	}
   2.108  
   2.109  
   2.110  	void Handler_Func3_Pre(int x)
   2.111 -	{
   2.112 -		ADD_STATE(State_Func3_Pre(META_IFACEPTR(IBase), x));
   2.113 -
   2.114 -		RETURN_META_NEWPARAMS(MRES_IGNORED, &IBase::Func3, (x+1));
   2.115 +	{
   2.116 +		ADD_STATE(State_Func3_Pre(META_IFACEPTR(IBase), x));
   2.117 +
   2.118 +		RETURN_META_NEWPARAMS(MRES_IGNORED, &IBase::Func3, (x+1));
   2.119  	}
   2.120  	void Handler_Func3_Post(int x)
   2.121 -	{
   2.122 -		ADD_STATE(State_Func3_Post(META_IFACEPTR(IBase), x));
   2.123 +	{
   2.124 +		ADD_STATE(State_Func3_Post(META_IFACEPTR(IBase), x));
   2.125  	}
   2.126  
   2.127  	SH_DECL_HOOK0_void(IBase, Func1, SH_NOATTRIB, 0);
   2.128 @@ -110,24 +110,24 @@
   2.129  }
   2.130  
   2.131  bool TestVPHooks(std::string &error)
   2.132 -{
   2.133 +{
   2.134  	GET_SHPTR(g_SHPtr);
   2.135 -	g_PLID = 1337;
   2.136 -
   2.137 -	CDerived1 d1i1;
   2.138 -	CDerived1 d1i2;
   2.139 -	CDerived2 d2i1;
   2.140 -
   2.141 -	IBase *p_d1i1 = &d1i1;
   2.142 -	IBase *p_d1i2 = &d1i2;
   2.143 -	IBase *p_d2i1 = &d2i1;
   2.144 -	
   2.145 -	int hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.146 -
   2.147 -	p_d1i1->Func1();
   2.148 -	p_d1i2->Func1();
   2.149 -	p_d2i1->Func1();
   2.150 -
   2.151 +	g_PLID = 1337;
   2.152 +
   2.153 +	CDerived1 d1i1;
   2.154 +	CDerived1 d1i2;
   2.155 +	CDerived2 d2i1;
   2.156 +
   2.157 +	IBase *p_d1i1 = &d1i1;
   2.158 +	IBase *p_d1i2 = &d1i2;
   2.159 +	IBase *p_d2i1 = &d2i1;
   2.160 +	
   2.161 +	int hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.162 +
   2.163 +	p_d1i1->Func1();
   2.164 +	p_d1i2->Func1();
   2.165 +	p_d2i1->Func1();
   2.166 +
   2.167  	CHECK_STATES((&g_States,
   2.168  		new State_Func1_Pre(p_d1i1),
   2.169  		new State_D1_Func1(p_d1i1),
   2.170 @@ -136,33 +136,32 @@
   2.171  		new State_D1_Func1(p_d1i2),
   2.172  
   2.173  		new State_D2_Func1(p_d2i1),
   2.174 -		NULL), "Part 1");
   2.175 -
   2.176 -	SH_REMOVE_HOOK_ID(hook1);
   2.177 -
   2.178 -	p_d1i1->Func1();
   2.179 -	p_d1i2->Func1();
   2.180 -	p_d2i1->Func1();
   2.181 -
   2.182 +		NULL), "Part 1");
   2.183 +
   2.184 +	SH_REMOVE_HOOK_ID(hook1);
   2.185 +
   2.186 +	p_d1i1->Func1();
   2.187 +	p_d1i2->Func1();
   2.188 +	p_d2i1->Func1();
   2.189 +
   2.190  	CHECK_STATES((&g_States,
   2.191  		new State_D1_Func1(p_d1i1),
   2.192  
   2.193  		new State_D1_Func1(p_d1i2),
   2.194  
   2.195  		new State_D2_Func1(p_d2i1),
   2.196 -		NULL), "Part 2");
   2.197 -
   2.198 -
   2.199 -
   2.200 -	// Normal hook, then vp hook
   2.201 -
   2.202 -	int hook2 = SH_ADD_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.203 -	hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.204 -
   2.205 -	p_d1i1->Func1();
   2.206 -	p_d1i2->Func1();
   2.207 -	p_d2i1->Func1();
   2.208 -
   2.209 +		NULL), "Part 2");
   2.210 +
   2.211 +
   2.212 +	// Normal hook, then vp hook
   2.213 +
   2.214 +	int hook2 = SH_ADD_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.215 +	hook1 = SH_ADD_VPHOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
   2.216 +
   2.217 +	p_d1i1->Func1();
   2.218 +	p_d1i2->Func1();
   2.219 +	p_d2i1->Func1();
   2.220 +
   2.221  	CHECK_STATES((&g_States,
   2.222  		new State_Func1_Pre(p_d1i1),
   2.223  		new State_Func1_Pre(p_d1i1),
   2.224 @@ -172,14 +171,14 @@
   2.225  		new State_D1_Func1(p_d1i2),
   2.226  
   2.227  		new State_D2_Func1(p_d2i1),
   2.228 -		NULL), "Part 3");
   2.229 -
   2.230 -	SH_REMOVE_HOOK_ID(hook1);
   2.231 -
   2.232 -	p_d1i1->Func1();
   2.233 -	p_d1i2->Func1();
   2.234 -	p_d2i1->Func1();
   2.235 -
   2.236 +		NULL), "Part 3");
   2.237 +
   2.238 +	SH_REMOVE_HOOK_ID(hook1);
   2.239 +
   2.240 +	p_d1i1->Func1();
   2.241 +	p_d1i2->Func1();
   2.242 +	p_d2i1->Func1();
   2.243 +
   2.244  	CHECK_STATES((&g_States,
   2.245  		new State_Func1_Pre(p_d1i1),
   2.246  		new State_D1_Func1(p_d1i1),
   2.247 @@ -187,33 +186,33 @@
   2.248  		new State_D1_Func1(p_d1i2),
   2.249  
   2.250  		new State_D2_Func1(p_d2i1),
   2.251 -		NULL), "Part 4");
   2.252 -
   2.253 -	SH_REMOVE_HOOK_ID(hook2);
   2.254 -
   2.255 -	p_d1i1->Func1();
   2.256 -	p_d1i2->Func1();
   2.257 -	p_d2i1->Func1();
   2.258 -
   2.259 +		NULL), "Part 4");
   2.260 +
   2.261 +	SH_REMOVE_HOOK_ID(hook2);
   2.262 +
   2.263 +	p_d1i1->Func1();
   2.264 +	p_d1i2->Func1();
   2.265 +	p_d2i1->Func1();
   2.266 +
   2.267  	CHECK_STATES((&g_States,
   2.268  		new State_D1_Func1(p_d1i1),
   2.269  
   2.270  		new State_D1_Func1(p_d1i2),
   2.271  
   2.272  		new State_D2_Func1(p_d2i1),
   2.273 -		NULL), "Part 5");
   2.274 -
   2.275 -	// Test this:
   2.276 -	// Normal hook AND vp hook on Func2
   2.277 -	// Func2's pre handler removes the VP hook.
   2.278 -
   2.279 -	hook1 = SH_ADD_VPHOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
   2.280 -	hook2 = SH_ADD_HOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
   2.281 -
   2.282 -	g_F2_Pre_HookToRemove = hook1;
   2.283 -	p_d1i1->Func2();
   2.284 -	p_d1i1->Func2();
   2.285 -
   2.286 +		NULL), "Part 5");
   2.287 +
   2.288 +	// Test this:
   2.289 +	// Normal hook AND vp hook on Func2
   2.290 +	// Func2's pre handler removes the VP hook.
   2.291 +
   2.292 +	hook1 = SH_ADD_VPHOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
   2.293 +	hook2 = SH_ADD_HOOK(IBase, Func2, p_d1i1, SH_STATIC(Handler_Func2_Pre), false);
   2.294 +
   2.295 +	g_F2_Pre_HookToRemove = hook1;
   2.296 +	p_d1i1->Func2();
   2.297 +	p_d1i1->Func2();
   2.298 +
   2.299  	CHECK_STATES((&g_States,
   2.300  		new State_Func2_Pre(p_d1i1),
   2.301  		new State_D1_Func2(p_d1i1),
   2.302 @@ -221,22 +220,22 @@
   2.303  		new State_Func2_Pre(p_d1i1),
   2.304  		new State_D1_Func2(p_d1i1),
   2.305  
   2.306 -		NULL), "Part 6");
   2.307 -
   2.308 -	SH_REMOVE_HOOK_ID(hook1);
   2.309 -
   2.310 -	// Hook function 3:
   2.311 -	//  Using manualhook, VP
   2.312 -	hook1 = SH_ADD_MANUALVPHOOK(IBase_Func3_Manual, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.313 -
   2.314 -	//  Normally, VP
   2.315 -	hook2 = SH_ADD_VPHOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.316 -
   2.317 -	// Normally, no VP
   2.318 -	int hook3 = SH_ADD_HOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.319 -
   2.320 -	p_d1i1->Func3(1);
   2.321 -
   2.322 +		NULL), "Part 6");
   2.323 +
   2.324 +	SH_REMOVE_HOOK_ID(hook1);
   2.325 +
   2.326 +	// Hook function 3:
   2.327 +	//  Using manualhook, VP
   2.328 +	hook1 = SH_ADD_MANUALVPHOOK(IBase_Func3_Manual, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.329 +
   2.330 +	//  Normally, VP
   2.331 +	hook2 = SH_ADD_VPHOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.332 +
   2.333 +	// Normally, no VP
   2.334 +	int hook3 = SH_ADD_HOOK(IBase, Func3, p_d1i1, SH_STATIC(Handler_Func3_Pre), false);
   2.335 +
   2.336 +	p_d1i1->Func3(1);
   2.337 +
   2.338  	CHECK_STATES((&g_States,
   2.339  		new State_Func3_Pre(p_d1i1, 1),		// manual vp hook
   2.340  		new State_Func3_Pre(p_d1i1, 2),		// normal vp hook
   2.341 @@ -244,17 +243,18 @@
   2.342  
   2.343  		new State_D1_Func3(p_d1i1, 4),		// function
   2.344  
   2.345 -		NULL), "Part 7.1");
   2.346 -
   2.347 -	p_d1i2->Func3(1);
   2.348 -
   2.349 +		NULL), "Part 7.1");
   2.350 +
   2.351 +	p_d1i2->Func3(1);
   2.352 +
   2.353  	CHECK_STATES((&g_States,
   2.354  		new State_Func3_Pre(p_d1i2, 1),		// manual vp hook
   2.355  		new State_Func3_Pre(p_d1i2, 2),		// normal vp hook
   2.356  
   2.357  		new State_D1_Func3(p_d1i2, 3),		// function
   2.358  
   2.359 -		NULL), "Part 7.2");
   2.360 -
   2.361 -	return true;
   2.362 -}
   2.363 \ No newline at end of file
   2.364 +		NULL), "Part 7.2");
   2.365 +
   2.366 +	return true;
   2.367 +}
   2.368 +