Browse Source

Int32 update

Nicolas Cannasse 18 years ago
parent
commit
e8335cf9b0
2 changed files with 26 additions and 1 deletions
  1. 3 0
      doc/CHANGES.txt
  2. 23 1
      std/neko/Int32.hx

+ 3 - 0
doc/CHANGES.txt

@@ -1,3 +1,6 @@
+2007-??-??: 1.17
+	fixed Int32.compare, added Int32.read and Int32.write
+
 2007-10-31: 1.16
 	use _sans font for default flash traces (better Linux support)
 	fixed haxe.remoting.Connection compilation for Flash<8

+ 23 - 1
std/neko/Int32.hx

@@ -26,6 +26,28 @@ package neko;
 
 class Int32 {
 
+	public static function make( a : Int, b : Int ) {
+		return Int32.add(Int32.shl(cast a,16),cast b);
+	}
+
+	public static function read( i : neko.io.Input, ?b : Bool ) {
+		var f = if( b ) i.readUInt16B else i.readUInt16;
+		var a = f();
+		return if( b ) make(a,f()) else make(f(),a);
+	}
+
+	public static function write( o : neko.io.Output, i : Int32, ?b : Bool ) {
+		var low = cast Int32.and(i,cast 0xFFFF);
+		var high = cast Int32.ushr(i,16);
+		if( b ) {
+			o.writeUInt16B(high);
+			o.writeUInt16B(low);
+		} else {
+			o.writeUInt16(low);
+			o.writeUInt16(high);
+		}
+	}
+
 	public static var ofInt : Int -> Int32 = neko.Lib.load("std","int32_new",1);
 	public static var toInt : Int32 -> Int = neko.Lib.load("std","int32_to_int",1);
 	public static var toFloat : Int32 -> Float = neko.Lib.load("std","int32_to_float",1);
@@ -43,6 +65,6 @@ class Int32 {
 	public static var xor : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_xor",2);
 	public static var neg : Int32 -> Int32 = neko.Lib.load("std","int32_neg",1);
 	public static var complement : Int32 -> Int32 = neko.Lib.load("std","int32_complement",1);
-	public static var compare : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_compare",2);
+	public static var compare : Int32 -> Int32 -> Int = neko.Lib.load("std","int32_compare",2);
 
 }