diff -r b340e8665151 -r c86a55fbcd88 sourcehook/test/testevents.h --- a/sourcehook/test/testevents.h Sun Nov 18 13:12:51 2007 +0000 +++ b/sourcehook/test/testevents.h Sun Nov 18 15:08:03 2007 +0000 @@ -151,9 +151,9 @@ p1_type m_Param1; \ name(p1_type param1) : m_Param1(param1) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1;\ } \ virtual void Dump() { \ @@ -166,9 +166,9 @@ p2_type m_Param2; \ name(p1_type param1, p2_type param2) : m_Param1(param1), m_Param2(param2) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2;\ } \ virtual void Dump() { \ @@ -182,9 +182,9 @@ p3_type m_Param3; \ name(p1_type param1, p2_type param2, p3_type param3) : m_Param1(param1), m_Param2(param2), m_Param3(param3) {} \ virtual bool IsEqual(State *other) { \ - name *other2 = dynamic_cast(other); \ - if (!other2) \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ return false; \ + name *other2 = static_cast(other); \ return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3;\ } \ virtual void Dump() { \ @@ -192,6 +192,23 @@ const char *GetName() { return #name; } \ } +#define MAKE_STATE_4(name, p1_type, p2_type, p3_type, p4_type) struct name : State { \ + p1_type m_Param1; \ + p2_type m_Param2; \ + p3_type m_Param3; \ + p4_type m_Param4; \ + 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) {} \ + virtual bool IsEqual(State *other) { \ + if (MakeHash(GetName()) != MakeHash(other->GetName())) \ + return false; \ + name *other2 = static_cast(other); \ + return other2->m_Param1 == m_Param1 && other2->m_Param2 == m_Param2 && other2->m_Param3 == m_Param3 && other2->m_Param4 == m_Param4;\ + } \ + virtual void Dump() { \ + std::cout << " " << #name << "; Param1=" << m_Param1 << "; Param2=" << m_Param2 << "; Param3=" << m_Param3 << "; Param4=" << m_Param4 << std::endl; } \ + const char *GetName() { return #name; } \ + } + #define CHECK_COND(c, err) if (!(c)) { error = err; return false; } #endif