|
VR-Engage
2.2
|
This class provides a C++ interface to Lua functions, allowing them to be called with type-safe parameter passing and return value handling. It supports invoking Lua functions with up to five parameters and retrieving the results with proper type conversion.
#include <luaFunction.h>
Public Member Functions | |
| DtLuaFunction () | |
| DtLuaFunction (lua_State &state, int index) | |
| virtual | ~DtLuaFunction () override |
| DtLuaFunction (const DtLuaObject &funcObj) | |
| DtLuaFunction (const DtLuaFunction &funcObj) | |
| DtLuaFunction & | operator= (const DtLuaObject &funcObj) |
| DtLuaFunction & | operator= (const DtLuaFunction &func) |
| template<typename RT> | |
| RT | call () |
| template<typename RT, typename P0> | |
| RT | call (const P0 &arg1) |
| template<typename RT, typename P0, typename P1> | |
| RT | call (const P0 &arg1, const P1 &arg2) |
| template<typename RT, typename P0, typename P1, typename P2> | |
| RT | call (const P0 &arg1, const P1 &arg2, const P2 &arg3) |
| template<typename RT, typename P0, typename P1, typename P2, typename P3> | |
| RT | call (const P0 &arg1, const P1 &arg2, const P2 &arg3, const P3 &arg4) |
| template<typename RT, typename P0, typename P1, typename P2, typename P3, typename P4> | |
| RT | call (const P0 &arg1, const P1 &arg2, const P2 &arg3, const P3 &arg4, const P4 &arg5) |
Public Member Functions inherited from makVre::DtLuaObject | |
| DtLuaObject () | |
| DtLuaObject (lua_State &state, int index) | |
| virtual | ~DtLuaObject () override |
| DtLuaObject (const DtLuaObject &orig) | |
| DtLuaObject & | operator= (const DtLuaObject &orig) |
| virtual bool | operator== (const DtLuaObject &rhs) |
| template<typename RT> | |
| RT | get () |
| virtual void | push () const |
| virtual lua_State * | state () |
| virtual std::string | serialize () |
| virtual bool | isValid () const |
| virtual bool | hasField (const std::string &name, bool resolveDots=true) |
| virtual bool | hasField (int index) |
| virtual DtLuaObject | operator[] (std::string name) |
| virtual DtLuaObject | operator[] (int index) |
| virtual int | tableSize () |
| std::vector< std::string > | keys () |
| template<typename T> | |
| void | setField (const std::string &name, const T &val) |
| template<typename T> | |
| void | setField (int index, const T &val) |
Public Member Functions inherited from makVre::DtLuaValue | |
| virtual ScriptDataTypeEnum | type () const |
| virtual std::string | typeName () const |
| DtLuaValue () | |
| DtLuaValue (bool v) | |
| DtLuaValue (int v) | |
| DtLuaValue (float v) | |
| DtLuaValue (double v) | |
| DtLuaValue (const std::string &v) | |
| DtLuaValue (const char *v) | |
| DtLuaValue (void *v) | |
| virtual | ~DtLuaValue () |
| DtLuaValue (const DtLuaValue &orig) | |
| DtLuaValue & | operator= (const DtLuaValue &orig) |
| virtual bool | isNil () const |
| virtual bool | isBool () const |
| virtual bool | isInt () const |
| virtual bool | isFloat () const |
| virtual bool | isDouble () const |
| virtual bool | isString () const |
| virtual bool | isPointer () const |
| virtual bool | isTable () const |
| virtual bool | isFunction () const |
| virtual bool | boolValue () const |
| virtual int | intValue () const |
| virtual float | floatValue () const |
| virtual double | doubleValue () const |
| virtual std::string | stringValue () const |
| virtual void * | pointerValue () const |
Protected Member Functions | |
| virtual void | preFunction () |
| virtual void | postFunction (int argc) |
Protected Member Functions inherited from makVre::DtLuaObject | |
| virtual bool | getItemOnStack (const std::string &name, bool resolveDots) |
| virtual bool | getItemOnStack (int index) |
| virtual void | setTable (int index) |
Protected Attributes | ||
| int | myErrorIndex | |
Protected Attributes inherited from makVre::DtLuaObject | ||
| DtLuaReference * | myReference | |
| lua_State * | myState | |
Protected Attributes inherited from makVre::DtLuaValue | ||
| ScriptDataTypeEnum | myType | |
| union { | ||
| bool myBool | ||
| int myInt | ||
| float myFloat | ||
| double myDouble | ||
| const char * myString | ||
| void * myPtr | ||
| }; | ||
Additional Inherited Members | |
Public Types inherited from makVre::DtLuaValue | |
| enum | ScriptDataTypeEnum { SCRIPT_NIL , SCRIPT_BOOL , SCRIPT_INT , SCRIPT_FLOAT , SCRIPT_DOUBLE , SCRIPT_STRING , SCRIPT_POINTER , SCRIPT_FUNCTION , SCRIPT_TABLE } |
| makVre::DtLuaFunction::DtLuaFunction | ( | ) |
Default constructor.
Creates an empty, invalid function reference
Referenced by DtLuaFunction(), operator=(), and operator=().
| makVre::DtLuaFunction::DtLuaFunction | ( | lua_State & | state, |
| int | index ) |
Constructor from Lua stack value.
| state | The Lua state containing the function |
| index | Index of the function on the Lua stack |
References makVre::DtLuaObject::state().
|
overridevirtual |
Virtual destructor.
| makVre::DtLuaFunction::DtLuaFunction | ( | const DtLuaObject & | funcObj | ) |
Construct from a Lua object.
| funcObj | Lua object referencing a function |
Constructs a function reference from a generic Lua object
References makVre::DtLuaObject::DtLuaObject().
| makVre::DtLuaFunction::DtLuaFunction | ( | const DtLuaFunction & | funcObj | ) |
| DtLuaFunction & makVre::DtLuaFunction::operator= | ( | const DtLuaObject & | funcObj | ) |
Assignment operator from Lua object.
| funcObj | Lua object referencing a function |
References DtLuaFunction(), and makVre::DtLuaObject::DtLuaObject().
| DtLuaFunction & makVre::DtLuaFunction::operator= | ( | const DtLuaFunction & | func | ) |
Assignment operator.
| func | Source function to assign from |
References DtLuaFunction().
| RT makVre::DtLuaFunction::call | ( | ) |
Calls the Lua function with no parameters.
| RT | Return type to convert the Lua result to |
| std::string | if the function call fails or type conversion fails |
| RT makVre::DtLuaFunction::call | ( | const P0 & | arg1 | ) |
Calls the Lua function with one parameter.
| RT | Return type to convert the Lua result to |
| P0 | Type of the first parameter |
| arg1 | The first parameter to pass to the function |
| std::string | if the function call fails or type conversion fails |
| RT makVre::DtLuaFunction::call | ( | const P0 & | arg1, |
| const P1 & | arg2 ) |
Calls the Lua function with two parameters.
| RT | Return type to convert the Lua result to |
| P0 | Type of the first parameter |
| P1 | Type of the second parameter |
| arg1 | The first parameter to pass to the function |
| arg2 | The second parameter to pass to the function |
| std::string | if the function call fails or type conversion fails |
| RT makVre::DtLuaFunction::call | ( | const P0 & | arg1, |
| const P1 & | arg2, | ||
| const P2 & | arg3 ) |
Calls the Lua function with three parameters.
| RT | Return type to convert the Lua result to |
| P0 | Type of the first parameter |
| P1 | Type of the second parameter |
| P2 | Type of the third parameter |
| arg1 | The first parameter to pass to the function |
| arg2 | The second parameter to pass to the function |
| arg3 | The third parameter to pass to the function |
| std::string | if the function call fails or type conversion fails |
| RT makVre::DtLuaFunction::call | ( | const P0 & | arg1, |
| const P1 & | arg2, | ||
| const P2 & | arg3, | ||
| const P3 & | arg4 ) |
Calls the Lua function with four parameters.
| RT | Return type to convert the Lua result to |
| P0 | Type of the first parameter |
| P1 | Type of the second parameter |
| P2 | Type of the third parameter |
| P3 | Type of the fourth parameter |
| arg1 | The first parameter to pass to the function |
| arg2 | The second parameter to pass to the function |
| arg3 | The third parameter to pass to the function |
| arg4 | The fourth parameter to pass to the function |
| std::string | if the function call fails or type conversion fails |
| RT makVre::DtLuaFunction::call | ( | const P0 & | arg1, |
| const P1 & | arg2, | ||
| const P2 & | arg3, | ||
| const P3 & | arg4, | ||
| const P4 & | arg5 ) |
Calls the Lua function with five parameters.
| RT | Return type to convert the Lua result to |
| P0 | Type of the first parameter |
| P1 | Type of the second parameter |
| P2 | Type of the third parameter |
| P3 | Type of the fourth parameter |
| P4 | Type of the fifth parameter |
| arg1 | The first parameter to pass to the function |
| arg2 | The second parameter to pass to the function |
| arg3 | The third parameter to pass to the function |
| arg4 | The fourth parameter to pass to the function |
| arg5 | The fifth parameter to pass to the function |
| std::string | if the function call fails or type conversion fails |
|
protectedvirtual |
Prepares the stack for a function call.
Sets up error handling and pushes the function onto the stack
|
protectedvirtual |
Cleans up after a function call.
| argc | Number of arguments that were passed to the function |
Removes the error handler and adjusts the stack as needed
|
protected |
Stack index for the error handler function.