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.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moScriptManager.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moScriptManager.cpp
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 *******************************************************************************/
31 
32 #include "moScriptManager.h"
33 
35 {
38 
39  SetName("Script Manager");
40  SetLabelName("Script Manager");
41 }
42 
44 {
45  Finish();
46 }
47 
49 {
50 
52  RegisterLunaClasses();
53  return true;
54 }
55 
57  if (!m_vm.Ok()) {
60  }
61 }
62 
63 
65 {
66  m_vm.FinaliseVM();
68  return true;
69 }
70 
72 {
73  return moScript::m_vm;
74 }
75 
77 {
78  return m_dbg;
79 }
80 
81 void moScriptManager::RegisterLunaClasses()
82 {
83  lua_State *state = (lua_State *) m_vm;
84 
85  //REGISTERING GLOBAL VARIABLES (necessary to load .lua files from scripts in local directory
86  if (m_pResourceManager) {
87  lua_pushstring( state, m_pResourceManager->GetDataMan()->GetDataPath() );
88  lua_setglobal( state , "ConsoleDataPath" );
89 
90  lua_pushstring( state, m_pResourceManager->GetDataMan()->GetAppPath() );
91  lua_setglobal( state , "MoldeoAppPath" );
92  }
93 
94 
96  REGISTER_CLASS(moLuaMath, state);
97  //REGISTER_CLASS(moLuaParserFunction, state);
98  REGISTER_CLASS(moLuaP5, state);
99 
100 
101 
102  m_pLuaResourceManager = new moLuaResourceManager( state );
103  m_pLuaResourceManager->Set( GetResourceManager() );
104 
105 }
106 
108 
109  lua_State *state = (lua_State *) m_vm;
110 
111  if (p_pResourceManager) {
112  m_pLuaResourceManager->Set( p_pResourceManager );
113  }
114 
115  if (m_pLuaResourceManager) {
116  moLuna<moLuaResourceManager>::createFromExisting( state, m_pLuaResourceManager );
117  }
118  return m_pLuaResourceManager;
119 }
120 
bool InitialiseVM(void)
Definition: moLuaBase.cpp:148
virtual bool Ok(void)
Definition: moLuaBase.h:129
moResourceManager * GetResourceManager()
void SetName(const moText &p_name)
static moLuaVirtualMachine & GetVM(void)
#define MOboolean
Definition: moTypes.h:385
#define REGISTER_CLASS(ClassName, LuaState)
Definition: moLuna.h:631
void InitaliseDBG()
Definition: moLuaBase.cpp:390
void SetResourceType(moResourceType p_restype)
bool FinaliseVM(void)
Definition: moLuaBase.cpp:188
static moLuaDebugger m_dbg
Definition: moScript.h:200
virtual MOboolean Init()
static T * createFromExisting(lua_State *L, T *existingobj)
Definition: moLuna.h:384
moResourceManager * m_pResourceManager
Puntero al administrador de recursos.
Dispositivo de entrada/salida, típicamente, interfaces humanas de IO y datos ( teclado, mouse, tableta, tcp, udp, serial )
Definition: moTypes.h:532
moLuaResourceManager * PushLuaResourceManager(moResourceManager *p_pResourceManager=NULL)
Administrador de recursos.
void SetLabelName(const moText &p_labelname)
static void InitVM()
virtual MOboolean Finish()
moDataManager * GetDataMan()
moText GetDataPath()
static moLuaVirtualMachine m_vm
Definition: moScript.h:199
static moLuaDebugger & GetDBG(void)
void SetType(moMoldeoObjectType p_type)
void FinaliseDBG(void)
Definition: moLuaBase.cpp:401