core/sourcehook/test/sourcehook_test.h
changeset 539 db914129ae01
parent 480 d096210677d4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/sourcehook/test/sourcehook_test.h	Fri Nov 14 04:04:02 2008 -0600
     1.3 @@ -0,0 +1,49 @@
     1.4 +// This file is used for backwards compatibility testing
     1.5 +// It allows us to test binary backwards compatibility by using an older include file HERE:
     1.6 +#include "sourcehook.h"			// <-- here
     1.7 +// There. main.cpp which implements all of the following function is always usign sourcehook.h
     1.8 +// and the up-to-date sourcehook_impl.h/sourcehook.cpp. The tests use this file however.
     1.9 +// If the test needs an up-to-date version (like the recall test), it can simply
    1.10 +// #include "sourcehook.h" before including this, thus overriding our decision.
    1.11 +
    1.12 +
    1.13 +SourceHook::ISourceHook *Test_Factory();
    1.14 +void Test_Delete(SourceHook::ISourceHook *shptr);
    1.15 +
    1.16 +template <class T>
    1.17 +struct CAutoPtrDestruction
    1.18 +{
    1.19 +	T *m_Ptr;
    1.20 +	CAutoPtrDestruction(T *p) : m_Ptr(p) { }
    1.21 +	~CAutoPtrDestruction() { if (m_Ptr) delete m_Ptr; }
    1.22 +	void clear() { m_Ptr = NULL; }
    1.23 +	void set(T *ptr) { m_Ptr = ptr; }
    1.24 +};
    1.25 +
    1.26 +struct CSHPtrAutoDestruction
    1.27 +{
    1.28 +	SourceHook::ISourceHook *m_SHPtr;
    1.29 +	CSHPtrAutoDestruction(SourceHook::ISourceHook *shptr) : m_SHPtr(shptr) {}
    1.30 +	~CSHPtrAutoDestruction() { Test_Delete(m_SHPtr); }
    1.31 +};
    1.32 +
    1.33 +#define GET_SHPTR(var) var = Test_Factory(); CSHPtrAutoDestruction ___autodestruction(var);
    1.34 +
    1.35 +// Access to CSourceHookImpl functions
    1.36 +void Test_CompleteShutdown(SourceHook::ISourceHook *shptr);
    1.37 +void Test_UnloadPlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);
    1.38 +void Test_PausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);
    1.39 +void Test_UnpausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug);
    1.40 +
    1.41 +SourceHook::IHookManagerAutoGen *Test_HMAG_Factory(SourceHook::ISourceHook *pSHPtr);
    1.42 +void Test_HMAG_Delete(SourceHook::IHookManagerAutoGen *ptr);
    1.43 +
    1.44 +struct CHMAGAutoDestruction
    1.45 +{
    1.46 +	SourceHook::IHookManagerAutoGen *m_Ptr;
    1.47 +	CHMAGAutoDestruction(SourceHook::IHookManagerAutoGen *ptr) : m_Ptr(ptr) {}
    1.48 +	~CHMAGAutoDestruction() { Test_HMAG_Delete(m_Ptr); }
    1.49 +};
    1.50 +
    1.51 +
    1.52 +#define GET_HMAG(var, shptr) var = Test_HMAG_Factory(shptr); CHMAGAutoDestruction __hmagautodestruction(var);