mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-12-04 16:24:16 +01:00
93ead5a2e0
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40506
94 lines
1.8 KiB
C++
94 lines
1.8 KiB
C++
/* ======== SourceHook ========
|
|
* Copyright (C) 2004-2007 Metamod:Source Development Team
|
|
* No warranties of any kind
|
|
*
|
|
* License: zlib/libpng
|
|
*
|
|
* Author(s): Pavol "PM OnoTo" Marko
|
|
* ============================
|
|
*/
|
|
|
|
#ifndef __SOURCEHOOK_IMPL_CPROTO_H__
|
|
#define __SOURCEHOOK_IMPL_CPROTO_H__
|
|
|
|
namespace SourceHook
|
|
{
|
|
namespace Impl
|
|
{
|
|
|
|
class CProto
|
|
{
|
|
ProtoInfo *m_Proto;
|
|
|
|
static bool Equal(const ProtoInfo *p1, const ProtoInfo *p2);
|
|
static ProtoInfo *DupProto(const ProtoInfo *src);
|
|
static void FreeProto(ProtoInfo *prot);
|
|
public:
|
|
CProto() : m_Proto(NULL)
|
|
{
|
|
}
|
|
|
|
CProto(const ProtoInfo *pProto) : m_Proto(DupProto(pProto))
|
|
{
|
|
}
|
|
|
|
CProto(const CProto &other) : m_Proto(DupProto(other.m_Proto))
|
|
{
|
|
}
|
|
|
|
~CProto()
|
|
{
|
|
FreeProto(m_Proto);
|
|
m_Proto = NULL;
|
|
}
|
|
|
|
void operator = (const ProtoInfo *pProto)
|
|
{
|
|
if (m_Proto)
|
|
FreeProto(m_Proto);
|
|
m_Proto = DupProto(pProto);
|
|
}
|
|
|
|
void operator = (const CProto &other)
|
|
{
|
|
if (m_Proto)
|
|
FreeProto(m_Proto);
|
|
m_Proto = DupProto(other.m_Proto);
|
|
}
|
|
|
|
bool operator == (const ProtoInfo *pProto) const
|
|
{
|
|
return Equal(pProto, m_Proto);
|
|
}
|
|
bool operator == (const CProto &other) const
|
|
{
|
|
return Equal(other.m_Proto, m_Proto);
|
|
}
|
|
|
|
const ProtoInfo *GetProto() const
|
|
{
|
|
return m_Proto;
|
|
}
|
|
|
|
// For old sourcehook.h: flags 0 -> assume ByVal
|
|
static unsigned int GetRealFlags(const PassInfo &info)
|
|
{
|
|
return (info.flags == 0) ? PassInfo::PassFlag_ByVal : info.flags;
|
|
}
|
|
|
|
static size_t GetRealSize(const PassInfo &info)
|
|
{
|
|
if (GetRealFlags(info) & PassInfo::PassFlag_ByRef)
|
|
{
|
|
return sizeof(void*);
|
|
}
|
|
|
|
return info.size;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|