Pārlūkot izejas kodu

added readDouble/readFloat on haxe.io.Bytes

Nicolas Cannasse 11 gadi atpakaļ
vecāks
revīzija
8aed734e92
1 mainītis faili ar 24 papildinājumiem un 0 dzēšanām
  1. 24 0
      std/haxe/io/Bytes.hx

+ 24 - 0
std/haxe/io/Bytes.hx

@@ -177,6 +177,30 @@ class Bytes {
 		#end
 	}
 
+	public function readDouble( pos : Int ) : Float {
+		#if neko
+		return untyped Input._double_of_bytes(sub(pos,8).b,false);
+		#elseif flash9
+		b.position = pos;
+		return b.readDouble();
+		#else
+		var b = new haxe.io.BytesInput(this,pos,8);
+		return b.readDouble();
+		#end
+	}
+
+	public function readFloat( pos : Int ) : Float {
+		#if neko
+		return untyped Input._float_of_bytes(sub(pos,4).b,false);
+		#elseif flash9
+		b.position = pos;
+		return b.readFloat();
+		#else
+		var b = new haxe.io.BytesInput(this,pos,4);
+		return b.readFloat();
+		#end
+	}
+
 	public function readString( pos : Int, len : Int ) : String {
 		#if !neko
 		if( pos < 0 || len < 0 || pos + len > length ) throw Error.OutsideBounds;