1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-02 14:24:16 +01:00
HLMetaModOfficial/sourcehook/sourcehook_impl_cproto.h
Pavol Marko 94223941d2 Progress in GCC compat; TODO atm: proper passing of byval parameters with destructors (private copy, then byref pass?)
--HG--
branch : hookman_autogen
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/hookman_autogen%40547
2007-11-07 15:15:05 +00:00

125 lines
2.2 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
{
// Internal representation
struct IntPassInfo
{
size_t size;
int type;
unsigned int flags;
void *pNormalCtor;
void *pCopyCtor;
void *pDtor;
void *pAssignOperator;
};
class CProto
{
int m_Version; // -1 = invalid
int m_NumOfParams;
IntPassInfo m_RetPassInfo;
CVector<IntPassInfo> m_ParamsPassInfo;
int m_Convention;
void Fill(const ProtoInfo *pProto);
// For old sourcehook.h: flags 0 -> assume ByVal
static unsigned int GetRealFlags(const PassInfo &info)
{
return (info.flags == 0) ? PassInfo::PassFlag_ByVal : info.flags;
}
public:
CProto() : m_Version(-1)
{
}
CProto(const ProtoInfo *pProto)
{
Fill(pProto);
}
CProto(const CProto &other) : m_Version(other.m_Version), m_NumOfParams(other.m_NumOfParams),
m_RetPassInfo(other.m_RetPassInfo), m_ParamsPassInfo(other.m_ParamsPassInfo),
m_Convention(other.m_Convention)
{
}
~CProto()
{
}
void operator = (const ProtoInfo *pProto)
{
Fill (pProto);
}
bool operator == (const CProto &other) const;
int GetVersion() const
{
return m_Version;
}
int GetNumOfParams() const
{
return m_NumOfParams;
}
const IntPassInfo & GetParam(int i) const
{
return m_ParamsPassInfo[i];
}
IntPassInfo & GetParam(int i)
{
return m_ParamsPassInfo[i];
}
const IntPassInfo & GetRet() const
{
return m_RetPassInfo;
}
IntPassInfo & GetRet()
{
return m_RetPassInfo;
}
int GetConvention() const
{
return m_Convention;
}
static size_t GetRealSize(const IntPassInfo &info)
{
if (info.flags & PassInfo::PassFlag_ByRef)
{
return sizeof(void*);
}
return info.size;
}
};
}
}
#endif