nngn
|
Namespaces | |
namespace | detail |
Classes | |
struct | alloc_info |
Tracks state allocations. More... | |
class | defer_pop |
Pops n values from the Lua stack at scope exit. More... | |
struct | error |
"Pushing" this value causes lua_error to be called. More... | |
struct | function_value |
Owning reference to a function on the stack. More... | |
struct | function_view |
Non-owning reference to a function on the stack. More... | |
class | global_table |
Table interface to the global environment. More... | |
struct | nil_type |
Used to push nil values onto the stack. More... | |
struct | stack_get |
Reads a value from the Lua stack. More... | |
struct | stack_get< bool > |
Converts a value to boolean using Lua's rules (i.e. More... | |
struct | stack_get< const char * > |
Reads a C string value. More... | |
struct | stack_get< const lua_vector< T > & > |
struct | stack_get< lua_CFunction > |
Reads a lua_CFunction value. More... | |
struct | stack_get< lua_vector< T > * > |
struct | stack_get< pos > |
struct | stack_get< state_view > |
struct | stack_get< std::optional< T > > |
Reads a T if a value exists at that index (no type check is performed). More... | |
struct | stack_get< std::string > |
Reads a string value as ptr+size. More... | |
struct | stack_get< std::string_view > |
Reads a string value as ptr+size. More... | |
struct | stack_get< std::tuple< Ts... > > |
Reads a sequence of values from the stack. More... | |
struct | stack_get< std::vector< T > > |
Reads a table array as a vector. More... | |
struct | stack_get< T & > |
Reads a user type as a full user data value (reference overload). More... | |
struct | stack_get< T * > |
Reads a light user data value as void* . More... | |
struct | stack_get< T > |
Reads a value convertible to lua_Integer . More... | |
struct | stack_push |
Pushes a value onto the Lua stack. More... | |
struct | stack_push< bool > |
Pushes a value as a Lua boolean. More... | |
struct | stack_push< const char * > |
Pushes a C string value. More... | |
struct | stack_push< error< T > > |
Emits an error. More... | |
struct | stack_push< lua_CFunction > |
Pushes a lua_CFunction value. More... | |
struct | stack_push< lua_vector< T > > |
struct | stack_push< nil_type > |
Pushes a Lua nil value. More... | |
struct | stack_push< R(*)(Args...)> |
Pushes a function pointer. More... | |
struct | stack_push< R(T::*)(Args...) const > |
Same as the previous specialization, but for const member functions. More... | |
struct | stack_push< R(T::*)(Args...)> |
Same as the previous specialization, but for member functions. More... | |
struct | stack_push< std::optional< T > > |
Pushes a T if the object contains a value, otherwise nothing. More... | |
struct | stack_push< std::string > |
Convenience specialization for the std::string_view overload. More... | |
struct | stack_push< std::string_view > |
Pushes a ptr+size string value. More... | |
struct | stack_push< std::tuple< Ts... > > |
Pushes a sequence of values onto the stack. More... | |
struct | stack_push< std::variant< Ts... > > |
Pushes the active member of the variant. More... | |
struct | stack_push< T & > |
Pushes a user type as a full user data value (reference specialization). More... | |
struct | stack_push< T * > |
Pushes a generic pointer as a light user data value. More... | |
struct | stack_push< T > |
Pushes a value convertible to lua_Integer . More... | |
struct | stack_push< table_proxy< T, Ks... > > |
struct | stack_push< void > |
Generic version of stack_push, deduces type from the argument. More... | |
struct | state |
Owning lua_State wrapper. More... | |
class | state_view |
class | static_register |
Registers a function to be executed when the Lua state is initialized. More... | |
struct | table |
Owning reference to a table on the stack, popped when destroyed. More... | |
class | table_proxy |
Expression template for table assignemnts. More... | |
struct | table_view |
Non-owning reference to a table on the stack. More... | |
class | traceback |
Type used to output the Lua call stack. More... | |
class | user_data |
Data block allocated for user data objects. More... | |
struct | user_data< T > |
struct | user_data_header |
Header placed before a user data allocation. More... | |
struct | value |
Owning stack value reference. More... | |
class | value_view |
Base, non-owning generic stack value reference. More... | |
Concepts | |
concept | user_type |
concept | stack_ref |
Enumerations | |
enum class | type : int { X , none = LUA_TNONE , nil = LUA_TNIL , boolean = LUA_TBOOLEAN , light_user_data = LUA_TLIGHTUSERDATA , number = LUA_TNUMBER , string = LUA_TSTRING , table = LUA_TTABLE , function = LUA_TFUNCTION , user_data = LUA_TUSERDATA , thread = LUA_TTHREAD } |
LUA_T* constants as a scoped enumeration. More... | |
Functions | |
template<typename R , typename ... Args> | |
R | call (lua_State *L, R(*f)(Args...), int i) |
Calls the regular function f with arguments taken from the stack. | |
template<typename R , typename T , typename ... Args> | |
R | call (lua_State *L, R(T::*f)(Args...), int i) |
Calls member function f with object/arguments taken from the stack. | |
template<stateless_lambda T> | |
call (lua_State *L, T, int i) | |
Calls a stateless lambda. | |
template<typename T > | |
auto | ipairs (const T &table) |
Simple wrapper for a table value, returns ipairs -style iterators. | |
int | msgh (lua_State *L) |
Default message handler for lua_pcall . | |
void | print_stack (lua_State *L) |
Logs the current data stack. | |
void | print_traceback (lua_State *L) |
Logs the current call stack. | |
template<typename T > | |
error (T) -> error< T > | |
constexpr type | type_from_lua (int t) |
Maps LUA_T* values to type. | |
std::string_view | type_str (type t) |
template<member_pointer auto p> | |
int | accessor (lua_State *L) |
Lua function template which pushes an object's member. | |
template<member_pointer auto p> | |
int | value_accessor (lua_State *L) |
Similar to nngn::lua::accessor, but returns the member by value. | |
template<typename T > | |
T | get (nngn::lua::state_view L, int i) |
template<typename T = value_view> | |
T | push (nngn::lua::state_view lua, auto &&v) |
template<typename T , typename PT , typename ... Ks> | |
operator== (T &&lhs, const table_proxy< PT, Ks... > &rhs) | |
template<typename T , typename PT , typename ... Ks> | |
operator== (const table_proxy< PT, Ks... > &lhs, T &&rhs) | |
table | table_array (state_view lua, auto &&...args) |
Creates a table array with each argument in succession. | |
template<std::ranges::range T> | |
table | table_from_range (state_view lua, T &&r) |
Creates a table array from a range. | |
table | table_map (state_view lua, auto &&...args) |
Creates a table with each successive argument pair as key/value. | |
std::ostream & | operator<< (std::ostream &os, const traceback &t) |
auto | defer_settop (lua_State *L, int i=-1) |
Resets the top of the stack at scope exit. | |
auto | stack_mark (lua_State *L, int extra=0) |
Creates a scoped object which verifies the stack top at scope exit. | |
template<typename T > | |
bool | operator== (T &&lhs, const value_view &rhs) |
template<typename T > | |
bool | operator== (const value_view &lhs, T &&rhs) |
Variables | |
constexpr struct nngn::lua::nil_type | nil |
constexpr std::array | types |
type values as a sequential array. | |
template<typename T > | |
constexpr auto | is_user_type = false |
Flag which indicates that a type is to be treated as a user type. | |
template<typename T > | |
constexpr empty | metatable_name = {} |
Key in the global table where the meta-table for T is stored. | |
template<typename T > | |
constexpr bool | is_stack_ref = false |
Determines whether a type is a reference to a value on the stack. | |
template<typename T > | |
constexpr bool | is_stack_ref< T > = true |
template<typename T > | |
constexpr auto | user_data_header_align |
|
strong |
int nngn::lua::accessor | ( | lua_State * | L | ) |
Lua function template which pushes an object's member.
Receives a user data value of the containing type and returns a pointer to the member.
R nngn::lua::call | ( | lua_State * | L, |
R(* | f )(Args...), | ||
int | i ) |
Calls the regular function f
with arguments taken from the stack.
R nngn::lua::call | ( | lua_State * | L, |
R(T::* | f )(Args...), | ||
int | i ) |
Calls member function f
with object/arguments taken from the stack.
Calls member function, const
overload.
Calls a stateless lambda.
|
inline |
Resets the top of the stack at scope exit.
T nngn::lua::get | ( | nngn::lua::state_view | L, |
int | i ) |
Simple wrapper for a table value, returns ipairs
-style iterators.
Intended to be used directly in a range for
expressions to modify the implicit begin
/end
calls, e.g.:
Since it is a function, most uses can omit the namespace qualification and use the name directly due to ADL.
int nngn::lua::msgh | ( | lua_State * | L | ) |
Default message handler for lua_pcall
.
nngn::lua::operator== | ( | const table_proxy< PT, Ks... > & | lhs, |
T && | rhs ) |
bool nngn::lua::operator== | ( | const value_view & | lhs, |
T && | rhs ) |
nngn::lua::operator== | ( | T && | lhs, |
const table_proxy< PT, Ks... > & | rhs ) |
bool nngn::lua::operator== | ( | T && | lhs, |
const value_view & | rhs ) |
void nngn::lua::print_stack | ( | lua_State * | L | ) |
Logs the current data stack.
void nngn::lua::print_traceback | ( | lua_State * | L | ) |
Logs the current call stack.
T nngn::lua::push | ( | nngn::lua::state_view | lua, |
auto && | v ) |
|
inline |
Creates a scoped object which verifies the stack top at scope exit.
At the end of the object's scope, a message is logged if the current top of the stack is different than orig + extra
, where orig
is the top at the time of the stack_mark
call.
table nngn::lua::table_array | ( | state_view | lua, |
auto &&... | args ) |
Creates a table array with each argument in succession.
table nngn::lua::table_from_range | ( | state_view | lua, |
T && | r ) |
Creates a table array from a range.
table nngn::lua::table_map | ( | state_view | lua, |
auto &&... | args ) |
Creates a table with each successive argument pair as key/value.
I.e {[args[0]] = args[1], [args[2]] = args[3], ...}
.
Maps LUA_T*
values to type.
|
inline |
int nngn::lua::value_accessor | ( | lua_State * | L | ) |
Similar to nngn::lua::accessor, but returns the member by value.
Determines whether a type is a reference to a value on the stack.
These will be left on the stack after they are retrieved from a table. Specializations can be added for user-provided types.
|
inlineconstexpr |
|
inlineconstexpr |
Flag which indicates that a type is to be treated as a user type.
Specializations should be added (see NNGN_LUA_DECLARE_USER_TYPE) to indicate that values of this type should be read from / pushed onto the stack as Lua full user data values.
Key in the global table where the meta-table for T
is stored.
Actual type is fixed_string, empty is used to make the unspecialized value invalid.
struct nngn::lua::nil_type nngn::lua::nil |
|
inlineconstexpr |