Jelajahi Sumber

use getString instead of readString

Simon Krajewski 11 tahun lalu
induk
melakukan
51ace6bac0
3 mengubah file dengan 11 tambahan dan 11 penghapusan
  1. 1 1
      std/haxe/io/Bytes.hx
  2. 3 3
      std/neko/net/ThreadRemotingServer.hx
  3. 7 7
      tests/unit/TestBytes.hx

+ 1 - 1
std/haxe/io/Bytes.hx

@@ -298,7 +298,7 @@ class Bytes {
 		}
 		catch (e:Dynamic) throw e;
 		#else
-		return readString(0,length);
+		return getString(0,length);
 		#end
 	}
 

+ 3 - 3
std/neko/net/ThreadRemotingServer.hx

@@ -70,7 +70,7 @@ class ThreadRemotingServer extends ThreadServer<haxe.remoting.SocketConnection,S
 		var msgLen = cnx.getProtocol().messageLength(buf.get(pos),buf.get(pos+1));
 		if( msgLen == null ) {
 			if( buf.get(pos) != 60 )
-				throw "Invalid remoting message '"+buf.readString(pos,len)+"'";
+				throw "Invalid remoting message '"+buf.getString(pos,len)+"'";
 			var p = pos;
 			while( p < len ) {
 				if( buf.get(p) == 0 )
@@ -81,7 +81,7 @@ class ThreadRemotingServer extends ThreadServer<haxe.remoting.SocketConnection,S
 				return null;
 			p -= pos;
 			return {
-				msg : buf.readString(pos,p),
+				msg : buf.getString(pos,p),
 				bytes : p + 1,
 			};
 		}
@@ -90,7 +90,7 @@ class ThreadRemotingServer extends ThreadServer<haxe.remoting.SocketConnection,S
 		if( buf.get(pos + msgLen-1) != 0 )
 			throw "Truncated message";
 		return {
-			msg : buf.readString(pos+2,msgLen-3),
+			msg : buf.getString(pos+2,msgLen-3),
 			bytes : msgLen,
 		};
 	}

+ 7 - 7
tests/unit/TestBytes.hx

@@ -60,13 +60,13 @@ class TestBytes extends Test {
 		// readString
 		var bs = haxe.io.Bytes.ofString("One é accent");
 		bs.set(3,0); // cut betwen "One" and "é"
-		eq(bs.readString(0,3),"One");
-		eq(bs.readString(4,bs.length-4),"é accent");
-		eq(bs.readString(4,2),"é");
-		exc(function() bs.readString(-1,1));
-		exc(function() bs.readString(1,20));
-		unspec(function() bs.readString(4,1)); // might not allow to cut UTF8 char
-		unspec(function() bs.readString(1,5)); // the handling of \0 might vary
+		eq(bs.getString(0,3),"One");
+		eq(bs.getString(4,bs.length-4),"é accent");
+		eq(bs.getString(4,2),"é");
+		exc(function() bs.getString(-1,1));
+		exc(function() bs.getString(1,20));
+		unspec(function() bs.getString(4,1)); // might not allow to cut UTF8 char
+		unspec(function() bs.getString(1,5)); // the handling of \0 might vary
 		/**
 		 	HANDLING of 0x00 in string :
 				Flash8 : ignore