MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaL_traverse_table_with_nested

Function luaL_traverse_table_with_nested

src/Chain/libraries/glua/lapi.cpp:1386–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1384}
1385
1386size_t luaL_traverse_table_with_nested(lua_State *L, int index, lua_table_traverser_with_nested traverser, void *ud, std::list<const void*> &jsons, size_t recur_depth)
1387{
1388 if (index > lua_gettop(L))
1389 return 0;
1390 if (!lua_istable(L, index))
1391 return 0;
1392 lua_len(L, index);
1393 auto len = (size_t) lua_tointegerx(L, -1, nullptr);
1394 lua_pop(L, 1);
1395 size_t keys_count = 0;
1396 for (auto i = 0; i < len; ++i)
1397 {
1398 lua_pushinteger(L, i + 1);
1399 auto new_index = index < 0 ? (index - 1) : index;
1400 lua_geti(L, new_index, i + 1);
1401 ++keys_count;
1402 if (nullptr != traverser)
1403 traverser(L, ud, len, jsons, recur_depth+1);
1404 lua_pop(L, 2);
1405 }
1406 lua_pushvalue(L, index);
1407 int it = lua_gettop(L);
1408 lua_pushnil(L);
1409 while (lua_next(L, it))
1410 {
1411 if (lua_isinteger(L, -2))
1412 {
1413 auto key_int = lua_tointeger(L, -2);
1414 if (((int)key_int) <= len && key_int > 0)
1415 {
1416 lua_pop(L, 1);
1417 continue;
1418 }
1419 }
1420 ++keys_count;
1421 if (traverser)
1422 traverser(L, ud, len, jsons, recur_depth+1);
1423 lua_pop(L, 1);
1424 }
1425 lua_pop(L, 1);
1426 return keys_count;
1427}
1428
1429size_t luaL_traverse_table(lua_State *L, int index, lua_table_traverser traverser, void *ud)
1430{

Callers 3

lualib_http_requestFunction · 0.85
tojsonstring_with_nestedFunction · 0.85

Calls 8

lua_gettopFunction · 0.85
lua_lenFunction · 0.85
lua_pushintegerFunction · 0.85
lua_getiFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_isintegerFunction · 0.85

Tested by

no test coverage detected