1.1 --- a/sourcehook/test/testhookmangen.cpp Mon Nov 19 14:41:31 2007 +0000
1.2 +++ b/sourcehook/test/testhookmangen.cpp Fri Nov 23 15:08:44 2007 +0000
1.3 @@ -30,6 +30,7 @@
1.4 SourceHook::List<const void*> g_PtrHash;
1.5
1.6 bool g_Inside_LeafFunc = false; // inside a hook or a func
1.7 + bool g_Silent_CtorDtor = false; // inside a hook or a func
1.8
1.9
1.10 // POD / Object types
1.11 @@ -74,32 +75,32 @@
1.12 Object(char initch)
1.13 {
1.14 memset(reinterpret_cast<void*>(x), initch, MYSIZE);
1.15 - if (!g_Inside_LeafFunc)
1.16 + if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
1.17 ADD_STATE(State_ObjOCtor_Called(MYSIZE));
1.18 }
1.19
1.20 Object()
1.21 {
1.22 - if (!g_Inside_LeafFunc)
1.23 + if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
1.24 ADD_STATE(State_ObjOCtor_Called(MYSIZE));
1.25 }
1.26
1.27 Object(const Object<MYSIZE> & other)
1.28 {
1.29 memcpy(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE);
1.30 - if (!g_Inside_LeafFunc)
1.31 + if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
1.32 ADD_STATE(State_ObjCCtor_Called(MYSIZE));
1.33 }
1.34
1.35 ~Object()
1.36 {
1.37 - if (!g_Inside_LeafFunc)
1.38 + if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
1.39 ADD_STATE(State_ObjODtor_Called(MYSIZE));
1.40 }
1.41
1.42 Object & operator = (const Object &other)
1.43 {
1.44 - if (!g_Inside_LeafFunc)
1.45 + if (!g_Inside_LeafFunc && !g_Silent_CtorDtor)
1.46 ADD_STATE(State_ObjAssignOp_Called(MYSIZE));
1.47
1.48 memcpy(reinterpret_cast<void*>(x), reinterpret_cast<const void*>(other.x), MYSIZE);
1.49 @@ -477,6 +478,11 @@
1.50 );
1.51 THGM_SETUP_RI(213, PodRet8, SourceHook::PassInfo::PassType_Object, SourceHook::PassInfo::PassFlag_ByVal);
1.52
1.53 + THGM_MAKE_TEST1_vafmt_void(214, Object<133>);
1.54 + THGM_SETUP_PI1(214, Object<133>, SourceHook::PassInfo::PassType_Object,
1.55 + SourceHook::PassInfo::PassFlag_ByVal | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor |
1.56 + SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp);
1.57 +
1.58
1.59 MAKE_STATE(State_Hello_Func4_Called);
1.60 MAKE_STATE(State_Hello_Func79_Called);
1.61 @@ -1032,8 +1038,14 @@
1.62 THGM_DO_TEST(212, (5, "Hello %s%d%s", "BA", 1, "L!"));
1.63 THGM_DO_TEST(213, (5, "Hello %s%d%s", "BA", 1, "L!"));
1.64
1.65 + // Silence Object's ctors/dtors: we only want a forced byref param
1.66 + g_Silent_CtorDtor = true;
1.67 + Object<133> *myobj133 = new Object<133>;
1.68 + THGM_DO_TEST_void(214, (*myobj133, "Hello %s%d%s", "BA", 1, "L!"));
1.69 + delete myobj133;
1.70 + g_Silent_CtorDtor = false;
1.71
1.72 - // Test for lange vtable indices
1.73 + // Test for high vtable indices
1.74 Hello *pHello = new Hello;
1.75 SourceHook::CProtoInfoBuilder helloPi(SourceHook::ProtoInfo::CallConv_ThisCall);
1.76 SourceHook::HookManagerPubFunc helloHM_4 = g_HMAGPtr->MakeHookMan(helloPi, 0, 4);