Browse Source

[As3] fixed Reflect.getEnumValue

Simon Krajewski 12 năm trước cách đây
mục cha
commit
c312aeb5a1
2 tập tin đã thay đổi với 7 bổ sung8 xóa
  1. 6 7
      std/flash/_std/Reflect.hx
  2. 1 1
      tests/unit/compile.hxml

+ 6 - 7
std/flash/_std/Reflect.hx

@@ -97,19 +97,18 @@
 		if( v == null )
 			return false;
 		var t = __typeof__(v);
-		if( t == "object" ) {
-			try {
-				if( v.__enum__ == true )
-					return false;
-			} catch( e : Dynamic ) {
-			}
-			return true;
+		if ( t == "object" ) {
+			return !isEnumValue(v);
 		}
 		return (t == "string");
 	}
 	
 	public static function isEnumValue( v : Dynamic ) : Bool {
+		#if as3
+		return try Type.getEnum(v) != null catch ( e: Dynamic) false;
+		#else
 		return try v.__enum__ == true catch ( e : Dynamic) false;
+		#end
 	}
 
 	public static function deleteField( o : Dynamic, field : String ) : Bool untyped {

+ 1 - 1
tests/unit/compile.hxml

@@ -61,7 +61,7 @@ unit.Test
 --next
 -main unit.Test
 -as3 as3
-#-cmd mxmlc -static-link-runtime-shared-libraries=true -debug as3/__main__.as --output unit9_as3.swf
+-cmd mxmlc -static-link-runtime-shared-libraries=true -debug as3/__main__.as --output unit9_as3.swf
 
 #cpp
 --next