| 222 | } |
| 223 | |
| 224 | void 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 | |
| 253 | void ComponentLua::removeLuaTable() |
| 254 | { |
nothing calls this directly
no test coverage detected