Corrected an API design flaw with pausing. Contexts can now be flagged as paused, and IsRunnable() is moved from IBaseContext to IPluginFunction. While this allows for per-function pausing, it is not intended that way.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40531
This commit is contained in:
@@ -40,7 +40,6 @@ BaseContext::BaseContext(sp_context_t *_ctx)
|
||||
ctx->dbreak = GlobalDebugBreak;
|
||||
m_InExec = false;
|
||||
m_CustomMsg = false;
|
||||
m_Runnable = true;
|
||||
m_funcsnum = ctx->vmbase->FunctionCount(ctx);
|
||||
m_priv_funcs = NULL;
|
||||
m_pub_funcs = NULL;
|
||||
@@ -153,7 +152,7 @@ IPluginDebugInfo *BaseContext::GetDebugInfo()
|
||||
|
||||
int BaseContext::Execute(uint32_t code_addr, cell_t *result)
|
||||
{
|
||||
if (!m_Runnable)
|
||||
if ((ctx->flags & SPFLAG_PLUGIN_PAUSED) == SPFLAG_PLUGIN_PAUSED)
|
||||
{
|
||||
return SP_ERROR_NOT_RUNNABLE;
|
||||
}
|
||||
@@ -928,14 +927,4 @@ void BaseContext::SetIdentity(SourceMod::IdentityToken_t *token)
|
||||
{
|
||||
m_pToken = token;
|
||||
}
|
||||
|
||||
bool BaseContext::IsRunnable()
|
||||
{
|
||||
return m_Runnable;
|
||||
}
|
||||
|
||||
void BaseContext::SetRunnable(bool runnable)
|
||||
{
|
||||
m_Runnable = runnable;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -68,8 +68,6 @@ namespace SourcePawn
|
||||
#if defined SOURCEMOD_BUILD
|
||||
virtual SourceMod::IdentityToken_t *GetIdentity();
|
||||
void SetIdentity(SourceMod::IdentityToken_t *token);
|
||||
bool IsRunnable();
|
||||
void SetRunnable(bool runnable);
|
||||
#endif
|
||||
public: //IPluginDebugInfo
|
||||
virtual int LookupFile(ucell_t addr, const char **filename);
|
||||
@@ -88,7 +86,6 @@ namespace SourcePawn
|
||||
char m_MsgCache[1024];
|
||||
bool m_CustomMsg;
|
||||
bool m_InExec;
|
||||
bool m_Runnable;
|
||||
unsigned int m_funcsnum;
|
||||
CFunction **m_priv_funcs;
|
||||
CFunction **m_pub_funcs;
|
||||
|
||||
@@ -26,10 +26,21 @@ void CFunction::Set(uint32_t code_addr, IPluginContext *plugin)
|
||||
m_curparam = 0;
|
||||
m_errorstate = SP_ERROR_NONE;
|
||||
m_Invalid = false;
|
||||
m_pCtx = plugin ? plugin->GetContext() : NULL;
|
||||
}
|
||||
|
||||
bool CFunction::IsRunnable()
|
||||
{
|
||||
return ((m_pCtx->flags & SPFLAG_PLUGIN_PAUSED) != SPFLAG_PLUGIN_PAUSED);
|
||||
}
|
||||
|
||||
int CFunction::CallFunction(const cell_t *params, unsigned int num_params, cell_t *result)
|
||||
{
|
||||
if (!IsRunnable())
|
||||
{
|
||||
return SP_ERROR_NOT_RUNNABLE;
|
||||
}
|
||||
|
||||
while (num_params--)
|
||||
{
|
||||
m_pContext->PushCell(params[num_params]);
|
||||
@@ -48,6 +59,10 @@ CFunction::CFunction(uint32_t code_addr, IPluginContext *plugin) :
|
||||
m_errorstate(SP_ERROR_NONE)
|
||||
{
|
||||
m_Invalid = false;
|
||||
if (plugin)
|
||||
{
|
||||
m_pCtx = plugin->GetContext();
|
||||
}
|
||||
}
|
||||
|
||||
int CFunction::PushCell(cell_t cell)
|
||||
@@ -201,6 +216,10 @@ void CFunction::Cancel()
|
||||
int CFunction::Execute(cell_t *result)
|
||||
{
|
||||
int err;
|
||||
if (!IsRunnable())
|
||||
{
|
||||
m_errorstate = SP_ERROR_NOT_RUNNABLE;
|
||||
}
|
||||
if (m_errorstate != SP_ERROR_NONE)
|
||||
{
|
||||
err = m_errorstate;
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
{
|
||||
m_Invalid = true;
|
||||
}
|
||||
bool IsRunnable();
|
||||
public:
|
||||
void Set(uint32_t code_addr, IPluginContext *plugin);
|
||||
private:
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
private:
|
||||
uint32_t m_codeaddr;
|
||||
IPluginContext *m_pContext;
|
||||
sp_context_t *m_pCtx;
|
||||
cell_t m_params[SP_MAX_EXEC_PARAMS];
|
||||
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
|
||||
unsigned int m_curparam;
|
||||
|
||||
Reference in New Issue
Block a user