Bläddra i källkod

renamed read* to get* (except readString, to keep 3.0 compatibility), added setDouble/setFloat

Nicolas Cannasse 11 år sedan
förälder
incheckning
80263217d5
1 ändrade filer med 24 tillägg och 2 borttagningar
  1. 24 2
      std/haxe/io/Bytes.hx

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

@@ -177,7 +177,7 @@ class Bytes {
 		#end
 	}
 
-	public function readDouble( pos : Int ) : Float {
+	public function getDouble( pos : Int ) : Float {
 		#if neko
 		return untyped Input._double_of_bytes(sub(pos,8).b,false);
 		#elseif flash9
@@ -189,7 +189,7 @@ class Bytes {
 		#end
 	}
 
-	public function readFloat( pos : Int ) : Float {
+	public function getFloat( pos : Int ) : Float {
 		#if neko
 		return untyped Input._float_of_bytes(sub(pos,4).b,false);
 		#elseif flash9
@@ -200,6 +200,28 @@ class Bytes {
 		return b.readFloat();
 		#end
 	}
+	
+	public function setDouble( pos : Int, v : Float ) : Void {
+		#if neko
+		untyped $sblit(b, pos, Output._double_bytes(v,false), 0, 8);
+		#elseif flash9
+		b.position = pos;
+		b.writeDouble(v);
+		#else
+		throw "Not supported";
+		#end
+	}
+
+	public function setFloat( pos : Int, v : Float ) : Void {
+		#if neko
+		untyped $sblit(b, pos, Output._float_bytes(v,false), 0, 4);
+		#elseif flash9
+		b.position = pos;
+		b.writeFloat(v);
+		#else
+		throw "Not supported";
+		#end
+	}
 
 	public function readString( pos : Int, len : Int ) : String {
 		#if !neko