diff -r 30d2be004032 -r 07575ad47137 sourcehook/test/testhookmangen.cpp --- a/sourcehook/test/testhookmangen.cpp Fri Nov 02 12:41:00 2007 +0000 +++ b/sourcehook/test/testhookmangen.cpp Fri Nov 02 20:15:19 2007 +0000 @@ -18,6 +18,17 @@ namespace { + StateList g_States; + SourceHook::ISourceHook *g_SHPtr; + SourceHook::Plugin g_PLID; + + // PtrBuf(ptr) gives ptrs unique numbers + // in the order they appear + SourceHook::List g_PtrHash; + + bool g_Inside_LeafFunc = false; // inside a hook or a func + + // POD / Object types template struct POD @@ -151,52 +162,6 @@ } \ }; - #include "testhookmangen.h" - - StateList g_States; - SourceHook::ISourceHook *g_SHPtr; - SourceHook::Plugin g_PLID; - - // PtrBuf(ptr) gives ptrs unique numbers - // in the order they appear - SourceHook::List g_PtrHash; - - bool g_Inside_LeafFunc = false; // inside a hook or a func - - template - int PtrBuf(T ptr) - { - int a = 0; - - const void *vptr = reinterpret_cast(ptr); - for (SourceHook::List::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end(); ++iter) - { - if (*iter == vptr) - return a; - else - ++a; - } - g_PtrHash.push_back(vptr); - return static_cast(g_PtrHash.size()) - 1; - } - - template - T PtrBufPtr(T ptr) - { - PtrBuf(ptr); - return ptr; - } - - void PtrBuf_Clear(int leave_in = 0) - { - for (SourceHook::List::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end();) - { - if (--leave_in < 0) - iter = g_PtrHash.erase(iter); - else - ++iter; - } - } // "Increment" something: (reproducible change for recall tests) @@ -250,6 +215,44 @@ } }; + #include "testhookmangen.h" + + template + int PtrBuf(T ptr) + { + int a = 0; + + const void *vptr = reinterpret_cast(ptr); + for (SourceHook::List::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end(); ++iter) + { + if (*iter == vptr) + return a; + else + ++a; + } + g_PtrHash.push_back(vptr); + return static_cast(g_PtrHash.size()) - 1; + } + + template + T PtrBufPtr(T ptr) + { + PtrBuf(ptr); + return ptr; + } + + void PtrBuf_Clear(int leave_in = 0) + { + for (SourceHook::List::iterator iter = g_PtrHash.begin(); iter != g_PtrHash.end();) + { + if (--leave_in < 0) + iter = g_PtrHash.erase(iter); + else + ++iter; + } + } + + // MyDelegate base class for other delegates class MyDelegate : public SourceHook::ISHDelegate { @@ -879,4 +882,4 @@ memset((void*)test4[2], 0, ps / 4); return true; -} \ No newline at end of file +}