Explorar o código

Lua : Update Reflect.callMethod

This method is still a wip, but it's a decent first attempt at providing
an "apply" mechanism in lua that works for the equivalent Haxe reflect
method.
Justin Donaldson %!s(int64=10) %!d(string=hai) anos
pai
achega
061b86d7cc
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      std/lua/_std/Reflect.hx

+ 6 - 1
std/lua/_std/Reflect.hx

@@ -44,7 +44,12 @@
 	}
 
 	public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
-		return func.apply(o,args);
+		if (args == null || args.length == 0){
+			return func(o);
+		} else {
+			var new_args = [o].concat(args);
+			return func(unpack(new_args,1,lua.TableTools.maxn(untyped new_args)));
+		}
 	}
 
 	public static function fields( o : Dynamic ) : Array<String> {