|
@@ -72,22 +72,44 @@ class Bytes {
|
|
return r;
|
|
return r;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #if hl_check_align
|
|
|
|
+ static var alignBuffer : hl.Bytes = new hl.Bytes(8);
|
|
|
|
+ #end
|
|
|
|
+
|
|
public function getDouble( pos : Int ) : Float {
|
|
public function getDouble( pos : Int ) : Float {
|
|
- return if( out(pos + 7) ) 0. else b.getF64(pos);
|
|
|
|
|
|
+ if( out(pos + 7) ) return 0.;
|
|
|
|
+ #if hl_check_align
|
|
|
|
+ return if( pos & 3 == 0 ) b.getF64(pos) else { alignBuffer.blit(0, b, pos, 8); alignBuffer.getF64(0); }
|
|
|
|
+ #else
|
|
|
|
+ return b.getF64(pos);
|
|
|
|
+ #end
|
|
}
|
|
}
|
|
|
|
|
|
public function getFloat( pos : Int ) : Float {
|
|
public function getFloat( pos : Int ) : Float {
|
|
- return if( out(pos + 3) ) 0. else b.getF32(pos);
|
|
|
|
|
|
+ if( out(pos + 3) ) return 0.;
|
|
|
|
+ #if hl_check_align
|
|
|
|
+ return if( pos & 3 == 0 ) b.getF32(pos) else { alignBuffer.blit(0, b, pos, 4); alignBuffer.getF32(0); }
|
|
|
|
+ #else
|
|
|
|
+ return b.getF32(pos);
|
|
|
|
+ #end
|
|
}
|
|
}
|
|
|
|
|
|
public function setDouble( pos : Int, v : Float ) : Void {
|
|
public function setDouble( pos : Int, v : Float ) : Void {
|
|
if( out(pos + 7) ) throw Error.OutsideBounds;
|
|
if( out(pos + 7) ) throw Error.OutsideBounds;
|
|
|
|
+ #if hl_check_align
|
|
|
|
+ if( pos & 7 == 0 ) b.setF64(pos, v); else { alignBuffer.setF64(0,v); b.blit(pos,alignBuffer,0,8); }
|
|
|
|
+ #else
|
|
b.setF64(pos, v);
|
|
b.setF64(pos, v);
|
|
|
|
+ #end
|
|
}
|
|
}
|
|
|
|
|
|
public function setFloat( pos : Int, v : Float ) : Void {
|
|
public function setFloat( pos : Int, v : Float ) : Void {
|
|
if( out(pos + 3) ) throw Error.OutsideBounds;
|
|
if( out(pos + 3) ) throw Error.OutsideBounds;
|
|
|
|
+ #if hl_check_align
|
|
|
|
+ if( pos & 3 == 0 ) b.setF32(pos, v); else { alignBuffer.setF32(0,v); b.blit(pos,alignBuffer,0,4); }
|
|
|
|
+ #else
|
|
b.setF32(pos, v);
|
|
b.setF32(pos, v);
|
|
|
|
+ #end
|
|
}
|
|
}
|
|
|
|
|
|
public inline function getUInt16( pos : Int ) : Int {
|
|
public inline function getUInt16( pos : Int ) : Int {
|