MCPcopy Create free account
hub / github.com/axmolengine/axmol / storeLuaTable

Method storeLuaTable

extensions/scripting/lua-bindings/manual/ComponentLua.cpp:224–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void ComponentLua::storeLuaTable()
225{
226 lua_State* l = LuaEngine::getInstance()->getLuaStack()->getLuaState();
227
228 _index++;
229 _strIndex.append(StringUtils::toString(_index));
230
231 // LUA_REGISTRYINDEX["component"][strIndex] = table return from lua
232 lua_pushstring(l, KEY_COMPONENT); // stack: table_return_from_lua "component"
233 lua_rawget(l, LUA_REGISTRYINDEX); // stack: table_return_from_lua table_of_component
234 lua_pushstring(l, _strIndex.c_str()); // stack: table_return_from_lua table_of_component strIndex
235 lua_pushvalue(l, -3); // stack: table_return_from_lua table_of_component strIndex table_return_from_lua
236 lua_rawset(l, -3); // stack: table_return_from_lua table_of_component
237 lua_pop(l, 1); // stack: table_return_from_lua
238
239 // add table's elements to userdata's metatable
240 object_to_luaval<ax::ComponentLua>(l, "ax.ComponentLua", this); // stack: table_return_from_lua userdata
241 lua_getmetatable(l, -1); // stack: table_return_from_lua userdata mt
242 lua_remove(l, -2); // stack: table_return_from_lua mt
243 lua_pushnil(l); // stack: table_return_from_lua mt nil
244 while (lua_next(l, -3)) // stack: table_return_from_lua mt key value
245 {
246 lua_pushvalue(l, -2); // stack: table_return_from_lua mt key value key
247 lua_insert(l, -2); // stack: table_return_from_lua mt key key value
248 lua_rawset(l, -4); // stack: table_return_from_lua mt key
249 }
250 lua_pop(l, 2);
251}
252
253void ComponentLua::removeLuaTable()
254{

Callers

nothing calls this directly

Calls 12

getInstanceFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawgetFunction · 0.85
lua_pushvalueFunction · 0.85
lua_rawsetFunction · 0.85
lua_getmetatableFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
getLuaStateMethod · 0.80
toStringFunction · 0.50
appendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected