OOLua  2.0.1
C++ and Lua binding
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OOLUA::Lua_function Struct Reference

Structure which is used to call a Lua function. More...

#include <oolua_function.h>

Public Member Functions

 Lua_function ()
 Default constructor initialises the object. More...
 
 Lua_function (lua_State *vm)
 Binds the state vm to this instance.
 
void bind_script (lua_State *const vm)
 Sets the state in which functions will be called. More...
 
template<typename FUNC_TYPE >
bool operator() (FUNC_TYPE const &func)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 >
bool operator() (FUNC_TYPE const &func, P1 p1)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 , typename P9 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9)
 Function call operator. More...
 
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 , typename P9 , typename P10 >
bool operator() (FUNC_TYPE const &func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10)
 Function call operator. More...
 

Detailed Description

Structure which is used to call a Lua function.

Calling a Lua function, from C++ code using OOLua's API, can be achieved using a Lua_function object. This is a state bound caller, and the state in which the callee will be invoked is specified either in the constructor or via the bind_script member function.

To invoke a callee, the OOLUA::Lua_function type uses a call operator. The operator's first parameter must be the callee and it can be specified using one of the following types:

  • std::string A function in the bound state's global table
  • OOLUA::Lua_func_ref A reference to a function
  • int A valid stack index If the callee is identified via a valid stack index, then this index will remain on the stack at same absolute location after the caller has returned.

The call operator is also overloaded to enable the passing of parameters to the callee; the maximum number of parameters is defined by the configurable value "lua_params".

Constructor & Destructor Documentation

OOLUA::Lua_function::Lua_function ( )

Default constructor initialises the object.

Postcondition
Any call to a function call operator will cause an error until a lua_State is bound via bind_script

Member Function Documentation

void OOLUA::Lua_function::bind_script ( lua_State *const  vm)

Sets the state in which functions will be called.

Parameters
[in]vmThe state to bind to the instance.
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 , typename P9 , typename P10 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7,
P8  p8,
P9  p9,
P10  p10 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 , typename P9 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7,
P8  p8,
P9  p9 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 , typename P8 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7,
P8  p8 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 , typename P4 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3,
P4  p4 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 , typename P2 , typename P3 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1,
P2  p2,
P3  p3 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting
template<typename FUNC_TYPE , typename P1 >
bool OOLUA::Lua_function::operator() ( FUNC_TYPE const &  func,
P1  p1 
)

Function call operator.

Returns
Result indicating success
Template Parameters
FUNC_TYPE
See Also
Error Reporting

The documentation for this struct was generated from the following file: