Skip to content

Commit

Permalink
Reflect.callMethod should accept Function only.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Aug 19, 2014
1 parent 721ce12 commit 6cb1e40
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern class Reflect {
/**
Call a method with the given object and arguments.
**/
public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic;
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic;

/**
Returns the fields of structure `o`.
Expand Down
2 changes: 1 addition & 1 deletion std/cpp/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
o.__SetField(field,value,true);
}

public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
if (func!=null && func.__GetType()==__global__.vtString)
func = o.__Field(func,true);
untyped func.__SetThis(o);
Expand Down
2 changes: 1 addition & 1 deletion std/cs/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import cs.internal.Function;
@:functionCode('
return ((haxe.lang.Function) func).__hx_invokeDynamic(args);
')
public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion std/flash/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
}

public inline static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
return func.apply(o,args);
}

Expand Down
2 changes: 1 addition & 1 deletion std/flash/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ enum ValueType {
}

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
var f = untyped e[constr];
var f:Dynamic = untyped e[constr];
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down
2 changes: 1 addition & 1 deletion std/flash8/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Reflect.setField(o, field, value);
}

public inline static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
return func["apply"](o,args);
}

Expand Down
2 changes: 1 addition & 1 deletion std/flash8/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ enum ValueType {
}

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
var f = Reflect.field(e,constr);
var f:Dynamic = Reflect.field(e,constr);
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down
2 changes: 1 addition & 1 deletion std/java/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import java.Boot;
@:functionCode('
return ((haxe.lang.Function) func).__hx_invokeDynamic(args);
')
public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if( o.__properties__ && (tmp=o.__properties__["set_"+field]) ) o[tmp](value) else o[field] = __define_feature__("Reflect.setProperty",value);
}

public inline static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
return func.apply(o,args);
}

Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ enum ValueType {
}

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
var f = Reflect.field(e,constr);
var f:Dynamic = Reflect.field(e,constr);
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down
2 changes: 1 addition & 1 deletion std/neko/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
}

public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
var a = args.__neko();
// pad missing args with null's
var n = $nargs(func);
Expand Down
2 changes: 1 addition & 1 deletion std/neko/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ enum ValueType {
}

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
var f = Reflect.field(e,constr);
var f:Dynamic = Reflect.field(e,constr);
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down
5 changes: 1 addition & 4 deletions std/php/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
return untyped __php__("$o->$field = $value");
}

public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic untyped {
if (__call__("is_string", o) && !__call__("is_array", func)) {
return __call__("call_user_func_array", field(o, func), __field__(args, "a"));
}
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic untyped {
return __call__("call_user_func_array", __call__("is_callable", func) ? func : __call__("array", o, func), (null == args ? __call__("array") : __field__(args, "a")));
}

Expand Down
2 changes: 1 addition & 1 deletion std/php/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ enum ValueType {
}

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T {
var f = Reflect.field(e,constr);
var f:Dynamic = Reflect.field(e,constr);
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down
2 changes: 1 addition & 1 deletion std/python/_std/Reflect.hx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Reflect {
else Builtin.setattr(o,field, value);
}

public static function callMethod( o : Dynamic, func : Dynamic, args : Array<Dynamic> ) : Dynamic
public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array<Dynamic> ) : Dynamic
{
var args:VarArgs = args;
return if (Builtin.callable(func)) func(python.Syntax.varArgs(args)) else null;
Expand Down
2 changes: 1 addition & 1 deletion std/python/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ enum ValueType {

public static function createEnum<T>( e : Enum<T>, constr : String, ?params : Array<Dynamic> ) : T
{
var f = Reflect.field(e,constr);
var f:Dynamic = Reflect.field(e,constr);
if( f == null ) throw "No such constructor "+constr;
if( Reflect.isFunction(f) ) {
if( params == null ) throw "Constructor "+constr+" need parameters";
Expand Down

0 comments on commit 6cb1e40

Please sign in to comment.