MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / RecursiveTableDump

Function RecursiveTableDump

Code/CryEngine/CryScriptSystem/ScriptSystem.cpp:2546–2597  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

2544
2545//////////////////////////////////////////////////////////////////////////
2546static void RecursiveTableDump(CScriptSystem* pSS, lua_State* L, int idx, int nLevel, IRecursiveLuaDump* sink, std::set<void*>& tables)
2547{
2548 const char* sKey = 0;
2549 int nKey = 0;
2550
2551 CHECK_STACK(L);
2552
2553 void* pTable = (void*)lua_topointer(L, idx);
2554 if (tables.find(pTable) != tables.end())
2555 {
2556 // This table was already dumped.
2557 return;
2558 }
2559 tables.insert(pTable);
2560
2561 lua_pushnil(L);
2562 while (lua_next(L, idx) != 0)
2563 {
2564 // `key' is at index -2 and `value' at index -1
2565 if (lua_type(L, -2) == LUA_TSTRING)
2566 sKey = lua_tostring(L, -2);
2567 else
2568 {
2569 sKey = 0;
2570 nKey = (int)lua_tonumber(L, -2); // key index.
2571 }
2572 int type = lua_type(L, -1);
2573 switch (type)
2574 {
2575 case LUA_TNIL:
2576 break;
2577 case LUA_TTABLE:
2578 {
2579 if (!(sKey != 0 && nLevel == 0 && strcmp(sKey, "_G") == 0))
2580 {
2581 sink->OnBeginTable(nLevel, sKey, nKey);
2582 RecursiveTableDump(pSS, L, lua_gettop(L), nLevel + 1, sink, tables);
2583 sink->OnEndTable(nLevel);
2584 }
2585 }
2586 break;
2587 default:
2588 {
2589 ScriptAnyValue any;
2590 pSS->ToAny(any, -1);
2591 sink->OnElement(nLevel, sKey, nKey, any);
2592 }
2593 break;
2594 }
2595 lua_pop(L, 1);
2596 }
2597}
2598
2599//////////////////////////////////////////////////////////////////////////
2600void CScriptSystem::DumpStateToFile(const char* filename)

Callers 1

DumpStateToFileMethod · 0.85

Calls 8

strcmpFunction · 0.85
OnBeginTableMethod · 0.80
OnEndTableMethod · 0.80
ToAnyMethod · 0.80
OnElementMethod · 0.80
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected