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

Function LuaPrint

engine/script/src/script.cpp:434–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432 }
433
434 int LuaPrint(lua_State* L)
435 {
436 int n = lua_gettop(L);
437 lua_getglobal(L, "tostring");
438 char buffer[dmLog::MAX_STRING_SIZE];
439 buffer[0] = 0;
440 for (int i = 1; i <= n; ++i)
441 {
442 const char *s;
443 lua_pushvalue(L, -1);
444 lua_pushvalue(L, i);
445 lua_call(L, 1, 1);
446 s = lua_tostring(L, -1);
447 if (s == 0x0)
448 return luaL_error(L, LUA_QL("tostring") " must return a string to " LUA_QL("print"));
449 if (i > 1)
450 dmStrlCat(buffer, "\t", sizeof(buffer));
451 dmStrlCat(buffer, s, sizeof(buffer));
452 lua_pop(L, 1);
453 }
454 dmLogUserDebug("%s", buffer);
455 lua_pop(L, 1);
456 assert(n == lua_gettop(L));
457 return 0;
458 }
459
460 static const char* PushValueAsString(lua_State* L, int index)
461 {

Callers

nothing calls this directly

Calls 6

lua_gettopFunction · 0.85
lua_pushvalueFunction · 0.85
lua_callFunction · 0.85
luaL_errorFunction · 0.85
dmStrlCatFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected