sourcehook/test/sourcehook_test.h
author Pavol Marko <pavolmarko@gmail.com>
Sun Oct 14 11:59:13 2007 +0000 (2007-10-14)
changeset 418 109309ff6350
parent 404 75808639f384
child 432 f26dd3e3030b
child 480 d096210677d4
permissions -rw-r--r--
Removed "trust the prototype" model which could lead to problems. Instead, every CVfnPtr now has a list of hook managers.
-> Removed CHookManagerContainer
Also removed listcat (unnecessary since "V2" interface)
     1 // This file is used for backwards compatibility testing
     2 // It allows us to test binary backwards compatibility by using an older include file HERE:
     3 #include "sourcehook.h"			// <-- here
     4 // There. main.cpp which implements all of the following function is always usign sourcehook.h
     5 // and the up-to-date sourcehook_impl.h/sourcehook.cpp. The tests use this file however.
     6 // If the test needs an up-to-date version (like the recall test), it can simply
     7 // #include "sourcehook.h" before including this, thus overriding our decision.
     8 
     9 
    10 SourceHook::ISourceHook *Test_Factory();
    11 void Test_Delete(SourceHook::ISourceHook *shptr);
    12 
    13 template <class T>
    14 struct CAutoPtrDestruction
    15 {
    16 	T *m_Ptr;
    17 	CAutoPtrDestruction(T *p) : m_Ptr(p) { }
    18 	~CAutoPtrDestruction() { if (m_Ptr) delete m_Ptr; }
    19 	void clear() { m_Ptr = NULL; }
    20 };
    21 
    22 struct CSHPtrAutoDestruction
    23 {
    24 	SourceHook::ISourceHook *m_SHPtr;
    25 	CSHPtrAutoDestruction(SourceHook::ISourceHook *shptr) : m_SHPtr(shptr) {}
    26 	~CSHPtrAutoDestruction() { Test_Delete(m_SHPtr); }
    27 };
    28 
    29 #define GET_SHPTR(var) var = Test_Factory(); CSHPtrAutoDestruction ___autodestruction(var);
    30 
    31 // Access to CSourceHookImpl functions
    32 void Test_CompleteShutdown(SourceHook::ISourceHook *shptr);
    33 void Test_UnloadPlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);
    34 void Test_PausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);
    35 void Test_UnpausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);