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

Function luaB_pprint

src/Chain/libraries/glua/lbaselib.cpp:52–72  ·  view source on GitHub ↗

* pretty print */

Source from the content-addressed store, hash-verified

50 * pretty print
51 */
52static int luaB_pprint(lua_State *L)
53{
54 int n = lua_gettop(L); /* number of arguments */
55 int i;
56 lua_getglobal(L, "tojsonstring");
57 for (i = 1; i <= n; i++) {
58 const char *s;
59 size_t l;
60 lua_pushvalue(L, -1); /* function to be called */
61 lua_pushvalue(L, i); /* value to print */
62 lua_call(L, 1, 1);
63 s = lua_tolstring(L, -1, &l); /* get result */
64 if (s == nullptr)
65 return luaL_error(L, "'tojsonstring' must return a string to 'pprint'");
66 if (i > 1) luaL_writestring(L, "\t", 1);
67 luaL_writestring(L, s, l);
68 lua_pop(L, 1); /* pop result */
69 }
70 luaL_writeline(L);
71 return 0;
72}
73
74static int luaB_exit_repl(lua_State *L)
75{

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
lua_getglobalFunction · 0.85
lua_pushvalueFunction · 0.85
lua_tolstringFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected