Lua-API++
2015-02-12-3
Lua-API++ library
|
Main include file for Lua API++ library (no other files need to be included). More...
Namespaces | |
lua | |
Every thing in Lua API++ library is contained inside this namespace. | |
Macros | |
#define | LUAPP_USERDATA(type, class_name) namespace lua { template <> struct UserData<type> {typedef void enabled; static constexpr const char* const classname = class_name;}; } |
Userdata type to name string binder. More... | |
#define | LUAPP_ARG_CONVERT(src_type, body) namespace lua { namespace _ { namespace wrap { template<> inline src_type argCvt<src_type>(const ::lua::Valref& val) body }}} |
Argument conversion binder. More... | |
#define | LUAPP_RV_CONVERT(rv_type, body) namespace lua { namespace _ { namespace wrap { template<> inline lua::Retval rvCvt<rv_type>(rv_type val, lua::Context& context) body }}} |
Return value conversion binder. More... | |
Typedefs | |
using | LFunction = Retval(*)(Context &) |
Pointer to Lua API++ compatible function. More... | |
Functions | |
template<LFunction F> | |
int | mkcf (lua_State *l) |
Wrapper for LFunction that creates a proper Lua-compatible C function. More... | |
Main include file for Lua API++ library (no other files need to be included).
#define LUAPP_USERDATA | ( | type, | |
class_name | |||
) | namespace lua { template <> struct UserData<type> {typedef void enabled; static constexpr const char* const classname = class_name;}; } |
Userdata type to name string binder.
type | Userdata type being registered. Must be copyable or moveable. |
class_name | String identifier. |
Use this macro to register some type as a userdata type. After registration this type will be recognised as userdata and can be implicitly converted to Lua value and explicitly converted to from Lua value. The storage for the object is allocated by Lua.
__gc
metamethod. #define LUAPP_ARG_CONVERT | ( | src_type, | |
body | |||
) | namespace lua { namespace _ { namespace wrap { template<> inline src_type argCvt<src_type>(const ::lua::Valref& val) body }}} |
Argument conversion binder.
src_type | Native type of function argument. Must not be supported native type or userdata. |
body | The body of conversion function with curved braces. |
This macro is used to define a conversion routine to transform Lua value into native value that will be used as an argument to a wrapped function passed to Context::wrap function.
Provide the type for the argument to be converted to from Lua value and the body for function receiving const Valref& val
parameter and returning src_type
. Example:
#define LUAPP_RV_CONVERT | ( | rv_type, | |
body | |||
) | namespace lua { namespace _ { namespace wrap { template<> inline lua::Retval rvCvt<rv_type>(rv_type val, lua::Context& context) body }}} |
Return value conversion binder.
rv_type | Native type of function argument. Must not be supported native type or userdata. |
body | The body of conversion function with curved braces. |
This macro is used to define a conversion routine to transform native value returned by arbitrary C++ function into a Lua value that will be returned by wrapper function created by Context::wrap function.
Provide the type for the return value to be converted to from Lua value and the body for function receiving arguments (rv_type&& val, lua::Context& context
parameter. Example: