Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Utilities to write lua bindings. More...
#include <geogram/basic/common.h>
#include <geogram/basic/assert.h>
#include <geogram/basic/numeric.h>
#include <geogram/basic/string.h>
#include <geogram/basic/memory.h>
#include <geogram/third_party/lua/lua.h>
#include <geogram/third_party/lua/lauxlib.h>
#include <geogram/third_party/lua/lualib.h>
Go to the source code of this file.
Classes | |
class | GEO::lua_to< T > |
Converts LUA variables to C++ variables. More... | |
class | GEO::lua_to< int > |
lua_to specialization for int. More... | |
class | GEO::lua_to< Numeric::uint32 > |
lua_to specialization for Numeric::uint32. More... | |
class | GEO::lua_to< Numeric::uint64 > |
lua_to specialization for Numeric::uint64. More... | |
class | GEO::lua_to< Numeric::int64 > |
lua_to specialization for Numeric::int64. More... | |
class | GEO::lua_to< float > |
lua_to specialization for float. More... | |
class | GEO::lua_to< double > |
lua_to specialization for double. More... | |
class | GEO::lua_to< bool > |
lua_to specialization for bool. More... | |
class | GEO::lua_to< const char * > |
lua_to specialization for raw string (const char*). More... | |
class | GEO::lua_to< const std::string & > |
lua_to specialization for reference to std::string. More... | |
class | GEO::lua_to< std::string > |
lua_to specialization for std::string. More... | |
class | GEO::lua_wrapper< FPTR > |
Manages wrappers around C++ functions to be called from LUA. More... | |
Namespaces | |
GEO | |
Global Vorpaline namespace. | |
Macros | |
#define | LUA_DECLAREENUMTYPE(T) |
Declares a new enum type that can be used by LUA wrappers. More... | |
#define | lua_bindwrapper(L, f) |
Binds a LUA wrapper around a C++ function to the table on the top of the LUA stack. More... | |
#define | lua_bindwrapperglobal(L, f) |
Binds a LUA wrapper around a C++ function to the global scope. More... | |
Typedefs | |
typedef int(* | GEO::lua_test_func) (lua_State *L, int idx) |
A pointer to a LUA function to test an argument in the LUA stack. | |
Functions | |
int | GEO::my_lua_isboolean (lua_State *L, int idx) |
Tests whether a LUA variable is a boolean. More... | |
int | GEO::my_lua_islightuserdata (lua_State *L, int idx) |
Tests whether a LUA variable is a light user data. More... | |
int | GEO::my_lua_ispositiveinteger (lua_State *L, int idx) |
Tests whether a LUA variable is a positive integer. More... | |
void | GEO::lua_set_error (lua_State *L, const char *error) |
Memorizes an error message in LUA registry. More... | |
void | GEO::lua_set_error (lua_State *L, const std::string &error) |
Memorizes an error message in LUA registry. More... | |
void | GEO::lua_clear_error (lua_State *L) |
Clears the last error message in LUA registry. More... | |
bool | GEO::lua_has_error (lua_State *L) |
Tests whether an error message was memorized in the registry. More... | |
bool | GEO::lua_check_type (lua_State *L, int idx, lua_test_func test) |
Tests whether a LUA variable has the correct type. More... | |
bool | GEO::lua_check_nb_args (lua_State *L, int expected_nb_args) |
Tests whether the expected number of arguments was pushed onto the stack. More... | |
int | GEO::lua_notify_last_error (lua_State *L) |
Takes the last error message memorized in the registry and sends it back to LUA. More... | |
template<class T > | |
void | GEO::lua_push (lua_State *L, T x) |
Converts and pushes a C++ variable onto the LUA stack. More... | |
template<> | |
void | GEO::lua_push (lua_State *L, int x) |
Specialization of lua_push() for int. | |
template<> | |
void | GEO::lua_push (lua_State *L, Numeric::uint32 x) |
Specialization of lua_push() for Numeric::uint32. | |
template<> | |
void | GEO::lua_push (lua_State *L, Numeric::uint64 x) |
Specialization of lua_push() for Numeric::uint64. | |
template<> | |
void | GEO::lua_push (lua_State *L, Numeric::int64 x) |
Specialization of lua_push() for Numeric::int64. | |
template<> | |
void | GEO::lua_push (lua_State *L, float x) |
Specialization of lua_push() for float. | |
template<> | |
void | GEO::lua_push (lua_State *L, double x) |
Specialization of lua_push() for double. | |
template<> | |
void | GEO::lua_push (lua_State *L, bool x) |
Specialization of lua_push() for bool. | |
template<> | |
void | GEO::lua_push (lua_State *L, const char *x) |
Specialization of lua_push() for raw string (const char*). | |
template<> | |
void | GEO::lua_push (lua_State *L, const std::string &x) |
Specialization of lua_push() for reference to std::string. | |
template<> | |
void | GEO::lua_push (lua_State *L, std::string x) |
Specialization of lua_push() for std::string. | |
template<class T > | |
void | GEO::lua_push (lua_State *L, const std::vector< T > &x) |
Specialization of lua_push() for vectors. More... | |
template<class R > | |
int | GEO::lua_wrap (lua_State *L, R(*fptr)(void)) |
Calls a C++ function from LUA. More... | |
template<class R , class T1 > | |
int | GEO::lua_wrap (lua_State *L, R(*fptr)(T1)) |
Calls a C++ function from LUA. More... | |
template<class R , class T1 , class T2 > | |
int | GEO::lua_wrap (lua_State *L, R(*fptr)(T1, T2)) |
Calls a C++ function from LUA. More... | |
template<class R , class T1 , class T2 , class T3 > | |
int | GEO::lua_wrap (lua_State *L, R(*fptr)(T1, T2, T3)) |
Calls a C++ function from LUA. More... | |
template<class R , class T1 , class T2 , class T3 , class T4 > | |
int | GEO::lua_wrap (lua_State *L, R(*fptr)(T1, T2, T3, T4)) |
Calls a C++ function from LUA. More... | |
template<> | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(void)) |
Calls a C++ function from LUA. More... | |
template<class T1 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8, T9)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)) |
Calls a C++ function from LUA. More... | |
template<class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 > | |
int | GEO::lua_wrap (lua_State *L, void(*fptr)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)) |
Calls a C++ function from LUA. More... | |
template<> | |
int | GEO::lua_wrap (lua_State *L, lua_CFunction fptr) |
Specialization of the wrapper for functions that are "already wrapped". More... | |
template<class FPTR > | |
void | GEO::lua_pushwrapper (lua_State *L, FPTR f) |
Pushes a wrapper for a given C++ function onto the LUA stack. More... | |
template<> | |
void | GEO::lua_pushwrapper (lua_State *L, lua_CFunction f) |
Specialization for lua_CFunction. More... | |
template<class FPTR > | |
void | GEO::lua_bindwrapperwithname (lua_State *L, FPTR f, const std::string &name) |
Binds a wrapper to a name in the table at the top of the LUA stack. More... | |
template<class FPTR > | |
void | GEO::lua_bindwrapperwithnameglobal (lua_State *L, FPTR f, const std::string &name) |
Binds a wrapper to a name in the global scole. More... | |
std::string | GEO::lua_wrappername (lua_State *L, const char *functionname) |
Converts a C++ function name into a LUA function name. More... | |
Utilities to write lua bindings.
Definition in file lua_wrap.h.
#define lua_bindwrapper | ( | L, | |
f | |||
) |
Binds a LUA wrapper around a C++ function to the table on the top of the LUA stack.
The arguments are automatically converted from the LUA stack to the function arguments. If the function is non-void, the return value is automatically converted to LUA and pushed onto the LUA stack. If the function is already a LUA interface (takes a lua_State* as an argument and returns an integer), then it will be directly called, without any conversion. The name of the function is obtained by removing all namespaces from f
.
[in] | L | a pointer to the LUA state. |
[in] | f | a pointer to the C++ function to be wrapped. It cannot be a non-static object member function. |
Definition at line 1351 of file lua_wrap.h.
#define lua_bindwrapperglobal | ( | L, | |
f | |||
) |
Binds a LUA wrapper around a C++ function to the global scope.
The arguments are automatically converted from the LUA stack to the function arguments. If the function is non-void, the return value is automatically converted to LUA and pushed onto the LUA stack. If the function is already a LUA interface (takes a lua_State* as an argument and returns an integer), then it will be directly called, without any conversion. The name of the function is obtained by removing all namespaces from f
.
[in] | L | a pointer to the LUA state. |
[in] | f | a pointer to the C++ function to be wrapped. It cannot be a non-static object member function. |
Definition at line 1369 of file lua_wrap.h.
#define LUA_DECLAREENUMTYPE | ( | T | ) |
Declares a new enum type that can be used by LUA wrappers.
enum types that can be used in wrapped functions need to be explicitely declared before using lua_bindwrapper() and lua_bindwrapperglobal(). This will be no longer the case when we will switch to C++11 (but for now, geogram needs to remain compatible with C++98).
[in] | T | the C++ type name of the enum. |
Definition at line 586 of file lua_wrap.h.