sourcehook/test/testevents.h
branchhookman_autogen
changeset 465 c86a55fbcd88
parent 459 53e363661d53
     1.1 --- a/sourcehook/test/testevents.h	Sun Nov 18 13:12:51 2007 +0000
     1.2 +++ b/sourcehook/test/testevents.h	Sun Nov 18 15:08:03 2007 +0000
     1.3 @@ -151,9 +151,9 @@
     1.4  		p1_type m_Param1; \
     1.5  		name(p1_type param1) : m_Param1(param1) {} \
     1.6  		virtual bool IsEqual(State *other) { \
     1.7 -			name *other2 = dynamic_cast<name*>(other); \
     1.8 -			if (!other2) \
     1.9 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    1.10  				return false; \
    1.11 +			name *other2 = static_cast<name*>(other); \
    1.12  			return other2->m_Param1 == m_Param1;\
    1.13  		} \
    1.14  		virtual void Dump() { \
    1.15 @@ -166,9 +166,9 @@
    1.16  		p2_type m_Param2; \
    1.17  		name(p1_type param1, p2_type param2) : m_Param1(param1), m_Param2(param2) {} \
    1.18  		virtual bool IsEqual(State *other) { \
    1.19 -			name *other2 = dynamic_cast<name*>(other); \
    1.20 -			if (!other2) \
    1.21 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    1.22  				return false; \
    1.23 +			name *other2 = static_cast<name*>(other); \
    1.24  			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2;\
    1.25  		} \
    1.26  		virtual void Dump() { \
    1.27 @@ -182,9 +182,9 @@
    1.28  		p3_type m_Param3; \
    1.29  		name(p1_type param1, p2_type param2, p3_type param3) : m_Param1(param1), m_Param2(param2), m_Param3(param3) {} \
    1.30  		virtual bool IsEqual(State *other) { \
    1.31 -			name *other2 = dynamic_cast<name*>(other); \
    1.32 -			if (!other2) \
    1.33 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    1.34  				return false; \
    1.35 +			name *other2 = static_cast<name*>(other); \
    1.36  			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3;\
    1.37  		} \
    1.38  		virtual void Dump() { \
    1.39 @@ -192,6 +192,23 @@
    1.40  		const char *GetName() { return #name; } \
    1.41  	}
    1.42  
    1.43 +#define MAKE_STATE_4(name, p1_type, p2_type, p3_type, p4_type) struct name : State { \
    1.44 +		p1_type m_Param1; \
    1.45 +		p2_type m_Param2; \
    1.46 +		p3_type m_Param3; \
    1.47 +		p4_type m_Param4; \
    1.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) {} \
    1.49 +		virtual bool IsEqual(State *other) { \
    1.50 +			if (MakeHash(GetName()) != MakeHash(other->GetName())) \
    1.51 +				return false; \
    1.52 +			name *other2 = static_cast<name*>(other); \
    1.53 +			return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3 && other2->m_Param4 == m_Param4;\
    1.54 +		} \
    1.55 +		virtual void Dump() { \
    1.56 +			std::cout << "  " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << "; Param3=" << m_Param3 << "; Param4=" << m_Param4 << std::endl; } \
    1.57 +		const char *GetName() { return #name; } \
    1.58 +	}
    1.59 +
    1.60  #define CHECK_COND(c, err) if (!(c)) { error = err; return false; }
    1.61  
    1.62  #endif