faudes::LuaState Class Reference
[Lua Bindings PlugIn]

Wrapper class to maintain a Lua state. More...

#include <lbp_function.h>

List of all members.

Public Member Functions

 LuaState (void)
 Constructor.
 ~LuaState (void)
 Destructor.
lua_State * LL (void)
 Access Lua state.
void Reset (void)
 Reinitialize Lua state.
void Install (const std::string &rFilename)
 Install LuaExtension to Lua state.
void Push (const Type *fdata)
 Push faudes typed object on the Lua stack.
TypePop (void)
 Pop faudes typed object from Lua stack.
TypeGlobal (const std::string &gname, const Type *fdata=0)
 Get/set global data.
void Evaluate (const std::string &expr)
 Evaluate Lua expression.
std::list< std::string > Complete (const std::string &word)
 Complete Lua identifier.

Static Public Member Functions

static LuaStateG (void)
 Convenience global Lua state.
static void Initialize (lua_State *pLL)
 Initialze.
static void Install (lua_State *pLL, const std::string &rFilename)
 Install LuaExtension to Lua state.
static void Push (lua_State *pLL, const Type *fdata)
 Push faudes typed object on the Lua stack.
static TypePop (lua_State *pLL)
 Pop faudes typed object from Lua stack.
static TypeGlobal (lua_State *pLL, const std::string &gname, const Type *fdata=0)
 Get/set global data.
static void Evaluate (lua_State *pLL, const std::string &expr)
 Evaluate Lua expression.
static std::list< std::string > Complete (lua_State *pLL, const std::string &word)
 Complete Lua identifier.

Private Member Functions

 LuaState (const LuaState &)
void Open (void)
void Close (void)

Private Attributes

lua_State * mpLL

Detailed Description

Wrapper class to maintain a Lua state.

This class is still under construction. It aims for a sensible collection of operations that we may want to execute on a Lua state from the libFAUDES perspective. The current implementation provides static members that directly operate on a lua_State as well as a more comfortable interface that operates on thre wrapped faudes::LusState.

Definition at line 413 of file lbp_function.h.


Constructor & Destructor Documentation

faudes::LuaState::LuaState ( void   ) 

Constructor.

Definition at line 1137 of file lbp_function.cpp.

faudes::LuaState::~LuaState ( void   ) 

Destructor.

Definition at line 1138 of file lbp_function.cpp.

faudes::LuaState::LuaState ( const LuaState  )  [inline, private]

Definition at line 657 of file lbp_function.h.


Member Function Documentation

void faudes::LuaState::Close ( void   )  [private]

Definition at line 1181 of file lbp_function.cpp.

std::list< std::string > faudes::LuaState::Complete ( lua_State *  pLL,
const std::string &  word 
) [static]

Complete Lua identifier.

This static version is meant for applications that maintain their Lua state themselves. See also Evaluate(const std::string&)

Parameters:
pLL Lua state
word String to complete
Returns:
List of completions, first entry is longest common prefix.

Definition at line 1477 of file lbp_function.cpp.

std::list< std::string > faudes::LuaState::Complete ( const std::string &  word  ) 

Complete Lua identifier.

This method uses a variation of Mike Pall's advaced readline support patch to fugure possible completions if a string to match a valid identifyer.

Parameters:
pLL Lua state
word String to complete
Returns:
List of completions, first entry is longest common prefix.

Definition at line 1472 of file lbp_function.cpp.

void faudes::LuaState::Evaluate ( lua_State *  pLL,
const std::string &  expr 
) [static]

Evaluate Lua expression.

This static version is meant for applications that maintain their Lua state themselves. See also Evaluate(const std::string&)

Parameters:
pLL Lua state
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1436 of file lbp_function.cpp.

void faudes::LuaState::Evaluate ( const std::string &  expr  ) 

Evaluate Lua expression.

This method runs the Lua-interpreter on the specified expression. In the case of an error, an exception will be thrown.

Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1431 of file lbp_function.cpp.

LuaState * faudes::LuaState::G ( void   )  [static]

