91#ifndef NNGN_LUA_REGISTER_H
92#define NNGN_LUA_REGISTER_H
107#define NNGN_LUA_PROXY(T, ...) \
108 NNGN_OVERLOAD(NNGN_LUA_PROXY, T __VA_OPT__(,) __VA_ARGS__)
109#define NNGN_LUA_PROXY1(T) NNGN_LUA_PROXY2(T, [](auto){})
110#define NNGN_LUA_PROXY2(T, f) \
111 static auto NNGN_ANON() = nngn::lua::static_register{ \
112 [](lua_State *nngn_L) { \
113 [[maybe_unused]] const auto mark = nngn::lua::stack_mark(nngn_L); \
114 (f)(nngn::lua::state_view{nngn_L}.new_user_type<T>()); \
124#define NNGN_LUA_DECLARE_USER_TYPE(T, ...) \
125 NNGN_OVERLOAD(NNGN_LUA_DECLARE_USER_TYPE, T __VA_OPT__(,) __VA_ARGS__)
126#define NNGN_LUA_DECLARE_USER_TYPE1(T) NNGN_LUA_DECLARE_USER_TYPE2(T, #T)
127#define NNGN_LUA_DECLARE_USER_TYPE2(T, N) \
129 inline constexpr auto nngn::lua::is_user_type<T> = true; \
131 inline constexpr nngn::fixed_string nngn::lua::metatable_name<T> = N;
141 using fn = void(lua_State*);
147 using V = std::vector<fn*>;
Registers a function to be executed when the Lua state is initialized.
Definition register.h:139
std::vector< fn * > V
Definition register.h:147
static V & registry(void)
Definition register.h:148
void(lua_State *) fn
Definition register.h:141
static_register(fn *f)
Adds a function to the list.
Definition register.h:145
static void register_all(lua_State *L)
Executes all registered function and removes them from the list.
Definition register.cpp:5
Definition lua_audio.cpp:19
v[1]
Definition math.lua:22