mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Consolidate API object code (#12728)
Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
parent
b21fb18379
commit
7632af3c73
42 changed files with 463 additions and 1079 deletions
|
@ -100,6 +100,29 @@ bool ModApiBase::registerFunction(lua_State *L, const char *name,
|
|||
return true;
|
||||
}
|
||||
|
||||
void ModApiBase::registerClass(lua_State *L, const char *name,
|
||||
const luaL_Reg *methods,
|
||||
const luaL_Reg *metamethods)
|
||||
{
|
||||
luaL_newmetatable(L, name);
|
||||
luaL_register(L, NULL, metamethods);
|
||||
int metatable = lua_gettop(L);
|
||||
|
||||
lua_newtable(L);
|
||||
luaL_register(L, NULL, methods);
|
||||
int methodtable = lua_gettop(L);
|
||||
|
||||
lua_pushvalue(L, methodtable);
|
||||
lua_setfield(L, metatable, "__index");
|
||||
|
||||
// Protect the real metatable.
|
||||
lua_pushvalue(L, methodtable);
|
||||
lua_setfield(L, metatable, "__metatable");
|
||||
|
||||
// Pop methodtable and metatable.
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
|
||||
int ModApiBase::l_deprecated_function(lua_State *L, const char *good, const char *bad, lua_CFunction func)
|
||||
{
|
||||
thread_local std::vector<u64> deprecated_logged;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue