1.1 --- a/sourcehook/sourcehook.h Sat Apr 30 19:10:07 2005 +0000
1.2 +++ b/sourcehook/sourcehook.h Sun May 01 09:55:51 2005 +0000
1.3 @@ -124,6 +124,10 @@
1.4 {
1.5 }
1.6
1.7 + CSHDelegate(const CSHDelegate &other) : m_Deleg(other.m_Deleg)
1.8 + {
1.9 + }
1.10 +
1.11 void DeleteThis()
1.12 {
1.13 delete this;
1.14 @@ -165,17 +169,18 @@
1.15 };
1.16
1.17 void *vfnptr; //!< Pointer to the function
1.18 - void *orig_entry; //!< The original vtable entry
1.19 + void *orig_entry; //!< The original vtable entry
1.20
1.21 typedef std::list<Iface> IfaceList;
1.22 typedef IfaceList::iterator IfaceListIter;
1.23 - IfaceList ifaces;
1.24 + IfaceList ifaces; //!< List of interface pointers
1.25
1.26 bool operator ==(void *other)
1.27 {
1.28 return vfnptr == other;
1.29 }
1.30 };
1.31 +
1.32 Plugin plug; //!< The owner plugin
1.33 const char *proto; //!< The prototype of the function the hook manager is responsible for
1.34 int vtbl_idx; //!< The vtable index
1.35 @@ -272,16 +277,17 @@
1.36 };
1.37 }
1.38
1.39 -//////////////////////////////////////////////////////////////////////////
1.40 -// Macro interface
1.41 -#define SET_META_RESULT(result) SH_GLOB_SHPTR->SetRes(result)
1.42 -#define RETURN_META(result) do { SH_GLOB_SHPTR->SetRes(result); return; } while(0)
1.43 -#define RETURN_META_VALUE(result, value) do { SH_GLOB_SHPTR->SetRes(result); return (value); } while(0)
1.44 +/************************************************************************/
1.45 +/* High level interface */
1.46 +/************************************************************************/
1.47 +#define SET_META_RESULT(result) SH_GLOB_SHPTR->SetRes(result)
1.48 +#define RETURN_META(result) do { SET_META_RESULT(result); return; } while(0)
1.49 +#define RETURN_META_VALUE(result, value) do { SET_META_RESULT(result); return (value); } while(0)
1.50
1.51 #define META_RESULT_STATUS SH_GLOB_SHPTR->GetStatus()
1.52 #define META_RESULT_PREVIOUS SH_GLOB_SHPTR->GetPrevRes()
1.53 -#define META_RESULT_ORIG_RET(type) *(const type *)SH_GLOB_SHPTR->GetOrigRet()
1.54 -#define META_RESULT_OVERRIDE_RET(type) *(const type *)SH_GLOB_SHPTR->GetOverrideRet()
1.55 +#define META_RESULT_ORIG_RET(type) *reinterpret_cast<const type*>(SH_GLOB_SHPTR->GetOrigRet())
1.56 +#define META_RESULT_OVERRIDE_RET(type) *reinterpret_cast<const type*>(SH_GLOB_SHPTR->GetOverrideRet())
1.57 #define META_IFACEPTR SH_GLOB_SHPTR->GetIfacePtr()
1.58
1.59
1.60 @@ -291,13 +297,20 @@
1.61 * @param ifaceptr The interface pointer
1.62 */
1.63 template<class ifacetype>
1.64 -inline SourceHook::CallClass<ifacetype> *SH_GET_CALLCLASS(ifacetype *ptr)
1.65 +inline SourceHook::CallClass<ifacetype> *SH_GET_CALLCLASS_R(SourceHook::ISourceHook *shptr, ifacetype *ptr)
1.66 {
1.67 return reinterpret_cast<SourceHook::CallClass<ifacetype>*>(
1.68 - SH_GLOB_SHPTR->GetCallClass(reinterpret_cast<void*>(ptr)));
1.69 + shptr->GetCallClass(reinterpret_cast<void*>(ptr)));
1.70 }
1.71
1.72 -#define SH_RELEASE_CALLCLASS(ptr) SH_GLOB_SHPTR->ReleaseCallClass(reinterpret_cast<SourceHook::GenericCallClass*>(ptr))
1.73 +template<class ifacetype>
1.74 +inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::CallClass<ifacetype> *ptr)
1.75 +{
1.76 + shptr->ReleaseCallClass(reinterpret_cast<SourceHook::GenericCallClass*>(ptr));
1.77 +}
1.78 +
1.79 +#define SH_GET_CALLCLASS(ptr) SH_GET_CALLCLASS_R(SH_GLOB_SHPTR, ptr)
1.80 +#define SH_RELEASE_CALLCLASS(ptr) SH_RELEASE_CALLCLASS_R(SH_GLOB_SHPTR, ptr)
1.81
1.82 #define SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
1.83 __SourceHook_FHAdd##ifacetype##ifacefunc((void*)ifaceptr, post, handler)
1.84 @@ -317,6 +330,7 @@
1.85
1.86
1.87
1.88 +
1.89 #if SH_COMP == SH_COMP_MSVC
1.90 # define SH_SETUP_MFP(mfp) \
1.91 reinterpret_cast<void**>(&mfp)[0] = vfnptr.orig_entry;