MCPcopy Create free account
hub / github.com/defold/defold / PrintTable

Function PrintTable

engine/lua/src/test/test_lua_csharp.cpp:26–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26static void PrintTable(lua_State* L, int indent)
27{
28 if ((lua_type(L, -2) == LUA_TSTRING))
29 {
30 PrintIndent(indent);
31 printf("%s\n", lua_tostring(L, -2));
32 }
33
34 lua_pushnil(L);
35 while(lua_next(L, -2) != 0) {
36 if(lua_isstring(L, -1))
37 {
38 PrintIndent(indent);
39 printf("%s = %s\n", lua_tostring(L, -2), lua_tostring(L, -1));
40 }
41 else if(lua_isnumber(L, -1))
42 {
43 PrintIndent(indent);
44 printf("%s = %f\n", lua_tostring(L, -2), lua_tonumber(L, -1));
45 }
46 else if(lua_istable(L, -1))
47 {
48 PrintTable(L, indent+1);
49 }
50 lua_pop(L, 1);
51 }
52}
53
54static bool RunString(lua_State* L, const char* script)
55{

Callers 1

TESTFunction · 0.85

Calls 7

lua_typeFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_isstringFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
PrintIndentFunction · 0.70

Tested by

no test coverage detected