Remove more invalid uses of luaL_error and luaL_check

This commit is contained in:
2021-12-27 17:03:42 -05:00
parent 9517b3e004
commit 0c021dc93a
3 changed files with 24 additions and 58 deletions

View File

@@ -304,12 +304,6 @@ private:
void push_any_value(lua_CFunction s) const { lua_pushcfunction(L_, s); }
void push_any_value(bool b) const { lua_pushboolean(L_, b ? 1:0); }
// Pop any value off the stack, by type.
void pop_any_value(LuaSlot &s) const { lua_replace(L_, s); }
void pop_any_value(lua_Integer &s) const;
void pop_any_value(lua_Number &s) const;
void pop_any_value(std::string &s) const;
// Push multiple values on the stack, in order, by type.
template<typename T0, typename... T>
void push_any_values(T0 arg0, T... args) {
@@ -353,7 +347,6 @@ public:
bool isboolean(LuaSlot s) const { return lua_type(L_, s) == LUA_TBOOLEAN; }
bool isnil(LuaSlot s) const { return lua_type(L_, s) == LUA_TNIL; }
bool iscfunction(LuaSlot s) const { return lua_iscfunction(L_, s) != 0; }
bool issortablekey(LuaSlot s) const;
void checktable(LuaSlot index) const { checktype(index, LUA_TTABLE); }
void checkstring(LuaSlot index) const { checktype(index, LUA_TSTRING); }
@@ -373,7 +366,6 @@ public:
void clearmetatable(LuaSlot tab) const;
void setmetatable(LuaSlot tab, LuaSlot mt) const;
bool getmetatable(LuaSlot mt, LuaSlot tab) const;
void checknometa(LuaSlot index) const;
void newtable(LuaSlot target) const;
void createtable(LuaSlot target, int narr, int nrec) const;
@@ -415,6 +407,12 @@ public:
// this module.
int64_t tanid(LuaSlot tab) const;
// Return true if the value is a sortable key (string, number, or boolean).
bool issortablekey(LuaSlot s) const;
// Move a sortable key (string, number, or boolean) from one lua
// environment to another lua environment. WARNING: this assert-fails
// if the value is not a sortable key.
void movesortablekey(LuaSlot val, LuaStack &other, LuaSlot otherslot);
bool rawequal(LuaSlot v1, LuaSlot v2) const {
@@ -428,23 +426,22 @@ public:
return result;
}
template<typename T1, typename T2>
void set(T1 &target, T2 value) const {
template<typename VT>
void set(LuaSlot target, VT value) const {
push_any_value(value);
pop_any_value(target);
lua_replace(L_, target);
}
template<typename RT, typename KT>
void rawget(RT &target, LuaSlot tab, KT key) const {
template<typename KT>
void rawget(LuaSlot target, LuaSlot tab, KT key) const {
push_any_value(key);
lua_rawget(L_, tab);
pop_any_value(target);
lua_replace(L_, target);
}
template<typename RT>
void rawget(RT &target, LuaSlot tab, int key) const {
lua_rawgeti(L_, tab, key);
pop_any_value(target);
void rawget(LuaSlot target, LuaSlot tab, int key) const {
lua_rawgeti(L_, tab, key);
lua_replace(L_, target);
}
template<typename KT, typename VT>