diff options
Diffstat (limited to 'src/script/lua_api/l_storage.cpp')
-rw-r--r-- | src/script/lua_api/l_storage.cpp | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp index cba34fb63..fe3b4d74c 100644 --- a/src/script/lua_api/l_storage.cpp +++ b/src/script/lua_api/l_storage.cpp @@ -53,8 +53,7 @@ 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) { } @@ -90,7 +89,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)); @@ -108,27 +107,28 @@ 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,17 +139,10 @@ 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}}; |