44 Lua(lua_State* L) : L(L) {}
45 Lua(
Lua&& oL) noexcept : L(oL.L) { oL.L =
nullptr; }
56 int getTop() {
return lua_gettop(L); }
57 void setTop(
int idx) { lua_settop(L, idx); }
58 void pop(
int n = 1) { lua_settop(L, -(n)-1); }
60 void remove(
int idx) { lua_remove(L, idx); }
61 void insert(
int idx) { lua_insert(L, idx); }
62 void replace(
int idx) { lua_replace(L, idx); }
63 void copy(
int fromidx,
int toidx) { lua_copy(L, fromidx, toidx); }
64 void copy(
int fromidx) { lua_pushvalue(L, fromidx); }
65 void checkStack(
int sz,
const char* msg =
nullptr) { luaL_checkstack(L, sz, msg); }
67 if ((index < 0) && (index > LUA_REGISTRYINDEX))
return getTop() + index + 1;
72 void push() { lua_pushnil(L); }
73 void push(
bool b) { lua_pushboolean(L,
b); }
75 void push(std::nullptr_t) { lua_pushlightuserdata(L,
nullptr); }
76 void push(
const char*
s,
size_t len) { lua_pushlstring(L,
s, len); }
79 lua_pushlstring(L,
s, S - 1);
81 void push(eastl::string_view
s) { lua_pushlstring(L,
s.data(),
s.size()); }
82 void vpushf(
const char* fmt, va_list ap) { lua_pushvfstring(L, fmt, ap); }
83 void pushf(
const char* fmt, ...);
84 void push(lua_CFunction f,
int closure = 0) { lua_pushcclosure(L, f, closure); }
86 void push(
void* p) { lua_pushlightuserdata(L, p); }
90 void push(FixedPoint<> fp);
97 bool toBoolean(
int idx) {
return lua_toboolean(L, idx); }
98 lua_Number
toNumber(
int idx,
bool* isnum =
nullptr);
99 const char*
toString(
int idx,
size_t* len =
nullptr) {
return lua_tolstring(L, idx, len); }
100 size_t rawLen(
int idx) {
return lua_rawlen(L, idx); }
101 lua_CFunction
toCFunction(
int idx) {
return lua_tocfunction(L, idx); }
102 template <
typename T =
void>
104 return reinterpret_cast<T*
>(lua_touserdata(L, idx));
106 lua_State*
toThread(
int idx) {
return lua_tothread(L, idx); }
107 const void*
toPointer(
int idx) {
return lua_topointer(L, idx); }
110 int type(
int idx) {
return lua_type(L, idx); }
111 const char*
typeName(
int tp) {
return lua_typename(L, tp); }
112 bool isNil(
int idx) {
return lua_isnil(L, idx); }
113 bool isNone(
int idx) {
return lua_isnone(L, idx); }
115 bool isBoolean(
int idx) {
return lua_isboolean(L, idx); }
116 bool isNumber(
int idx) {
return lua_isnumber(L, idx); }
117 bool isString(
int idx) {
return lua_isstring(L, idx); }
118 bool isTable(
int idx) {
return lua_istable(L, idx); }
123 bool isThread(
int idx) {
return lua_isthread(L, idx); }
127 void createTable(
int narr,
int nrec) { lua_createtable(L, narr, nrec); }
129 void getField(
int idx,
const char* k) { lua_getfield(L, idx, k); }
130 void getGlobal(
const char* name) { lua_getglobal(L, name); }
132 void setField(
int idx,
const char* k) { lua_setfield(L, idx, k); }
133 void setGlobal(
const char* name) { lua_setglobal(L, name); }
134 void rawGet(
int idx) { lua_rawget(L, idx); }
135 void rawGetI(
int idx,
int n) { lua_rawgeti(L, idx, n); }
136 void rawGetP(
int idx,
const void* p) { lua_rawgetp(L, idx, p); }
137 void rawSet(
int idx) { lua_rawset(L, idx); }
138 void rawSetI(
int idx,
int n) { lua_rawseti(L, idx, n); }
139 void rawSetP(
int idx,
const void* p) { lua_rawsetp(L, idx, p); }
140 int next(
int idx) {
return lua_next(L, idx); }
143 int newMetatable(
const char* tname) {
return luaL_newmetatable(L, tname); }
145 int getMetatable(
int objindex) {
return lua_getmetatable(L, objindex); }
146 int setMetatable(
int objindex) {
return lua_setmetatable(L, objindex); }
149 void call(
int nargs,
int nresults = LUA_MULTRET) { lua_call(L, nargs, nresults); }
150 int pcall(
int nargs,
int nresults = LUA_MULTRET);
154 return luaL_loadbuffer(L,
buff, sz, chunkname);
158 return luaL_loadbuffer(L,
buff, S - 1, chunkname);
165 int ref(
int t = LUA_REGISTRYINDEX) {
return luaL_ref(L,
t); }
169 int gc(
int what,
int data = 0) {
return lua_gc(L, what, data); }
172 int error(
const char* fmt, ...);
173 int argError(
int narg,
const char* extramsg) {
return luaL_argerror(L, narg, extramsg); }
175 void checkAny(
int narg) { luaL_checkany(L, narg); }
176 lua_Number
checkNumber(
int narg) {
return luaL_checknumber(L, narg); }
177 lua_Number
optNumber(
int narg, lua_Number def) {
return luaL_optnumber(L, narg, def); }
178 const char*
checkString(
int narg) {
return luaL_checkstring(L, narg); }
179 const char*
optString(
int narg,
const char* def) {
return luaL_optstring(L, narg, def); }
180 const char*
checkLString(
int narg,
size_t* len) {
return luaL_checklstring(L, narg, len); }
181 const char*
optLString(
int narg,
const char* def,
size_t* len) {
return luaL_optlstring(L, narg, def, len); }
182 void*
checkUdata(
int narg,
const char* tname) {
return luaL_checkudata(L, narg, tname); }
183 void argCheck(
bool cond,
int narg,
const char* extramsg) { luaL_argcheck(L, cond, narg, extramsg); }
184 int checkOption(
int narg,
const char* def,
const char*
const lst[]) {
return luaL_checkoption(L, narg, def, lst); }
186 luaL_checktype(L, narg, LUA_TBOOLEAN);
187 return lua_toboolean(L, narg);
189 bool optBoolean(
int narg,
bool def) {
return lua_isnoneornil(L, narg) ? def : lua_toboolean(L, narg); }
192 int getStack(
int level, lua_Debug* ar) {
return lua_getstack(L, level, ar); }
193 int getInfo(
const char* what, lua_Debug* ar) {
return lua_getinfo(L, what, ar); }
194 const char*
getLocal(
const lua_Debug* ar,
int n) {
return lua_getlocal(L, ar, n); }
195 const char*
setLocal(
const lua_Debug* ar,
int n) {
return lua_setlocal(L, ar, n); }
198 int yield(
int nresults) {
return lua_yield(L, nresults); }
199 int resume(
Lua from,
int narg) {
return lua_resume(L, from.L, narg); }
204 void setupFixedPointMetatable();
205 static int traceback(lua_State* L);