32 std::string_view str = lua_check<std::string_view>(L, 2);
34 auto it =
getters.find(std::string(str));
36 if(it->second(L,
false)) {
42 method.push_back(std::string(str));
48 std::ostringstream
err;
50 return luaL_argerror(L, 2,
err.str().c_str());
54 std::string_view str = lua_check<std::string_view>(L, 2);
56 auto it =
setters.find(std::string(str));
58 if(it->second(L, 3,
false)) {
63 std::ostringstream
err;
65 return luaL_argerror(L, 2,
err.str().c_str());
69 std::vector<std::string> keys;
70 if(lua_istable(L, 2)) {
71 keys = lua_check<std::vector<std::string>>(L, 2);
74 std::set<std::string> inactive;
81 for(
const auto& [key, func] :
getters) {
82 if(inactive.count(key) > 0)
continue;
88 for(
const auto& [key, func] :
setters) {
89 if(inactive.count(key) > 0)
continue;
98 keys.insert(keys.end(), methods.begin(), methods.end());
bool luaW_getglobal(lua_State *L, const std::vector< std::string > &path)
Pushes the value found by following the variadic names (char *), if the value is not nil.
std::vector< std::string > luaW_get_attributes(lua_State *L, int idx)
This function does the actual work of grabbing all the attribute names.
void lua_push(lua_State *L, const T &val)
int dir(lua_State *L)
Implement __dir metamethod.
getters_list getters
A map of callbacks that read data from the object.
setters_list setters
A map of callbacks that write data to the object.
validators_list validators
A map of callbacks that check if a member is available.
static std::map< std::string_view, std::reference_wrapper< luaW_Registry > > lookup
std::string private_metatable
The internal metatable string for the object (from __metatable)
std::vector< std::string > public_metatable
Optional external metatable for the object (eg "wesnoth", "units") All entries of this table will be ...
int set(lua_State *L)
Implement __newindex metamethod.
int get(lua_State *L)
Implement __index metamethod.