1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-01 13:24:25 +01:00

Better treatement of deprecated callclasses

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40393
This commit is contained in:
Pavol Marko 2007-05-12 19:05:16 +00:00
parent cdead2f8fc
commit ac92e7ff05
6 changed files with 56 additions and 63 deletions

Binary file not shown.

View File

@ -298,15 +298,12 @@ namespace SourceHook
}
};
template<class B> struct CallClass
template<class B> struct DeprecatedCallClass
{
virtual B *GetThisPtr() = 0;
virtual void *GetOrigFunc(int vtbloffs, int vtblidx) = 0;
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
// 09.08.2008 (6 AM, I just woke up, the others are still sleeping so i finally can use this notebook !!)
// - Today is an important day.
// I'm adding support for functions which return references.
@ -408,14 +405,14 @@ namespace SourceHook
* @param iface The interface pointer
* @param size Size of the class instance
*/
virtual GenericCallClass *GetCallClass(void *iface, size_t size) = 0;
virtual DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size) = 0;
/**
* @brief Release a callclass
*
* @param ptr Pointer to the callclass
*/
virtual void ReleaseCallClass(GenericCallClass *ptr) = 0;
virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr) = 0;
virtual void SetRes(META_RES res) = 0; //!< Sets the meta result
virtual META_RES GetPrevRes() = 0; //!< Gets the meta result of the
@ -569,11 +566,11 @@ namespace SourceHook
};
// For source-level compatibility
template <class T> struct LegacyCallClass
template <class T> struct CallClass
{
T *ptr;
LegacyCallClass(T *p) : ptr(p)
CallClass(T *p) : ptr(p)
{
}
@ -583,17 +580,21 @@ namespace SourceHook
}
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
template <class T>
LegacyCallClass<T> *GetLegacyCallClass(T *p)
CallClass<T> *GetCallClass(T *p)
{
return new LegacyCallClass<T>(p);
return new CallClass<T>(p);
}
template <class T>
void ReleaseLegacyCallClass(LegacyCallClass<T> *p)
void ReleaseCallClass(CallClass<T> *p)
{
delete p;
}
}
/************************************************************************/
@ -707,12 +708,10 @@ namespace SourceHook
} while (0)
// For source-level compatibility
#define CallClass LegacyCallClass
#define ManualCallClass LegacyCallClass<SourceHook::EmptyClass>
#define SH_GET_CALLCLASS(ptr) SourceHook::GetLegacyCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetLegacyCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseLegacyCallClass(ptr)
#define SH_GET_CALLCLASS(ptr) SourceHook::GetCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseCallClass(ptr)
// New ADD / REMOVE macros.
#define SH_STATIC(func) fastdelegate::MakeDelegate(func)
@ -3166,12 +3165,12 @@ namespace SourceHook
}
};
template <class T> struct CCW< LegacyCallClass<T> >
template <class T> struct CCW< CallClass<T> >
{
typedef T type;
// Get Real Pointer!
static inline T *GRP(LegacyCallClass<T> *p)
static inline T *GRP(CallClass<T> *p)
{
return p->ptr;
}

View File

@ -298,15 +298,12 @@ namespace SourceHook
}
};
template<class B> struct CallClass
template<class B> struct DeprecatedCallClass
{
virtual B *GetThisPtr() = 0;
virtual void *GetOrigFunc(int vtbloffs, int vtblidx) = 0;
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
// 09.08.2008 (6 AM, I just woke up, the others are still sleeping so i finally can use this notebook !!)
// - Today is an important day.
// I'm adding support for functions which return references.
@ -408,14 +405,14 @@ namespace SourceHook
* @param iface The interface pointer
* @param size Size of the class instance
*/
virtual GenericCallClass *GetCallClass(void *iface, size_t size) = 0;
virtual DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size) = 0;
/**
* @brief Release a callclass
*
* @param ptr Pointer to the callclass
*/
virtual void ReleaseCallClass(GenericCallClass *ptr) = 0;
virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr) = 0;
virtual void SetRes(META_RES res) = 0; //!< Sets the meta result
virtual META_RES GetPrevRes() = 0; //!< Gets the meta result of the
@ -569,11 +566,11 @@ namespace SourceHook
};
// For source-level compatibility
template <class T> struct LegacyCallClass
template <class T> struct CallClass
{
T *ptr;
LegacyCallClass(T *p) : ptr(p)
CallClass(T *p) : ptr(p)
{
}
@ -583,17 +580,21 @@ namespace SourceHook
}
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
template <class T>
LegacyCallClass<T> *GetLegacyCallClass(T *p)
CallClass<T> *GetCallClass(T *p)
{
return new LegacyCallClass<T>(p);
return new CallClass<T>(p);
}
template <class T>
void ReleaseLegacyCallClass(LegacyCallClass<T> *p)
void ReleaseCallClass(CallClass<T> *p)
{
delete p;
}
}
/************************************************************************/
@ -707,12 +708,10 @@ namespace SourceHook
} while (0)
// For source-level compatibility
#define CallClass LegacyCallClass
#define ManualCallClass LegacyCallClass<SourceHook::EmptyClass>
#define SH_GET_CALLCLASS(ptr) SourceHook::GetLegacyCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetLegacyCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseLegacyCallClass(ptr)
#define SH_GET_CALLCLASS(ptr) SourceHook::GetCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseCallClass(ptr)
// New ADD / REMOVE macros.
#define SH_STATIC(func) fastdelegate::MakeDelegate(func)
@ -1286,12 +1285,12 @@ namespace SourceHook
}
};
template <class T> struct CCW< LegacyCallClass<T> >
template <class T> struct CCW< CallClass<T> >
{
typedef T type;
// Get Real Pointer!
static inline T *GRP(LegacyCallClass<T> *p)
static inline T *GRP(CallClass<T> *p)
{
return p->ptr;
}

View File

@ -595,7 +595,7 @@ namespace SourceHook
return status;
}
GenericCallClass *CSourceHookImpl::GetCallClass(void *iface, size_t size)
DeprecatedCallClass<void> *CSourceHookImpl::GetCallClass(void *iface, size_t size)
{
for (Impl_CallClassList::iterator cciter = m_CallClasses.begin(); cciter != m_CallClasses.end(); ++cciter)
{
@ -614,7 +614,7 @@ namespace SourceHook
return &m_CallClasses.back();
}
void CSourceHookImpl::ReleaseCallClass(GenericCallClass *ptr)
void CSourceHookImpl::ReleaseCallClass(DeprecatedCallClass<void> *ptr)
{
Impl_CallClassList::iterator iter = m_CallClasses.find(ptr);
if (iter == m_CallClasses.end())

View File

@ -298,15 +298,12 @@ namespace SourceHook
}
};
template<class B> struct CallClass
template<class B> struct DeprecatedCallClass
{
virtual B *GetThisPtr() = 0;
virtual void *GetOrigFunc(int vtbloffs, int vtblidx) = 0;
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
// 09.08.2008 (6 AM, I just woke up, the others are still sleeping so i finally can use this notebook !!)
// - Today is an important day.
// I'm adding support for functions which return references.
@ -408,14 +405,14 @@ namespace SourceHook
* @param iface The interface pointer
* @param size Size of the class instance
*/
virtual GenericCallClass *GetCallClass(void *iface, size_t size) = 0;
virtual DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size) = 0;
/**
* @brief Release a callclass
*
* @param ptr Pointer to the callclass
*/
virtual void ReleaseCallClass(GenericCallClass *ptr) = 0;
virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr) = 0;
virtual void SetRes(META_RES res) = 0; //!< Sets the meta result
virtual META_RES GetPrevRes() = 0; //!< Gets the meta result of the
@ -569,11 +566,11 @@ namespace SourceHook
};
// For source-level compatibility
template <class T> struct LegacyCallClass
template <class T> struct CallClass
{
T *ptr;
LegacyCallClass(T *p) : ptr(p)
CallClass(T *p) : ptr(p)
{
}
@ -583,17 +580,21 @@ namespace SourceHook
}
};
typedef CallClass<void> GenericCallClass;
typedef CallClass<EmptyClass> ManualCallClass;
template <class T>
LegacyCallClass<T> *GetLegacyCallClass(T *p)
CallClass<T> *GetCallClass(T *p)
{
return new LegacyCallClass<T>(p);
return new CallClass<T>(p);
}
template <class T>
void ReleaseLegacyCallClass(LegacyCallClass<T> *p)
void ReleaseCallClass(CallClass<T> *p)
{
delete p;
}
}
/************************************************************************/
@ -707,12 +708,10 @@ namespace SourceHook
} while (0)
// For source-level compatibility
#define CallClass LegacyCallClass
#define ManualCallClass LegacyCallClass<SourceHook::EmptyClass>
#define SH_GET_CALLCLASS(ptr) SourceHook::GetLegacyCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetLegacyCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseLegacyCallClass(ptr)
#define SH_GET_CALLCLASS(ptr) SourceHook::GetCallClass(ptr)
#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseCallClass(ptr)
// New ADD / REMOVE macros.
#define SH_STATIC(func) fastdelegate::MakeDelegate(func)
@ -3166,12 +3165,12 @@ namespace SourceHook
}
};
template <class T> struct CCW< LegacyCallClass<T> >
template <class T> struct CCW< CallClass<T> >
{
typedef T type;
// Get Real Pointer!
static inline T *GRP(LegacyCallClass<T> *p)
static inline T *GRP(CallClass<T> *p)
{
return p->ptr;
}

View File

@ -170,10 +170,6 @@ New SH_CALL
the original function. Everything works fine. This works even for VP hooks.
*/
// See sourcehook.hxx :)
#undef CallClass
#undef ManualCallClass
namespace SourceHook
{
/**
@ -555,7 +551,7 @@ namespace SourceHook
void AddHookManager(Plugin plug, const CHookManagerInfo &hookman);
};
class CCallClassImpl : public GenericCallClass
class CCallClassImpl : public DeprecatedCallClass<void>
{
public:
@ -721,14 +717,14 @@ namespace SourceHook
* @param iface The interface pointer
* @param size Size of the class instance
*/
GenericCallClass *GetCallClass(void *iface, size_t size);
DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size);
/**
* @brief Release a callclass
*
* @param ptr Pointer to the callclass
*/
virtual void ReleaseCallClass(GenericCallClass *ptr);
virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr);
virtual void SetRes(META_RES res); //!< Sets the meta result
virtual META_RES GetPrevRes(); //!< Gets the meta result of the previously called handler