From 4b8bc87db9beacc870eea0274b4af66b27235ec5 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Tue, 1 Aug 2023 13:15:56 +0200 Subject: [PATCH] added printArgs debug function --- src/lib/Debug.hx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib/Debug.hx b/src/lib/Debug.hx index c4d558d..be28d6a 100644 --- a/src/lib/Debug.hx +++ b/src/lib/Debug.hx @@ -1,5 +1,6 @@ package lib; +import lua.TableTools; import kernel.KernelEvents; import kernel.log.Log; import lua.NativeStringTools; @@ -37,6 +38,27 @@ class Debug { Log.debug("\n" + lines.join("\n")); } + public static function printArgs(?pos:haxe.PosInfos) { + var info = lua.Debug.getinfo(2); + + var args = ""; + + for (i in 1...info.nparams + 1) { + var t = TableTools.pack(lua.Debug.getlocal(2, i)); + if (t[1] == "self") { + continue; + } + + if (args != "") { + args += ", "; + } + + args += t[1] + ":" + t[2]; + } + + Log.debug('${pos.className}.${pos.methodName}($args)'); + } + #if Debug public static function printKernelEventsCount() { KernelEvents.printListenerCount();