diff -r e8a3f2617a3e -r f9e21a2ac558 sourcehook/test/test3.cpp --- a/sourcehook/test/test3.cpp Sun Oct 07 03:12:19 2007 +0000 +++ b/sourcehook/test/test3.cpp Sun Oct 07 22:10:07 2007 +0000 @@ -47,8 +47,6 @@ } }; - class DerivedDerived : public Derived { }; - SH_DECL_HOOK0_void(Derived, Func1, SH_NOATTRIB, 0); SH_DECL_HOOK0_void(Derived, Func2, SH_NOATTRIB, 0); SH_DECL_HOOK0_void(Derived, Func3, SH_NOATTRIB, 0); @@ -74,7 +72,7 @@ GET_SHPTR(g_SHPtr); g_PLID = 1337; - DerivedDerived inst; + Derived inst; Derived *pD = &inst; Base1 *pB1 = pD; Base2 *pB2 = pD; @@ -87,10 +85,11 @@ // Get a callclass for pD // Verify whether the this pointers are correct // Also call them normally to make sure that we aren't messing it up ;) + SourceHook::CallClass *pD_CC = SH_GET_CALLCLASS(pD); - SH_CALL(pD, &Derived::Func1)(); - SH_CALL(pD, &Derived::Func2)(); - SH_CALL(pD, &Derived::Func3)(); + SH_CALL(pD_CC, &Derived::Func1)(); + SH_CALL(pD_CC, &Derived::Func2)(); + SH_CALL(pD_CC, &Derived::Func3)(); pD->Func1(); pD->Func2(); pD->Func3(); @@ -104,8 +103,8 @@ new State_Func3_Called(pD), NULL), "Part 1"); - SH_CALL(pD, &Base1::Func1)(); - SH_CALL(pD, &Base2::Func2)(); + SH_CALL(pD_CC, &Base1::Func1)(); + SH_CALL(pD_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), @@ -115,8 +114,11 @@ // 2) // Get callclasses for the other ones and verify it as well - SH_CALL(pB1, &Base1::Func1)(); - SH_CALL(pB2, &Base2::Func2)(); + SourceHook::CallClass *pB1_CC = SH_GET_CALLCLASS(pB1); + SourceHook::CallClass *pB2_CC = SH_GET_CALLCLASS(pB2); + + SH_CALL(pB1_CC, &Base1::Func1)(); + SH_CALL(pB2_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), @@ -210,11 +212,11 @@ new State_Func3_Called(pD), NULL), "Part 5.1"); - SH_CALL(pD, &Derived::Func1)(); - SH_CALL(pD, &Derived::Func2)(); - SH_CALL(pD, &Derived::Func3)(); - SH_CALL(pB1, &Base1::Func1)(); - SH_CALL(pB2, &Base2::Func2)(); + SH_CALL(pD_CC, &Derived::Func1)(); + SH_CALL(pD_CC, &Derived::Func2)(); + SH_CALL(pD_CC, &Derived::Func3)(); + SH_CALL(pB1_CC, &Base1::Func1)(); + SH_CALL(pB2_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), @@ -228,5 +230,9 @@ SH_REMOVE_HOOK(Derived, Func2, pD, SH_STATIC(Handler_Func2), false); SH_REMOVE_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); + SH_RELEASE_CALLCLASS(pB1_CC); + SH_RELEASE_CALLCLASS(pB2_CC); + SH_RELEASE_CALLCLASS(pD_CC); + return true; }