lua::Lua Class Reference

Lua interpreter. More...

#include <src_lua_bind_lua.hh>

List of all members.

Public Types

typedef LUA_NUMBER Number
 Lua numeric type.

Public Member Functions

CLASS_METHOD LuaGetInstance (void)
void ExportCmdLine (int argc, char **argv)
void SetScriptDir (const string &scriptDir)
string GetScriptDir (void)
void RunScript (const string &scriptName, const bool recompile=false)
bool ReadVarAsBool (const string &varName)
Number ReadVarAsNumber (const string &varName)
string ReadVarAsString (const string &varName)
Number ReadTableAsNumber (const string &tableName, const int tableIdx)
Number ReadTableAsNumber (const string &tableName, const string &memberName)
string ReadTableAsString (const string &tableName, const int tableIdx)
string ReadTableAsString (const string &tableName, const string &memberName)
Number CallLuaFunc (const string &tableName, const string &funcName, const vector< Lua::Number > &args)

Private Types

typedef map< string, int > BytecodeMap

Private Member Functions

 Lua (void)
 ~Lua ()
void SaveStack (void)
void RestoreStack (void)
void ThrowLuaException (const string &msg)

Private Attributes

CLASS_VAR LuamsInstance
 instance of Lua
CLASS_VAR const luaL_Reg mFuncTable []
 C interface functions exported to Lua scripts.
lua_State * mLua
 the Lua interpreter (C code)
string mScriptDir
 directory containing scripts
BytecodeMap mBytecodeMap
 avoids recompiling Lua bytecode
int mSavedStack
 stack depth


Detailed Description

Lua interpreter.

NOTE: Most methods might throw a C++ exception.


Member Typedef Documentation

typedef LUA_NUMBER lua::Lua::Number

Lua numeric type.

typedef map<string,int> lua::Lua::BytecodeMap [private]


Constructor & Destructor Documentation

lua::Lua::Lua ( void   )  [private]

ctor/dtor.

lua::Lua::~Lua (  )  [private]


Member Function Documentation

CLASS_METHOD Lua& lua::Lua::GetInstance ( void   )  [inline]

void lua::Lua::ExportCmdLine ( int  argc,
char **  argv 
)

Export command-line args to Lua.

void lua::Lua::SetScriptDir ( const string &  scriptDir  ) 

Set the directory containing Lua scripts.

string lua::Lua::GetScriptDir ( void   )  [inline]

void lua::Lua::RunScript ( const string &  scriptName,
const bool  recompile = false 
)

THROWS C++ EXCEPTION. Execute a script. To avoid recompiling, the bytecode of a Lua script is stored in case the same script is called again. http://lua-users.org/lists/lua-l/2003-07/msg00082.html

bool lua::Lua::ReadVarAsBool ( const string &  varName  ) 

THROWS C++ EXCEPTION. Read a boolean variable from Lua. Note that the Lua C API treats boolean and number as distinct types. But this method will treat any non-zero number as "true" (as in C++). So this method will treat these as equivalent: enableLighting = true enableLighting = 1

Lua::Number lua::Lua::ReadVarAsNumber ( const string &  varName  ) 

THROWS C++ EXCEPTION. Read a number variable from Lua.

string lua::Lua::ReadVarAsString ( const string &  varName  ) 

THROWS C++ EXCEPTION. Read a string variable from Lua.

Lua::Number lua::Lua::ReadTableAsNumber ( const string &  tableName,
const int  tableIdx 
)

THROWS C++ EXCEPTION. Read a member of table by numeric index (treats table as an array).

Lua::Number lua::Lua::ReadTableAsNumber ( const string &  tableName,
const string &  memberName 
)

THROWS C++ EXCEPTION. Read a member of table by key (key is a string).

string lua::Lua::ReadTableAsString ( const string &  tableName,
const int  tableIdx 
)

THROWS C++ EXCEPTION. Read a member of table by numeric index (treats table as an array).

string lua::Lua::ReadTableAsString ( const string &  tableName,
const string &  memberName 
)

THROWS C++ EXCEPTION. Read a member of table by key (key is a string).

Lua::Number lua::Lua::CallLuaFunc ( const string &  tableName,
const string &  funcName,
const vector< Lua::Number > &  args 
)

Call a Lua function from C++ (as a method in a table). tableName:funcName( args )

Parameters:
tableName 
funcName 
args Can be empty.

void lua::Lua::SaveStack ( void   )  [inline, private]

void lua::Lua::RestoreStack ( void   )  [inline, private]

void lua::Lua::ThrowLuaException ( const string &  msg  )  [inline, private]


Member Data Documentation

instance of Lua

CLASS_VAR const luaL_Reg lua::Lua::mFuncTable[] [private]

C interface functions exported to Lua scripts.

lua_State* lua::Lua::mLua [private]

the Lua interpreter (C code)

string lua::Lua::mScriptDir [private]

directory containing scripts

avoids recompiling Lua bytecode

int lua::Lua::mSavedStack [private]

stack depth


The documentation for this class was generated from the following files:
Palomino Flight Simulator documents generated by doxygen 1.5.6 on Mon Dec 29 17:27:01 2008