Skip to content

Commit

Permalink
use FPHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Mar 1, 2015
1 parent 0e0aa82 commit 660142a
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions std/haxe/io/BytesBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,36 @@ class BytesBuffer {
add(Bytes.ofString(v));
#end
}

public #if flash9 inline #end function addInt32( v : Int ) {
#if flash9
b.writeUInt32(v);
#else
addByte(v&0xFF);
addByte((v>>8)&0xFF);
addByte((v>>16)&0xFF);
addByte(v>>>24);
#end
}

public #if flash9 inline #end function addInt64( v : haxe.Int64 ) {
addInt32(haxe.Int64.getLow(v));
addInt32(haxe.Int64.getHigh(v));
}

public inline function addFloat( v : Float ) {
#if neko
untyped StringBuf.__add(b, Output._float_bytes(v, false));
#elseif flash9
#if flash9
b.writeFloat(v);
#else
var b = new BytesOutput();
b.writeFloat(v);
add(b.getBytes());
addInt32(FPHelper.floatToI32(v));
#end
}

public inline function addDouble( v : Float ) {
#if neko
untyped StringBuf.__add(b, Output._double_bytes(v, false));
#elseif flash9
#if flash9
b.writeDouble(v);
#else
var b = new BytesOutput();
b.writeDouble(v);
add(b.getBytes());
addInt64(FPHelper.doubleToI64(v));
#end
}

Expand Down

0 comments on commit 660142a

Please sign in to comment.