| 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 | { |
nothing calls this directly
no test coverage detected