| 865 | } |
| 866 | |
| 867 | void LuaEngine::tableIterate(int handleIndex, function<bool(LuaValue key, LuaValue value)> iterator) { |
| 868 | lua_checkstack(m_state, 4); |
| 869 | |
| 870 | pushHandle(m_state, handleIndex); |
| 871 | lua_pushnil(m_state); |
| 872 | while (lua_next(m_state, -2) != 0) { |
| 873 | lua_pushvalue(m_state, -2); |
| 874 | LuaValue key = popLuaValue(m_state); |
| 875 | LuaValue value = popLuaValue(m_state); |
| 876 | bool cont = false; |
| 877 | try { |
| 878 | cont = iterator(std::move(key), std::move(value)); |
| 879 | } catch (...) { |
| 880 | lua_pop(m_state, 2); |
| 881 | throw; |
| 882 | } |
| 883 | if (!cont) { |
| 884 | lua_pop(m_state, 1); |
| 885 | break; |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | lua_pop(m_state, 1); |
| 890 | } |
| 891 | |
| 892 | Maybe<LuaTable> LuaEngine::tableGetMetatable(int handleIndex) { |
| 893 | lua_checkstack(m_state, 2); |
no test coverage detected