Browse Source

[all] Add Int64.is . Closes #4014

Cauê Waneck 10 years ago
parent
commit
245433a9ba

+ 3 - 0
std/cs/_std/haxe/Int64.hx

@@ -56,6 +56,9 @@ abstract Int64(__Int64) from __Int64 to __Int64
 		return cast x.val;
 		return cast x.val;
 	}
 	}
 
 
+	inline public static function is( val : Dynamic ) : Bool
+		return Std.is(val,cs.system.Int64);
+
 	public static inline function getHigh( x : Int64 ) : Int32
 	public static inline function getHigh( x : Int64 ) : Int32
 		return cast( x.val >> 32 );
 		return cast( x.val >> 32 );
 
 

+ 6 - 0
std/haxe/Int64.hx

@@ -65,6 +65,12 @@ abstract Int64(__Int64) from __Int64 to __Int64
 		return x.low;
 		return x.low;
 	}
 	}
 
 
+	/**
+		Returns whether the value `val` is of type `haxe.Int64`
+	**/
+	inline public static function is( val : Dynamic ) : Bool
+		return Std.is(val,__Int64);
+
 	/**
 	/**
 		Returns the high 32-bit word of `x`.
 		Returns the high 32-bit word of `x`.
 	**/
 	**/

+ 3 - 0
std/java/_std/haxe/Int64.hx

@@ -50,6 +50,9 @@ abstract Int64(__Int64) from __Int64 to __Int64
 	@:from public static inline function ofInt( x : Int ) : Int64
 	@:from public static inline function ofInt( x : Int ) : Int64
 		return cast x;
 		return cast x;
 
 
+	inline public static function is( val : Dynamic ) : Bool
+		return Std.is(val,java.lang.Long.LongClass);
+
 	public static inline function toInt( x : Int64 ) : Int {
 	public static inline function toInt( x : Int64 ) : Int {
 		if( x.val < 0x80000000 || x.val > 0x7FFFFFFF )
 		if( x.val < 0x80000000 || x.val > 0x7FFFFFFF )
 			throw "Overflow";
 			throw "Overflow";

+ 8 - 2
tests/unit/src/unit/issues/Issue3173.hx

@@ -20,7 +20,10 @@ private class O2 extends O<StringMap<Int>>
 	{
 	{
 	}
 	}
 
 
-	@:overload override public function foo(t:StringMap<Int>):Int
+#if (java || cs)
+	@:overload
+#end
+	override public function foo(t:StringMap<Int>):Int
 	{
 	{
 		return 1;
 		return 1;
 	}
 	}
@@ -28,7 +31,10 @@ private class O2 extends O<StringMap<Int>>
 
 
 private class O<T>
 private class O<T>
 {
 {
-	@:overload public function foo(t:T):Int
+#if (java || cs)
+	@:overload
+#end
+	public function foo(t:T):Int
 	{
 	{
 		return 0;
 		return 0;
 	}
 	}

+ 17 - 0
tests/unit/src/unit/issues/Issue4014.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+import haxe.Int64;
+
+class Issue4014 extends Test
+{
+	public function test()
+	{
+		var d = Int64.make(1,1);
+		var dyn:Dynamic = d;
+		t(Int64.is(dyn));
+		d = dyn;
+		eq(d.high,1);
+		eq(d.low,1);
+		dyn = {};
+		f(Int64.is(dyn));
+	}
+}