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
+8 -17
View File
@@ -304,6 +304,11 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
{
func = (*iter);
if (!func->IsRunnable())
{
continue;
}
for (unsigned int i=0; i<num_params; i++)
{
param = &temp_info[i];
@@ -633,21 +638,13 @@ bool CForward::RemoveFunction(IPluginFunction *func)
{
bool found = false;
FuncIter iter;
List<IPluginFunction *> *lst;
if (func->GetParentContext()->IsRunnable())
{
lst = &m_functions;
} else {
lst = &m_paused;
}
for (iter=lst->begin(); iter!=lst->end(); iter++)
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
{
if ((*iter) == func)
{
found = true;
lst->erase(iter);
m_functions.erase(iter);
break;
}
}
@@ -689,13 +686,7 @@ bool CForward::AddFunction(IPluginFunction *func)
return false;
}
//:IDEA: eventually we will tell the plugin we're using it [?]
if (func->GetParentContext()->IsRunnable())
{
m_functions.push_back(func);
} else {
m_paused.push_back(func);
}
m_functions.push_back(func);
return true;
}
+11 -6
View File
@@ -202,7 +202,6 @@ bool CPlugin::FinishMyCompile(char *error, size_t maxlength)
}
m_ctx.base = new BaseContext(m_ctx.ctx);
m_ctx.base->SetRunnable(false);
m_ctx.ctx->user[SM_CONTEXTVAR_MYSELF] = (void *)this;
m_status = Plugin_Created;
@@ -222,9 +221,9 @@ void CPlugin::SetErrorState(PluginStatus status, const char *error_fmt, ...)
vsnprintf(m_errormsg, sizeof(m_errormsg), error_fmt, ap);
va_end(ap);
if (m_ctx.base)
if (m_ctx.ctx)
{
m_ctx.base->SetRunnable(false);
m_ctx.ctx->flags |= SPFLAG_PLUGIN_PAUSED;
}
}
@@ -310,7 +309,6 @@ bool CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
}
m_status = Plugin_Loaded;
m_ctx.base->SetRunnable(true);
int err;
cell_t result;
@@ -397,8 +395,6 @@ bool CPlugin::SetPauseState(bool paused)
return false;
}
m_status = (paused) ? Plugin_Paused : Plugin_Running;
IPluginFunction *pFunction = m_ctx.base->GetFunctionByName("OnPluginPauseChange");
if (pFunction)
{
@@ -407,6 +403,15 @@ bool CPlugin::SetPauseState(bool paused)
pFunction->Execute(&result);
}
if (paused)
{
m_status = Plugin_Paused;
m_ctx.ctx->flags |= SPFLAG_PLUGIN_PAUSED;
} else {
m_status = Plugin_Running;
m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
}
g_PluginSys._SetPauseState(this, paused);
return true;