/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.internal.Function; import java.Boot; @:keep @:coreApi class Reflect { @:functionCode(' if (o instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) o).__hx_getField(field, false, true, false) != haxe.lang.Runtime.undefined; return haxe.lang.Runtime.slowHasField(o, field); ') public static function hasField( o : Dynamic, field : String ) : Bool { return false; } @:functionCode(' if (o instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) o).__hx_getField(field, false, false, false); return haxe.lang.Runtime.slowGetField(o, field, false); ') public static function field( o : Dynamic, field : String ) : Dynamic { return null; } @:functionCode(' if (o instanceof haxe.lang.IHxObject) ((haxe.lang.IHxObject) o).__hx_setField(field, value, false); else haxe.lang.Runtime.slowSetField(o, field, value); ') public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void { } @:functionCode(' if (o instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) o).__hx_getField(field, false, false, true); if (haxe.lang.Runtime.slowHasField(o, "get_" + field)) return haxe.lang.Runtime.slowCallField(o, "get_" + field, null); return haxe.lang.Runtime.slowGetField(o, field, false); ') public static function getProperty( o : Dynamic, field : String ) : Dynamic { return null; } @:functionCode(' if (o instanceof haxe.lang.IHxObject) ((haxe.lang.IHxObject) o).__hx_setField(field, value, true); else if (haxe.lang.Runtime.slowHasField(o, "set_" + field)) haxe.lang.Runtime.slowCallField(o, "set_" + field, new Array( new java.lang.Object[]{value} )); else haxe.lang.Runtime.slowSetField(o, field, value); ') public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void { } @:functionCode(' return ((haxe.lang.Function) func).__hx_invokeDynamic(args); ') public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic { return null; } @:functionCode(' if (o instanceof haxe.lang.IHxObject) { Array ret = new Array(); ((haxe.lang.IHxObject) o).__hx_getFields(ret); return ret; } else if (o instanceof java.lang.Class) { return Type.getClassFields( (java.lang.Class) o); } else { return new Array(); } ') public static function fields( o : Dynamic ) : Array { return null; } @:functionCode(' return f instanceof haxe.lang.Function; ') public static function isFunction( f : Dynamic ) : Bool { return false; } @:functionCode(' return haxe.lang.Runtime.compare(a, b); ') public static function compare( a : T, b : T ) : Int { return 0; } @:functionCode(' if (f1 == f2) return true; if (f1 instanceof haxe.lang.Closure && f2 instanceof haxe.lang.Closure) { haxe.lang.Closure f1c = (haxe.lang.Closure) f1; haxe.lang.Closure f2c = (haxe.lang.Closure) f2; return haxe.lang.Runtime.refEq(f1c.obj, f2c.obj) && f1c.field.equals(f2c.field); } return false; ') public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { return false; } @:functionCode(' return v != null && !(v instanceof haxe.lang.Enum || v instanceof haxe.lang.Function || v instanceof java.lang.Enum || v instanceof java.lang.Number || v instanceof java.lang.Boolean); ') public static function isObject( v : Dynamic ) : Bool { return false; } @:functionCode(' return v != null && (v instanceof haxe.lang.Enum || v instanceof java.lang.Enum); ') public static function isEnumValue( v : Dynamic ) : Bool { return switch(Type.typeof(v)) { case TEnum(_): true; case _: false; } } @:functionCode(' return (o instanceof haxe.lang.DynamicObject && ((haxe.lang.DynamicObject) o).__hx_deleteField(field)); ') public static function deleteField( o : Dynamic, field : String ) : Bool { return false; } public static function copy( o : T ) : T { var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return cast o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return new VarArgsFunction(f); } }