void LuaTable::Parse(lua_State* luaState, int depth) { PFFG_ASSERT(lua_istable(luaState, -1)); lua_pushnil(luaState); PFFG_ASSERT(lua_istable(luaState, -2)); while (lua_next(luaState, -2) != 0) { PFFG_ASSERT(lua_istable(luaState, -3)); switch (lua_type(luaState, -2)) { case LUA_TTABLE: { LuaTable* key = new LuaTable(); switch (lua_type(luaState, -1)) { case LUA_TTABLE: { TblTblPairs[key] = new LuaTable(); TblTblPairs[key]->Parse(luaState, depth + 1); lua_pop(luaState, 1); key->Parse(luaState, depth + 1); } break; case LUA_TSTRING: { TblStrPairs[key] = lua_tostring(luaState, -1); lua_pop(luaState, 1); key->Parse(luaState, depth + 1); } break; case LUA_TNUMBER: { TblFltPairs[key] = lua_tonumber(luaState, -1); lua_pop(luaState, 1); key->Parse(luaState, depth + 1); } break; } continue; } break; case LUA_TSTRING: { const std::string key = lua_tostring(luaState, -2); switch (lua_type(luaState, -1)) { case LUA_TTABLE: { StrTblPairs[key] = new LuaTable(); StrTblPairs[key]->Parse(luaState, depth + 1); } break; case LUA_TSTRING: { StrStrPairs[key] = lua_tostring(luaState, -1); } break; case LUA_TNUMBER: { StrFltPairs[key] = lua_tonumber(luaState, -1); } break; } lua_pop(luaState, 1); continue; } break; case LUA_TNUMBER: { const int key = lua_tointeger(luaState, -2); switch (lua_type(luaState, -1)) { case LUA_TTABLE: { IntTblPairs[key] = new LuaTable(); IntTblPairs[key]->Parse(luaState, depth + 1); } break; case LUA_TSTRING: { IntStrPairs[key] = lua_tostring(luaState, -1); } break; case LUA_TNUMBER: { IntFltPairs[key] = lua_tonumber(luaState, -1); } break; } lua_pop(luaState, 1); continue; } break; } } PFFG_ASSERT(lua_istable(luaState, -1)); }