added int32 support

This commit is contained in:
Nicolas Cannasse
2009-01-08 10:41:18 +00:00
parent cb0182f612
commit c381a758a8
7 changed files with 28 additions and 6 deletions
+12
View File
@@ -87,6 +87,13 @@ class Bytes {
bout.addByte((v >> 16) & 0xFF);
bout.addByte(v >>> 24);
}
case CInt32(v):
bout.addByte(4);
var mid = haxe.Int32.toInt(haxe.Int32.and(v,haxe.Int32.ofInt(0xFFFFFF)));
bout.addByte(mid & 0xFF);
bout.addByte((mid >> 8) & 0xFF);
bout.addByte(mid >> 16);
bout.addByte(haxe.Int32.toInt(haxe.Int32.ushr(v,24)));
case CFloat(f):
bout.addByte(2);
doEncodeString(Std.string(f));
@@ -108,6 +115,11 @@ class Bytes {
CFloat( Std.parseFloat(doDecodeString()) );
case 3:
CString( doDecodeString() );
case 4:
var i = bin.get(pin) | (bin.get(pin+1) << 8) | (bin.get(pin+2) << 16);
var j = bin.get(pin+3);
pin += 4;
CInt32(haxe.Int32.or(haxe.Int32.ofInt(i),haxe.Int32.shl(haxe.Int32.ofInt(j),24)));
default:
throw "Invalid code "+bin.get(pin-1);
}