added printArgs debug function

This commit is contained in:
Djeeberjr 2023-08-01 13:15:56 +02:00
parent 0c7280a2f5
commit 4b8bc87db9

View File

@ -1,5 +1,6 @@
package lib; package lib;
import lua.TableTools;
import kernel.KernelEvents; import kernel.KernelEvents;
import kernel.log.Log; import kernel.log.Log;
import lua.NativeStringTools; import lua.NativeStringTools;
@ -37,6 +38,27 @@ class Debug {
Log.debug("\n" + lines.join("\n")); 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 #if Debug
public static function printKernelEventsCount() { public static function printKernelEventsCount() {
KernelEvents.printListenerCount(); KernelEvents.printListenerCount();