45 #define BEGIN_LUA_CHECK(vm)   lua_State *state = (lua_State *) vm; \ 
   47 #define END_LUA_CHECK         } 
   74 static int LuaCallback (lua_State *lua)
 
   77    int iNumberIdx = lua_upvalueindex (1);
 
   80    bool fSuccess = 
false;
 
   83    if (lua_istable (lua, 1))
 
   86       lua_rawgeti (lua, 1, 0);
 
   88       if (lua_islightuserdata (lua, -1))
 
   94          int iMethodIdx = (int) lua_tonumber (lua, iNumberIdx);
 
   97          assert (!(iMethodIdx > pThis->
methods ()));
 
  103          lua_remove (lua, -1);
 
  112    if (fSuccess == 
false)
 
  114       lua_pushstring (lua, 
"LuaCallback -> Failed to call the class function");
 
  138  : m_initialized(false),
 
  143  m_iMethodBaseIterator(0),
 
  144  m_iMethodBaseAncestors(0)
 
  191       lua_newtable (state);
 
  192       m_iThisRef = luaL_ref (state, LUA_REGISTRYINDEX);
 
  196       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  197       lua_pushlightuserdata (state, (
void *) 
this);
 
  198       lua_rawseti (state, -2, 0);
 
  210       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  214       lua_rawseti (state, -2, 0);
 
  237    assert (pbBuffer != NULL && 
"moScript::CompileBuffer ->  pbBuffer == NULL");
 
  238    assert (szLen != 0 && 
"moScript::CompileBuffer -> szLen == 0");
 
  239    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  263    assert (strFilename != NULL && 
"moScript::CompileFile -> strFilename == NULL");
 
  264    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  288    assert (strFuncName != NULL && 
"moScript::RegisterFunction -> strFuncName == NULL");
 
  289    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  300       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  303       lua_pushstring (state, strFuncName);
 
  304       lua_pushnumber (state, (lua_Number) iMethodIdx);
 
  305       lua_pushcclosure (state, LuaCallback, 1);
 
  306       lua_settable (state, -3);
 
  315    assert (strFuncName != NULL && 
"moScript::RegisterFunction -> strFuncName == NULL");
 
  316    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  327       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  330       lua_pushstring (state, strFuncName);
 
  331       lua_pushnumber (state, (lua_Number) iMethodIdx);
 
  332       lua_pushcclosure (state, LuaCallback, 1);
 
  333       lua_settable (state, -3);
 
  372    assert (strFuncName != NULL && 
"moScript::SelectScriptFunction -> strFuncName == NULL");
 
  373    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  375    bool fSuccess = 
true;
 
  379       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  380       lua_pushstring (state, strFuncName);
 
  381       lua_rawget (state, -2);
 
  382       lua_remove (state, -2);
 
  385       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  388       if (!lua_isfunction (state, -2))
 
  421    if ( !
m_vm.
Ok () ) 
return false;
 
  425    bool fFoundFunc = 
false;
 
  428       lua_rawgeti (state, LUA_REGISTRYINDEX, 
m_iThisRef);
 
  429       lua_pushstring (state, strScriptName);
 
  430       lua_rawget (state, -2);
 
  431       lua_remove (state, -2);
 
  433       if (lua_isfunction (state, -1))
 
  458    assert (
string != NULL && 
"moScript::AddFunctionParam -> string == NULL");
 
  459    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  462       lua_pushstring (state, 
string);
 
  483    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  486       lua_pushnumber (state, (lua_Number) iInt);
 
  507    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  510       lua_pushnumber (state, (lua_Number) fFloat);
 
  531    assert (
m_vm.
Ok () && 
"VM Not OK");
 
  539    if (fSuccess == 
true && nReturns > 0)
 
  543       lua_pop ((lua_State *) 
m_vm, nReturns);
 
int(* Function)(moLuaVirtualMachine &vm)
 
int RegisterBaseFunction(const char *strFuncName)
 
static void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto. 
 
bool CompileFile(const char *strFilename)
 
int m_MethodBases[256]
increment on each call to RegisterFunctions 
 
bool RunSelectedFunction(int nReturns=0)
 
static moLuaDebugger m_dbg
 
bool CompileBuffer(unsigned char *pbBuffer, size_t szLen)
 
bool ScriptHasFunction(const char *strScriptName)
 
virtual int ScriptCalling(moLuaVirtualMachine &vm, int iFunctionNumber)=0
 
bool CallFunction(int nArgs, int nReturns=0)
 
void AddFunctionParam(int iInt)
 
const char * m_strFunctionName
 
restaurador del stack de LUA 
 
bool RunBuffer(const unsigned char *pbBuffer, size_t szLen, const char *strName=NULL)
 
static moLuaVirtualMachine m_vm
 
LIBMOLDEO_API moText0 IntToStr(int a)
 
int m_iMethodBaseAncestors
actual class iterator index method base 
 
bool RunFile(const char *strFilename)
 
bool SelectScriptFunction(const char *strFuncName)
 
#define BEGIN_LUA_CHECK(vm)
 
virtual void HandleReturns(moLuaVirtualMachine &vm, const char *strFunc)=0
 
int RegisterFunction(const char *strFuncName, moScript::Function &fun)
 
moLuaVirtualMachine & mvm(void)