diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 16:57:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:57:47 +0100 |
commit | 3e16c3a78fff61c20e63ba730d15e94e3bb877b4 (patch) | |
tree | c070350db219f2c4241d22bc31949685c7b42fe9 /src/script/lua_api/l_storage.cpp | |
parent | 5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (diff) | |
parent | 6ccb5835ff55d85156be91473c598eca9d6cb9a6 (diff) | |
download | dragonfireclient-3e16c3a78fff61c20e63ba730d15e94e3bb877b4.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/script/lua_api/l_storage.cpp')
-rw-r--r-- | src/script/lua_api/l_storage.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp index fe3b4d74c..cba34fb63 100644 --- a/src/script/lua_api/l_storage.cpp +++ b/src/script/lua_api/l_storage.cpp @@ -53,7 +53,8 @@ void ModApiStorage::Initialize(lua_State *L, int top) API_FCT(get_mod_storage); } -StorageRef::StorageRef(ModMetadata *object) : m_object(object) +StorageRef::StorageRef(ModMetadata *object): + m_object(object) { } @@ -89,7 +90,7 @@ void StorageRef::Register(lua_State *L) lua_pushliteral(L, "__metatable"); lua_pushvalue(L, methodtable); - lua_settable(L, metatable); // hide metatable from Lua getmetatable() + lua_settable(L, metatable); // hide metatable from Lua getmetatable() lua_pushliteral(L, "metadata_class"); lua_pushlstring(L, className, strlen(className)); @@ -107,28 +108,27 @@ void StorageRef::Register(lua_State *L) lua_pushcfunction(L, l_equals); lua_settable(L, metatable); - lua_pop(L, 1); // drop metatable + lua_pop(L, 1); // drop metatable - luaL_openlib(L, 0, methods, 0); // fill methodtable - lua_pop(L, 1); // drop methodtable + luaL_openlib(L, 0, methods, 0); // fill methodtable + lua_pop(L, 1); // drop methodtable } -StorageRef *StorageRef::checkobject(lua_State *L, int narg) +StorageRef* StorageRef::checkobject(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); - if (!ud) - luaL_typerror(L, narg, className); - return *(StorageRef **)ud; // unbox pointer + if (!ud) luaL_typerror(L, narg, className); + return *(StorageRef**)ud; // unbox pointer } -ModMetadata *StorageRef::getobject(StorageRef *ref) +ModMetadata* StorageRef::getobject(StorageRef *ref) { ModMetadata *co = ref->m_object; return co; } -Metadata *StorageRef::getmeta(bool auto_create) +Metadata* StorageRef::getmeta(bool auto_create) { return m_object; } @@ -139,10 +139,17 @@ void StorageRef::clearMeta() } const char StorageRef::className[] = "StorageRef"; -const luaL_Reg StorageRef::methods[] = {luamethod(MetaDataRef, contains), - luamethod(MetaDataRef, get), luamethod(MetaDataRef, get_string), - luamethod(MetaDataRef, set_string), luamethod(MetaDataRef, get_int), - luamethod(MetaDataRef, set_int), luamethod(MetaDataRef, get_float), - luamethod(MetaDataRef, set_float), luamethod(MetaDataRef, to_table), - luamethod(MetaDataRef, from_table), luamethod(MetaDataRef, equals), - {0, 0}}; +const luaL_Reg StorageRef::methods[] = { + luamethod(MetaDataRef, contains), + luamethod(MetaDataRef, get), + luamethod(MetaDataRef, get_string), + luamethod(MetaDataRef, set_string), + luamethod(MetaDataRef, get_int), + luamethod(MetaDataRef, set_int), + luamethod(MetaDataRef, get_float), + luamethod(MetaDataRef, set_float), + luamethod(MetaDataRef, to_table), + luamethod(MetaDataRef, from_table), + luamethod(MetaDataRef, equals), + {0,0} +}; |