Represents a typed version of the lua stack.
More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/orxonox/scriptablecontroller/luatb_typed_stack.h>
|
template<typename T > |
static std::enable_if<!IsCallable< T >::value, T >::type | getArgument (lua_State *lua) |
| Get a non-function argument from the lua stack and convert it to type 'T'. More...
|
|
template<typename T > |
static std::enable_if< IsCallable< T >::value, T >::type | getArgument (lua_State *lua) |
| Get a function-type argument from the lua stack and convert it to type 'T'. More...
|
|
|
template<typename Ret , typename... Args> |
static void | callLuaFunction (lua_State *lua, int *ref, Args...args) |
| Pushes all arguments to the lua stack and calls a lua function afterwards. More...
|
|
template<typename T > |
static T | getFromLuaStack (lua_State *lua) |
| Get a value from the lua stack and convert it to type 'T'. More...
|
|
template<typename T > |
static void | pushArgumentsToLuaStack (lua_State *, T) |
| Pushes nothing onto the stack. More...
|
|
template<typename First , typename... Args> |
static void | pushArgumentsToLuaStack (lua_State *lua, First first, Args...args) |
| Recursively pushes arguments to the lua stack. More...
|
|
template<typename T > |
static void | pushToLuaStack (lua_State *lua, T value) |
| Pushes a value to the lua stack. More...
|
|
|
static std::list< std::unique_ptr< int > > | callbackRefs = {} |
|
Represents a typed version of the lua stack.
We need a separate class for this because we need to specialize the functions and that's not possible if we didn't specialize the class. And the logical separation makes sense as well.
template<typename Ret , typename... Args>
static void LuaTBTypedStack::callLuaFunction |
( |
lua_State * |
lua, |
|
|
int * |
ref, |
|
|
Args... |
args |
|
) |
| |
|
inlinestaticprivate |
Pushes all arguments to the lua stack and calls a lua function afterwards.
- Parameters
-
lua | Pointer to the lua state |
ref | Pointer to the lua registry reference where the function is stored |
args | Arguments for the function |
template<typename T >
static std::enable_if<!IsCallable<T>::value, T>::type LuaTBTypedStack::getArgument |
( |
lua_State * |
lua | ) |
|
|
inlinestatic |
Get a non-function argument from the lua stack and convert it to type 'T'.
- Parameters
-
lua | Pointer to the lua state |
- Returns
- Top element of the lua stack with the appropriate type
Note: Pops the value from the stack.
template<typename T >
static std::enable_if<IsCallable<T>::value, T>::type LuaTBTypedStack::getArgument |
( |
lua_State * |
lua | ) |
|
|
inlinestatic |
Get a function-type argument from the lua stack and convert it to type 'T'.
- Parameters
-
lua | Pointer to the lua state |
- Returns
- Top element of the lua stack with the appropriate type
Specialization if 'T' is a callable type (std::function). Saves the lua function in the registry and constructs a function to call it again.
Note: Pops the value from the stack.
template<>
int LuaTBTypedStack::getFromLuaStack |
( |
lua_State * |
lua | ) |
|
|
private |
template<>
double LuaTBTypedStack::getFromLuaStack |
( |
lua_State * |
lua | ) |
|
|
private |
template<typename T >
static T LuaTBTypedStack::getFromLuaStack |
( |
lua_State * |
lua | ) |
|
|
staticprivate |
Get a value from the lua stack and convert it to type 'T'.
- Parameters
-
lua | Pointer to the lua state |
- Returns
- Top element of the lua stack with the appropriate type
Note: Does NOT pop the value from the stack.
template<typename T >
static void LuaTBTypedStack::pushArgumentsToLuaStack |
( |
lua_State * |
, |
|
|
T |
|
|
) |
| |
|
inlinestaticprivate |
Pushes nothing onto the stack.
This is needed in case the function has no arguments at all. Otherwise, we would have a missing argument for such a function. This is also why we pass a dummy argument in 'callLuaFunction', so we have at least one argument. It is the termination point for the recursive template.
template<typename First , typename... Args>
static void LuaTBTypedStack::pushArgumentsToLuaStack |
( |
lua_State * |
lua, |
|
|
First |
first, |
|
|
Args... |
args |
|
) |
| |
|
inlinestaticprivate |
Recursively pushes arguments to the lua stack.
- Parameters
-
lua | Pointer to the lua state |
first | First argument to push onto the stack |
args | The remaining arguments to push onto the stack |
template<>
void LuaTBTypedStack::pushToLuaStack |
( |
lua_State * |
lua, |
|
|
int |
value |
|
) |
| |
|
private |
template<>
void LuaTBTypedStack::pushToLuaStack |
( |
lua_State * |
lua, |
|
|
double |
value |
|
) |
| |
|
private |
template<typename T >
static void LuaTBTypedStack::pushToLuaStack |
( |
lua_State * |
lua, |
|
|
T |
value |
|
) |
| |
|
staticprivate |
Pushes a value to the lua stack.
- Parameters
-
lua | Pointer to the lua state |
value | The value to push |
Note: Only the specializations are valid
std::list< std::unique_ptr< int > > LuaTBTypedStack::callbackRefs = {} |
|
staticprivate |
The documentation for this class was generated from the following files: