MCPcopy Create free account
hub / github.com/Tencent/xLua / Print

Function Print

Assets/XLua/Src/StaticLuaCallbacks.cs:602–636  ·  view source on GitHub ↗
(RealStatePtr L)

Source from the content-addressed store, hash-verified

600
601#if !XLUA_GENERAL
602 [MonoPInvokeCallback(typeof(LuaCSFunction))]
603 internal static int Print(RealStatePtr L)
604 {
605 try
606 {
607 int n = LuaAPI.lua_gettop(L);
608 string s = String.Empty;
609
610 if (0 != LuaAPI.xlua_getglobal(L, "tostring"))
611 {
612 return LuaAPI.luaL_error(L, "can not get tostring in print:");
613 }
614
615 for (int i = 1; i <= n; i++)
616 {
617 LuaAPI.lua_pushvalue(L, -1); /* function to be called */
618 LuaAPI.lua_pushvalue(L, i); /* value to print */
619 if (0 != LuaAPI.lua_pcall(L, 1, 1, 0))
620 {
621 return LuaAPI.lua_error(L);
622 }
623 s += LuaAPI.lua_tostring(L, -1);
624
625 if (i != n) s += "\t";
626
627 LuaAPI.lua_pop(L, 1); /* pop result */
628 }
629 UnityEngine.Debug.Log("LUA: " + s);
630 return 0;
631 }
632 catch (System.Exception e)
633 {
634 return LuaAPI.luaL_error(L, "c# exception in print:" + e);
635 }
636 }
637#endif
638
639#if (!UNITY_SWITCH && !UNITY_WEBGL) || UNITY_EDITOR

Callers

nothing calls this directly

Calls 9

lua_gettopMethod · 0.80
xlua_getglobalMethod · 0.80
luaL_errorMethod · 0.80
lua_pushvalueMethod · 0.80
lua_pcallMethod · 0.80
lua_errorMethod · 0.80
lua_tostringMethod · 0.80
lua_popMethod · 0.80
LogMethod · 0.80

Tested by

no test coverage detected