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:
David Anderson
2007-02-22 02:05:50 +00:00
parent 3de592d387
commit 8553f12d59
9 changed files with 61 additions and 45 deletions
+19
View File
@@ -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;