MCPcopy Create free account
hub / github.com/Tencent/UnLua / TraverseTable

Function TraverseTable

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp:1252–1284  ·  view source on GitHub ↗

* Traverse a Lua table */

Source from the content-addressed store, hash-verified

1250 * Traverse a Lua table
1251 */
1252int32 TraverseTable(lua_State *L, int32 Index, void *Userdata, bool(*TraverseWorker)(lua_State*, void*))
1253{
1254 if (Index < 0 && Index > LUA_REGISTRYINDEX)
1255 {
1256 int32 Top = lua_gettop(L);
1257 Index = Top + Index + 1;
1258 }
1259 int32 Type = lua_type(L, Index);
1260 if (Type == LUA_TTABLE)
1261 {
1262 if (!lua_checkstack(L, 2))
1263 {
1264 return INDEX_NONE;
1265 }
1266
1267 int32 NumElements = 0;
1268 lua_pushnil(L);
1269 while (lua_next(L, Index) != 0)
1270 {
1271 if (TraverseWorker)
1272 {
1273 bool b = TraverseWorker(L, Userdata);
1274 if (b)
1275 {
1276 ++NumElements;
1277 }
1278 }
1279 lua_pop(L, 1);
1280 }
1281 return NumElements;
1282 }
1283 return INDEX_NONE;
1284}
1285
1286/**
1287 * __index meta methods for enum

Callers 4

SetValueInternalMethod · 0.85
SetValueInternalMethod · 0.85
SetValueInternalMethod · 0.85
GetFunctionNamesFunction · 0.85

Calls 5

lua_gettopFunction · 0.85
lua_typeFunction · 0.85
lua_checkstackFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85

Tested by

no test coverage detected