Debian Codegraph @

src/plan/ScriptCmd.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "ScriptCmd.h"
10
11 #include "ScriptState.h"
12
13 //-----------------------------------------------------------------
14 /**
15 * Obtain script function.
16 * @param script script state where to execute
17 * @param funcRef index of function at registry
18 */
19 ScriptCmd::ScriptCmd(ScriptState *script, int funcRef)
20 {
21 m_script = script;
22 m_funcRef = funcRef;
23 }
24 //-----------------------------------------------------------------
25 /**
26 * Remove function from registry.
27 */
28 ScriptCmd::~ScriptCmd()
29 {
30 m_script->unref(m_funcRef);
31 }
32 //-----------------------------------------------------------------
33 /**
34 * Return true when command has finished his work.
35 * @param count number of calls
36 * @return true for finish
37 * @throws ScriptException when error occures
38 */
39 bool
40 ScriptCmd::finish(int count)
41 {
42 return m_script->callCommand(m_funcRef, count);
43 }
44