Fixed formatting in LuaScript.*

This commit is contained in:
madmaxoft 2013-07-29 10:03:42 +02:00
parent 5530178aad
commit e51221eaf9
2 changed files with 40 additions and 3 deletions

View File

@ -1,4 +1,8 @@
// LuaScript.cpp
// Implements the cLuaScript class that loads a Lua script file to produce a web template out of it
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "LuaScript.h" #include "LuaScript.h"
@ -186,10 +190,14 @@ bool cLuaScript::CallFunction( const char* a_Function, AString& ReturnedString )
// Push the desired function on the stack // Push the desired function on the stack
if (!LuaPushFunction(a_Function)) if (!LuaPushFunction(a_Function))
{
return false; return false;
}
if (!LuaCallFunction(0, 1, a_Function)) if (!LuaCallFunction(0, 1, a_Function))
{
return false; return false;
}
if (lua_isstring(m_LuaState, -1)) if (lua_isstring(m_LuaState, -1))
{ {
@ -211,12 +219,16 @@ bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_Use
// Push the desired function on the stack // Push the desired function on the stack
if (!LuaPushFunction(a_Function)) if (!LuaPushFunction(a_Function))
{
return false; return false;
}
tolua_pushusertype(m_LuaState, a_UserType.Object, a_UserType.ClassName); tolua_pushusertype(m_LuaState, a_UserType.Object, a_UserType.ClassName);
if (!LuaCallFunction(1, 1, a_Function)) if (!LuaCallFunction(1, 1, a_Function))
{
return false; return false;
}
if (lua_isstring(m_LuaState, -1)) if (lua_isstring(m_LuaState, -1))
{ {
@ -238,13 +250,17 @@ bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_Use
// Push the desired function on the stack // Push the desired function on the stack
if (!LuaPushFunction(a_Function)) if (!LuaPushFunction(a_Function))
{
return false; return false;
}
tolua_pushusertype(m_LuaState, a_UserType1.Object, a_UserType1.ClassName); tolua_pushusertype(m_LuaState, a_UserType1.Object, a_UserType1.ClassName);
tolua_pushusertype(m_LuaState, a_UserType2.Object, a_UserType2.ClassName); tolua_pushusertype(m_LuaState, a_UserType2.Object, a_UserType2.ClassName);
if (!LuaCallFunction(2, 1, a_Function)) if (!LuaCallFunction(2, 1, a_Function))
{
return false; return false;
}
if (lua_isstring(m_LuaState, -1)) if (lua_isstring(m_LuaState, -1))
{ {

View File

@ -1,14 +1,31 @@
// LuaScript.h
// Declares the cLuaScript class that loads a Lua script file to produce a web template out of it
#pragma once #pragma once
struct lua_State; struct lua_State;
struct sLuaUsertype struct sLuaUsertype
{ {
sLuaUsertype(void* a_pObject, const char* a_pClassName) : Object(a_pObject), ClassName(a_pClassName) {} sLuaUsertype(void* a_pObject, const char* a_pClassName) : Object(a_pObject), ClassName(a_pClassName) {}
// //
void* Object; void* Object;
const char* ClassName; const char* ClassName;
}; } ;
class cLuaScript class cLuaScript
{ {
@ -39,4 +56,8 @@ protected:
bool LuaCallFunction(int a_NumArgs, int a_NumResults, const char * a_FunctionName ); // a_FunctionName is only used for error messages, nothing else bool LuaCallFunction(int a_NumArgs, int a_NumResults, const char * a_FunctionName ); // a_FunctionName is only used for error messages, nothing else
private: private:
lua_State* m_LuaState; lua_State* m_LuaState;
}; } ;