Convenience global Lua state.

Definition at line 1163 of file lbp_function.cpp.

Type * faudes::LuaState::Global ( lua_State *  pLL,
const std::string &  gname,
const Type fdata = 0 
) [static]

Get/set global data.

This static version is meant for applications that maintain their Lua state themselves. See also Globat(const std::string&, const Type*)

Parameters:
pLL Lua state
gname Name of global variable
fdata Data to set
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1415 of file lbp_function.cpp.

Type * faudes::LuaState::Global ( const std::string &  gname,
const Type fdata = 0 
)

Get/set global data.

This method provides access to global variables. To set a variable, provide a non-NULL fdata parameter. If you obmitt the fdata paraneter, the default will indicate a get operation. Here, the value is returned as a copy and owned by the caller.

An expection is thrown if the variable either does not exist, or cannot be converted to a faudes::Type.

Parameters:
gname Name of global variable
fdata Data to set
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1410 of file lbp_function.cpp.

void faudes::LuaState::Initialize ( lua_State *  pLL  )  [static]

Initialze.

Loads std libraries and libFAUDES wrappers.

Note: this static version is provided for applications that maintain their lua state themselves. If yo use the wrapper class LuaState, you dont need explicit initialisation.

Parameters:
pLL Lua state

Definition at line 1189 of file lbp_function.cpp.

void faudes::LuaState::Install ( const std::string &  rFilename  ) 

Install LuaExtension to Lua state.

This function instantiates a LuaFunctionDefinition objects from the file and uses the Install member function to install each function to the specified lua state. Thus, after the extension has been installed, the respective Lua functions can be invoked within Lua as if they where C++ function with SWIG generated wrappers.

Note: if you want to use the extension via the run-time-interface, you must also register them with the FunctionRegistry; see also the static method LuaFunctionDefinition::Register(const std::string&).

Parameters:
rFilename Source file (typically .flx)

Definition at line 1158 of file lbp_function.cpp.

lua_State * faudes::LuaState::LL ( void   ) 

Access Lua state.

Definition at line 1141 of file lbp_function.cpp.

void faudes::LuaState::Open ( void   )  [private]

Definition at line 1170 of file lbp_function.cpp.

Type * faudes::LuaState::Pop ( lua_State *  pLL  )  [static]

Pop faudes typed object from Lua stack.

This static version is meant for applications that maintain their Lua state themselves. See also Pop(const Type&)

Parameters:
pLL Lua state
Returns:
Destination for pop data
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1327 of file lbp_function.cpp.

Type * faudes::LuaState::Pop ( void   ) 

Pop faudes typed object from Lua stack.

This method uses SWIG generated type casts to retrieve the faudes object from the userdata on the top of the stack. It then uses the faudes Copy() method to instantiate a copy, to be owned by the caller.

Returns:
Destination for pop data
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1322 of file lbp_function.cpp.

void faudes::LuaState::Push ( lua_State *  pLL,
const Type fdata 
) [static]

Push faudes typed object on the Lua stack.

This static version is meant for applications that maintain their Lus state themselves. See also Push(const Type&)

Parameters:
pLL Lua state
fdata Data to push
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1222 of file lbp_function.cpp.

void faudes::LuaState::Push ( const Type fdata  ) 

Push faudes typed object on the Lua stack.

This method uses SWIG generated constructors to instantiate new Lua userdata object of the same type as the specified data. It than invokes the faudes Assign method to assign a copy.

Parameters:
fdata Data to push
Exceptions:
Exception 
  • Lua Error (id 49)

Definition at line 1217 of file lbp_function.cpp.

void faudes::LuaState::Reset ( void   ) 

Reinitialize Lua state.

This method reconstructs the internal Lua state. Any references become invalid. Any LuaFunctiondefinitions from the FunctionRegistry will be (re-)installed to the new state.

Definition at line 1144 of file lbp_function.cpp.


Member Data Documentation

lua_State* faudes::LuaState::mpLL [private]

Definition at line 657 of file lbp_function.h.


The documentation for this class was generated from the following files:

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen