1.1 --- a/core/systems/ForwardSys.cpp Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,737 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#include <assert.h>
1.36 -#include <stdarg.h>
1.37 -#include <string.h>
1.38 -#include "ForwardSys.h"
1.39 -#include "PluginSys.h"
1.40 -#include "ShareSys.h"
1.41 -#include "DebugReporter.h"
1.42 -
1.43 -CForwardManager g_Forwards;
1.44 -
1.45 -/**
1.46 - * Genesis turns to its source, reduction occurs stepwise although the essence is all one.
1.47 - * End of line. FTL system check.
1.48 - *
1.49 - * :TODO: WHAT NEEDS TO BE TESTED IN THIS BEAST
1.50 - * VARARG FUNCTIONS:
1.51 - * - Pushing no varargs
1.52 - */
1.53 -
1.54 -// :TODO: IMPORTANT!!! The result pointer arg in the execute function maybe invalid if the forward fails
1.55 -// so later evaluation of this result may cause problems on higher levels of abstraction. DOCUMENT OR FIX ALL FORWARDS!
1.56 -
1.57 -CForwardManager::~CForwardManager()
1.58 -{
1.59 - CStack<CForward *>::iterator iter;
1.60 - for (iter=m_FreeForwards.begin(); iter!=m_FreeForwards.end(); iter++)
1.61 - {
1.62 - delete (*iter);
1.63 - }
1.64 - m_FreeForwards.popall();
1.65 -}
1.66 -
1.67 -void CForwardManager::OnSourceModAllInitialized()
1.68 -{
1.69 - g_PluginSys.AddPluginsListener(this);
1.70 - g_ShareSys.AddInterface(NULL, this);
1.71 -}
1.72 -
1.73 -IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, ...)
1.74 -{
1.75 - CForward *fwd;
1.76 - va_list ap;
1.77 - va_start(ap, types);
1.78 -
1.79 - fwd = CForward::CreateForward(name, et, num_params, types, ap);
1.80 -
1.81 - va_end(ap);
1.82 -
1.83 - if (fwd)
1.84 - {
1.85 - g_PluginSys.AddFunctionsToForward(name, fwd);
1.86 -
1.87 - m_managed.push_back(fwd);
1.88 - }
1.89 -
1.90 - return fwd;
1.91 -}
1.92 -
1.93 -IChangeableForward *CForwardManager::CreateForwardEx(const char *name, ExecType et, int num_params, const ParamType *types, ...)
1.94 -{
1.95 - CForward *fwd;
1.96 - va_list ap;
1.97 - va_start(ap, types);
1.98 -
1.99 - fwd = CForward::CreateForward(name, et, num_params, types, ap);
1.100 -
1.101 - va_end(ap);
1.102 -
1.103 - if (fwd)
1.104 - {
1.105 - m_unmanaged.push_back(fwd);
1.106 - }
1.107 -
1.108 - return fwd;
1.109 -}
1.110 -
1.111 -void CForwardManager::OnPluginLoaded(IPlugin *plugin)
1.112 -{
1.113 - /* Attach any globally managed forwards */
1.114 - List<CForward *>::iterator iter;
1.115 - CForward *fwd;
1.116 -
1.117 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.118 - {
1.119 - fwd = (*iter);
1.120 - IPluginFunction *pFunc = plugin->GetBaseContext()->GetFunctionByName(fwd->GetForwardName());
1.121 - if (pFunc)
1.122 - {
1.123 - fwd->AddFunction(pFunc);
1.124 - }
1.125 - }
1.126 -}
1.127 -
1.128 -void CForwardManager::OnPluginUnloaded(IPlugin *plugin)
1.129 -{
1.130 - List<CForward *>::iterator iter;
1.131 - CForward *fwd;
1.132 -
1.133 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.134 - {
1.135 - fwd = (*iter);
1.136 - fwd->RemoveFunctionsOfPlugin(plugin);
1.137 - }
1.138 -
1.139 - for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
1.140 - {
1.141 - fwd = (*iter);
1.142 - fwd->RemoveFunctionsOfPlugin(plugin);
1.143 - }
1.144 -}
1.145 -
1.146 -IForward *CForwardManager::FindForward(const char *name, IChangeableForward **ifchng)
1.147 -{
1.148 - List<CForward *>::iterator iter;
1.149 - CForward *fwd;
1.150 -
1.151 - for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
1.152 - {
1.153 - fwd = (*iter);
1.154 - if (strcmp(fwd->GetForwardName(), name) == 0)
1.155 - {
1.156 - if (ifchng)
1.157 - {
1.158 - *ifchng = NULL;
1.159 - }
1.160 - return fwd;
1.161 - }
1.162 - }
1.163 -
1.164 - for (iter=m_unmanaged.begin(); iter!=m_unmanaged.end(); iter++)
1.165 - {
1.166 - fwd = (*iter);
1.167 - if (strcmp(fwd->GetForwardName(), name) == 0)
1.168 - {
1.169 - if (ifchng)
1.170 - {
1.171 - *ifchng = fwd;
1.172 - }
1.173 - return fwd;
1.174 - }
1.175 - }
1.176 -
1.177 - if (ifchng)
1.178 - {
1.179 - *ifchng = NULL;
1.180 - }
1.181 -
1.182 - return NULL;
1.183 -}
1.184 -
1.185 -void CForwardManager::ReleaseForward(IForward *forward)
1.186 -{
1.187 - ForwardFree(static_cast<CForward *>(forward));
1.188 -}
1.189 -
1.190 -void CForwardManager::ForwardFree(CForward *fwd)
1.191 -{
1.192 - if (fwd == NULL)
1.193 - {
1.194 - return;
1.195 - }
1.196 -
1.197 - m_FreeForwards.push(fwd);
1.198 - m_managed.remove(fwd);
1.199 -}
1.200 -
1.201 -CForward *CForwardManager::ForwardMake()
1.202 -{
1.203 - CForward *fwd;
1.204 - if (m_FreeForwards.empty())
1.205 - {
1.206 - fwd = new CForward;
1.207 - } else {
1.208 - fwd = m_FreeForwards.front();
1.209 - m_FreeForwards.pop();
1.210 - }
1.211 - return fwd;
1.212 -}
1.213 -
1.214 -void CForwardManager::OnPluginPauseChange(IPlugin *plugin, bool paused)
1.215 -{
1.216 - /* No longer used */
1.217 -}
1.218 -
1.219 -/*************************************
1.220 - * ACTUAL FORWARD API IMPLEMENTATION *
1.221 - *************************************/
1.222 -
1.223 -CForward *CForward::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, va_list ap)
1.224 -{
1.225 - ParamType _types[SP_MAX_EXEC_PARAMS];
1.226 -
1.227 - if (num_params > SP_MAX_EXEC_PARAMS)
1.228 - {
1.229 - return NULL;
1.230 - }
1.231 -
1.232 - if (types == NULL && num_params)
1.233 - {
1.234 - for (unsigned int i=0; i<num_params; i++)
1.235 - {
1.236 - _types[i] = (ParamType)va_arg(ap, int);
1.237 - if (_types[i] == Param_VarArgs && (i != num_params - 1))
1.238 - {
1.239 - return NULL;
1.240 - }
1.241 - }
1.242 - types = _types;
1.243 - } else {
1.244 - for (unsigned int i=0; i<num_params; i++)
1.245 - {
1.246 - _types[i] = types[i];
1.247 - if (types[i] == Param_VarArgs && (i != num_params - 1))
1.248 - {
1.249 - return NULL;
1.250 - }
1.251 - }
1.252 - }
1.253 -
1.254 - /* First parameter can never be varargs */
1.255 - if (num_params && _types[0] == Param_VarArgs)
1.256 - {
1.257 - return NULL;
1.258 - }
1.259 -
1.260 - CForward *pForward = g_Forwards.ForwardMake();
1.261 - pForward->m_curparam = 0;
1.262 - pForward->m_ExecType = et;
1.263 - snprintf(pForward->m_name, FORWARDS_NAME_MAX, "%s", name ? name : "");
1.264 -
1.265 - for (unsigned int i=0; i<num_params; i++)
1.266 - {
1.267 - pForward->m_types[i] = _types[i];
1.268 - }
1.269 -
1.270 - if (num_params && _types[num_params-1] == Param_VarArgs)
1.271 - {
1.272 - pForward->m_varargs = num_params--;
1.273 - } else {
1.274 - pForward->m_varargs = false;
1.275 - }
1.276 -
1.277 - pForward->m_numparams = num_params;
1.278 - pForward->m_errstate = SP_ERROR_NONE;
1.279 -
1.280 - pForward->m_functions.clear();
1.281 -
1.282 - return pForward;
1.283 -}
1.284 -
1.285 -int CForward::Execute(cell_t *result, IForwardFilter *filter)
1.286 -{
1.287 - if (m_errstate)
1.288 - {
1.289 - int err = m_errstate;
1.290 - Cancel();
1.291 - return err;
1.292 - }
1.293 -
1.294 - if (filter)
1.295 - {
1.296 - filter->OnExecuteBegin();
1.297 - }
1.298 -
1.299 - FuncIter iter = m_functions.begin();
1.300 - IPluginFunction *func;
1.301 - cell_t cur_result = 0;
1.302 - cell_t high_result = 0;
1.303 - int err;
1.304 - unsigned int failed=0, success=0;
1.305 - unsigned int num_params = m_curparam;
1.306 - FwdParamInfo temp_info[SP_MAX_EXEC_PARAMS];
1.307 - FwdParamInfo *param;
1.308 - ParamType type;
1.309 -
1.310 - /* Save local, reset */
1.311 - memcpy(temp_info, m_params, sizeof(m_params));
1.312 - m_curparam = 0;
1.313 -
1.314 - for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
1.315 - {
1.316 - func = (*iter);
1.317 -
1.318 - for (unsigned int i=0; i<num_params; i++)
1.319 - {
1.320 - int err = SP_ERROR_PARAM;
1.321 - param = &temp_info[i];
1.322 - if (i >= m_numparams || m_types[i] == Param_Any)
1.323 - {
1.324 - type = param->pushedas;
1.325 - } else {
1.326 - type = m_types[i];
1.327 - }
1.328 - if ((i >= m_numparams) || (type & SP_PARAMFLAG_BYREF))
1.329 - {
1.330 - /* If we're byref or we're vararg, we always push everything by ref.
1.331 - * Even if they're byval, we must push them byref.
1.332 - */
1.333 - if (type == Param_String)
1.334 - {
1.335 - err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
1.336 - } else if (type == Param_Float || type == Param_Cell) {
1.337 - err = func->PushCellByRef(¶m->val);
1.338 - } else {
1.339 - err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags);
1.340 - assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
1.341 - }
1.342 - } else {
1.343 - /* If we're not byref or not vararg, our job is a bit easier. */
1.344 - assert(type == Param_Cell || type == Param_Float);
1.345 - err = func->PushCell(param->val);
1.346 - }
1.347 - if (err != SP_ERROR_NONE)
1.348 - {
1.349 - if (!filter || !filter->OnErrorReport(this, func, err))
1.350 - {
1.351 - g_DbgReporter.GenerateError(func->GetParentContext(),
1.352 - func->GetFunctionID(),
1.353 - err,
1.354 - "Failed to push parameter while executing forward");
1.355 - }
1.356 - continue;
1.357 - }
1.358 - }
1.359 -
1.360 - /* Call the function and deal with the return value. */
1.361 - if ((err=func->Execute(&cur_result)) != SP_ERROR_NONE)
1.362 - {
1.363 - if (filter)
1.364 - {
1.365 - filter->OnErrorReport(this, func, err);
1.366 - }
1.367 - failed++;
1.368 - } else {
1.369 - success++;
1.370 - switch (m_ExecType)
1.371 - {
1.372 - case ET_Event:
1.373 - {
1.374 - if (cur_result > high_result)
1.375 - {
1.376 - high_result = cur_result;
1.377 - }
1.378 - break;
1.379 - }
1.380 - case ET_Hook:
1.381 - {
1.382 - if (cur_result > high_result)
1.383 - {
1.384 - high_result = cur_result;
1.385 - if ((ResultType)high_result == Pl_Stop)
1.386 - {
1.387 - goto done;
1.388 - }
1.389 - }
1.390 - break;
1.391 - }
1.392 - case ET_Custom:
1.393 - {
1.394 - if (filter)
1.395 - {
1.396 - if (filter->OnFunctionReturn(this, func, &cur_result) == Pl_Stop)
1.397 - {
1.398 - goto done;
1.399 - }
1.400 - }
1.401 - break;
1.402 - }
1.403 - default:
1.404 - {
1.405 - break;
1.406 - }
1.407 - }
1.408 - }
1.409 - }
1.410 -
1.411 -done:
1.412 - if (success)
1.413 - {
1.414 - if (m_ExecType == ET_Event || m_ExecType == ET_Hook)
1.415 - {
1.416 - cur_result = high_result;
1.417 - } else if (m_ExecType == ET_Ignore) {
1.418 - cur_result = 0;
1.419 - }
1.420 - if (result)
1.421 - {
1.422 - *result = cur_result;
1.423 - }
1.424 - }
1.425 -
1.426 - if (filter)
1.427 - {
1.428 - filter->OnExecuteEnd(&cur_result, success, failed);
1.429 - }
1.430 -
1.431 - return SP_ERROR_NONE;
1.432 -}
1.433 -
1.434 -int CForward::PushCell(cell_t cell)
1.435 -{
1.436 - if (m_curparam < m_numparams)
1.437 - {
1.438 - if (m_types[m_curparam] == Param_Any)
1.439 - {
1.440 - m_params[m_curparam].pushedas = Param_Cell;
1.441 - } else if (m_types[m_curparam] != Param_Cell) {
1.442 - return SetError(SP_ERROR_PARAM);
1.443 - }
1.444 - } else {
1.445 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.446 - {
1.447 - return SetError(SP_ERROR_PARAMS_MAX);
1.448 - }
1.449 - m_params[m_curparam].pushedas = Param_Cell;
1.450 - }
1.451 -
1.452 - m_params[m_curparam++].val = cell;
1.453 -
1.454 - return SP_ERROR_NONE;
1.455 -}
1.456 -
1.457 -int CForward::PushFloat(float number)
1.458 -{
1.459 - if (m_curparam < m_numparams)
1.460 - {
1.461 - if (m_types[m_curparam] == Param_Any)
1.462 - {
1.463 - m_params[m_curparam].pushedas = Param_Float;
1.464 - } else if (m_types[m_curparam] != Param_Float) {
1.465 - return SetError(SP_ERROR_PARAM);
1.466 - }
1.467 - } else {
1.468 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.469 - {
1.470 - return SetError(SP_ERROR_PARAMS_MAX);
1.471 - }
1.472 - m_params[m_curparam].pushedas = Param_Float;
1.473 - }
1.474 -
1.475 - m_params[m_curparam++].val = *(cell_t *)&number;
1.476 -
1.477 - return SP_ERROR_NONE;
1.478 -}
1.479 -
1.480 -int CForward::PushCellByRef(cell_t *cell, int flags)
1.481 -{
1.482 - if (m_curparam < m_numparams)
1.483 - {
1.484 - if (m_types[m_curparam] == Param_Any)
1.485 - {
1.486 - m_params[m_curparam].pushedas = Param_CellByRef;
1.487 - } else if (m_types[m_curparam] != Param_CellByRef) {
1.488 - return SetError(SP_ERROR_PARAM);
1.489 - }
1.490 - } else {
1.491 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.492 - {
1.493 - return SetError(SP_ERROR_PARAMS_MAX);
1.494 - }
1.495 - m_params[m_curparam].pushedas = Param_CellByRef;
1.496 - }
1.497 -
1.498 - _Int_PushArray(cell, 1, flags);
1.499 - m_curparam++;
1.500 -
1.501 - return SP_ERROR_NONE;
1.502 -}
1.503 -
1.504 -int CForward::PushFloatByRef(float *num, int flags)
1.505 -{
1.506 - if (m_curparam < m_numparams)
1.507 - {
1.508 - if (m_types[m_curparam] == Param_Any)
1.509 - {
1.510 - m_params[m_curparam].pushedas = Param_FloatByRef;
1.511 - } else if (m_types[m_curparam] != Param_FloatByRef) {
1.512 - return SetError(SP_ERROR_PARAM);
1.513 - }
1.514 - } else {
1.515 - if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
1.516 - {
1.517 - return SetError(SP_ERROR_PARAMS_MAX);
1.518 - }
1.519 - m_params[m_curparam].pushedas = Param_FloatByRef;
1.520 - }
1.521 -
1.522 - _Int_PushArray((cell_t *)num, 1, flags);
1.523 - m_curparam++;
1.524 -
1.525 - return SP_ERROR_NONE;
1.526 -}
1.527 -
1.528 -void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags)
1.529 -{
1.530 - m_params[m_curparam].byref.cells = cells;
1.531 - m_params[m_curparam].byref.flags = flags;
1.532 - m_params[m_curparam].byref.orig_addr = inarray;
1.533 -}
1.534 -
1.535 -int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags)
1.536 -{
1.537 - /* We don't allow this here */
1.538 - if (!inarray)
1.539 - {
1.540 - return SetError(SP_ERROR_PARAM);
1.541 - }
1.542 -
1.543 - if (m_curparam < m_numparams)
1.544 - {
1.545 - if (m_types[m_curparam] == Param_Any)
1.546 - {
1.547 - m_params[m_curparam].pushedas = Param_Array;
1.548 - } else if (m_types[m_curparam] != Param_Array) {
1.549 - return SetError(SP_ERROR_PARAM);
1.550 - }
1.551 - } else {
1.552 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.553 - {
1.554 - return SetError(SP_ERROR_PARAMS_MAX);
1.555 - }
1.556 - m_params[m_curparam].pushedas = Param_Array;
1.557 - }
1.558 -
1.559 - _Int_PushArray(inarray, cells, flags);
1.560 -
1.561 - m_curparam++;
1.562 -
1.563 - return SP_ERROR_NONE;
1.564 -}
1.565 -
1.566 -void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags)
1.567 -{
1.568 - m_params[m_curparam].byref.cells = cells; /* Notice this contains the char count not cell count */
1.569 - m_params[m_curparam].byref.flags = cp_flags;
1.570 - m_params[m_curparam].byref.orig_addr = inarray;
1.571 - m_params[m_curparam].byref.sz_flags = sz_flags;
1.572 -}
1.573 -
1.574 -int CForward::PushString(const char *string)
1.575 -{
1.576 - if (m_curparam < m_numparams)
1.577 - {
1.578 - if (m_types[m_curparam] == Param_Any)
1.579 - {
1.580 - m_params[m_curparam].pushedas = Param_String;
1.581 - } else if (m_types[m_curparam] != Param_String) {
1.582 - return SetError(SP_ERROR_PARAM);
1.583 - }
1.584 - } else {
1.585 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.586 - {
1.587 - return SetError(SP_ERROR_PARAMS_MAX);
1.588 - }
1.589 - m_params[m_curparam].pushedas = Param_String;
1.590 - }
1.591 -
1.592 - _Int_PushString((cell_t *)string, strlen(string)+1, SM_PARAM_STRING_COPY, 0);
1.593 - m_curparam++;
1.594 -
1.595 - return SP_ERROR_NONE;
1.596 -}
1.597 -
1.598 -int CForward::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags)
1.599 -{
1.600 - if (m_curparam < m_numparams)
1.601 - {
1.602 - if (m_types[m_curparam] == Param_Any)
1.603 - {
1.604 - m_params[m_curparam].pushedas = Param_String;
1.605 - } else if (m_types[m_curparam] != Param_String) {
1.606 - return SetError(SP_ERROR_PARAM);
1.607 - }
1.608 - } else {
1.609 - if (!m_varargs || m_curparam > SP_MAX_EXEC_PARAMS)
1.610 - {
1.611 - return SetError(SP_ERROR_PARAMS_MAX);
1.612 - }
1.613 - m_params[m_curparam].pushedas = Param_String;
1.614 - }
1.615 -
1.616 - _Int_PushString((cell_t *)buffer, length, sz_flags, cp_flags);
1.617 - m_curparam++;
1.618 -
1.619 - return SP_ERROR_NONE;
1.620 -}
1.621 -
1.622 -void CForward::Cancel()
1.623 -{
1.624 - if (!m_curparam)
1.625 - {
1.626 - return;
1.627 - }
1.628 -
1.629 - m_curparam = 0;
1.630 - m_errstate = SP_ERROR_NONE;
1.631 -}
1.632 -
1.633 -bool CForward::AddFunction(IPluginContext *pContext, funcid_t index)
1.634 -{
1.635 - IPluginFunction *pFunc = pContext->GetFunctionById(index);
1.636 -
1.637 - if (!pFunc)
1.638 - {
1.639 - return false;
1.640 - }
1.641 -
1.642 - return AddFunction(pFunc);
1.643 -}
1.644 -
1.645 -bool CForward::RemoveFunction(IPluginContext *pContext, funcid_t index)
1.646 -{
1.647 - IPluginFunction *pFunc = pContext->GetFunctionById(index);
1.648 -
1.649 - if (!pFunc)
1.650 - {
1.651 - return false;
1.652 - }
1.653 -
1.654 - return RemoveFunction(pFunc);
1.655 -}
1.656 -
1.657 -bool CForward::RemoveFunction(IPluginFunction *func)
1.658 -{
1.659 - bool found = false;
1.660 - FuncIter iter;
1.661 - List<IPluginFunction *> *lst;
1.662 -
1.663 - if (func->IsRunnable())
1.664 - {
1.665 - lst = &m_functions;
1.666 - } else {
1.667 - lst = &m_paused;
1.668 - }
1.669 -
1.670 - for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
1.671 - {
1.672 - if ((*iter) == func)
1.673 - {
1.674 - found = true;
1.675 - lst->erase(iter);
1.676 - break;
1.677 - }
1.678 - }
1.679 -
1.680 - /* Cancel a call, if any */
1.681 - if (found || m_curparam)
1.682 - {
1.683 - func->Cancel();
1.684 - }
1.685 -
1.686 - return found;
1.687 -}
1.688 -
1.689 -unsigned int CForward::RemoveFunctionsOfPlugin(IPlugin *plugin)
1.690 -{
1.691 - FuncIter iter;
1.692 - IPluginFunction *func;
1.693 - unsigned int removed = 0;
1.694 - IPluginContext *pContext = plugin->GetBaseContext();
1.695 - for (iter=m_functions.begin(); iter!=m_functions.end();)
1.696 - {
1.697 - func = (*iter);
1.698 - if (func->GetParentContext() == pContext)
1.699 - {
1.700 - iter = m_functions.erase(iter);
1.701 - removed++;
1.702 - } else {
1.703 - iter++;
1.704 - }
1.705 - }
1.706 -
1.707 - return removed;
1.708 -}
1.709 -
1.710 -bool CForward::AddFunction(IPluginFunction *func)
1.711 -{
1.712 - if (m_curparam)
1.713 - {
1.714 - return false;
1.715 - }
1.716 -
1.717 - if (func->IsRunnable())
1.718 - {
1.719 - m_functions.push_back(func);
1.720 - } else {
1.721 - m_paused.push_back(func);
1.722 - }
1.723 -
1.724 - return true;
1.725 -}
1.726 -
1.727 -const char *CForward::GetForwardName()
1.728 -{
1.729 - return m_name;
1.730 -}
1.731 -
1.732 -unsigned int CForward::GetFunctionCount()
1.733 -{
1.734 - return m_functions.size();
1.735 -}
1.736 -
1.737 -ExecType CForward::GetExecType()
1.738 -{
1.739 - return m_ExecType;
1.740 -}