Rename BaseContext to PluginContext.
This commit is contained in:
parent
8b8edf6e70
commit
2e77155b4e
@ -25,7 +25,7 @@ typedef struct sp_plugin_debug_s
|
||||
bool unpacked; /**< Whether debug structures are unpacked */
|
||||
} sp_plugin_debug_t;
|
||||
|
||||
class BaseContext;
|
||||
class PluginContext;
|
||||
|
||||
/**
|
||||
* Breaks into a debugger
|
||||
@ -34,7 +34,7 @@ class BaseContext;
|
||||
* [1] - frm
|
||||
* [2] - cip
|
||||
*/
|
||||
typedef int (*SPVM_DEBUGBREAK)(BaseContext *, uint32_t, uint32_t);
|
||||
typedef int (*SPVM_DEBUGBREAK)(PluginContext *, uint32_t, uint32_t);
|
||||
|
||||
/**
|
||||
* @brief The rebased memory format of a plugin. This differs from the on-disk structure
|
||||
@ -69,7 +69,7 @@ namespace SourcePawn
|
||||
}
|
||||
|
||||
struct tracker_t;
|
||||
class BaseContext;
|
||||
class PluginContext;
|
||||
|
||||
typedef struct sp_context_s
|
||||
{
|
||||
@ -83,7 +83,7 @@ typedef struct sp_context_s
|
||||
uint32_t n_idx; /**< Current native index being executed */
|
||||
tracker_t *tracker;
|
||||
sp_plugin_t *plugin;
|
||||
BaseContext *basecx;
|
||||
PluginContext *basecx;
|
||||
void * vm[8]; /**< VM-specific pointers */
|
||||
cell_t rp; /**< Return stack pointer */
|
||||
cell_t rstk_cips[SP_MAX_RETURN_STACK];
|
||||
|
@ -300,7 +300,7 @@ int PluginRuntime::CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base)
|
||||
md5_data.finalize();
|
||||
md5_data.raw_digest(m_DataHash);
|
||||
|
||||
m_pCtx = new BaseContext(this);
|
||||
m_pCtx = new PluginContext(this);
|
||||
|
||||
SetupFloatNativeRemapping();
|
||||
function_map_size_ = m_plugin.pcode_size / sizeof(cell_t) + 1;
|
||||
@ -559,7 +559,7 @@ size_t PluginRuntime::GetMemUsage()
|
||||
|
||||
mem += sizeof(this);
|
||||
mem += sizeof(sp_plugin_t);
|
||||
mem += sizeof(BaseContext);
|
||||
mem += sizeof(PluginContext);
|
||||
mem += m_plugin.base_size;
|
||||
|
||||
return mem;
|
||||
@ -575,7 +575,7 @@ unsigned char *PluginRuntime::GetDataHash()
|
||||
return m_DataHash;
|
||||
}
|
||||
|
||||
BaseContext *PluginRuntime::GetBaseContext()
|
||||
PluginContext *PluginRuntime::GetBaseContext()
|
||||
{
|
||||
return m_pCtx;
|
||||
}
|
||||
@ -598,7 +598,7 @@ PluginRuntime::CreateBlank(uint32_t heastk)
|
||||
m_plugin.mem_size = heastk;
|
||||
m_plugin.memory = new uint8_t[heastk];
|
||||
|
||||
m_pCtx = new BaseContext(this);
|
||||
m_pCtx = new PluginContext(this);
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "compiled-function.h"
|
||||
#include "scripted-invoker.h"
|
||||
|
||||
class BaseContext;
|
||||
class PluginContext;
|
||||
|
||||
class DebugInfo : public IPluginDebugInfo
|
||||
{
|
||||
@ -84,7 +84,7 @@ class PluginRuntime
|
||||
unsigned GetNativeReplacement(size_t index);
|
||||
ScriptedInvoker *GetPublicFunction(size_t index);
|
||||
|
||||
BaseContext *GetBaseContext();
|
||||
PluginContext *GetBaseContext();
|
||||
const sp_plugin_t *plugin() const {
|
||||
return &m_plugin;
|
||||
}
|
||||
@ -111,7 +111,7 @@ class PluginRuntime
|
||||
|
||||
public:
|
||||
DebugInfo m_Debug;
|
||||
BaseContext *m_pCtx;
|
||||
PluginContext *m_pCtx;
|
||||
ScriptedInvoker **m_PubFuncs;
|
||||
CompiledFunction **m_PubJitFuncs;
|
||||
|
||||
|
@ -26,7 +26,7 @@ using namespace SourcePawn;
|
||||
#define CELLBOUNDMAX (INT_MAX/sizeof(cell_t))
|
||||
#define STACKMARGIN ((cell_t)(16*sizeof(cell_t)))
|
||||
|
||||
BaseContext::BaseContext(PluginRuntime *pRuntime)
|
||||
PluginContext::PluginContext(PluginRuntime *pRuntime)
|
||||
{
|
||||
m_pRuntime = pRuntime;
|
||||
|
||||
@ -66,56 +66,56 @@ BaseContext::BaseContext(PluginRuntime *pRuntime)
|
||||
m_ctx.plugin = const_cast<sp_plugin_t *>(pRuntime->plugin());
|
||||
}
|
||||
|
||||
BaseContext::~BaseContext()
|
||||
PluginContext::~PluginContext()
|
||||
{
|
||||
free(m_ctx.tracker->pBase);
|
||||
delete m_ctx.tracker;
|
||||
}
|
||||
|
||||
IVirtualMachine *
|
||||
BaseContext::GetVirtualMachine()
|
||||
PluginContext::GetVirtualMachine()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sp_context_t *
|
||||
BaseContext::GetContext()
|
||||
PluginContext::GetContext()
|
||||
{
|
||||
return reinterpret_cast<sp_context_t *>((IPluginContext * )this);
|
||||
}
|
||||
|
||||
sp_context_t *
|
||||
BaseContext::GetCtx()
|
||||
PluginContext::GetCtx()
|
||||
{
|
||||
return &m_ctx;
|
||||
}
|
||||
|
||||
bool
|
||||
BaseContext::IsDebugging()
|
||||
PluginContext::IsDebugging()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::SetDebugBreak(void *newpfn, void *oldpfn)
|
||||
PluginContext::SetDebugBreak(void *newpfn, void *oldpfn)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
IPluginDebugInfo *
|
||||
BaseContext::GetDebugInfo()
|
||||
PluginContext::GetDebugInfo()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::Execute(uint32_t code_addr, cell_t *result)
|
||||
PluginContext::Execute(uint32_t code_addr, cell_t *result)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
void
|
||||
BaseContext::SetErrorMessage(const char *msg, va_list ap)
|
||||
PluginContext::SetErrorMessage(const char *msg, va_list ap)
|
||||
{
|
||||
m_CustomMsg = true;
|
||||
|
||||
@ -123,7 +123,7 @@ BaseContext::SetErrorMessage(const char *msg, va_list ap)
|
||||
}
|
||||
|
||||
void
|
||||
BaseContext::_SetErrorMessage(const char *msg, ...)
|
||||
PluginContext::_SetErrorMessage(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
@ -132,7 +132,7 @@ BaseContext::_SetErrorMessage(const char *msg, ...)
|
||||
}
|
||||
|
||||
cell_t
|
||||
BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...)
|
||||
PluginContext::ThrowNativeErrorEx(int error, const char *msg, ...)
|
||||
{
|
||||
if (!m_InExec)
|
||||
return 0;
|
||||
@ -150,7 +150,7 @@ BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...)
|
||||
}
|
||||
|
||||
cell_t
|
||||
BaseContext::ThrowNativeError(const char *msg, ...)
|
||||
PluginContext::ThrowNativeError(const char *msg, ...)
|
||||
{
|
||||
if (!m_InExec)
|
||||
return 0;
|
||||
@ -168,7 +168,7 @@ BaseContext::ThrowNativeError(const char *msg, ...)
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr)
|
||||
PluginContext::HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr)
|
||||
{
|
||||
cell_t *addr;
|
||||
ucell_t realmem;
|
||||
@ -207,7 +207,7 @@ BaseContext::HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_add
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::HeapPop(cell_t local_addr)
|
||||
PluginContext::HeapPop(cell_t local_addr)
|
||||
{
|
||||
cell_t cellcount;
|
||||
cell_t *addr;
|
||||
@ -230,7 +230,7 @@ BaseContext::HeapPop(cell_t local_addr)
|
||||
|
||||
|
||||
int
|
||||
BaseContext::HeapRelease(cell_t local_addr)
|
||||
PluginContext::HeapRelease(cell_t local_addr)
|
||||
{
|
||||
if (local_addr < (cell_t)m_pRuntime->plugin()->data_size)
|
||||
return SP_ERROR_INVALID_ADDRESS;
|
||||
@ -241,91 +241,91 @@ BaseContext::HeapRelease(cell_t local_addr)
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::FindNativeByName(const char *name, uint32_t *index)
|
||||
PluginContext::FindNativeByName(const char *name, uint32_t *index)
|
||||
{
|
||||
return m_pRuntime->FindNativeByName(name, index);
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::GetNativeByIndex(uint32_t index, sp_native_t **native)
|
||||
PluginContext::GetNativeByIndex(uint32_t index, sp_native_t **native)
|
||||
{
|
||||
return m_pRuntime->GetNativeByIndex(index, native);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BaseContext::GetNativesNum()
|
||||
PluginContext::GetNativesNum()
|
||||
{
|
||||
return m_pRuntime->GetNativesNum();
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::FindPublicByName(const char *name, uint32_t *index)
|
||||
PluginContext::FindPublicByName(const char *name, uint32_t *index)
|
||||
{
|
||||
return m_pRuntime->FindPublicByName(name, index);
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::GetPublicByIndex(uint32_t index, sp_public_t **pblic)
|
||||
PluginContext::GetPublicByIndex(uint32_t index, sp_public_t **pblic)
|
||||
{
|
||||
return m_pRuntime->GetPublicByIndex(index, pblic);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BaseContext::GetPublicsNum()
|
||||
PluginContext::GetPublicsNum()
|
||||
{
|
||||
return m_pRuntime->GetPublicsNum();
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar)
|
||||
PluginContext::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar)
|
||||
{
|
||||
return m_pRuntime->GetPubvarByIndex(index, pubvar);
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::FindPubvarByName(const char *name, uint32_t *index)
|
||||
PluginContext::FindPubvarByName(const char *name, uint32_t *index)
|
||||
{
|
||||
return m_pRuntime->FindPubvarByName(name, index);
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr)
|
||||
PluginContext::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr)
|
||||
{
|
||||
return m_pRuntime->GetPubvarAddrs(index, local_addr, phys_addr);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BaseContext::GetPubVarsNum()
|
||||
PluginContext::GetPubVarsNum()
|
||||
{
|
||||
return m_pRuntime->GetPubVarsNum();
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite)
|
||||
PluginContext::BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::BindNative(const sp_nativeinfo_t *native)
|
||||
PluginContext::BindNative(const sp_nativeinfo_t *native)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC func)
|
||||
PluginContext::BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC func)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::BindNativeToAny(SPVM_NATIVE_FUNC native)
|
||||
PluginContext::BindNativeToAny(SPVM_NATIVE_FUNC native)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr)
|
||||
PluginContext::LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr)
|
||||
{
|
||||
if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) ||
|
||||
(local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size))
|
||||
@ -340,25 +340,25 @@ BaseContext::LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr)
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::PushCell(cell_t value)
|
||||
PluginContext::PushCell(cell_t value)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::PushCellsFromArray(cell_t array[], unsigned int numcells)
|
||||
PluginContext::PushCellsFromArray(cell_t array[], unsigned int numcells)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells)
|
||||
PluginContext::PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::LocalToString(cell_t local_addr, char **addr)
|
||||
PluginContext::LocalToString(cell_t local_addr, char **addr)
|
||||
{
|
||||
if (((local_addr >= m_ctx.hp) && (local_addr < m_ctx.sp)) ||
|
||||
(local_addr < 0) || ((ucell_t)local_addr >= m_pRuntime->plugin()->mem_size))
|
||||
@ -371,13 +371,13 @@ BaseContext::LocalToString(cell_t local_addr, char **addr)
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::PushString(cell_t *local_addr, char **phys_addr, const char *string)
|
||||
PluginContext::PushString(cell_t *local_addr, char **phys_addr, const char *string)
|
||||
{
|
||||
return SP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::StringToLocal(cell_t local_addr, size_t bytes, const char *source)
|
||||
PluginContext::StringToLocal(cell_t local_addr, size_t bytes, const char *source)
|
||||
{
|
||||
char *dest;
|
||||
size_t len;
|
||||
@ -439,7 +439,7 @@ __CheckValidChar(char *c)
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes)
|
||||
PluginContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes)
|
||||
{
|
||||
char *dest;
|
||||
size_t len;
|
||||
@ -475,19 +475,19 @@ BaseContext::StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *s
|
||||
}
|
||||
|
||||
IPluginFunction *
|
||||
BaseContext::GetFunctionById(funcid_t func_id)
|
||||
PluginContext::GetFunctionById(funcid_t func_id)
|
||||
{
|
||||
return m_pRuntime->GetFunctionById(func_id);
|
||||
}
|
||||
|
||||
IPluginFunction *
|
||||
BaseContext::GetFunctionByName(const char *public_name)
|
||||
PluginContext::GetFunctionByName(const char *public_name)
|
||||
{
|
||||
return m_pRuntime->GetFunctionByName(public_name);
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::LocalToStringNULL(cell_t local_addr, char **addr)
|
||||
PluginContext::LocalToStringNULL(cell_t local_addr, char **addr)
|
||||
{
|
||||
int err;
|
||||
if ((err = LocalToString(local_addr, addr)) != SP_ERROR_NONE)
|
||||
@ -500,7 +500,7 @@ BaseContext::LocalToStringNULL(cell_t local_addr, char **addr)
|
||||
}
|
||||
|
||||
SourceMod::IdentityToken_t *
|
||||
BaseContext::GetIdentity()
|
||||
PluginContext::GetIdentity()
|
||||
{
|
||||
SourceMod::IdentityToken_t *tok;
|
||||
|
||||
@ -510,7 +510,7 @@ BaseContext::GetIdentity()
|
||||
}
|
||||
|
||||
cell_t *
|
||||
BaseContext::GetNullRef(SP_NULL_TYPE type)
|
||||
PluginContext::GetNullRef(SP_NULL_TYPE type)
|
||||
{
|
||||
if (type == SP_NULL_VECTOR)
|
||||
return m_pNullVec;
|
||||
@ -519,13 +519,13 @@ BaseContext::GetNullRef(SP_NULL_TYPE type)
|
||||
}
|
||||
|
||||
bool
|
||||
BaseContext::IsInExec()
|
||||
PluginContext::IsInExec()
|
||||
{
|
||||
return m_InExec;
|
||||
}
|
||||
|
||||
int
|
||||
BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result)
|
||||
PluginContext::Execute2(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result)
|
||||
{
|
||||
int ir;
|
||||
int serial;
|
||||
@ -656,7 +656,7 @@ BaseContext::Execute2(IPluginFunction *function, const cell_t *params, unsigned
|
||||
}
|
||||
|
||||
IPluginRuntime *
|
||||
BaseContext::GetRuntime()
|
||||
PluginContext::GetRuntime()
|
||||
{
|
||||
return m_pRuntime;
|
||||
}
|
||||
@ -778,19 +778,19 @@ DebugInfo::LookupLine(ucell_t addr, uint32_t *line)
|
||||
#undef USHR
|
||||
|
||||
int
|
||||
BaseContext::GetLastNativeError()
|
||||
PluginContext::GetLastNativeError()
|
||||
{
|
||||
return m_ctx.n_err;
|
||||
}
|
||||
|
||||
cell_t *
|
||||
BaseContext::GetLocalParams()
|
||||
PluginContext::GetLocalParams()
|
||||
{
|
||||
return (cell_t *)(m_pRuntime->plugin()->memory + m_ctx.frm + (2 * sizeof(cell_t)));
|
||||
}
|
||||
|
||||
void
|
||||
BaseContext::SetKey(int k, void *value)
|
||||
PluginContext::SetKey(int k, void *value)
|
||||
{
|
||||
if (k < 1 || k > 4)
|
||||
return;
|
||||
@ -800,7 +800,7 @@ BaseContext::SetKey(int k, void *value)
|
||||
}
|
||||
|
||||
bool
|
||||
BaseContext::GetKey(int k, void **value)
|
||||
PluginContext::GetKey(int k, void **value)
|
||||
{
|
||||
if (k < 1 || k > 4 || m_keys_set[k - 1] == false)
|
||||
return false;
|
||||
@ -810,7 +810,7 @@ BaseContext::GetKey(int k, void **value)
|
||||
}
|
||||
|
||||
void
|
||||
BaseContext::ClearLastNativeError()
|
||||
PluginContext::ClearLastNativeError()
|
||||
{
|
||||
m_ctx.n_err = SP_ERROR_NONE;
|
||||
}
|
||||
|
@ -18,15 +18,11 @@
|
||||
#include "plugin-runtime.h"
|
||||
#include "jit_shared.h"
|
||||
|
||||
/**
|
||||
* :TODO: Make functions allocate as a lump instead of individual allocations!
|
||||
*/
|
||||
|
||||
class BaseContext : public IPluginContext
|
||||
class PluginContext : public IPluginContext
|
||||
{
|
||||
public:
|
||||
BaseContext(PluginRuntime *pRuntime);
|
||||
~BaseContext();
|
||||
PluginContext(PluginRuntime *pRuntime);
|
||||
~PluginContext();
|
||||
|
||||
public: //IPluginContext
|
||||
IVirtualMachine *GetVirtualMachine();
|
||||
|
Loading…
Reference in New Issue
Block a user