add generator layers
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user