Browse Source

deprecate Int64.getLow/High

Simon Krajewski 10 years ago
parent
commit
a49a045f60

+ 7 - 1
std/cs/_std/haxe/Int64.hx

@@ -38,6 +38,12 @@ abstract Int64(__Int64) from __Int64 to __Int64
 	inline function get_val() : __Int64 return this;
 	inline function get_val() : __Int64 return this;
 	inline function set_val( x : __Int64 ) : __Int64 return this = x;
 	inline function set_val( x : __Int64 ) : __Int64 return this = x;
 
 
+	public var high( get, never ):Int32;
+	public inline function get_high():Int32 return cast(this >> 32);
+
+	public var low( get, never ):Int32;
+	public inline function get_low():Int32 return cast this;
+
 	public inline function copy():Int64
 	public inline function copy():Int64
 		return new Int64( this );
 		return new Int64( this );
 
 
@@ -98,7 +104,7 @@ abstract Int64(__Int64) from __Int64 to __Int64
 
 
 	@:op(A--) private inline function postDecrement() : Int64
 	@:op(A--) private inline function postDecrement() : Int64
 		return this--;
 		return this--;
-	
+
 	@:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64
 	@:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64
 		return a.val + b.val;
 		return a.val + b.val;
 
 

+ 4 - 2
std/haxe/Int64.hx

@@ -68,12 +68,14 @@ abstract Int64(__Int64) from __Int64 to __Int64
 	/**
 	/**
 		Returns the high 32-bit word of `x`.
 		Returns the high 32-bit word of `x`.
 	**/
 	**/
+	@:deprecated("Use high instead")
 	public static inline function getHigh( x : Int64 ) : Int32
 	public static inline function getHigh( x : Int64 ) : Int32
 		return x.high;
 		return x.high;
 
 
 	/**
 	/**
 		Returns the low 32-bit word of `x`.
 		Returns the low 32-bit word of `x`.
 	**/
 	**/
+	@:deprecated("Use low instead")
 	public static inline function getLow( x : Int64 ) : Int32
 	public static inline function getLow( x : Int64 ) : Int32
 		return x.low;
 		return x.low;
 
 
@@ -409,11 +411,11 @@ abstract Int64(__Int64) from __Int64 to __Int64
 			else make( 0, a.high >>> (b - 32) );
 			else make( 0, a.high >>> (b - 32) );
 	}
 	}
 
 
-	private var high(get,set) : Int32;
+	public var high(get, never) : Int32;
 	private inline function get_high() return this.high;
 	private inline function get_high() return this.high;
 	private inline function set_high(x) return this.high = x;
 	private inline function set_high(x) return this.high = x;
 
 
-	private var low(get,set) : Int32;
+	public var low(get, never) : Int32;
 	private inline function get_low() return this.low;
 	private inline function get_low() return this.low;
 	private inline function set_low(x) return this.low = x;
 	private inline function set_low(x) return this.low = x;
 }
 }

+ 2 - 2
std/haxe/io/Bytes.hx

@@ -266,8 +266,8 @@ class Bytes {
 		untyped __global__.__hxcpp_memory_set_double(b,pos,v);
 		untyped __global__.__hxcpp_memory_set_double(b,pos,v);
 		#else
 		#else
 		var i = FPHelper.doubleToI64(v);
 		var i = FPHelper.doubleToI64(v);
-		setInt32(pos, haxe.Int64.getLow(i));
-		setInt32(pos + 4, haxe.Int64.getHigh(i));
+		setInt32(pos, i.low);
+		setInt32(pos + 4, i.high);
 		#end
 		#end
 	}
 	}
 
 

+ 12 - 12
std/haxe/io/FPHelper.hx

@@ -217,8 +217,8 @@ class FPHelper {
 			var i64 : haxe.Int64 = helper[1], int2 = helper[0];
 			var i64 : haxe.Int64 = helper[1], int2 = helper[0];
 			untyped $dtoi(v,int2,false);
 			untyped $dtoi(v,int2,false);
 			@:privateAccess {
 			@:privateAccess {
-				i64.low = int2[0];
-				i64.high = int2[1];
+				i64.set_low(int2[0]);
+				i64.set_high(int2[1]);
 			}
 			}
 			return i64;
 			return i64;
 			#else
 			#else
@@ -226,8 +226,8 @@ class FPHelper {
 			if( i64 == null )
 			if( i64 == null )
 				i64 = i64tmp.value = haxe.Int64.ofInt(0);
 				i64 = i64tmp.value = haxe.Int64.ofInt(0);
 			@:privateAccess {
 			@:privateAccess {
-				i64.low = untyped $sget(r,0) | ($sget(r,1)<<8) | ($sget(r,2)<<16) | ($sget(r,3)<<24);
-				i64.high =  untyped $sget(r,4) | ($sget(r,5)<<8) | ($sget(r,6)<<16) | ($sget(r,7)<<24);
+				i64.set_low(untyped $sget(r,0) | ($sget(r,1)<<8) | ($sget(r,2)<<16) | ($sget(r,3)<<24));
+				i64.set_high(untyped $sget(r,4) | ($sget(r,5)<<8) | ($sget(r,6)<<16) | ($sget(r,7)<<24));
 			}
 			}
 			return i64;
 			return i64;
 			#end
 			#end
@@ -257,24 +257,24 @@ class FPHelper {
 			helper.position = 0;
 			helper.position = 0;
 			var i64 = i64tmp;
 			var i64 = i64tmp;
 			@:privateAccess {
 			@:privateAccess {
-				i64.low = cast helper.readUnsignedInt();
-				i64.high = cast helper.readUnsignedInt();
+				i64.set_low(cast helper.readUnsignedInt());
+				i64.set_high(cast helper.readUnsignedInt());
 			}
 			}
 			return i64;
 			return i64;
 		#elseif php
 		#elseif php
 			var a = untyped __call__('unpack',isLittleEndian ? 'V2' : 'N2',__call__('pack', 'd', v));
 			var a = untyped __call__('unpack',isLittleEndian ? 'V2' : 'N2',__call__('pack', 'd', v));
 			var i64 = i64tmp;
 			var i64 = i64tmp;
 			@:privateAccess {
 			@:privateAccess {
-				i64.low = a[isLittleEndian ? 1 : 2];
-				i64.high = a[isLittleEndian ? 2 : 1];
+				i64.set_low(a[isLittleEndian ? 1 : 2]);
+				i64.set_high(a[isLittleEndian ? 2 : 1]);
 			}
 			}
 			return i64;
 			return i64;
 		#else
 		#else
 			var i64 = i64tmp;
 			var i64 = i64tmp;
 			if( v == 0 ) {
 			if( v == 0 ) {
 				@:privateAccess {
 				@:privateAccess {
-					i64.low = 0;
-					i64.high = 0;
+					i64.set_low(0);
+					i64.set_high(0);
 				}
 				}
 			} else {
 			} else {
 				var av = v < 0 ? -v : v;
 				var av = v < 0 ? -v : v;
@@ -283,8 +283,8 @@ class FPHelper {
 				var sig_l = Std.int(sig);
 				var sig_l = Std.int(sig);
 				var sig_h = Std.int(sig / 4294967296.0);
 				var sig_h = Std.int(sig / 4294967296.0);
 				@:privateAccess {
 				@:privateAccess {
-					i64.low = sig_l;
-					i64.high = (v < 0 ? 0x80000000 : 0) | ((exp + 1023) << 20) | sig_h;
+					i64.set_low(sig_l);
+					i64.set_high((v < 0 ? 0x80000000 : 0) | ((exp + 1023) << 20) | sig_h);
 				}
 				}
 			}
 			}
 			return i64;
 			return i64;

+ 4 - 4
std/haxe/io/Output.hx

@@ -142,11 +142,11 @@ class Output {
 	public function writeDouble( x : Float ) {
 	public function writeDouble( x : Float ) {
 		var i64 = FPHelper.doubleToI64(x);
 		var i64 = FPHelper.doubleToI64(x);
 		if( bigEndian ) {
 		if( bigEndian ) {
-			writeInt32(haxe.Int64.getHigh(i64));
-			writeInt32(haxe.Int64.getLow(i64));
+			writeInt32(i64.high);
+			writeInt32(i64.low);
 		} else {
 		} else {
-			writeInt32(haxe.Int64.getLow(i64));
-			writeInt32(haxe.Int64.getHigh(i64));
+			writeInt32(i64.low);
+			writeInt32(i64.high);
 		}
 		}
 	}
 	}
 
 

+ 7 - 1
std/java/_std/haxe/Int64.hx

@@ -38,6 +38,12 @@ abstract Int64(__Int64) from __Int64 to __Int64
 	inline function get_val() : __Int64 return this;
 	inline function get_val() : __Int64 return this;
 	inline function set_val( x : __Int64 ) : __Int64 return this = x;
 	inline function set_val( x : __Int64 ) : __Int64 return this = x;
 
 
+	public var high( get, never ):Int32;
+	public inline function get_high():Int32 return cast(this >> 32);
+
+	public var low( get, never ):Int32;
+	public inline function get_low():Int32 return cast this;
+
 	public inline function copy():Int64
 	public inline function copy():Int64
 		return new Int64( this );
 		return new Int64( this );
 
 
@@ -98,7 +104,7 @@ abstract Int64(__Int64) from __Int64 to __Int64
 
 
 	@:op(A--) private inline function postDecrement() : Int64
 	@:op(A--) private inline function postDecrement() : Int64
 		return this--;
 		return this--;
-	
+
 	@:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64
 	@:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64
 		return a.val + b.val;
 		return a.val + b.val;
 
 

+ 18 - 18
tests/unit/src/unit/TestInt64.hx

@@ -10,31 +10,31 @@ class TestInt64 extends Test {
 
 
 		// Test creation and fields
 		// Test creation and fields
 		a = Int64.make(10,0xFFFFFFFF);
 		a = Int64.make(10,0xFFFFFFFF);
-		eq( a.getHigh(), 10 );
-		eq( a.getLow(), 0xFFFFFFFF );
+		eq( a.high, 10 );
+		eq( a.low, 0xFFFFFFFF );
 
 
 		// Int casts
 		// Int casts
 		a = 1;
 		a = 1;
 		eq( a.toInt(), 1 );
 		eq( a.toInt(), 1 );
 
 
 		a = -1;
 		a = -1;
-		eq( a.getHigh(), 0xFFFFFFFF );
-		eq( a.getLow(), 0xFFFFFFFF );
+		eq( a.high, 0xFFFFFFFF );
+		eq( a.low, 0xFFFFFFFF );
 		eq( a.toInt(), -1 );
 		eq( a.toInt(), -1 );
 
 
 		a = Int64.make(0,0x80000000);
 		a = Int64.make(0,0x80000000);
-		eq( a.getHigh(), 0 );
-		eq( a.getLow(), 0x80000000 );
+		eq( a.high, 0 );
+		eq( a.low, 0x80000000 );
 		exc( tryOverflow.bind(a) );	// Throws Overflow
 		exc( tryOverflow.bind(a) );	// Throws Overflow
 
 
 		a = Int64.make(0xFFFFFFFF,0x80000000);
 		a = Int64.make(0xFFFFFFFF,0x80000000);
-		eq( a.getHigh(), 0xFFFFFFFF );
-		eq( a.getLow(), 0x80000000 );
+		eq( a.high, 0xFFFFFFFF );
+		eq( a.low, 0x80000000 );
 		eq( a.toInt(), -2147483648 );
 		eq( a.toInt(), -2147483648 );
 
 
 		a = Int64.make(0xFFFFFFFF,0x7FFFFFFF);
 		a = Int64.make(0xFFFFFFFF,0x7FFFFFFF);
-		eq( a.getHigh(), 0xFFFFFFFF );
-		eq( a.getLow(), 0x7FFFFFFF );
+		eq( a.high, 0xFFFFFFFF );
+		eq( a.low, 0x7FFFFFFF );
 		exc( tryOverflow.bind(a) );	// Throws Overflow
 		exc( tryOverflow.bind(a) );	// Throws Overflow
 	}
 	}
 
 
@@ -44,18 +44,18 @@ class TestInt64 extends Test {
 		var arr:Array<Int64> = [];
 		var arr:Array<Int64> = [];
 		arr.push(1);
 		arr.push(1);
 		arr.push(Int64.make(0xFFFFFFFF,0x80000000));
 		arr.push(Int64.make(0xFFFFFFFF,0x80000000));
-		eq(arr[0].getHigh(), 0);
-		eq(arr[0].getLow(), 1);
-		eq(arr[1].getHigh(), 0xFFFFFFFF);
-		eq(arr[1].getLow(), 0x80000000);
+		eq(arr[0].high, 0);
+		eq(arr[0].low, 1);
+		eq(arr[1].high, 0xFFFFFFFF);
+		eq(arr[1].low, 0x80000000);
 
 
 		var n:Null<Int64> = null;
 		var n:Null<Int64> = null;
 		eq(n, null);
 		eq(n, null);
 		var dyn:Dynamic = n;
 		var dyn:Dynamic = n;
 		eq(dyn, null);
 		eq(dyn, null);
 		n = Int64.make(0xf0f0f0f0, 0xefefefef);
 		n = Int64.make(0xf0f0f0f0, 0xefefefef);
-		eq(n.getHigh(), 0xf0f0f0f0);
-		eq(n.getLow(), 0xefefefef);
+		eq(n.high, 0xf0f0f0f0);
+		eq(n.low, 0xefefefef);
 	}
 	}
 
 
 	function tryOverflow( a : Int64 )
 	function tryOverflow( a : Int64 )
@@ -343,13 +343,13 @@ class TestInt64 extends Test {
 		var a = Int64.make(0xFF00FF00,0xF0F0F0F0),
 		var a = Int64.make(0xFF00FF00,0xF0F0F0F0),
 		    b = Int64.make(0xFF00FF00,0xF0F0F0F0);
 		    b = Int64.make(0xFF00FF00,0xF0F0F0F0);
 		eq(a.compare(b), 0);
 		eq(a.compare(b), 0);
-		eq(a.getHigh(), 0xFF00FF00);
+		eq(a.high, 0xFF00FF00);
 		function test() return Int64.compare(a,Int64.make(0xFF00FF00,0xF0F0F0F0));
 		function test() return Int64.compare(a,Int64.make(0xFF00FF00,0xF0F0F0F0));
 		eq(test(),0);
 		eq(test(),0);
 		function testSet(v:Int64) b = v;
 		function testSet(v:Int64) b = v;
 		testSet( make(0xFF00FF00, 0xFF0) );
 		testSet( make(0xFF00FF00, 0xFF0) );
 		eq(b.compare(make(0xFF00FF00,0xFF0)),0);
 		eq(b.compare(make(0xFF00FF00,0xFF0)),0);
-		eq(b.getHigh(), 0xFF00FF00);
+		eq(b.high, 0xFF00FF00);
 	}
 	}
 
 
 	public function testMath() {
 	public function testMath() {

+ 2 - 2
tests/unit/src/unit/issues/Issue2752.hx

@@ -6,8 +6,8 @@ class Issue2752 extends Test {
 	function test() {
 	function test() {
 		var big : Int64 = Int64.make(2000,1000);
 		var big : Int64 = Int64.make(2000,1000);
 		var call = function(){
 		var call = function(){
-			eq(big.getHigh(),2000);
-			eq(big.getLow(),1000);
+			eq(big.high,2000);
+			eq(big.low,1000);
 		}
 		}
 		call();
 		call();
 	}
 	}

+ 2 - 2
tests/unit/src/unit/issues/Issue3203.hx

@@ -7,8 +7,8 @@ class Issue3203 extends Test {
 		var i64 = I64(Int64.make(1,2));
 		var i64 = I64(Int64.make(1,2));
 		switch (i64) {
 		switch (i64) {
 			case I64(x):
 			case I64(x):
-				eq(x.getHigh(),1);
-				eq(x.getLow(),2);
+				eq(x.high,1);
+				eq(x.low,2);
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
tests/unit/src/unit/issues/Issue3370.hx

@@ -15,7 +15,7 @@ abstract FunInt64(Int64)
     {
     {
         if (k >= 63)
         if (k >= 63)
         {
         {
-            return (Int64.getHigh(j) < 0) ? NEGATIVE_ONE : ZERO;
+            return ((j : Int64).high < 0) ? NEGATIVE_ONE : ZERO;
         }
         }
         return new FunInt64(Int64.shr(j, k));
         return new FunInt64(Int64.shr(j, k));
     }
     }