5#ifndef NNGN_LUA_UTILS_H
6#define NNGN_LUA_UTILS_H
20 std::bind_front(lua_settop, L,
i == -1 ? lua_gettop(L) :
i));
27 explicit
defer_pop(lua_State *L_,
int n_ = 1) :
L{L_},
n{n_} {}
47 if(
const int t1 = lua_gettop(L_); t0 != t1)
49 <<
"unexpected stack top: "
50 << t1 <<
" != " << t0 <<
'\n';
51 }, L, lua_gettop(L) + extra);
static std::ostream & l()
Definition log.cpp:56
Pops n values from the Lua stack at scope exit.
Definition utils.h:24
void set_n(int n_)
Definition utils.h:29
int n
Definition utils.h:32
~defer_pop(void)
Definition utils.h:28
lua_State * L
Definition utils.h:31
for i
Definition font.lua:5
Definition lua_audio.cpp:19
auto stack_mark(lua_State *L, int extra=0)
Creates a scoped object which verifies the stack top at scope exit.
Definition utils.h:42
auto defer_settop(lua_State *L, int i=-1)
Resets the top of the stack at scope exit.
Definition utils.h:18
empty
Definition utils.h:89
auto make_scoped(F &&f, Ts &&...ts)
Definition scoped.h:44
#define NNGN_MOVE_ONLY(x)
Definition utils.h:39