faudes::LuaFunction Class Reference
|
Public Member Functions | |
LuaFunction (const LuaFunctionDefinition *fdef) | |
Constructor. | |
~LuaFunction (void) | |
Destructor. | |
virtual LuaFunction * | New () const |
Construct on heap. | |
void | Definition (const FunctionDefinition *fdef) |
Set function definition. | |
const LuaFunctionDefinition * | Definition (void) const |
Get function definition. | |
void | SyntaxCheck (void) |
Syntax check lua code. | |
void | Evaluate (void) |
Evaluate lua code. | |
void | L (LuaState *l) |
Set lua state. | |
LuaState * | L (void) |
Get default lua state. | |
Protected Member Functions | |
virtual void | DoVariant (int n) |
virtual bool | DoTypeCheck (int n) |
Method to test the type of an assigned parameter with the specified faudes::Signature (i.e. | |
virtual void | DoExecute () |
Executes code as supplied by FunctionDefinition. | |
virtual void | DoExecuteA () |
Execute stages. | |
virtual void | DoExecuteB () |
Execute stages. | |
virtual void | DoExecuteC () |
Execute stages. | |
virtual void | DoExecuteD () |
Execute stages. | |
virtual void | DoExecuteE () |
Execute stages. | |
Protected Attributes | |
const LuaFunctionDefinition * | pLuaFuncDef |
Typed reference to definition. | |
LuaState * | pL |
State of Lua interpreter. | |
lua_State * | pLL |
int | mFtable |
int | mEntryStack |
void * | mFType |
std::vector< bool > | mLReturn |
std::vector< bool > | mLParameter |
int | mLReturnCount |
int | mLParameterCount |
A LuaFunction is a faudes-function that executes a luafaudes script.
LuaFunction is derived from Function and implements the DoTypeCheck and DoExecute interface to run the lua code as supplied by the corresponding function defintion. Thus, it is considered an error to set the function definition to an object that does not cast to a LuaFunctionDefinition.
Definition at line 677 of file lbp_function.h.
faudes::LuaFunction::LuaFunction | ( | const LuaFunctionDefinition * | fdef | ) |
Constructor.
For the function to be operational, a valid reference to the corresponding LuaFunctionDefinition is required. The only exception is the prototype function object used in the LuaFunctionDefinition itself.
Definition at line 641 of file lbp_function.cpp.
faudes::LuaFunction::~LuaFunction | ( | void | ) | [inline] |
Destructor.
Definition at line 689 of file lbp_function.h.
const LuaFunctionDefinition * faudes::LuaFunction::Definition | ( | void | ) | const |
Get function definition.
Reimplemented from faudes::Function.
Definition at line 663 of file lbp_function.cpp.
void faudes::LuaFunction::Definition | ( | const FunctionDefinition * | fdef | ) | [virtual] |
Set function definition.
Normally, functions are provided with a function definition on construction. The only exception are prototype objects used in function definitions themselfs and in the function registry.
fdef | Function definition to set. |
Reimplemented from faudes::Function.
Definition at line 656 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecute | ( | void | ) | [protected, virtual] |
Executes code as supplied by FunctionDefinition.
Implements faudes::Function.
Definition at line 709 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecuteA | ( | void | ) | [protected, virtual] |
Execute stages.
Definition at line 767 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecuteB | ( | void | ) | [protected, virtual] |
Execute stages.
Definition at line 801 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecuteC | ( | void | ) | [protected, virtual] |
Execute stages.
Definition at line 855 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecuteD | ( | void | ) | [protected, virtual] |
Execute stages.
Definition at line 969 of file lbp_function.cpp.
void faudes::LuaFunction::DoExecuteE | ( | void | ) | [protected, virtual] |
Execute stages.
Definition at line 1026 of file lbp_function.cpp.
bool faudes::LuaFunction::DoTypeCheck | ( | int | n | ) | [protected, virtual] |
Method to test the type of an assigned parameter with the specified faudes::Signature (i.e.
their TypeDefinition label).
Note: this method is called by Function::Execute() before actual function execution via DoExecute(). It may be used to perform a dynamic cast in preparation of DoExecute(). The latter is only called, if all types match.
n | Position of parameter to check |
Implements faudes::Function.
Definition at line 681 of file lbp_function.cpp.
void faudes::LuaFunction::DoVariant | ( | int | n | ) | [protected, virtual] |
Reimplemented from faudes::Function.
Definition at line 668 of file lbp_function.cpp.
void faudes::LuaFunction::Evaluate | ( | void | ) |
Evaluate lua code.
This routine avaluates the associated Lua code literally, i.e. no arguments are passed, no specific function is invoked. See also Execute().
Exception |
|
Definition at line 753 of file lbp_function.cpp.
LuaState * faudes::LuaFunction::L | ( | void | ) |
void faudes::LuaFunction::L | ( | LuaState * | l | ) |
Set lua state.
Sets the lua state which this function will use for execution. If set to NULL (e.g. on consruction), the function definition's default state will be used. If this is not set either, the global state is used.
l | Lua state |
Definition at line 703 of file lbp_function.cpp.
LuaFunction * faudes::LuaFunction::New | ( | void | ) | const [virtual] |
Construct on heap.
Create a new instance of this function class and return pointer. The new instance will use the same function definition as this instance.
Implements faudes::Function.
Definition at line 651 of file lbp_function.cpp.
void faudes::LuaFunction::SyntaxCheck | ( | void | ) |
Syntax check lua code.
This routine does all it needs to run the script, except to invoke the specified function. The reasoning is, that the script may hang and, thus, never return. A consequence is, that you must set a variant and you must supply parameter values befor checking. You may use AllocateValues() and FreeValues() for this purpose. Errors are indicated by an exception.
Note that the LuaFunctionDefinition provides a convenience wrapper that runs the check on all variants and cares about value allocation.
Exception |
|
Definition at line 733 of file lbp_function.cpp.
int faudes::LuaFunction::mEntryStack [protected] |
Definition at line 875 of file lbp_function.h.
int faudes::LuaFunction::mFtable [protected] |
Definition at line 874 of file lbp_function.h.
void* faudes::LuaFunction::mFType [protected] |
Definition at line 876 of file lbp_function.h.
std::vector<bool> faudes::LuaFunction::mLParameter [protected] |
Definition at line 878 of file lbp_function.h.
int faudes::LuaFunction::mLParameterCount [protected] |
Definition at line 880 of file lbp_function.h.
std::vector<bool> faudes::LuaFunction::mLReturn [protected] |
Definition at line 877 of file lbp_function.h.
int faudes::LuaFunction::mLReturnCount [protected] |
Definition at line 879 of file lbp_function.h.
LuaState* faudes::LuaFunction::pL [protected] |
State of Lua interpreter.
Definition at line 872 of file lbp_function.h.
lua_State* faudes::LuaFunction::pLL [protected] |
Definition at line 873 of file lbp_function.h.
const LuaFunctionDefinition* faudes::LuaFunction::pLuaFuncDef [protected] |
Typed reference to definition.
Definition at line 869 of file lbp_function.h.
libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen