sourcehook/test/testevents.h
branchhookman_autogen
changeset 459 53e363661d53
parent 432 f26dd3e3030b
child 465 c86a55fbcd88
     1.1 --- a/sourcehook/test/testevents.h	Sun Nov 11 17:35:24 2007 +0000
     1.2 +++ b/sourcehook/test/testevents.h	Sun Nov 11 18:51:56 2007 +0000
     1.3 @@ -19,6 +19,19 @@
     1.4  
     1.5  extern bool g_Verbose;
     1.6  
     1.7 +static unsigned int MakeHash(const char *name)
     1.8 +{
     1.9 +	int a = 0;
    1.10 +	unsigned int res = 0xFFFFFFFF;
    1.11 +
    1.12 +	while (*name)
    1.13 +	{
    1.14 +		res ^= ((unsigned int)*name << ((a++ % 4)*8));
    1.15 +		++name;
    1.16 +	}
    1.17 +	return res;
    1.18 +}
    1.19 +
    1.20  struct State
    1.21  {
    1.22  	virtual ~State()
    1.23 @@ -28,7 +41,7 @@
    1.24  
    1.25  	virtual bool IsEqual(State *other)
    1.26  	{
    1.27 -		return (typeid(other) == typeid(this)) ? true : false;
    1.28 +		return (MakeHash(GetName()) == MakeHash(other->GetName())) ? true : false;
    1.29  	}
    1.30  
    1.31  	virtual bool Ignore()
    1.32 @@ -37,6 +50,7 @@
    1.33  	}
    1.34  
    1.35  	virtual void Dump() = 0;
    1.36 +	virtual const char *GetName() = 0;
    1.37  };
    1.38  
    1.39  struct IgnoreState : public State
    1.40 @@ -130,6 +144,7 @@
    1.41  #define MAKE_STATE(name) struct name : State { \
    1.42  		virtual void Dump() { \
    1.43  			std::cout << "  " << #name << std::endl; } \
    1.44 +		const char *GetName() { return #name; } \
    1.45  	};
    1.46  
    1.47  #define MAKE_STATE_1(name, p1_type) struct name : State { \
    1.48 @@ -143,6 +158,7 @@
    1.49  		} \
    1.50  		virtual void Dump() { \
    1.51  			std::cout << "  " << #name << "; Param1=" << m_Param1 << std::endl; } \
    1.52 +		const char *GetName() { return #name; } \
    1.53  	}
    1.54  
    1.55  #define MAKE_STATE_2(name, p1_type, p2_type) struct name : State { \
    1.56 @@ -157,6 +173,7 @@
    1.57  		} \
    1.58  		virtual void Dump() { \
    1.59  			std::cout << "  " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << std::endl; } \
    1.60 +		const char *GetName() { return #name; } \
    1.61  	}
    1.62  
    1.63  #define MAKE_STATE_3(name, p1_type, p2_type, p3_type) struct name : State { \
    1.64 @@ -172,6 +189,7 @@
    1.65  		} \
    1.66  		virtual void Dump() { \
    1.67  			std::cout << "  " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << "; Param3=" << m_Param3 << std::endl; } \
    1.68 +		const char *GetName() { return #name; } \
    1.69  	}
    1.70  
    1.71  #define CHECK_COND(c, err) if (!(c)) { error = err; return false; }