64#define NNGN_LUA_TYPES(X) \
67 X(boolean, LUA_TBOOLEAN) \
68 X(light_user_data, LUA_TLIGHTUSERDATA) \
69 X(number, LUA_TNUMBER) \
70 X(string, LUA_TSTRING) \
71 X(table, LUA_TTABLE) \
72 X(function, LUA_TFUNCTION) \
73 X(user_data, LUA_TUSERDATA) \
74 X(thread, LUA_TTHREAD)
87template<
typename T>
struct error {
T e; };
93inline constexpr std::array
types = [] {
94 using U = std::underlying_type_t<type>;
97 constexpr auto n =
e - b;
98 std::array<U, n> u = {};
99 std::array<type, n> ret = {};
102 std::ranges::begin(u), std::ranges::end(u),
103 std::ranges::begin(ret),
to<type>{});
134 static int push(lua_State *L,
T &&t) {
158template<
typename R,
typename ...Args>
159R
call(lua_State *L, R(*
f)(Args...),
int i = 1);
160template<
typename R,
typename T,
typename ...Args>
161R
call(lua_State *L, R(
T::*
f)(Args...),
int i = 1);
162template<
typename R,
typename T,
typename ...Args>
164template<stateless_lambda T>
165decltype(
auto)
call(lua_State *L,
T,
int i = 1);
183inline constexpr bool can_get =
requires(lua_State *L) {
189inline constexpr bool can_push =
requires(lua_State *L,
T t) {
201 { t.state() } -> std::same_as<state_view>;
202 { t.push() } -> std::same_as<int>;
233int msgh(lua_State *L);
241#define X(n, _) case type::n: return #n;
244 default:
return "unknown";
local class const
Definition animation.lua:7
CRTP base for table iterators.
Definition lua.h:169
lua_next-based table iterator.
Definition lua.h:170
ipairs-style table iterator.
Definition lua.h:171
precision highp int
Definition common.h:14
As std::convertible_to, but excluding implicit conversions.
Definition concepts.h:27
A type which can be fully represented by a lua_Integer.
Definition lua.h:207
A type which can be fully represented by a lua_Number.
Definition lua.h:211
A built-in type from this library with stack manipulation operations.
Definition lua.h:199
A type which can be read from / pushed onto the stack.
Definition lua.h:195
assert
Definition debug.lua:3
function DEMO text end
Definition demo0.lua:6
for i
Definition font.lua:5
local n
Definition dump_lights.lua:5
constexpr bool is_optional
Definition lua.h:213
op_mode
Definition lua.h:173
@ normal
Definition lua.h:173
@ raw
Definition lua.h:173
constexpr bool can_push
Whether this library knows how to push a T value onto the stack.
Definition lua.h:189
constexpr bool can_get
Whether this library knows how to read a T value from the stack.
Definition lua.h:183
Definition lua_audio.cpp:19
constexpr type type_from_lua(int t)
Maps LUA_T* values to type.
Definition lua.h:109
void print_stack(lua_State *L)
Logs the current data stack.
Definition lua.cpp:26
int msgh(lua_State *L)
Default message handler for lua_pcall.
Definition lua.cpp:15
T push(nngn::lua::state_view lua, auto &&v)
Definition state.h:186
std::string_view type_str(type t)
Definition lua.h:239
constexpr bool is_stack_ref< T >
Definition table.h:452
constexpr bool is_stack_ref
Determines whether a type is a reference to a value on the stack.
Definition lua.h:223
type
LUA_T* constants as a scoped enumeration.
Definition lua.h:77
constexpr auto is_user_type
Flag which indicates that a type is to be treated as a user type.
Definition lua.h:145
R call(lua_State *L, R(*f)(Args...), int i)
Calls the regular function f with arguments taken from the stack.
Definition function.h:125
constexpr struct nngn::lua::nil_type nil
constexpr empty metatable_name
Key in the global table where the meta-table for T is stored.
Definition lua.h:156
void print_traceback(lua_State *L)
Logs the current call stack.
Definition lua.cpp:59
constexpr const R * begin(const T< R > &v)
Definition vec.h:207
constexpr auto to_underlying(T t)
Definition utils.h:138
constexpr bool is_sequence(R &&r, Proj proj={})
Definition ranges.h:119
empty
Definition utils.h:89
#define NNGN_LUA_TYPES(X)
Definition lua.h:64
#define FWD(...)
Definition utils.h:18
local error
Definition strict.lua:2
Tag to relate all table_base instantiations via inheritance.
Definition lua.h:176
Tag to relate all table_proxy instantiations via inheritance.
Definition lua.h:179
"Pushing" this value causes lua_error to be called.
Definition lua.h:87
Used to push nil values onto the stack.
Definition lua.h:84
Reads a value from the Lua stack.
Definition lua.h:118
static int push(lua_State *L, T &&t)
Definition lua.h:134
Pushes a value onto the Lua stack.
Definition lua.h:120
Function object which converts its argument to T via static_cast.
Definition fn.h:25
local e
Definition math.lua:4