add generator layers

This commit is contained in:
MihailRis
2024-08-17 18:11:52 +03:00
parent 30925df319
commit 2a767a3638
7 changed files with 125 additions and 14 deletions
+10 -1
View File
@@ -496,17 +496,26 @@ namespace lua {
}
int pushvalue(lua::State*, const dynamic::Value& value);
[[nodiscard]]
dynamic::Value tovalue(lua::State*, int idx);
inline bool getfield(lua::State* L, const std::string& name, int idx = -1) {
lua_getfield(L, idx, name.c_str());
if (isnil(L, -1)) {
if (isnil(L, idx)) {
pop(L);
return false;
}
return true;
}
inline int requirefield(lua::State* L, const std::string& name, int idx = -1) {
if (getfield(L, name, idx)) {
return 1;
}
throw std::runtime_error("object has no member '"+name+"'");
}
inline bool hasfield(lua::State* L, const std::string& name, int idx = -1) {
lua_getfield(L, idx, name.c_str());
if (isnil(L, -1)) {