Implement the 'keywords' lua module

This commit is contained in:
2025-01-20 21:11:59 -05:00
parent 2d531b28b3
commit 485caee05d
3 changed files with 136 additions and 9 deletions

View File

@@ -518,10 +518,8 @@ private:
int size_;
public:
LuaExtraArgs() {
index_ = 0;
size_ = 0;
}
LuaExtraArgs() : index_(0), size_(0) {}
LuaExtraArgs(int i, int s) : index_(i), size_(s) {}
LuaSpecial operator[] (int n) const { return LuaSpecial(index_ + n); }
int size() const { return size_; }
@@ -1186,7 +1184,9 @@ public:
~LuaExtStack() {
if (!lua_isthrowing(L_)) {
lua_settop(L_, oldtop_);
if (lua_gettop(L_) > oldtop_) {
lua_settop(L_, oldtop_);
}
}
}
};
@@ -1247,13 +1247,13 @@ public:
// Fetch the value of the keyword. If the keyword is found, then the
// keyword is added to the [FOUND] set, the value is returned in slot,
// and returns true. Otherwise, sets slot to nil and returns false.
bool optional(LuaSlot slot, const char *kw);
bool optional(LuaSlot slot, std::string_view kw);
// Fetch the value of the keyword. If the keyword is found, then the
// keyword is added to the [FOUND] set, the value is returned in slot,
// and returns true. Otherwise, sets slot to nil, returns false, and
// stores an [ERROR] report in the keyword table.
bool required(LuaSlot slot, const char *kw);
bool required(LuaSlot slot, std::string_view kw);
// Check if there are any errors so far. If any error has been
// detected, returns an error message, otherwise, returns empty