libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
moScript.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moScript.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright (C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 
30  Description:
31  Base class for Lua-scriptable classes. Based in the Lua article and
32  VC project by Richard Shephard, available online at:
33  http://www.codeproject.com/cpp/luaincpp.asp?msg=1741798
34 
35 *******************************************************************************/
36 
37 #ifndef __MO_SCRIPT_H__
38 #define __MO_SCRIPT_H__
39 
40 #include "moLuaBase.h"
41 
49 {
50 public:
51 
52  typedef int (*Function)(moLuaVirtualMachine& vm);
53 
54  Function Functions[255];
55 
59  moScript();
63  virtual ~moScript (void);
64 
68  void InitScript();
72  void FinishScript();
73 
74  bool IsInitialized() {
75  return m_initialized;
76  }
77 
83  bool CompileFile(const char *strFilename);
90  bool CompileBuffer(unsigned char *pbBuffer, size_t szLen);
91 
97  int RegisterFunction(const char *strFuncName, moScript::Function& fun );
98  int RegisterFunction(const char *strFuncName);
107  int RegisterBaseFunction (const char *strFuncName);
108 
109 
116  bool SelectScriptFunction(const char *strFuncName);
121  void AddFunctionParam(int iInt);
126  void AddFunctionParam(float fFloat);
131  void AddFunctionParam(char *string);
132 
139  bool RunSelectedFunction(int nReturns = 0);
140 
146  bool ScriptHasFunction(const char *strScriptName);
147 
153  int methods(void) { return m_nMethods; }
154 
162  virtual int ScriptCalling(moLuaVirtualMachine& vm, int iFunctionNumber) = 0;
163 
172  virtual int ResetScriptCalling() {
173  m_iMethodBaseIterator = m_iMethodBaseAncestors-1;
174  m_iMethodBase = m_MethodBases[m_iMethodBaseIterator--];
175  return m_iMethodBase;
176  }
177 
178  virtual int NextScriptCalling() {
179  if (m_iMethodBaseIterator>=0) m_iMethodBase = m_MethodBases[m_iMethodBaseIterator--];
180  return m_iMethodBase;
181  }
182 
189  virtual void HandleReturns(moLuaVirtualMachine& vm, const char *strFunc) = 0;
190 
195  moLuaVirtualMachine& mvm (void) { return m_vm; }
196 protected:
202  int m_nArgs;
203  const char *m_strFunctionName;
204 
205  // For indexing scripted methods.
208  //and manage inheritance indexed methods
210  int m_MethodBases[256];
211 
212 };
213 
214 #endif
215 
virtual int NextScriptCalling()
Definition: moScript.h:178
bool IsInitialized()
Definition: moScript.h:74
int(* Function)(moLuaVirtualMachine &vm)
Definition: moScript.h:52
static moLuaDebugger m_dbg
Definition: moScript.h:200
#define LIBMOLDEO_API
Definition: moTypes.h:180
int m_iThisRef
Definition: moScript.h:201
virtual int ResetScriptCalling()
Definition: moScript.h:172
const char * m_strFunctionName
Definition: moScript.h:203
int m_iMethodBaseIterator
actual class index method base
Definition: moScript.h:207
int m_nMethods
Definition: moScript.h:198
int methods(void)
Definition: moScript.h:153
bool m_initialized
Definition: moScript.h:197
static moLuaVirtualMachine m_vm
Definition: moScript.h:199
int m_iMethodBaseAncestors
actual class iterator index method base
Definition: moScript.h:209
int m_nArgs
Definition: moScript.h:202
int m_iMethodBase
Definition: moScript.h:206
moLuaVirtualMachine & mvm(void)
Definition: moScript.h:195