Holds a lookup table for members of one type of object. More...
#include <lua_attributes.hpp>
Public Types | |
using | getters_list = std::map< std::string, std::function< bool(lua_State *L, bool nop)> > |
using | setters_list = std::map< std::string, std::function< bool(lua_State *L, int idx, bool nop)> > |
using | validators_list = std::map< std::string, std::function< bool(lua_State *L)> > |
Public Member Functions | |
luaW_Registry ()=delete | |
luaW_Registry (const std::initializer_list< std::string > &mt) | |
~luaW_Registry () | |
int | get (lua_State *L) |
Implement __index metamethod. More... | |
int | set (lua_State *L) |
Implement __newindex metamethod. More... | |
int | dir (lua_State *L) |
Implement __dir metamethod. More... | |
Public Attributes | |
getters_list | getters |
A map of callbacks that read data from the object. More... | |
setters_list | setters |
A map of callbacks that write data to the object. More... | |
validators_list | validators |
A map of callbacks that check if a member is available. More... | |
std::string | private_metatable |
The internal metatable string for the object (from __metatable) More... | |
std::vector< std::string > | public_metatable |
Optional external metatable for the object (eg "wesnoth", "units") All entries of this table will be treated as members of the object. More... | |
Static Public Attributes | |
static std::map< std::string_view, std::reference_wrapper< luaW_Registry > > | lookup |
Holds a lookup table for members of one type of object.
Definition at line 36 of file lua_attributes.hpp.
using luaW_Registry::getters_list = std::map<std::string , std::function<bool(lua_State* L,bool nop)> > |
Definition at line 38 of file lua_attributes.hpp.
using luaW_Registry::setters_list = std::map<std::string, std::function<bool(lua_State* L,int idx,bool nop)> > |
Definition at line 41 of file lua_attributes.hpp.
using luaW_Registry::validators_list = std::map<std::string, std::function<bool(lua_State* L)> > |
Definition at line 44 of file lua_attributes.hpp.
|
delete |
luaW_Registry::luaW_Registry | ( | const std::initializer_list< std::string > & | mt | ) |
Definition at line 21 of file lua_attributes.cpp.
References lookup, private_metatable, and public_metatable.
luaW_Registry::~luaW_Registry | ( | ) |
Definition at line 27 of file lua_attributes.cpp.
References lookup, and private_metatable.
int luaW_Registry::dir | ( | lua_State * | L | ) |
Implement __dir metamethod.
Definition at line 68 of file lua_attributes.cpp.
References getters, lua_push(), luaW_get_attributes(), luaW_getglobal(), public_metatable, setters, and validators.
Referenced by game_lua_kernel::impl_current_dir(), lua_kernel_base::impl_game_config_dir(), impl_game_events_dir(), game_lua_kernel::impl_scenario_dir(), game_lua_kernel::impl_schedule_dir(), impl_side_dir(), impl_unit_dir(), and impl_unit_type_dir().
int luaW_Registry::get | ( | lua_State * | L | ) |
Implement __index metamethod.
Definition at line 31 of file lua_attributes.cpp.
References lg::err(), getters, luaW_getglobal(), private_metatable, and public_metatable.
Referenced by game_lua_kernel::impl_current_get(), lua_kernel_base::impl_game_config_get(), impl_game_events_get(), game_lua_kernel::impl_scenario_get(), game_lua_kernel::impl_schedule_get(), impl_side_get(), impl_unit_get(), and impl_unit_type_get().
int luaW_Registry::set | ( | lua_State * | L | ) |
Implement __newindex metamethod.
Definition at line 53 of file lua_attributes.cpp.
References lg::err(), private_metatable, and setters.
Referenced by lua_kernel_base::impl_game_config_set(), game_lua_kernel::impl_scenario_set(), game_lua_kernel::impl_schedule_set(), and impl_unit_set().
getters_list luaW_Registry::getters |
A map of callbacks that read data from the object.
Definition at line 40 of file lua_attributes.hpp.
|
inlinestatic |
Definition at line 37 of file lua_attributes.hpp.
Referenced by luaW_Registry(), register_lua_attribute(), and ~luaW_Registry().
std::string luaW_Registry::private_metatable |
The internal metatable string for the object (from __metatable)
Definition at line 48 of file lua_attributes.hpp.
Referenced by get(), luaW_Registry(), set(), and ~luaW_Registry().
std::vector<std::string> luaW_Registry::public_metatable |
Optional external metatable for the object (eg "wesnoth", "units") All entries of this table will be treated as members of the object.
Definition at line 51 of file lua_attributes.hpp.
Referenced by dir(), get(), and luaW_Registry().
setters_list luaW_Registry::setters |
A map of callbacks that write data to the object.
Definition at line 43 of file lua_attributes.hpp.
validators_list luaW_Registry::validators |
A map of callbacks that check if a member is available.
Definition at line 46 of file lua_attributes.hpp.
Referenced by dir().