Added the ability for extensions to invoke arbitrary natives (bug 3605, r=ds,theY4Kman).
This commit is contained in:
@@ -535,3 +535,21 @@ uint32_t BaseRuntime::AddJittedFunction(JitFunction *fn)
|
||||
|
||||
return m_NumFuncs;
|
||||
}
|
||||
|
||||
int BaseRuntime::CreateBlank(uint32_t heastk)
|
||||
{
|
||||
memset(m_pPlugin, 0, sizeof(sp_plugin_t));
|
||||
|
||||
/* Align to cell_t bytes */
|
||||
heastk += sizeof(cell_t);
|
||||
heastk -= heastk % sizeof(cell_t);
|
||||
|
||||
m_pPlugin->mem_size = heastk;
|
||||
m_pPlugin->memory = new uint8_t[heastk];
|
||||
|
||||
m_pPlugin->profiler = g_engine2.GetProfiler();
|
||||
m_pCtx = new BaseContext(this);
|
||||
m_pCo = g_Jit.StartCompilation(this);
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
BaseRuntime();
|
||||
~BaseRuntime();
|
||||
public:
|
||||
virtual int CreateBlank(uint32_t heastk);
|
||||
virtual int CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base);
|
||||
virtual bool IsDebugging();
|
||||
virtual IPluginDebugInfo *GetDebugInfo();
|
||||
|
||||
@@ -191,3 +191,22 @@ void SourcePawnEngine2::Shutdown()
|
||||
{
|
||||
g_Jit.ShutdownJIT();
|
||||
}
|
||||
|
||||
IPluginRuntime *SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory)
|
||||
{
|
||||
int err;
|
||||
BaseRuntime *rt;
|
||||
|
||||
rt = new BaseRuntime();
|
||||
if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE)
|
||||
{
|
||||
delete rt;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rt->m_pPlugin->name = strdup(name != NULL ? name : "<anonymous>");
|
||||
|
||||
rt->ApplyCompilationOptions(NULL);
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace SourcePawn
|
||||
const char *GetErrorString(int err);
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
IPluginRuntime *CreateEmptyRuntime(const char *name, uint32_t memory);
|
||||
public:
|
||||
IProfiler *GetProfiler();
|
||||
private:
|
||||
|
||||
@@ -873,3 +873,8 @@ bool BaseContext::GetKey(int k, void **value)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseContext::ClearLastNativeError()
|
||||
{
|
||||
m_ctx.n_err = SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public: //IPluginContext
|
||||
void SetKey(int k, void *value);
|
||||
bool GetKey(int k, void **value);
|
||||
void Refresh();
|
||||
void ClearLastNativeError();
|
||||
public:
|
||||
bool IsInExec();
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user