Browse Source

use haxe.io and haxe.Int32

Nicolas Cannasse 17 years ago
parent
commit
0fd67cb562

+ 4 - 1
doc/CHANGES.txt

@@ -27,7 +27,10 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	flash9 : some minor optimizations in haxe.Serializer
 	flash9 : some minor optimizations in haxe.Serializer
 	added haxe.io package (removed things from neko.io)
 	added haxe.io package (removed things from neko.io)
 	__resolve becomes resolve (and should be documented)
 	__resolve becomes resolve (and should be documented)
-	TODO read/write int31+int32
+	added haxe.Int32
+	removed neko.Int32
+	removed neko.io.Input/Output/Eof/Error/Logger/Multiple/StringInput/StringOutput
+	changed neko apis to use haxe.io and Bytes instead of String buffers
 
 
 2008-04-05: 1.19
 2008-04-05: 1.19
 	fixed flash9 Array.toString
 	fixed flash9 Array.toString

+ 38 - 35
std/haxe/Http.hx

@@ -26,8 +26,8 @@ package haxe;
 
 
 #if neko
 #if neko
 private typedef AbstractSocket = {
 private typedef AbstractSocket = {
-	var input(default,null) : neko.io.Input;
-	var output(default,null) : neko.io.Output;
+	var input(default,null) : haxe.io.Input;
+	var output(default,null) : haxe.io.Output;
 	function connect( host : neko.net.Host, port : Int ) : Void;
 	function connect( host : neko.net.Host, port : Int ) : Void;
 	function setTimeout( t : Float ) : Void;
 	function setTimeout( t : Float ) : Void;
 	function write( str : String ) : Void;
 	function write( str : String ) : Void;
@@ -45,8 +45,8 @@ class Http {
 	var responseHeaders : Hash<String>;
 	var responseHeaders : Hash<String>;
 	var postData : String;
 	var postData : String;
 	var chunk_size : Int;
 	var chunk_size : Int;
-	var chunk_buf : String;
-	var file : { param : String, filename : String, io : neko.io.Input, size : Int };
+	var chunk_buf : haxe.io.Bytes;
+	var file : { param : String, filename : String, io : haxe.io.Input, size : Int };
 #elseif js
 #elseif js
 	var async : Bool;
 	var async : Bool;
 	var postData : String;
 	var postData : String;
@@ -226,7 +226,7 @@ class Http {
 			onError("Failed to initialize Connection");
 			onError("Failed to initialize Connection");
 	#elseif neko
 	#elseif neko
 		var me = this;
 		var me = this;
-		var output = new neko.io.StringOutput();
+		var output = new haxe.io.BytesOutput();
 		var old = onError;
 		var old = onError;
 		var err = false;
 		var err = false;
 		onError = function(e) {
 		onError = function(e) {
@@ -235,17 +235,17 @@ class Http {
 		}
 		}
 		customRequest(post,output);
 		customRequest(post,output);
 		if( !err )
 		if( !err )
-			me.onData(output.toString());
+			me.onData(new String(cast output.getBytes().getData()));
 	#end
 	#end
 	}
 	}
 
 
 #if neko
 #if neko
 
 
-	public function fileTransfert( argname : String, filename : String, file : neko.io.Input, size : Int ) {
+	public function fileTransfert( argname : String, filename : String, file : haxe.io.Input, size : Int ) {
 		this.file = { param : argname, filename : filename, io : file, size : size };
 		this.file = { param : argname, filename : filename, io : file, size : size };
 	}
 	}
 
 
-	public function customRequest( post : Bool, api : neko.io.Output, ?sock : AbstractSocket, ?method : String  ) {
+	public function customRequest( post : Bool, api : haxe.io.Output, ?sock : AbstractSocket, ?method : String  ) {
 		var url_regexp = ~/^(http:\/\/)?([a-zA-Z\.0-9-]+)(:[0-9]+)?(.*)$/;
 		var url_regexp = ~/^(http:\/\/)?([a-zA-Z\.0-9-]+)(:[0-9]+)?(.*)$/;
 		if( !url_regexp.match(url) ) {
 		if( !url_regexp.match(url) ) {
 			onError("Invalid URL");
 			onError("Invalid URL");
@@ -367,10 +367,10 @@ class Http {
 			sock.write(b.toString());
 			sock.write(b.toString());
 			if( multipart ) {
 			if( multipart ) {
 				var bufsize = 4096;
 				var bufsize = 4096;
-				var buf = neko.Lib.makeString(bufsize);
+				var buf = haxe.io.Bytes.alloc(bufsize);
 				while( file.size > 0 ) {
 				while( file.size > 0 ) {
 					var size = if( file.size > bufsize ) bufsize else file.size;
 					var size = if( file.size > bufsize ) bufsize else file.size;
-					var len = try file.io.readBytes(buf,0,size) catch( e : neko.io.Eof ) break;
+					var len = try file.io.readBytes(buf,0,size) catch( e : haxe.io.Eof ) break;
 					sock.output.writeFullBytes(buf,0,len);
 					sock.output.writeFullBytes(buf,0,len);
 					file.size -= len;
 					file.size -= len;
 				}
 				}
@@ -387,20 +387,20 @@ class Http {
 		}
 		}
 	}
 	}
 
 
-	function readHttpResponse( api : neko.io.Output, sock : AbstractSocket ) {
+	function readHttpResponse( api : haxe.io.Output, sock : AbstractSocket ) {
 		// READ the HTTP header (until \r\n\r\n)
 		// READ the HTTP header (until \r\n\r\n)
-		var b = new StringBuf();
+		var b = new haxe.io.BytesBuffer();
 		var k = 4;
 		var k = 4;
-		var s = neko.Lib.makeString(4);
+		var s = haxe.io.Bytes.alloc(4);
 		sock.setTimeout(cnxTimeout); // 10 seconds
 		sock.setTimeout(cnxTimeout); // 10 seconds
 		while( true ) {
 		while( true ) {
 			var p = sock.input.readBytes(s,0,k);
 			var p = sock.input.readBytes(s,0,k);
 			while( p != k )
 			while( p != k )
 				p += sock.input.readBytes(s,p,k - p);
 				p += sock.input.readBytes(s,p,k - p);
-			b.addSub(s,0,k);
+			b.addBytes(s,0,k);
 			switch( k ) {
 			switch( k ) {
 			case 1:
 			case 1:
-				var c = s.charCodeAt(0);
+				var c = s.get(0);
 				if( c == 10 )
 				if( c == 10 )
 					break;
 					break;
 				if( c == 13 )
 				if( c == 13 )
@@ -408,9 +408,9 @@ class Http {
 				else
 				else
 					k = 4;
 					k = 4;
 			case 2:
 			case 2:
-				var c = s.charCodeAt(1);
+				var c = s.get(1);
 				if( c == 10 ) {
 				if( c == 10 ) {
-					if( s.charCodeAt(0) == 13 )
+					if( s.get(0) == 13 )
 						break;
 						break;
 					k = 4;
 					k = 4;
 				} else if( c == 13 )
 				} else if( c == 13 )
@@ -418,39 +418,39 @@ class Http {
 				else
 				else
 					k = 4;
 					k = 4;
 			case 3:
 			case 3:
-				var c = s.charCodeAt(2);
+				var c = s.get(2);
 				if( c == 10 ) {
 				if( c == 10 ) {
-					if( s.charCodeAt(1) != 13 )
+					if( s.get(1) != 13 )
 						k = 4;
 						k = 4;
-					else if( s.charCodeAt(0) != 10 )
+					else if( s.get(0) != 10 )
 						k = 2;
 						k = 2;
 					else
 					else
 						break;
 						break;
 				} else if( c == 13 ) {
 				} else if( c == 13 ) {
-					if( s.charCodeAt(1) != 10 || s.charCodeAt(0) != 13 )
+					if( s.get(1) != 10 || s.get(0) != 13 )
 						k = 1;
 						k = 1;
 					else
 					else
 						k = 3;
 						k = 3;
 				} else
 				} else
 					k = 4;
 					k = 4;
 			case 4:
 			case 4:
-				var c = s.charCodeAt(3);
+				var c = s.get(3);
 				if( c == 10 ) {
 				if( c == 10 ) {
-					if( s.charCodeAt(2) != 13 )
+					if( s.get(2) != 13 )
 						continue;
 						continue;
-					else if( s.charCodeAt(1) != 10 || s.charCodeAt(0) != 13 )
+					else if( s.get(1) != 10 || s.get(0) != 13 )
 						k = 2;
 						k = 2;
 					else
 					else
 						break;
 						break;
 				} else if( c == 13 ) {
 				} else if( c == 13 ) {
-					if( s.charCodeAt(2) != 10 || s.charCodeAt(1) != 13 )
+					if( s.get(2) != 10 || s.get(1) != 13 )
 						k = 3;
 						k = 3;
 					else
 					else
 						k = 1;
 						k = 1;
 				}
 				}
 			}
 			}
 		}
 		}
-		var headers = b.toString().split("\r\n");
+		var headers = new String(cast b.getBytes().getData()).split("\r\n");
 		var response = headers.shift();
 		var response = headers.shift();
 		var rp = response.split(" ");
 		var rp = response.split(" ");
 		var status = Std.parseInt(rp[1]);
 		var status = Std.parseInt(rp[1]);
@@ -481,7 +481,7 @@ class Http {
 		chunk_buf = null;
 		chunk_buf = null;
 
 
 		var bufsize = 1024;
 		var bufsize = 1024;
-		var buf = neko.Lib.makeString(bufsize);
+		var buf = haxe.io.Bytes.alloc(bufsize);
 		if( size == null ) {
 		if( size == null ) {
 			if( !noShutdown )
 			if( !noShutdown )
 				sock.shutdown(false,true);
 				sock.shutdown(false,true);
@@ -494,7 +494,7 @@ class Http {
 					} else
 					} else
 						api.writeBytes(buf,0,len);
 						api.writeBytes(buf,0,len);
 				}
 				}
-			} catch( e : neko.io.Eof ) {
+			} catch( e : haxe.io.Eof ) {
 			}
 			}
 		} else {
 		} else {
 			api.prepare(size);
 			api.prepare(size);
@@ -508,7 +508,7 @@ class Http {
 						api.writeBytes(buf,0,len);
 						api.writeBytes(buf,0,len);
 					size -= len;
 					size -= len;
 				}
 				}
-			} catch( e : neko.io.Eof ) {
+			} catch( e : haxe.io.Eof ) {
 				throw "Transfert aborted";
 				throw "Transfert aborted";
 			}
 			}
 		}
 		}
@@ -517,14 +517,17 @@ class Http {
 		api.close();
 		api.close();
 	}
 	}
 
 
-	function readChunk(chunk_re : EReg, api : neko.io.Output, buf : String, len ) {
+	function readChunk(chunk_re : EReg, api : haxe.io.Output, buf : haxe.io.Bytes, len ) {
 		if( chunk_size == null ) {
 		if( chunk_size == null ) {
 			if( chunk_buf != null ) {
 			if( chunk_buf != null ) {
-				buf = chunk_buf + buf.substr(0,len);
+				var b = new haxe.io.BytesBuffer();
+				b.add(chunk_buf);
+				b.addBytes(buf,0,len);
+				buf = b.getBytes();
 				len += chunk_buf.length;
 				len += chunk_buf.length;
 				chunk_buf = null;
 				chunk_buf = null;
 			}
 			}
-			if( chunk_re.match(buf) ) {
+			if( chunk_re.match(new String(cast buf.getData())) ) {
 				var p = chunk_re.matchedPos();
 				var p = chunk_re.matchedPos();
 				if( p.len <= len ) {
 				if( p.len <= len ) {
 					var cstr = chunk_re.matched(1);
 					var cstr = chunk_re.matched(1);
@@ -535,7 +538,7 @@ class Http {
 						return false;
 						return false;
 					}
 					}
 					len -= p.len;
 					len -= p.len;
-					return readChunk(chunk_re,api,buf.substr(p.len,len),len);
+					return readChunk(chunk_re,api,buf.sub(p.len,len),len);
 				}
 				}
 			}
 			}
 			// prevent buffer accumulation
 			// prevent buffer accumulation
@@ -543,7 +546,7 @@ class Http {
 				onError("Invalid chunk");
 				onError("Invalid chunk");
 				return false;
 				return false;
 			}
 			}
-			chunk_buf = buf.substr(0,len);
+			chunk_buf = buf.sub(0,len);
 			return true;
 			return true;
 		}
 		}
 		if( chunk_size > len ) {
 		if( chunk_size > len ) {
@@ -559,7 +562,7 @@ class Http {
 			chunk_size = null;
 			chunk_size = null;
 			if( len == 0 )
 			if( len == 0 )
 				return true;
 				return true;
-			return readChunk(chunk_re,api,buf.substr(end,len),len);
+			return readChunk(chunk_re,api,buf.sub(end,len),len);
 		}
 		}
 		if( chunk_size > 0 )
 		if( chunk_size > 0 )
 			api.writeBytes(buf,0,chunk_size);
 			api.writeBytes(buf,0,chunk_size);

+ 0 - 8
std/haxe/ImportAll.hx

@@ -369,25 +369,17 @@ import flash.text.TextRenderer;
 
 
 import neko.Boot;
 import neko.Boot;
 import neko.FileSystem;
 import neko.FileSystem;
-import neko.Int32;
 import neko.Lib;
 import neko.Lib;
 import neko.Random;
 import neko.Random;
 import neko.Sys;
 import neko.Sys;
 import neko.Utf8;
 import neko.Utf8;
 import neko.Web;
 import neko.Web;
 
 
-import neko.io.Error;
 import neko.io.File;
 import neko.io.File;
 import neko.io.FileInput;
 import neko.io.FileInput;
 import neko.io.FileOutput;
 import neko.io.FileOutput;
-import neko.io.Input;
-import neko.io.Logger;
-import neko.io.Multiple;
-import neko.io.Output;
 import neko.io.Path;
 import neko.io.Path;
 import neko.io.Process;
 import neko.io.Process;
-import neko.io.StringInput;
-import neko.io.StringOutput;
 
 
 import neko.zip.Compress;
 import neko.zip.Compress;
 import neko.zip.CRC32;
 import neko.zip.CRC32;

+ 14 - 1
std/haxe/io/BytesBuffer.hx

@@ -44,7 +44,7 @@ class BytesBuffer {
 		#end
 		#end
 	}
 	}
 
 
-	public inline function add( byte : Int ) {
+	public inline function addByte( byte : Int ) {
 		#if neko
 		#if neko
 		untyped StringBuf.__add_char(b,byte);
 		untyped StringBuf.__add_char(b,byte);
 		#elseif flash9
 		#elseif flash9
@@ -54,6 +54,19 @@ class BytesBuffer {
 		#end
 		#end
 	}
 	}
 
 
+	public inline function add( src : Bytes ) {
+		#if neko
+		untyped StringBuf.__add(b,src.getData());
+		#elseif flash9
+		b.writeBytes(src.getData());
+		#else
+		var b1 = b;
+		var b2 = src.getData();
+		for( i in 0...src.length )
+			b.push(b2[i]);
+		#end
+	}
+
 	public inline function addBytes( src : Bytes, pos : Int, len : Int ) {
 	public inline function addBytes( src : Bytes, pos : Int, len : Int ) {
 		#if !neko
 		#if !neko
 		if( pos < 0 || len < 0 || pos + len > src.length ) throw Error.OutsideBounds;
 		if( pos < 0 || len < 0 || pos + len > src.length ) throw Error.OutsideBounds;

+ 4 - 0
std/haxe/io/BytesInput.hx

@@ -139,6 +139,10 @@ class BytesInput extends Input {
 		return try cast b.readInt() catch( e : Dynamic ) throw new Eof();
 		return try cast b.readInt() catch( e : Dynamic ) throw new Eof();
 	}
 	}
 
 
+	override function readString( len : Int ) {
+		return try b.readUTFBytes(len) catch( e : Dynamic ) throw new Eof();
+	}
+
 	#end
 	#end
 
 
 }
 }

+ 6 - 1
std/haxe/io/BytesOutput.hx

@@ -44,7 +44,7 @@ class BytesOutput extends Output {
 		#if flash9
 		#if flash9
 		b.writeByte(c);
 		b.writeByte(c);
 		#else
 		#else
-		b.add(c);
+		b.addByte(c);
 		#end
 		#end
 	}
 	}
 
 
@@ -111,6 +111,11 @@ class BytesOutput extends Output {
 		if( size > 0 )
 		if( size > 0 )
 			b[size-1] = b[size-1];
 			b[size-1] = b[size-1];
 	}
 	}
+
+	override function writeString( s : String ) {
+		b.writeUTFBytes(s);
+	}
+
 	#end
 	#end
 
 
 	public function getBytes() {
 	public function getBytes() {

+ 10 - 2
std/haxe/io/Input.hx

@@ -39,10 +39,8 @@ class Input {
 	public function readBytes( s : Bytes, pos : Int, len : Int ) : Int {
 	public function readBytes( s : Bytes, pos : Int, len : Int ) : Int {
 		var k = len;
 		var k = len;
 		var b = s.getData();
 		var b = s.getData();
-		#if !neko
 		if( pos < 0 || len < 0 || pos + len > s.length )
 		if( pos < 0 || len < 0 || pos + len > s.length )
 			throw Error.OutsideBounds;
 			throw Error.OutsideBounds;
-		#end
 		while( k > 0 ) {
 		while( k > 0 ) {
 			#if neko
 			#if neko
 				untyped __dollar__sset(b,pos,readByte());
 				untyped __dollar__sset(b,pos,readByte());
@@ -218,6 +216,16 @@ class Input {
 		return bigEndian ? haxe.Int32.make((ch1 << 8) | ch2,(ch3 << 8) | ch4) : haxe.Int32.make((ch4 << 8) | ch3,(ch2 << 8) | ch1);
 		return bigEndian ? haxe.Int32.make((ch1 << 8) | ch2,(ch3 << 8) | ch4) : haxe.Int32.make((ch4 << 8) | ch3,(ch2 << 8) | ch1);
 	}
 	}
 
 
+	public function readString( len : Int ) : String {
+		var b = Bytes.alloc(len);
+		readFullBytes(b,0,len);
+		#if neko
+		return new String(cast b.getData());
+		#else
+		return b.toString();
+		#end
+	}
+
 #if neko
 #if neko
 	static var _float_of_bytes = neko.Lib.load("std","float_of_bytes",2);
 	static var _float_of_bytes = neko.Lib.load("std","float_of_bytes",2);
 	static var _double_of_bytes = neko.Lib.load("std","double_of_bytes",2);
 	static var _double_of_bytes = neko.Lib.load("std","double_of_bytes",2);

+ 5 - 0
std/haxe/io/Output.hx

@@ -222,6 +222,11 @@ class Output {
 		}
 		}
 	}
 	}
 
 
+	public function writeString( s : String ) {
+		var b = Bytes.ofString(s);
+		writeFullBytes(b,0,b.length);
+	}
+
 #if neko
 #if neko
 	static var _float_bytes = neko.Lib.load("std","float_bytes",2);
 	static var _float_bytes = neko.Lib.load("std","float_bytes",2);
 	static var _double_bytes = neko.Lib.load("std","double_bytes",2);
 	static var _double_bytes = neko.Lib.load("std","double_bytes",2);

+ 1 - 1
std/mtwin/templo/Template.hx

@@ -117,7 +117,7 @@ class Template {
 		s = "// generated from " + id + "\n// temploc v"+mtwin.templo.Template.VERSION+"\n" + s;
 		s = "// generated from " + id + "\n// temploc v"+mtwin.templo.Template.VERSION+"\n" + s;
 
 
 		var f = neko.io.File.write(path, false);
 		var f = neko.io.File.write(path, false);
-		f.write(s);
+		f.writeString(s);
 		f.close();
 		f.close();
 
 
 		var r = null;
 		var r = null;

+ 0 - 70
std/neko/Int32.hx

@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko;
-
-class Int32 {
-
-	public static function make( a : Int, b : Int ) {
-		return Int32.add(Int32.shl(cast a,16),cast b);
-	}
-
-	public static function read( i : neko.io.Input, ?b : Bool ) {
-		var f = if( b ) i.readUInt16B else i.readUInt16;
-		var a = f();
-		return if( b ) make(a,f()) else make(f(),a);
-	}
-
-	public static function write( o : neko.io.Output, i : Int32, ?b : Bool ) {
-		var low = cast Int32.and(i,cast 0xFFFF);
-		var high = cast Int32.ushr(i,16);
-		if( b ) {
-			o.writeUInt16B(high);
-			o.writeUInt16B(low);
-		} else {
-			o.writeUInt16(low);
-			o.writeUInt16(high);
-		}
-	}
-
-	public static var ofInt : Int -> Int32 = neko.Lib.load("std","int32_new",1);
-	public static var toInt : Int32 -> Int = neko.Lib.load("std","int32_to_int",1);
-	public static var toFloat : Int32 -> Float = neko.Lib.load("std","int32_to_float",1);
-	public static var address : Dynamic -> Int32 = neko.Lib.load("std","int32_address",1);
-	public static var add : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_add",2);
-	public static var sub : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_sub",2);
-	public static var mul : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_mul",2);
-	public static var div : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_div",2);
-	public static var mod : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_mod",2);
-	public static var shl : Int32 -> Int -> Int32 = neko.Lib.load("std","int32_shl",2);
-	public static var shr : Int32 -> Int -> Int32 = neko.Lib.load("std","int32_shr",2);
-	public static var ushr : Int32 -> Int -> Int32 = neko.Lib.load("std","int32_ushr",2);
-	public static var and : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_and",2);
-	public static var or : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_or",2);
-	public static var xor : Int32 -> Int32 -> Int32 = neko.Lib.load("std","int32_xor",2);
-	public static var neg : Int32 -> Int32 = neko.Lib.load("std","int32_neg",1);
-	public static var complement : Int32 -> Int32 = neko.Lib.load("std","int32_complement",1);
-	public static var compare : Int32 -> Int32 -> Int = neko.Lib.load("std","int32_compare",2);
-
-}

+ 0 - 14
std/neko/Lib.hx

@@ -92,20 +92,6 @@ class Lib {
 		});
 		});
 	}
 	}
 
 
-	/**
-		Creates a raw string of [size] bytes.
-	**/
-	public static function makeString( size : Int ) : String {
-		return new String(untyped __dollar__smake(size));
-	}
-
-	/**
-		Copy bytes between two strings.
-	**/
-	public static function copyBytes( dst : String, dst_pos : Int, src : String, src_pos : Int, len : Int ) : Void {
-		untyped __dollar__sblit(dst.__s,dst_pos,src.__s,src_pos,len);
-	}
-
 	/**
 	/**
 		Converts a Neko value to its haXe equivalent. Used for wrapping String and Arrays raw values into haXe Objects.
 		Converts a Neko value to its haXe equivalent. Used for wrapping String and Arrays raw values into haXe Objects.
 	**/
 	**/

+ 7 - 7
std/neko/Web.hx

@@ -239,13 +239,13 @@ class Web {
 	**/
 	**/
 	public static function getMultipart( maxSize : Int ) : Hash<String> {
 	public static function getMultipart( maxSize : Int ) : Hash<String> {
 		var h = new Hash();
 		var h = new Hash();
-		var buf : StringBuf = null;
+		var buf : haxe.io.BytesBuffer = null;
 		var curname = null;
 		var curname = null;
 		parseMultipart(function(p,_) {
 		parseMultipart(function(p,_) {
 			if( curname != null )
 			if( curname != null )
-				h.set(curname,buf.toString());
+				h.set(curname,new String(cast buf.getBytes().getData()));
 			curname = p;
 			curname = p;
-			buf = new StringBuf();
+			buf = new haxe.io.BytesBuffer();
 			maxSize -= p.length;
 			maxSize -= p.length;
 			if( maxSize < 0 )
 			if( maxSize < 0 )
 				throw "Maximum size reached";
 				throw "Maximum size reached";
@@ -253,10 +253,10 @@ class Web {
 			maxSize -= len;
 			maxSize -= len;
 			if( maxSize < 0 )
 			if( maxSize < 0 )
 				throw "Maximum size reached";
 				throw "Maximum size reached";
-			buf.addSub(str,pos,len);
+			buf.addBytes(str,pos,len);
 		});
 		});
 		if( curname != null )
 		if( curname != null )
-			h.set(curname,buf.toString());
+			h.set(curname,new String(cast buf.getBytes().getData()));
 		return h;
 		return h;
 	}
 	}
 
 
@@ -266,10 +266,10 @@ class Web {
 		and [onData] when some part data is readed. You can this way
 		and [onData] when some part data is readed. You can this way
 		directly save the data on hard drive in the case of a file upload.
 		directly save the data on hard drive in the case of a file upload.
 	**/
 	**/
-	public static function parseMultipart( onPart : String -> String -> Void, onData : String -> Int -> Int -> Void ) : Void {
+	public static function parseMultipart( onPart : String -> String -> Void, onData : haxe.io.Bytes -> Int -> Int -> Void ) : Void {
 		_parse_multipart(
 		_parse_multipart(
 			function(p,f) { onPart(new String(p),if( f == null ) null else new String(f)); },
 			function(p,f) { onPart(new String(p),if( f == null ) null else new String(f)); },
-			function(buf,pos,len) { onData(new String(buf),pos,len); }
+			function(buf,pos,len) { onData(untyped new haxe.io.Bytes(__dollar__ssize(buf),buf),pos,len); }
 		);
 		);
 	}
 	}
 
 

+ 0 - 36
std/neko/io/Eof.hx

@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-/**
-	This exception is raised when reading while data is no longer available in the [Input].
-**/
-class Eof {
-	public function new() {
-	}
-	function toString() {
-		return "Eof";
-	}
-}

+ 0 - 37
std/neko/io/Error.hx

@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-/**
-	The possible IO errors that can occur
-**/
-enum Error {
-	/** The IO is set into nonblocking mode and some data cannot be read or written **/
-	Blocked;
-	/** An operation is outside of its valid range **/
-	Overflow;
-	/** Other errors **/
-	Custom( e : Dynamic );
-}

+ 5 - 1
std/neko/io/File.hx

@@ -42,6 +42,10 @@ class File {
 		return new String(file_contents(untyped path.__s));
 		return new String(file_contents(untyped path.__s));
 	}
 	}
 
 
+	public static function getBytes( path : String ) {
+		return haxe.io.Bytes.ofString(getContent(path));
+	}
+
 	public static function read( path : String, binary : Bool ) {
 	public static function read( path : String, binary : Bool ) {
 		return new FileInput(untyped file_open(path.__s,(if( binary ) "rb" else "r").__s));
 		return new FileInput(untyped file_open(path.__s,(if( binary ) "rb" else "r").__s));
 	}
 	}
@@ -53,7 +57,7 @@ class File {
 	public static function append( path : String, binary : Bool ) {
 	public static function append( path : String, binary : Bool ) {
 		return new FileOutput(untyped file_open(path.__s,(if( binary ) "ab" else "a").__s));
 		return new FileOutput(untyped file_open(path.__s,(if( binary ) "ab" else "a").__s));
 	}
 	}
-	
+
 	public static function copy( src : String, dst : String ) {
 	public static function copy( src : String, dst : String ) {
 		var s = read(src,true);
 		var s = read(src,true);
 		var d = write(dst,true);
 		var d = write(dst,true);

+ 8 - 8
std/neko/io/FileInput.hx

@@ -28,7 +28,7 @@ import neko.io.File;
 /**
 /**
 	Use [neko.io.File.read] to create a [FileInput]
 	Use [neko.io.File.read] to create a [FileInput]
 **/
 **/
-class FileInput extends Input {
+class FileInput extends haxe.io.Input {
 
 
 	private var __f : FileHandle;
 	private var __f : FileHandle;
 
 
@@ -36,25 +36,25 @@ class FileInput extends Input {
 		__f = f;
 		__f = f;
 	}
 	}
 
 
-	public override function readChar() : Int {
+	public override function readByte() : Int {
 		return try {
 		return try {
 			file_read_char(__f);
 			file_read_char(__f);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
 			if( untyped __dollar__typeof(e) == __dollar__tarray )
 			if( untyped __dollar__typeof(e) == __dollar__tarray )
-				throw new Eof();
+				throw new haxe.io.Eof();
 			else
 			else
-				throw Error.Custom(e);
+				throw haxe.io.Error.Custom(e);
 		}
 		}
 	}
 	}
 
 
-	public override function readBytes( s : String, p : Int, l : Int ) : Int {
+	public override function readBytes( s : haxe.io.Bytes, p : Int, l : Int ) : Int {
 		return try {
 		return try {
-			file_read(__f,untyped s.__s,p,l);
+			file_read(__f,s.getData(),p,l);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
 			if( untyped __dollar__typeof(e) == __dollar__tarray )
 			if( untyped __dollar__typeof(e) == __dollar__tarray )
-				throw new Eof();
+				throw new haxe.io.Eof();
 			else
 			else
-				throw Error.Custom(e);
+				throw haxe.io.Error.Custom(e);
 		}
 		}
 	}
 	}
 
 

+ 5 - 13
std/neko/io/FileOutput.hx

@@ -28,7 +28,7 @@ import neko.io.File;
 /**
 /**
 	Use [neko.io.File.write] to create a [FileOutput]
 	Use [neko.io.File.write] to create a [FileOutput]
 **/
 **/
-class FileOutput extends Output {
+class FileOutput extends haxe.io.Output {
 
 
 	private var __f : FileHandle;
 	private var __f : FileHandle;
 
 
@@ -36,20 +36,12 @@ class FileOutput extends Output {
 		__f = f;
 		__f = f;
 	}
 	}
 
 
-	public override function writeChar( c : Int ) {
-		try {
-			file_write_char(__f,c);
-		} catch( e : Dynamic ) {
-			throw Error.Custom(e);
-		}
+	public override function writeByte( c : Int ) {
+		try file_write_char(__f,c) catch( e : Dynamic ) throw haxe.io.Error.Custom(e);
 	}
 	}
 
 
-	public override function writeBytes( s : String, p : Int, l : Int ) : Int {
-		return try {
-			file_write(__f,untyped s.__s,p,l);
-		} catch( e : Dynamic ) {
-			throw Error.Custom(e);
-		}
+	public override function writeBytes( s : haxe.io.Bytes, p : Int, l : Int ) : Int {
+		return try file_write(__f,s.getData(),p,l) catch( e : Dynamic ) throw haxe.io.Error.Custom(e);
 	}
 	}
 
 
 	public override function flush() {
 	public override function flush() {

+ 0 - 219
std/neko/io/Input.hx

@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-/**
-	An Input is an abstract reader. A specific input implementation will only
-	have to override the [readChar] and maybe [read] and [close] methods. See
-	[File] and [StringInput] for two ways of creating an Input.
-**/
-class Input {
-
-	public function readChar() : Int {
-		return throw "Not implemented";
-	}
-
-	public function readBytes( s : String, p : Int, len : Int ) : Int {
-		var k = len;
-		while( k > 0 ) {
-			var c = readChar();
-			untyped __dollar__sset(s.__s,p,c);
-			p += 1;
-			k -= 1;
-		}
-		return len;
-	}
-
-	public function close() {
-	}
-
-	/* ------------------ API ------------------ */
-
-	public function readAll( ?bufsize : Int ) : String {
-		if( bufsize == null )
-			bufsize = (1 << 14); // 16 Ko
-		var buf = neko.Lib.makeString(bufsize);
-		var total = new StringBuf();
-		try {
-			while( true ) {
-				var len = readBytes(buf,0,bufsize);
-				if( len == 0 )
-					throw Error.Blocked;
-				total.addSub(buf,0,len);
-			}
-		} catch( e : Eof ) {
-		}
-		return total.toString();
-	}
-
-	public function readFullBytes( s : String, pos : Int, len : Int ) {
-		while( len > 0 ) {
-			var k = readBytes(s,pos,len);
-			pos += k;
-			len -= k;
-		}
-	}
-
-	public function read( nbytes : Int ) : String {
-		var s = neko.Lib.makeString(nbytes);
-		var p = 0;
-		while( nbytes > 0 ) {
-			var k = readBytes(s,p,nbytes);
-			if( k == 0 ) throw Error.Blocked;
-			p += k;
-			nbytes -= k;
-		}
-		return s;
-	}
-
-	public function readUntil( end : Int ) : String {
-		var buf = new StringBuf();
-		var last : Int;
-		while( (last = readChar()) != end )
-			buf.addChar( last );
-		return buf.toString();
-	}
-
-	public function readLine() : String {
-		var buf = new StringBuf();
-		var last : Int;
-		var s;
-		try {
-			while( (last = readChar()) != 10 )
-				buf.addChar( last );
-			s = buf.toString();
-			if( s.charCodeAt(s.length-1) == 13 ) s = s.substr(0,-1);
-		} catch( e : Eof ) {
-			s = buf.toString();
-			if( s.length == 0 )
-				neko.Lib.rethrow(e);
-		}
-		return s;
-	}
-
-	public function readFloat() : Float {
-		return _float_of_bytes(untyped read(4).__s,false);
-	}
-
-	public function readFloatB() : Float {
-		return _float_of_bytes(untyped read(4).__s,true);
-	}
-
-	public function readDouble() : Float {
-		return _double_of_bytes(untyped read(8).__s,false);
-	}
-
-	public function readDoubleB() : Float {
-		return _double_of_bytes(untyped read(8).__s,true);
-	}
-
-	public function readInt8() {
-		var n = readChar();
-		if( n >= 128 )
-			return n - 256;
-		return n;
-	}
-
-	public function readInt16() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var n = ch1 | (ch2 << 8);
-		if( ch2 & 128 != 0 )
-			return n - 65536;
-		return n;
-	}
-
-	public function readUInt16() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		return ch1 | (ch2 << 8);
-	}
-
-	public function readUInt16B() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		return ch2 | (ch1 << 8);
-	}
-
-	public function readInt24() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		var n = ch1 | (ch2 << 8) | (ch3 << 16);
-		if( ch3 & 128 != 0 )
-			return n - (1 << 24);
-		return n;
-	}
-
-	public function readUInt24() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		return ch1 | (ch2 << 8) | (ch3 << 16);
-	}
-
-	public function readUInt24B() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		return ch3 | (ch2 << 8) | (ch1 << 16);
-	}
-
-	public function readInt32() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		var ch4 = readChar();
-		if( (ch4 & 128) != 0 ) {
-			if( ch4 & 64 == 0 ) throw Error.Overflow;
-			return ch1 | (ch2 << 8) | (ch3 << 16) | ((ch4 & 127) << 24);
-		} else {
-			if( ch4 & 64 != 0 ) throw Error.Overflow;
-			return ch1 | (ch2 << 8) | (ch3 << 16) | (ch4 << 24);
-		}
-	}
-
-	public function readUInt32() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		var ch4 = readChar();
-		if( ch4 >= 64 ) throw Error.Overflow;
-		return ch1 | (ch2 << 8) | (ch3 << 16) | (ch4 << 24);
-	}
-
-	public function readUInt32B() {
-		var ch1 = readChar();
-		var ch2 = readChar();
-		var ch3 = readChar();
-		var ch4 = readChar();
-		if( ch1 >= 64 ) throw Error.Overflow;
-		return ch4 | (ch3 << 8) | (ch2 << 16) | (ch1 << 24);
-	}
-
-	static var _float_of_bytes = neko.Lib.load("std","float_of_bytes",2);
-	static var _double_of_bytes = neko.Lib.load("std","double_of_bytes",2);
-
-}

+ 0 - 66
std/neko/io/Logger.hx

@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-class Logger extends Input {
-
-	var input : Input;
-	var output : Output;
-	var autoFlush : Bool;
-
-	public function new(i,?o,?flush) {
-		input = i;
-		output = o;
-		autoFlush = if( flush == null ) output != null else flush;
-	}
-
-	public function logChar( c : Int ) {
-	}
-
-	public function logString( buf : String ) {
-	}
-
-	public override function readChar() {
-		var c = input.readChar();
-		logChar(c);
-		if( output != null ) output.writeChar(c);
-		if( autoFlush ) output.flush();
-		return c;
-	}
-
-	public override function readBytes(buf,pos,len) {
-		var n = input.readBytes(buf,pos,len);
-		logString(buf.substr(pos,n));
-		if( output != null ) output.writeBytes(buf,pos,n);
-		if( autoFlush ) output.flush();
-		return n;
-	}
-
-	public override function close() {
-		input.close();
-		if( output != null ) output.close();
-	}
-
-}

+ 0 - 70
std/neko/io/Multiple.hx

@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-class Multiple extends Output {
-
-	var l : List<Output>;
-	public var position(default,null) : Int;
-
-	public function new() {
-		l = new List();
-		position = 0;
-	}
-
-	public function add( o : Output ) {
-		l.add(o);
-	}
-
-	public function remove( o : Output ) {
-		return l.remove(o);
-	}
-
-	public override function writeChar(c) {
-		for( o in l )
-			o.writeChar(c);
-		position++;
-	}
-
-	public override function writeBytes(s,pos,len) {
-		for( o in l ) {
-			var l = len;
-			var p = pos;
-			do {
-				var k = o.writeBytes(s,p,l);
-				p += k;
-				l -= k;
-			} while( l > 0 );
-		}
-		position += len;
-		return len;
-	}
-
-	public override function close() {
-		for( o in l )
-			o.close();
-	}
-
-}

+ 0 - 194
std/neko/io/Output.hx

@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-/**
-	An Output is an abstract write. A specific output implementation will only
-	have to override the [writeChar] and maybe the [write], [flush] and [close]
-	methods. See [File.write] and [String.write] for two ways of creating an
-	Output.
-**/
-class Output {
-
-	public function writeChar( c : Int ) : Void {
-		throw "Not implemented";
-	}
-
-	public function writeBytes( s : String, p : Int, len : Int ) : Int {
-		var k = len;
-		while( k > 0 ) {
-			writeChar(untyped __dollar__sget(s.__s,p));
-			p += 1;
-			k -= 1;
-		}
-		return len;
-	}
-
-	public function flush() {
-	}
-
-	public function close() {
-	}
-
-	/* ------------------ API ------------------ */
-
-	public function write( s : String ) : Void {
-		var l = s.length;
-		var p = 0;
-		while( l > 0 ) {
-			var k = writeBytes(s,p,l);
-			if( k == 0 ) throw Error.Blocked;
-			p += k;
-			l -= k;
-		}
-	}
-
-	public function writeFullBytes( s : String, pos : Int, len : Int ) {
-		while( len > 0 ) {
-			var k = writeBytes(s,pos,len);
-			pos += k;
-			len -= k;
-		}
-	}
-
-	public function writeFloat( c : Float ) {
-		write(new String(_float_bytes(c,false)));
-	}
-
-	public function writeFloatB( c : Float ) {
-		write(new String(_float_bytes(c,true)));
-	}
-
-	public function writeDouble( c : Float ) {
-		write(new String(_double_bytes(c,false)));
-	}
-
-	public function writeDoubleB( c : Float ) {
-		write(new String(_double_bytes(c,true)));
-	}
-
-	public function writeInt8( c : Int ) {
-		if( c < -0x80 || c > 0x7F )
-			throw Error.Overflow;
-		writeChar(c & 0xFF);
-	}
-
-	public function writeInt16( x : Int ) {
-		if( x < -0x8000 || x > 0x7FFF ) throw Error.Overflow;
-		if( x < 0 )
-			writeUInt16(0x10000 + x);
-		else
-			writeUInt16(x);
-	}
-
-	public function writeUInt16( x : Int ) {
-		if( x < 0 || x > 0xFFFF ) throw Error.Overflow;
-		writeChar(x & 0xFF);
-		writeChar(x >> 8);
-	}
-
-	public function writeUInt16B( x : Int ) {
-		if( x < 0 || x > 0xFFFF ) throw Error.Overflow;
-		writeChar(x >> 8);
-		writeChar(x & 0xFF);
-	}
-
-	public function writeInt24( x : Int ) {
-		if( x < -0x800000 || x > 0x7FFFFF ) throw Error.Overflow;
-		if( x < 0 )
-			writeUInt24(0x1000000 + x);
-		else
-			writeUInt24(x);
-	}
-
-	public function writeUInt24( x : Int ) {
-		if( x < 0 || x > 0xFFFFFF ) throw Error.Overflow;
-		writeChar(x & 0xFF);
-		writeChar((x >> 8) & 0xFF);
-		writeChar(x >> 16);
-	}
-
-	public function writeUInt24B( x : Int ) {
-		if( x < 0 || x > 0xFFFFFF ) throw Error.Overflow;
-		writeChar(x >> 16);
-		writeChar((x >> 8) & 0xFF);
-		writeChar(x & 0xFF);
-	}
-
-	public function writeInt32( x : Int ) {
-		writeChar(x & 0xFF);
-		writeChar((x >> 8) & 0xFF);
-		writeChar((x >> 16) & 0xFF);
-		writeChar(x >>> 24);
-	}
-
-	public function writeUInt32( x : Int ) {
-		if( x < 0 ) throw Error.Overflow;
-		writeInt32(x);
-	}
-
-	public function writeUInt32B( x : Int ) {
-		if( x < 0 ) throw Error.Overflow;
-		writeChar(x >>> 24);
-		writeChar((x >> 16) & 0xFF);
-		writeChar((x >> 8) & 0xFF);
-		writeChar(x & 0xFF);
-	}
-
-	/**
-		Inform that we are about to write at least a specified number of bytes.
-		The underlying implementation can allocate proper working space depending
-		on this information, or simply ignore it. This is not a mandatory call
-		but a tip and is only used in some specific cases.
-	**/
-	public function prepare( nbytes : Int ) {
-	}
-
-	public function writeInput( i : Input, ?bufsize : Int ) {
-		if( bufsize == null )
-			bufsize = 4096;
-		var buf = neko.Lib.makeString(bufsize);
-		try {
-			while( true ) {
-				var len = i.readBytes(buf,0,bufsize);
-				if( len == 0 )
-					throw Error.Blocked;
-				var p = 0;
-				while( len > 0 ) {
-					var k = writeBytes(buf,p,len);
-					if( k == 0 )
-						throw Error.Blocked;
-					p += k;
-					len -= k;
-				}
-			}
-		} catch( e : Eof ) {
-		}
-	}
-
-	static var _float_bytes = neko.Lib.load("std","float_bytes",2);
-	static var _double_bytes = neko.Lib.load("std","double_bytes",2);
-
-}

+ 21 - 19
std/neko/io/Process.hx

@@ -24,12 +24,14 @@
  */
  */
 package neko.io;
 package neko.io;
 
 
-private class Stdin extends neko.io.Output {
+private class Stdin extends haxe.io.Output {
 
 
 	var p : Void;
 	var p : Void;
+	var buf : haxe.io.Bytes;
 
 
 	public function new(p) {
 	public function new(p) {
 		this.p = p;
 		this.p = p;
+		buf = haxe.io.Bytes.alloc(1);
 	}
 	}
 
 
 	public override function close() {
 	public override function close() {
@@ -37,16 +39,16 @@ private class Stdin extends neko.io.Output {
 		_stdin_close(p);
 		_stdin_close(p);
 	}
 	}
 
 
-	public override function writeChar(c) {
-		if( writeBytes(Std.chr(c),0,1) == 0 )
-			throw Error.Blocked;
+	public override function writeByte(c) {
+		buf.set(0,c);
+		writeBytes(buf,0,1);
 	}
 	}
 
 
-	public override function writeBytes( str : String, pos : Int, len : Int ) : Int {
+	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
 		try {
 		try {
-			return _stdin_write(p,untyped str.__s,pos,len);
+			return _stdin_write(p,buf.getData(),pos,len);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
-			throw new Eof();
+			throw new haxe.io.Eof();
 		}
 		}
 	}
 	}
 
 
@@ -55,29 +57,29 @@ private class Stdin extends neko.io.Output {
 
 
 }
 }
 
 
-private class Stdout extends neko.io.Input {
+private class Stdout extends haxe.io.Input {
 
 
 	var p : Void;
 	var p : Void;
 	var out : Bool;
 	var out : Bool;
-	var buf : String;
+	var buf : haxe.io.Bytes;
 
 
 	public function new(p,out) {
 	public function new(p,out) {
 		this.p = p;
 		this.p = p;
 		this.out = out;
 		this.out = out;
-		buf = neko.Lib.makeString(1);
+		buf = haxe.io.Bytes.alloc(1);
 	}
 	}
 
 
-	public override function readChar() {
+	public override function readByte() {
 		if( readBytes(buf,0,1) == 0 )
 		if( readBytes(buf,0,1) == 0 )
-			throw Error.Blocked;
-		return buf.charCodeAt(0);
+			throw haxe.io.Error.Blocked;
+		return buf.get(0);
 	}
 	}
 
 
-	public override function readBytes( str : String, pos : Int, len : Int ) : Int {
+	public override function readBytes( str : haxe.io.Bytes, pos : Int, len : Int ) : Int {
 		try {
 		try {
-			return (out?_stdout_read:_stderr_read)(p,untyped str.__s,pos,len);
+			return (out?_stdout_read:_stderr_read)(p,str.getData(),pos,len);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
-			throw new Eof();
+			throw new haxe.io.Eof();
 		}
 		}
 	}
 	}
 
 
@@ -89,9 +91,9 @@ private class Stdout extends neko.io.Input {
 class Process {
 class Process {
 
 
 	var p : Void;
 	var p : Void;
-	public var stdout(default,null) : neko.io.Input;
-	public var stderr(default,null) : neko.io.Input;
-	public var stdin(default,null) : neko.io.Output;
+	public var stdout(default,null) : haxe.io.Input;
+	public var stderr(default,null) : haxe.io.Input;
+	public var stdin(default,null) : haxe.io.Output;
 
 
 	public function new( cmd : String, args : Array<String> ) {
 	public function new( cmd : String, args : Array<String> ) {
 		p = try _run(untyped cmd.__s,neko.Lib.haxeToNeko(args)) catch( e : Dynamic ) throw "Process creation failure : "+cmd;
 		p = try _run(untyped cmd.__s,neko.Lib.haxeToNeko(args)) catch( e : Dynamic ) throw "Process creation failure : "+cmd;

+ 0 - 61
std/neko/io/StringInput.hx

@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-class StringInput extends Input {
-
-	var s : String;
-	var pos : Int;
-	var len : Int;
-
-	public function new( s : String, ?pos : Int, ?len : Int ) {
-		this.s = s;
-		this.pos = if( pos == null ) 0 else pos;
-		this.len = if( len == null ) s.length else len;
-		if( this.pos < 0 || this.len < 0 )
-			throw "Invalid parameter";
-	}
-
-	public override function readChar() {
-		if( this.len == 0 )
-			throw new Eof();
-		var c = untyped __dollar__sget(s.__s,pos);
-		pos += 1;
-		len -= 1;
-		return c;
-	}
-
-	public override function readBytes( buf : String, bpos, blen ) : Int {
-		if( len == 0 && blen > 0 )
-			throw new Eof();
-		if( len < blen )
-			blen = len;
-		untyped __dollar__sblit(buf.__s,bpos,s.__s,pos,blen);
-		pos += blen;
-		len -= blen;
-		return blen;
-	}
-
-}

+ 0 - 48
std/neko/io/StringOutput.hx

@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.io;
-
-class StringOutput extends Output {
-
-	var b : StringBuf;
-
-	public function new() {
-		b = new StringBuf();
-	}
-
-	public override function writeChar(c) {
-		b.addChar(c);
-	}
-
-	public override function writeBytes( buf, bpos, blen ) : Int {
-		b.addSub(buf,bpos,blen);
-		return blen;
-	}
-
-	public function toString() {
-		return b.toString();
-	}
-
-}

+ 1 - 1
std/neko/net/Host.hx

@@ -28,7 +28,7 @@ package neko.net;
 
 
 class Host {
 class Host {
 
 
-	public var ip(default,null) : neko.Int32;
+	public var ip(default,null) : haxe.Int32;
 
 
 	public function new( name : String ) {
 	public function new( name : String ) {
 		ip = host_resolve(untyped name.__s);
 		ip = host_resolve(untyped name.__s);

+ 8 - 8
std/neko/net/ServerLoop.hx

@@ -26,7 +26,7 @@ package neko.net;
 
 
 private typedef ServerClient<ClientData> = {
 private typedef ServerClient<ClientData> = {
 	var sock : Socket;
 	var sock : Socket;
-	var buffer : String;
+	var buffer : haxe.io.Bytes;
 	var bufbytes : Int;
 	var bufbytes : Int;
 	var data : ClientData;
 	var data : ClientData;
 }
 }
@@ -115,7 +115,7 @@ class ServerLoop<ClientData> {
 		while sending the data, no exception will occur but the client will
 		while sending the data, no exception will occur but the client will
 		be gracefully disconnected.
 		be gracefully disconnected.
 	**/
 	**/
-	public function clientWrite( s : Socket, buf : String, pos : Int, len : Int ) {
+	public function clientWrite( s : Socket, buf : haxe.io.Bytes, pos : Int, len : Int ) {
 		try {
 		try {
 			while( len > 0 ) {
 			while( len > 0 ) {
 				var nbytes = s.output.writeBytes(buf,pos,len);
 				var nbytes = s.output.writeBytes(buf,pos,len);
@@ -133,7 +133,7 @@ class ServerLoop<ClientData> {
 		that needs to be removed from the buffer. It the data can't be handled (some
 		that needs to be removed from the buffer. It the data can't be handled (some
 		part of the message is missing for example), returns 0.
 		part of the message is missing for example), returns 0.
 	**/
 	**/
-	public function processClientData( d : ClientData, buf : String, bufpos : Int, buflen : Int ) {
+	public function processClientData( d : ClientData, buf : haxe.io.Bytes, bufpos : Int, buflen : Int ) {
 		throw "ServerLoop::processClientData is not implemented";
 		throw "ServerLoop::processClientData is not implemented";
 		return 0;
 		return 0;
 	}
 	}
@@ -156,8 +156,8 @@ class ServerLoop<ClientData> {
 					throw "Max buffer size reached";
 					throw "Max buffer size reached";
 				nsize = MAX_BUFSIZE;
 				nsize = MAX_BUFSIZE;
 			}
 			}
-			var buf2 = neko.Lib.makeString(nsize);
-			neko.Lib.copyBytes(buf2,0,cl.buffer,0,buflen);
+			var buf2 = haxe.io.Bytes.alloc(nsize);
+			buf2.blit(0,cl.buffer,0,buflen);
 			buflen = nsize;
 			buflen = nsize;
 			cl.buffer = buf2;
 			cl.buffer = buf2;
 		}
 		}
@@ -176,7 +176,7 @@ class ServerLoop<ClientData> {
 			cl.bufbytes -= nbytes;
 			cl.bufbytes -= nbytes;
 		}
 		}
 		if( pos > 0 )
 		if( pos > 0 )
-			neko.Lib.copyBytes(cl.buffer,0,cl.buffer,pos,cl.bufbytes);
+			cl.buffer.blit(0,cl.buffer,pos,cl.bufbytes);
 	}
 	}
 
 
 	/**
 	/**
@@ -197,7 +197,7 @@ class ServerLoop<ClientData> {
 					cl = {
 					cl = {
 						sock : sock,
 						sock : sock,
 						data : null,
 						data : null,
-						buffer : neko.Lib.makeString(DEFAULT_BUFSIZE),
+						buffer : haxe.io.Bytes.alloc(DEFAULT_BUFSIZE),
 						bufbytes : 0,
 						bufbytes : 0,
 					};
 					};
 					// bind the client
 					// bind the client
@@ -219,7 +219,7 @@ class ServerLoop<ClientData> {
 						readData(cl);
 						readData(cl);
 						processData(cl);
 						processData(cl);
 					} catch( e : Dynamic ) {
 					} catch( e : Dynamic ) {
-						if( !Std.is(e,neko.io.Eof) )
+						if( !Std.is(e,haxe.io.Eof) )
 							onError(e);
 							onError(e);
 						closeConnection(cl.sock);
 						closeConnection(cl.sock);
 					}
 					}

+ 7 - 7
std/neko/net/SocketInput.hx

@@ -24,9 +24,9 @@
  */
  */
 package neko.net;
 package neko.net;
 import neko.net.Socket;
 import neko.net.Socket;
-import neko.io.Error;
+import haxe.io.Error;
 
 
-class SocketInput extends neko.io.Input {
+class SocketInput extends haxe.io.Input {
 
 
 	var __s : SocketHandle;
 	var __s : SocketHandle;
 
 
@@ -34,7 +34,7 @@ class SocketInput extends neko.io.Input {
 		__s = s;
 		__s = s;
 	}
 	}
 
 
-	public override function readChar() {
+	public override function readByte() {
 		return try {
 		return try {
 			socket_recv_char(__s);
 			socket_recv_char(__s);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
@@ -43,14 +43,14 @@ class SocketInput extends neko.io.Input {
 			else if( __s == null )
 			else if( __s == null )
 				throw Custom(e);
 				throw Custom(e);
 			else
 			else
-				throw new neko.io.Eof();
+				throw new haxe.io.Eof();
 		}
 		}
 	}
 	}
 
 
-	public override function readBytes( buf : String, pos : Int, len : Int ) : Int {
+	public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
 		var r;
 		var r;
 		try {
 		try {
-			r = socket_recv(__s,untyped buf.__s,pos,len);
+			r = socket_recv(__s,buf.getData(),pos,len);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
 			if( e == "Blocking" )
 			if( e == "Blocking" )
 				throw Blocked;
 				throw Blocked;
@@ -58,7 +58,7 @@ class SocketInput extends neko.io.Input {
 				throw Custom(e);
 				throw Custom(e);
 		}
 		}
 		if( r == 0 )
 		if( r == 0 )
-			throw new neko.io.Eof();
+			throw new haxe.io.Eof();
 		return r;
 		return r;
 	}
 	}
 
 

+ 5 - 5
std/neko/net/SocketOutput.hx

@@ -24,9 +24,9 @@
  */
  */
 package neko.net;
 package neko.net;
 import neko.net.Socket;
 import neko.net.Socket;
-import neko.io.Error;
+import haxe.io.Error;
 
 
-class SocketOutput extends neko.io.Output {
+class SocketOutput extends haxe.io.Output {
 
 
 	var __s : SocketHandle;
 	var __s : SocketHandle;
 
 
@@ -34,7 +34,7 @@ class SocketOutput extends neko.io.Output {
 		__s = s;
 		__s = s;
 	}
 	}
 
 
-	public override function writeChar( c : Int ) {
+	public override function writeByte( c : Int ) {
 		try {
 		try {
 			socket_send_char(__s, c);
 			socket_send_char(__s, c);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
@@ -45,9 +45,9 @@ class SocketOutput extends neko.io.Output {
 		}
 		}
 	}
 	}
 
 
-	public override function writeBytes( buf : String, pos : Int, len : Int) : Int {
+	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int {
 		return try {
 		return try {
-			socket_send(__s, untyped buf.__s, pos, len);
+			socket_send(__s, buf.getData(), pos, len);
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
 			if( e == "Blocking" )
 			if( e == "Blocking" )
 				throw Blocked;
 				throw Blocked;

+ 9 - 9
std/neko/net/ThreadServer.hx

@@ -35,7 +35,7 @@ private typedef ClientInfos<Client> = {
 	var client : Client;
 	var client : Client;
 	var sock : neko.net.Socket;
 	var sock : neko.net.Socket;
 	var thread : ThreadInfos;
 	var thread : ThreadInfos;
-	var buf : String;
+	var buf : haxe.io.Bytes;
 	var bufpos : Int;
 	var bufpos : Int;
 }
 }
 
 
@@ -48,7 +48,7 @@ class ThreadServer<Client,Message> {
 	public var listen : Int;
 	public var listen : Int;
 	public var nthreads : Int;
 	public var nthreads : Int;
 	public var connectLag : Float;
 	public var connectLag : Float;
-	public var errorOutput : neko.io.Output;
+	public var errorOutput : haxe.io.Output;
 	public var initialBufferSize : Int;
 	public var initialBufferSize : Int;
 	public var maxBufferSize : Int;
 	public var maxBufferSize : Int;
 	public var messageHeaderSize : Int;
 	public var messageHeaderSize : Int;
@@ -87,8 +87,8 @@ class ThreadServer<Client,Message> {
 				if( c.buf.length == maxBufferSize )
 				if( c.buf.length == maxBufferSize )
 					throw "Max buffer size reached";
 					throw "Max buffer size reached";
 			}
 			}
-			var newbuf = neko.Lib.makeString(newsize);
-			neko.Lib.copyBytes(newbuf,0,c.buf,0,c.bufpos);
+			var newbuf = haxe.io.Bytes.alloc(newsize);
+			newbuf.blit(0,c.buf,0,c.bufpos);
 			c.buf = newbuf;
 			c.buf = newbuf;
 			available = newsize - c.bufpos;
 			available = newsize - c.bufpos;
 		}
 		}
@@ -104,7 +104,7 @@ class ThreadServer<Client,Message> {
 			work(callback(clientMessage,c.client,m.msg));
 			work(callback(clientMessage,c.client,m.msg));
 		}
 		}
 		if( pos > 0 )
 		if( pos > 0 )
-			neko.Lib.copyBytes(c.buf,0,c.buf,pos,len);
+			c.buf.blit(0,c.buf,pos,len);
 		c.bufpos = len;
 		c.bufpos = len;
 	}
 	}
 
 
@@ -116,7 +116,7 @@ class ThreadServer<Client,Message> {
 					readClientData(infos);
 					readClientData(infos);
 				} catch( e : Dynamic ) {
 				} catch( e : Dynamic ) {
 					t.socks.remove(s);
 					t.socks.remove(s);
-					if( !Std.is(e,neko.io.Eof) && !Std.is(e,neko.io.Error) )
+					if( !Std.is(e,haxe.io.Eof) && !Std.is(e,haxe.io.Error) )
 						logError(e);
 						logError(e);
 					work(callback(doClientDisconnected,s,infos.client));
 					work(callback(doClientDisconnected,s,infos.client));
 				}
 				}
@@ -161,7 +161,7 @@ class ThreadServer<Client,Message> {
 
 
 	public function onError( e : Dynamic, stack ) {
 	public function onError( e : Dynamic, stack ) {
 		var estr = try Std.string(e) catch( e2 : Dynamic ) "???" + try "["+Std.string(e2)+"]" catch( e : Dynamic ) "";
 		var estr = try Std.string(e) catch( e2 : Dynamic ) "???" + try "["+Std.string(e2)+"]" catch( e : Dynamic ) "";
-		errorOutput.write( estr + "\n" + haxe.Stack.toString(stack) );
+		errorOutput.writeString( estr + "\n" + haxe.Stack.toString(stack) );
 		errorOutput.flush();
 		errorOutput.flush();
 	}
 	}
 
 
@@ -178,7 +178,7 @@ class ThreadServer<Client,Message> {
 			thread : threads[Std.random(nthreads)],
 			thread : threads[Std.random(nthreads)],
 			client : clientConnected(sock),
 			client : clientConnected(sock),
 			sock : sock,
 			sock : sock,
-			buf : neko.Lib.makeString(initialBufferSize),
+			buf : haxe.io.Bytes.alloc(initialBufferSize),
 			bufpos : 0,
 			bufpos : 0,
 		};
 		};
 		sock.custom = infos;
 		sock.custom = infos;
@@ -250,7 +250,7 @@ class ThreadServer<Client,Message> {
 	public function clientDisconnected( c : Client ) {
 	public function clientDisconnected( c : Client ) {
 	}
 	}
 
 
-	public function readClientMessage( c : Client, buf : String, pos : Int, len : Int ) : { msg : Message, bytes : Int } {
+	public function readClientMessage( c : Client, buf : haxe.io.Bytes, pos : Int, len : Int ) : { msg : Message, bytes : Int } {
 		return {
 		return {
 			msg : null,
 			msg : null,
 			bytes : len,
 			bytes : len,

+ 22 - 22
std/neko/vm/Module.hx

@@ -44,7 +44,7 @@ class Module {
 	public function new( m ) {
 	public function new( m ) {
 		this.m = m;
 		this.m = m;
 	}
 	}
-	
+
 	/**
 	/**
 		Execute a module and returns its result (the latest evaluated expression).
 		Execute a module and returns its result (the latest evaluated expression).
 		A module can be executed several times but its globals are only initialized once
 		A module can be executed several times but its globals are only initialized once
@@ -53,7 +53,7 @@ class Module {
 	public function execute() : Dynamic {
 	public function execute() : Dynamic {
 		return _module_exec(m);
 		return _module_exec(m);
 	}
 	}
-	
+
 	/**
 	/**
 		Returns the Module name. This is the name that the Module was loaded with by the Loader.
 		Returns the Module name. This is the name that the Module was loaded with by the Loader.
 	**/
 	**/
@@ -70,28 +70,28 @@ class Module {
 
 
 	/**
 	/**
 		Returns the codeSize of the Module.
 		Returns the codeSize of the Module.
-	**/	
+	**/
 	public function codeSize() : Int {
 	public function codeSize() : Int {
 		return _module_code_size(m);
 		return _module_code_size(m);
 	}
 	}
 
 
 	/**
 	/**
 		Returns the number of globals in this Module global table.
 		Returns the number of globals in this Module global table.
-	**/	
+	**/
 	public function globalsCount() : Int {
 	public function globalsCount() : Int {
 		return _module_nglobals(m);
 		return _module_nglobals(m);
 	}
 	}
-	
+
 	/**
 	/**
 		Get a Module global value.
 		Get a Module global value.
-	**/	
+	**/
 	public function getGlobal( n : Int ) : Dynamic {
 	public function getGlobal( n : Int ) : Dynamic {
 		return _module_global_get(m,n);
 		return _module_global_get(m,n);
 	}
 	}
 
 
 	/**
 	/**
 		Set a Module global value.
 		Set a Module global value.
-	**/		
+	**/
 	public function setGlobal( n : Int, v : Dynamic ) {
 	public function setGlobal( n : Int, v : Dynamic ) {
 		_module_global_set(m,n,v);
 		_module_global_set(m,n,v);
 	}
 	}
@@ -111,8 +111,8 @@ class Module {
 			h.set(f,Reflect.field(exp,f));
 			h.set(f,Reflect.field(exp,f));
 		return h;
 		return h;
 	}
 	}
-	
-	
+
+
 	/**
 	/**
 		The raw export table.
 		The raw export table.
 	**/
 	**/
@@ -127,52 +127,52 @@ class Module {
 		var exp = _module_exports(m);
 		var exp = _module_exports(m);
 		Reflect.setField(exp,name,value);
 		Reflect.setField(exp,name,value);
 	}
 	}
-	
+
 	/**
 	/**
 		Returns the local Module, which is the one in which this
 		Returns the local Module, which is the one in which this
 		method is included.
 		method is included.
-	**/	
+	**/
 	public static function local() {
 	public static function local() {
 		return new Module(untyped __dollar__exports.__module);
 		return new Module(untyped __dollar__exports.__module);
-	}	
+	}
 
 
 	/**
 	/**
 		Reads a module from an Input by using the given Loader.
 		Reads a module from an Input by using the given Loader.
 		The module is initialized but has not yet been executed.
 		The module is initialized but has not yet been executed.
-	**/	
-	public static function read( i : neko.io.Input, l : Loader ) : Module {
+	**/
+	public static function read( i : haxe.io.Input, l : Loader ) : Module {
 		var m = _module_read(function(buf,pos,len) {
 		var m = _module_read(function(buf,pos,len) {
-			return i.readBytes(new String(buf),pos,len);
+			return i.readBytes(untyped new haxe.io.Bytes(len,buf),pos,len);
 		},l.l);
 		},l.l);
 		return new Module(m);
 		return new Module(m);
 	}
 	}
-	
+
 	/**
 	/**
 		Reads a module from a name and using the specified seach path and loader.
 		Reads a module from a name and using the specified seach path and loader.
 		The module is initialized but has not yet been executed.
 		The module is initialized but has not yet been executed.
-	**/		
+	**/
 	public static function readPath( name : String, path : Array<String>, loader : Loader ) {
 	public static function readPath( name : String, path : Array<String>, loader : Loader ) {
 		var p = null;
 		var p = null;
 		var i = path.length;
 		var i = path.length;
 		while( --i >= 0 )
 		while( --i >= 0 )
-			p = untyped __dollar__array(path[i].__s,p);		
+			p = untyped __dollar__array(path[i].__s,p);
 		var m = _module_read_path(p,untyped name.__s,loader.l);
 		var m = _module_read_path(p,untyped name.__s,loader.l);
 		return new Module(m);
 		return new Module(m);
 	}
 	}
-	
+
 	function __compare( other : Module ) {
 	function __compare( other : Module ) {
 		return untyped __dollar__compare(this.m,other.m);
 		return untyped __dollar__compare(this.m,other.m);
 	}
 	}
-	
+
 	static var _module_read = neko.Lib.load("std","module_read",2);
 	static var _module_read = neko.Lib.load("std","module_read",2);
 	static var _module_read_path = neko.Lib.load("std","module_read_path",3);
 	static var _module_read_path = neko.Lib.load("std","module_read_path",3);
 	static var _module_exec = neko.Lib.load("std","module_exec",1);
 	static var _module_exec = neko.Lib.load("std","module_exec",1);
-	static var _module_name = neko.Lib.load("std","module_name",1);	
+	static var _module_name = neko.Lib.load("std","module_name",1);
 	static var _module_exports = neko.Lib.load("std","module_exports",1);
 	static var _module_exports = neko.Lib.load("std","module_exports",1);
 	static var _module_loader = neko.Lib.load("std","module_loader",1);
 	static var _module_loader = neko.Lib.load("std","module_loader",1);
 	static var _module_code_size = neko.Lib.load("std","module_code_size",1);
 	static var _module_code_size = neko.Lib.load("std","module_code_size",1);
 	static var _module_nglobals = neko.Lib.load("std","module_nglobals",1);
 	static var _module_nglobals = neko.Lib.load("std","module_nglobals",1);
 	static var _module_global_get = neko.Lib.load("std","module_global_get",2);
 	static var _module_global_get = neko.Lib.load("std","module_global_get",2);
 	static var _module_global_set = neko.Lib.load("std","module_global_set",3);
 	static var _module_global_set = neko.Lib.load("std","module_global_set",3);
-	
+
 }
 }

+ 8 - 8
std/neko/zip/CRC32.hx

@@ -23,30 +23,30 @@
  * DAMAGE.
  * DAMAGE.
  */
  */
 package neko.zip;
 package neko.zip;
-import neko.Int32;
+import haxe.Int32;
 
 
 class CRC32 {
 class CRC32 {
-	private static var INITIAL_VALUE = Int32.make(0xFFFF, 0xFFFF);
-	private static var POLYNOM = Int32.make(0xEDB8, 0x8320);
 
 
 	/*
 	/*
 	 *  Function computes CRC32 code of a given string.
 	 *  Function computes CRC32 code of a given string.
 	 *  Warning: returns Int32 as result uses all 32 bits
 	 *  Warning: returns Int32 as result uses all 32 bits
 	 *  UTF - 8 coding is not supported
 	 *  UTF - 8 coding is not supported
 	 */
 	 */
-	public static function encode(str : String) : Int32 {
-		var crc = INITIAL_VALUE;
-		var s = untyped str.__s;
+	public static function encode(str : haxe.io.Bytes) : Int32 {
+		var init = Int32.make(0xFFFF, 0xFFFF);
+		var polynom = Int32.make(0xEDB8, 0x8320);
+		var crc = init;
+		var s = str.getData();
 		for( i in 0...str.length ) {
 		for( i in 0...str.length ) {
 			var tmp = Int32.and( Int32.xor(crc,untyped __dollar__sget(s,i)), cast 0xFF );
 			var tmp = Int32.and( Int32.xor(crc,untyped __dollar__sget(s,i)), cast 0xFF );
 			for( j in 0...8 ) {
 			for( j in 0...8 ) {
 				if( Int32.and(tmp,cast 1) == cast 1 )
 				if( Int32.and(tmp,cast 1) == cast 1 )
-					tmp = Int32.xor(Int32.ushr(tmp,1),POLYNOM);
+					tmp = Int32.xor(Int32.ushr(tmp,1),polynom);
 				else
 				else
 					tmp = Int32.ushr(tmp,1);
 					tmp = Int32.ushr(tmp,1);
 			}
 			}
 			crc = Int32.xor(Int32.ushr(crc,8), tmp);
 			crc = Int32.xor(Int32.ushr(crc,8), tmp);
 		}
 		}
-		return Int32.xor(crc, INITIAL_VALUE);
+		return Int32.xor(crc, init);
 	}
 	}
 }
 }

+ 5 - 5
std/neko/zip/Compress.hx

@@ -32,8 +32,8 @@ class Compress {
 		s = _deflate_init(level);
 		s = _deflate_init(level);
 	}
 	}
 
 
-	public function run( src : String, srcPos : Int, dst : String, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
-		return _deflate_buffer(s,untyped src.__s,srcPos,untyped dst.__s,dstPos);
+	public function run( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return _deflate_buffer(s,src.getData(),srcPos,dst.getData(),dstPos);
 	}
 	}
 
 
 	public function setFlushMode( f : Flush ) {
 	public function setFlushMode( f : Flush ) {
@@ -44,15 +44,15 @@ class Compress {
 		_deflate_end(s);
 		_deflate_end(s);
 	}
 	}
 
 
-	public static function run( s : String, level : Int ) : String {
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
 		var c = new Compress(level);
 		var c = new Compress(level);
 		c.setFlushMode(Flush.FINISH);
 		c.setFlushMode(Flush.FINISH);
-		var out = neko.Lib.makeString(_deflate_bound(c.s,s.length));
+		var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length));
 		var r = c.run(s,0,out,0);
 		var r = c.run(s,0,out,0);
 		c.close();
 		c.close();
 		if( !r.done || r.read != s.length )
 		if( !r.done || r.read != s.length )
 			throw "Compression failed";
 			throw "Compression failed";
-		return out.substr(0,r.write);
+		return out.sub(0,r.write);
 	}
 	}
 
 
 	static var _deflate_init = neko.Lib.load("zlib","deflate_init",1);
 	static var _deflate_init = neko.Lib.load("zlib","deflate_init",1);

+ 39 - 39
std/neko/zip/Reader.hx

@@ -30,19 +30,19 @@ typedef ZipEntry = {
 	var fileTime : Date;
 	var fileTime : Date;
 	var compressed : Bool;
 	var compressed : Bool;
 	var compressedSize : Int;
 	var compressedSize : Int;
-	var data : String;
-	var crc32 : Null<neko.Int32>;
+	var data : haxe.io.Bytes;
+	var crc32 : Null<haxe.Int32>;
 }
 }
 
 
 // see http://www.pkware.com/documents/casestudies/APPNOTE.TXT
 // see http://www.pkware.com/documents/casestudies/APPNOTE.TXT
 
 
 class Reader {
 class Reader {
 
 
-	public static function unzip( f : ZipEntry ) : String {
+	public static function unzip( f : ZipEntry ) : haxe.io.Bytes {
 		if( !f.compressed )
 		if( !f.compressed )
 			return f.data;
 			return f.data;
 		var c = new Uncompress(-15);
 		var c = new Uncompress(-15);
-		var s = neko.Lib.makeString(f.fileSize);
+		var s = haxe.io.Bytes.alloc(f.fileSize);
 		var r = c.run(f.data,0,s,0);
 		var r = c.run(f.data,0,s,0);
 		c.close();
 		c.close();
 		if( !r.done || r.read != f.data.length || r.write != f.fileSize )
 		if( !r.done || r.read != f.data.length || r.write != f.fileSize )
@@ -50,7 +50,7 @@ class Reader {
 		return s;
 		return s;
 	}
 	}
 
 
-	static function readZipDate( i : neko.io.Input ) {
+	static function readZipDate( i : haxe.io.Input ) {
 		var t = i.readUInt16();
 		var t = i.readUInt16();
 		var hour = (t >> 11) & 31;
 		var hour = (t >> 11) & 31;
 		var min = (t >> 5) & 63;
 		var min = (t >> 5) & 63;
@@ -62,8 +62,8 @@ class Reader {
 		return new Date(year + 1980, month-1, day, hour, min, sec << 1);
 		return new Date(year + 1980, month-1, day, hour, min, sec << 1);
 	}
 	}
 
 
-	public static function readZipEntry( i : neko.io.Input ) : ZipEntry {
-		var h = i.readInt32();
+	public static function readZipEntry( i : haxe.io.Input ) : ZipEntry {
+		var h = i.readInt31();
 		if( h == 0x02014B50 || h == 0x06054B50 )
 		if( h == 0x02014B50 || h == 0x06054B50 )
 			return null;
 			return null;
 		if( h != 0x04034B50 )
 		if( h != 0x04034B50 )
@@ -78,13 +78,13 @@ class Reader {
 		if( compressed && compression != 8 )
 		if( compressed && compression != 8 )
 			throw "Unsupported compression "+compression;
 			throw "Unsupported compression "+compression;
 		var mtime = readZipDate(i);
 		var mtime = readZipDate(i);
-		var crc32 = neko.Int32.read(i);
-		var csize = i.readInt32();
-		var usize = i.readInt32();
+		var crc32 = i.readInt32();
+		var csize = i.readUInt30();
+		var usize = i.readUInt30();
 		var fnamelen = i.readInt16();
 		var fnamelen = i.readInt16();
 		var elen = i.readInt16();
 		var elen = i.readInt16();
-		var fname = i.read(fnamelen);
-		var ename = i.read(elen);
+		var fname = i.readString(fnamelen);
+		var ename = i.readString(elen);
 		var data;
 		var data;
 		if( extraFields ) {
 		if( extraFields ) {
 			// TODO : it is needed to directly read the compressed
 			// TODO : it is needed to directly read the compressed
@@ -105,7 +105,7 @@ class Reader {
 		};
 		};
 	}
 	}
 
 
-	public static function readZip( i : neko.io.Input ) : List<ZipEntry> {
+	public static function readZip( i : haxe.io.Input ) : List<ZipEntry> {
 		var l = new List();
 		var l = new List();
 		while( true ) {
 		while( true ) {
 			var e = readZipEntry(i);
 			var e = readZipEntry(i);
@@ -116,12 +116,12 @@ class Reader {
 		return l;
 		return l;
 	}
 	}
 
 
-	public static function readTar( i : neko.io.Input, ?gz : Bool ) : List<ZipEntry> {
+	public static function readTar( i : haxe.io.Input, ?gz : Bool ) : List<ZipEntry> {
 		if( gz ) {
 		if( gz ) {
-			var tmp = new neko.io.StringOutput();
+			var tmp = new haxe.io.BytesOutput();
 			readGZHeader(i);
 			readGZHeader(i);
 			readGZData(i,tmp);
 			readGZData(i,tmp);
-			i = new neko.io.StringInput(tmp.toString());
+			i = new haxe.io.BytesInput(tmp.getBytes());
 		}
 		}
 		var l = new List();
 		var l = new List();
 		while( true ) {
 		while( true ) {
@@ -144,15 +144,15 @@ class Reader {
 		return l;
 		return l;
 	}
 	}
 
 
-	public static function readGZHeader( i : neko.io.Input ) : String {
-		if( i.readChar() != 0x1F || i.readChar() != 0x8B )
+	public static function readGZHeader( i : haxe.io.Input ) : String {
+		if( i.readByte() != 0x1F || i.readByte() != 0x8B )
 			throw "Invalid GZ header";
 			throw "Invalid GZ header";
-		if( i.readChar() != 8 )
+		if( i.readByte() != 8 )
 			throw "Invalid compression method";
 			throw "Invalid compression method";
-		var flags = i.readChar();
+		var flags = i.readByte();
 		var mtime = i.read(4);
 		var mtime = i.read(4);
-		var xflags = i.readChar();
-		var os = i.readChar();
+		var xflags = i.readByte();
+		var os = i.readByte();
 		var fname = null;
 		var fname = null;
 		var comments = null;
 		var comments = null;
 		if( flags & 4 != 0 ) {
 		if( flags & 4 != 0 ) {
@@ -170,12 +170,12 @@ class Reader {
 		return fname;
 		return fname;
 	}
 	}
 
 
-	public static function readGZData( i : neko.io.Input, o : neko.io.Output, ?bufsize : Int ) : Int {
+	public static function readGZData( i : haxe.io.Input, o : haxe.io.Output, ?bufsize : Int ) : Int {
 		if( bufsize == null ) bufsize = (1 << 16); // 65Ks
 		if( bufsize == null ) bufsize = (1 << 16); // 65Ks
 		var u = new Uncompress(-15);
 		var u = new Uncompress(-15);
 		u.setFlushMode(Flush.SYNC);
 		u.setFlushMode(Flush.SYNC);
-		var buf = neko.Lib.makeString(bufsize);
-		var out = neko.Lib.makeString(bufsize);
+		var buf = haxe.io.Bytes.alloc(bufsize);
+		var out = haxe.io.Bytes.alloc(bufsize);
 		var bufpos = bufsize;
 		var bufpos = bufsize;
 		var tsize = 0;
 		var tsize = 0;
 		while( true ) {
 		while( true ) {
@@ -186,9 +186,9 @@ class Reader {
 			var r = u.run(buf,bufpos,out,0);
 			var r = u.run(buf,bufpos,out,0);
 			if( r.read == 0 ) {
 			if( r.read == 0 ) {
 				if( bufpos == 0 )
 				if( bufpos == 0 )
-					throw new neko.io.Eof();
+					throw new haxe.io.Eof();
 				var len = buf.length - bufpos;
 				var len = buf.length - bufpos;
-				neko.Lib.copyBytes(buf,0,buf,bufpos,len);
+				buf.blit(0,buf,bufpos,len);
 				buf = refill(i,buf,len);
 				buf = refill(i,buf,len);
 				bufpos = 0;
 				bufpos = 0;
 			} else {
 			} else {
@@ -202,26 +202,26 @@ class Reader {
 		return tsize;
 		return tsize;
 	}
 	}
 
 
-	static function refill( i, buf : String, pos : Int ) {
+	static function refill( i, buf : haxe.io.Bytes, pos : Int ) {
 		try {
 		try {
 			while( pos != buf.length ) {
 			while( pos != buf.length ) {
 				var k = i.readBytes(buf,pos,buf.length-pos);
 				var k = i.readBytes(buf,pos,buf.length-pos);
 				pos += k;
 				pos += k;
 			}
 			}
-		} catch( e : neko.io.Eof ) {
+		} catch( e : haxe.io.Eof ) {
 		}
 		}
 		if( pos == 0 )
 		if( pos == 0 )
-			throw new neko.io.Eof();
+			throw new haxe.io.Eof();
 		if( pos != buf.length )
 		if( pos != buf.length )
-			buf = buf.substr(0,pos);
+			buf = buf.sub(0,pos);
 		return buf;
 		return buf;
 	}
 	}
 
 
-	public static function readTarEntry( i : neko.io.Input ) {
+	public static function readTarEntry( i : haxe.io.Input ) {
 		var fname = i.readUntil(0);
 		var fname = i.readUntil(0);
 		if( fname.length == 0 ) {
 		if( fname.length == 0 ) {
 			for( x in 0...511+512 )
 			for( x in 0...511+512 )
-				if( i.readChar() != 0 )
+				if( i.readByte() != 0 )
 					throw "Invalid TAR end";
 					throw "Invalid TAR end";
 			return null;
 			return null;
 		}
 		}
@@ -234,10 +234,10 @@ class Reader {
 		var mtime : Float = parseOctal(i.read(8));
 		var mtime : Float = parseOctal(i.read(8));
 		mtime = mtime * 512.0 + parseOctal(i.read(4));
 		mtime = mtime * 512.0 + parseOctal(i.read(4));
 		var crc = i.read(8);
 		var crc = i.read(8);
-		var type = i.readChar();
+		var type = i.readByte();
 		var lname = i.readUntil(0);
 		var lname = i.readUntil(0);
 		i.read(99 - lname.length); // skip
 		i.read(99 - lname.length); // skip
-		var ustar = i.read(8);
+		var ustar = i.readString(8);
 		if( ustar != "ustar  \x00" && ustar != "ustar\x00\x00\x00" ) {
 		if( ustar != "ustar  \x00" && ustar != "ustar\x00\x00\x00" ) {
 			//trace(StringTools.urlEncode(ustar));
 			//trace(StringTools.urlEncode(ustar));
 			throw "Not an tar ustar file";
 			throw "Not an tar ustar file";
@@ -257,9 +257,9 @@ class Reader {
 		};
 		};
 	}
 	}
 
 
-	public static function readTarData( i : neko.io.Input, o : neko.io.Output, size : Int, ?bufsize ) {
+	public static function readTarData( i : haxe.io.Input, o : haxe.io.Output, size : Int, ?bufsize ) {
 		if( bufsize == null ) bufsize = (1 << 16); // 65Ks
 		if( bufsize == null ) bufsize = (1 << 16); // 65Ks
-		var buf = neko.Lib.makeString(bufsize);
+		var buf = haxe.io.Bytes.alloc(bufsize);
 		var pad = Math.ceil(size / 512) * 512 - size;
 		var pad = Math.ceil(size / 512) * 512 - size;
 		while( size > 0 ) {
 		while( size > 0 ) {
 			var n = i.readBytes(buf,0,if( size > bufsize ) bufsize else size);
 			var n = i.readBytes(buf,0,if( size > bufsize ) bufsize else size);
@@ -269,10 +269,10 @@ class Reader {
 		i.read(pad);
 		i.read(pad);
 	}
 	}
 
 
-	static function parseOctal( n : String ) {
+	static function parseOctal( n : haxe.io.Bytes ) {
 		var i = 0;
 		var i = 0;
 		for( p in 0...n.length ) {
 		for( p in 0...n.length ) {
-			var c = n.charCodeAt(p);
+			var c = n.get(p);
 			if( c == 0 )
 			if( c == 0 )
 				break;
 				break;
 			if( c < 48 || c > 55 )
 			if( c < 48 || c > 55 )

+ 8 - 7
std/neko/zip/Uncompress.hx

@@ -32,8 +32,8 @@ class Uncompress {
 		s = _inflate_init(windowBits);
 		s = _inflate_init(windowBits);
 	}
 	}
 
 
-	public function run( src : String, srcPos : Int, dst : String, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
-		return _inflate_buffer(s,untyped src.__s,srcPos,untyped dst.__s,dstPos);
+	public function run( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return _inflate_buffer(s,src.getData(),srcPos,dst.getData(),dstPos);
 	}
 	}
 
 
 	public function setFlushMode( f : Flush ) {
 	public function setFlushMode( f : Flush ) {
@@ -44,21 +44,22 @@ class Uncompress {
 		_inflate_end(s);
 		_inflate_end(s);
 	}
 	}
 
 
-	public static function run( src : String ) : String {
+	public static function run( src : haxe.io.Bytes, ?bufsize ) : haxe.io.Bytes {
 		var u = new Uncompress(null);
 		var u = new Uncompress(null);
-		var tmp = neko.Lib.makeString(1 << 16); // 64K
-		var b = new StringBuf();
+		if( bufsize == null ) bufsize = 1 << 16; // 64K
+		var tmp = haxe.io.Bytes.alloc(bufsize);
+		var b = new haxe.io.BytesBuffer();
 		var pos = 0;
 		var pos = 0;
 		u.setFlushMode(Flush.SYNC);
 		u.setFlushMode(Flush.SYNC);
 		while( true ) {
 		while( true ) {
 			var r = u.run(src,pos,tmp,0);
 			var r = u.run(src,pos,tmp,0);
-			b.addSub(tmp,0,r.write);
+			b.addBytes(tmp,0,r.write);
 			pos += r.read;
 			pos += r.read;
 			if( r.done )
 			if( r.done )
 				break;
 				break;
 		}
 		}
 		u.close();
 		u.close();
-		return b.toString();
+		return b.getBytes();
 	}
 	}
 
 
 	static var _inflate_init = neko.Lib.load("zlib","inflate_init",1);
 	static var _inflate_init = neko.Lib.load("zlib","inflate_init",1);

+ 21 - 21
std/neko/zip/Writer.hx

@@ -42,7 +42,7 @@ class Writer {
 	*/
 	*/
 	private static var LOCAL_FILE_HEADER_FIELDS_SIZE = 30;
 	private static var LOCAL_FILE_HEADER_FIELDS_SIZE = 30;
 
 
-	static function writeZipDate( o : neko.io.Output, date : Date ) {
+	static function writeZipDate( o : haxe.io.Output, date : Date ) {
 		var hour = date.getHours();
 		var hour = date.getHours();
 		var min = date.getMinutes();
 		var min = date.getMinutes();
 		var sec = date.getSeconds() >> 1;
 		var sec = date.getSeconds() >> 1;
@@ -53,15 +53,15 @@ class Writer {
 		o.writeUInt16( (year << 9) | (month << 5) | day );
 		o.writeUInt16( (year << 9) | (month << 5) | day );
 	}
 	}
 
 
-	static function writeZipEntry( o : neko.io.Output, level, f : { data : String, fileName : String, fileTime : Date } ) {
+	static function writeZipEntry( o : haxe.io.Output, level, f : { data : haxe.io.Bytes, fileName : String, fileTime : Date } ) {
 		var fdata = f.data, cdata = null, crc32, compressed = true;
 		var fdata = f.data, cdata = null, crc32, compressed = true;
-		o.writeUInt32(0x04034B50);
+		o.writeUInt30(0x04034B50);
 		o.writeUInt16(0x0014); // version
 		o.writeUInt16(0x0014); // version
 		o.writeUInt16(0); // flags
 		o.writeUInt16(0); // flags
 		if( fdata == null ) {
 		if( fdata == null ) {
-			fdata = "";
-			cdata = "XXXXXX";
-			crc32 = neko.Int32.ofInt(0);
+			fdata = haxe.io.Bytes.alloc(0);
+			cdata = haxe.io.Bytes.ofString("XXXXXX");
+			crc32 = haxe.Int32.ofInt(0);
 			compressed = false;
 			compressed = false;
 		} else {
 		} else {
 			crc32 = CRC32.encode(f.data);
 			crc32 = CRC32.encode(f.data);
@@ -69,12 +69,12 @@ class Writer {
 		}
 		}
 		o.writeUInt16(compressed?8:0);
 		o.writeUInt16(compressed?8:0);
 		writeZipDate(o,f.fileTime);
 		writeZipDate(o,f.fileTime);
-		neko.Int32.write(o,crc32);
-		o.writeUInt32(cdata.length - 6);
-		o.writeUInt32(fdata.length);
+		o.writeInt32(crc32);
+		o.writeUInt30(cdata.length - 6);
+		o.writeUInt30(fdata.length);
 		o.writeUInt16(f.fileName.length);
 		o.writeUInt16(f.fileName.length);
 		o.writeUInt16(0);
 		o.writeUInt16(0);
-		o.write(f.fileName);
+		o.writeString(f.fileName);
 		if( cdata != null ) o.writeFullBytes(cdata,2,cdata.length-6);
 		if( cdata != null ) o.writeFullBytes(cdata,2,cdata.length-6);
 		return {
 		return {
 			compressed : compressed,
 			compressed : compressed,
@@ -86,34 +86,34 @@ class Writer {
 		};
 		};
 	}
 	}
 
 
-	public static function writeZip( o : neko.io.Output, files, compressionLevel : Int ) {
+	public static function writeZip( o : haxe.io.Output, files, compressionLevel : Int ) {
 		var files = Lambda.map(files,callback(writeZipEntry,o,compressionLevel));
 		var files = Lambda.map(files,callback(writeZipEntry,o,compressionLevel));
 		var cdr_size = 0;
 		var cdr_size = 0;
 		var cdr_offset = 0;
 		var cdr_offset = 0;
 		for( f in files ) {
 		for( f in files ) {
 			var namelen = f.fileName.length;
 			var namelen = f.fileName.length;
-			o.writeUInt32(0x02014B50); // header
+			o.writeUInt30(0x02014B50); // header
 			o.writeUInt16(0x0014); // version made-by
 			o.writeUInt16(0x0014); // version made-by
 			o.writeUInt16(0x0014); // version
 			o.writeUInt16(0x0014); // version
 			o.writeUInt16(0); // flags
 			o.writeUInt16(0); // flags
 			o.writeUInt16(f.compressed?8:0);
 			o.writeUInt16(f.compressed?8:0);
 			writeZipDate(o,f.date);
 			writeZipDate(o,f.date);
-			neko.Int32.write(o,f.crc32);
-			o.writeUInt32(f.clen);
-			o.writeUInt32(f.dlen);
+			o.writeInt32(f.crc32);
+			o.writeUInt30(f.clen);
+			o.writeUInt30(f.dlen);
 			o.writeUInt16(namelen);
 			o.writeUInt16(namelen);
 			o.writeUInt16(0); //extra field length always 0
 			o.writeUInt16(0); //extra field length always 0
 			o.writeUInt16(0); //comment length always 0
 			o.writeUInt16(0); //comment length always 0
 			o.writeUInt16(0); //disk number start
 			o.writeUInt16(0); //disk number start
 			o.writeUInt16(0); //internal file attributes
 			o.writeUInt16(0); //internal file attributes
-			o.writeUInt32(0);	//external file attributes
-			o.writeUInt32(0); //relative offset of local header
-			o.write(f.fileName);
+			o.writeUInt30(0);	//external file attributes
+			o.writeUInt30(0); //relative offset of local header
+			o.writeString(f.fileName);
 			cdr_size += CENTRAL_DIRECTORY_RECORD_FIELDS_SIZE + namelen;
 			cdr_size += CENTRAL_DIRECTORY_RECORD_FIELDS_SIZE + namelen;
 			cdr_offset += LOCAL_FILE_HEADER_FIELDS_SIZE + namelen + f.clen;
 			cdr_offset += LOCAL_FILE_HEADER_FIELDS_SIZE + namelen + f.clen;
 		}
 		}
 		//end of central dir signature
 		//end of central dir signature
-		o.writeUInt32(0x06054B50);
+		o.writeUInt30(0x06054B50);
 		//number of this disk
 		//number of this disk
 		o.writeUInt16(0);
 		o.writeUInt16(0);
 		//number of the disk with the start of the central directory
 		//number of the disk with the start of the central directory
@@ -123,9 +123,9 @@ class Writer {
 		//total number of entries in the central directory
 		//total number of entries in the central directory
 		o.writeUInt16(files.length);
 		o.writeUInt16(files.length);
 		//size of the central directory record
 		//size of the central directory record
-		o.writeUInt32(cdr_size);
+		o.writeUInt30(cdr_size);
 		//offset of start of central directory with respect to the starting disk number
 		//offset of start of central directory with respect to the starting disk number
-		o.writeUInt32(cdr_offset);
+		o.writeUInt30(cdr_offset);
 		// .ZIP file comment length
 		// .ZIP file comment length
 		o.writeUInt16(0);
 		o.writeUInt16(0);
 	}
 	}

+ 2 - 2
std/tools/haxedoc/Main.hx

@@ -37,7 +37,7 @@ class Main {
 
 
 	static function save(html : HtmlPrinter,x,file) {
 	static function save(html : HtmlPrinter,x,file) {
 		var f = neko.io.File.write(file,true);
 		var f = neko.io.File.write(file,true);
-		html.output = f.write;
+		html.output = f.writeString;
 		html.process(x);
 		html.process(x);
 		f.close();
 		f.close();
 		neko.Lib.print(".");
 		neko.Lib.print(".");
@@ -111,7 +111,7 @@ class Main {
 				data = parser.root;
 				data = parser.root;
 				var str = neko.Lib.serialize(data);
 				var str = neko.Lib.serialize(data);
 				var f = neko.io.File.write(dataFile,true);
 				var f = neko.io.File.write(dataFile,true);
-				f.write(str);
+				f.writeString(str);
 				f.close();
 				f.close();
 			}
 			}
 			var html = new HtmlPrinter("/api/","","");
 			var html = new HtmlPrinter("/api/","","");

+ 1 - 2
std/tools/haxelib/Datas.hx

@@ -83,13 +83,12 @@ class Datas {
 		var xmldata = null;
 		var xmldata = null;
 		for( f in zip )
 		for( f in zip )
 			if( StringTools.endsWith(f.fileName,XML) ) {
 			if( StringTools.endsWith(f.fileName,XML) ) {
-				xmldata = neko.zip.Reader.unzip(f);
+				xmldata = neko.zip.Reader.unzip(f).toString();
 				break;
 				break;
 			}
 			}
 		if( xmldata == null )
 		if( xmldata == null )
 			throw XML+" not found in package";
 			throw XML+" not found in package";
 		return readData(xmldata);
 		return readData(xmldata);
-
 	}
 	}
 
 
 	public static function readData( xmldata : String ) : XmlInfos {
 	public static function readData( xmldata : String ) : XmlInfos {

+ 15 - 15
std/tools/haxelib/Main.hx

@@ -9,9 +9,9 @@ enum Answer {
 class SiteProxy extends haxe.remoting.Proxy<tools.haxelib.SiteApi> {
 class SiteProxy extends haxe.remoting.Proxy<tools.haxelib.SiteApi> {
 }
 }
 
 
-class Progress extends neko.io.Output {
+class Progress extends haxe.io.Output {
 
 
-	var o : neko.io.Output;
+	var o : haxe.io.Output;
 	var cur : Int;
 	var cur : Int;
 	var max : Int;
 	var max : Int;
 	var start : Float;
 	var start : Float;
@@ -30,8 +30,8 @@ class Progress extends neko.io.Output {
 			neko.Lib.print(cur+"/"+max+" ("+Std.int((cur*100.0)/max)+"%)\r");
 			neko.Lib.print(cur+"/"+max+" ("+Std.int((cur*100.0)/max)+"%)\r");
 	}
 	}
 
 
-	public override function writeChar(c) {
-		o.writeChar(c);
+	public override function writeByte(c) {
+		o.writeByte(c);
 		bytes(1);
 		bytes(1);
 	}
 	}
 
 
@@ -57,9 +57,9 @@ class Progress extends neko.io.Output {
 
 
 }
 }
 
 
-class ProgressIn extends neko.io.Input {
+class ProgressIn extends haxe.io.Input {
 
 
-	var i : neko.io.Input;
+	var i : haxe.io.Input;
 	var pos : Int;
 	var pos : Int;
 	var tot : Int;
 	var tot : Int;
 
 
@@ -69,8 +69,8 @@ class ProgressIn extends neko.io.Input {
 		this.tot = tot;
 		this.tot = tot;
 	}
 	}
 
 
-	public override function readChar() {
-		var c = i.readChar();
+	public override function readByte() {
+		var c = i.readByte();
 		doRead(1);
 		doRead(1);
 		return c;
 		return c;
 	}
 	}
@@ -268,8 +268,8 @@ class Main {
 
 
 	function submit() {
 	function submit() {
 		var file = param("Package");
 		var file = param("Package");
-		var data = neko.io.File.getContent(file);
-		var zip = neko.zip.Reader.readZip(new neko.io.StringInput(data));
+		var data = neko.io.File.getBytes(file);
+		var zip = neko.zip.Reader.readZip(new haxe.io.BytesInput(data));
 		var infos = Datas.readInfos(zip);
 		var infos = Datas.readInfos(zip);
 		var user = infos.developers.first();
 		var user = infos.developers.first();
 		var password;
 		var password;
@@ -308,7 +308,7 @@ class Main {
 		var h = new haxe.Http("http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.url);
 		var h = new haxe.Http("http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.url);
 		h.onError = function(e) { throw e; };
 		h.onError = function(e) { throw e; };
 		h.onData = print;
 		h.onData = print;
-		h.fileTransfert("file",id,new ProgressIn(new neko.io.StringInput(data),data.length),data.length);
+		h.fileTransfert("file",id,new ProgressIn(new haxe.io.BytesInput(data),data.length),data.length);
 		print("Sending data.... ");
 		print("Sending data.... ");
 		h.request(true);
 		h.request(true);
 
 
@@ -421,7 +421,7 @@ class Main {
 		// set current version
 		// set current version
 		if( setcurrent || !neko.FileSystem.exists(pdir+".current") ) {
 		if( setcurrent || !neko.FileSystem.exists(pdir+".current") ) {
 			var f = neko.io.File.write(pdir+".current",true);
 			var f = neko.io.File.write(pdir+".current",true);
-			f.write(infos.version);
+			f.writeString(infos.version);
 			f.close();
 			f.close();
 			print("  Current version is now "+infos.version);
 			print("  Current version is now "+infos.version);
 		}
 		}
@@ -496,7 +496,7 @@ class Main {
 				}
 				}
 			}
 			}
 			var f = neko.io.File.write(config,true);
 			var f = neko.io.File.write(config,true);
-			f.write(rep);
+			f.writeString(rep);
 			f.close();
 			f.close();
 		} else if( !neko.FileSystem.exists(rep) )
 		} else if( !neko.FileSystem.exists(rep) )
 			throw "haxelib Repository "+rep+" does not exists. Please run haxelib setup again";
 			throw "haxelib Repository "+rep+" does not exists. Please run haxelib setup again";
@@ -615,7 +615,7 @@ class Main {
 		if( doAsk && ask("Set "+prj+" to version "+version) == No )
 		if( doAsk && ask("Set "+prj+" to version "+version) == No )
 			return;
 			return;
 		var f = neko.io.File.write(current,true);
 		var f = neko.io.File.write(current,true);
-		f.write(version);
+		f.writeString(version);
 		f.close();
 		f.close();
 		print("Project "+prj+" current version is now "+version);
 		print("Project "+prj+" current version is now "+version);
 	}
 	}
@@ -680,7 +680,7 @@ class Main {
 			print("Development directory disabled");
 			print("Development directory disabled");
 		} else {
 		} else {
 			var f = neko.io.File.write(devfile,false);
 			var f = neko.io.File.write(devfile,false);
-			f.write(dir);
+			f.writeString(dir);
 			f.close();
 			f.close();
 			print("Development directory set to "+dir);
 			print("Development directory set to "+dir);
 		}
 		}

+ 2 - 2
std/tools/haxelib/Site.hx

@@ -30,7 +30,7 @@ class Site {
 		var log = neko.io.File.append(TMP_DIR+"/log.txt",false);
 		var log = neko.io.File.append(TMP_DIR+"/log.txt",false);
 		var api = new SiteApi(db);
 		var api = new SiteApi(db);
 		server.setPrivatePrefix("db");
 		server.setPrivatePrefix("db");
-		server.setLogger(log.write);
+		server.setLogger(log.writeString);
 		server.addObject("api",api);
 		server.addObject("api",api);
 		var flag = server.handleRequest();
 		var flag = server.handleRequest();
 		log.close();
 		log.close();
@@ -65,7 +65,7 @@ class Site {
 	static function display() {
 	static function display() {
 		var data = neko.io.File.getContent(CWD + "website.mtt");
 		var data = neko.io.File.getContent(CWD + "website.mtt");
 		var page = new haxe.Template(data);
 		var page = new haxe.Template(data);
-		var ctx : Dynamic = Reflect.empty();
+		var ctx : Dynamic = {};
 		var macros = {
 		var macros = {
 			download : function( res, p, v ) {
 			download : function( res, p, v ) {
 				return "/"+Datas.REPOSITORY+"/"+Datas.fileName(res(p).name,res(v).name);
 				return "/"+Datas.REPOSITORY+"/"+Datas.fileName(res(p).name,res(v).name);

+ 1 - 0
std/tools/haxelib/haxelib.hxml

@@ -2,6 +2,7 @@
 -neko index.n
 -neko index.n
 -main tools.haxelib.Site
 -main tools.haxelib.Site
 
 
+
 --next
 --next
 # Command
 # Command
 -neko haxelib.n
 -neko haxelib.n

+ 1 - 1
std/tools/haxelib/haxelib.hxp

@@ -1,5 +1,5 @@
 <haxe selected="1">
 <haxe selected="1">
-  <output name="Site" mode="neko" out="index.n" class="tools.haxelib.Site" lib="" cmd="" main="True" debug="False">-D old_serialize</output>
+  <output name="Site" mode="neko" out="index.n" class="tools.haxelib.Site" lib="" cmd="" main="True" debug="False"></output>
   <output name="Command" mode="neko" out="haxelib.n" class="tools.haxelib.Main" lib="" cmd="" main="True" debug="False">-cmd nekotools boot haxelib.n</output>
   <output name="Command" mode="neko" out="haxelib.n" class="tools.haxelib.Main" lib="" cmd="" main="True" debug="False">-cmd nekotools boot haxelib.n</output>
   <files path="/">
   <files path="/">
     <file path="Datas.hx" />
     <file path="Datas.hx" />

+ 3 - 2
tests/unit/TestBytes.hx

@@ -98,11 +98,12 @@ class TestBytes extends Test {
 
 
 	function testBuffer() {
 	function testBuffer() {
 		var out = new haxe.io.BytesBuffer();
 		var out = new haxe.io.BytesBuffer();
+		out.add( haxe.io.Bytes.ofString("ABCDEF") );
 		for( i in 1...6 )
 		for( i in 1...6 )
-			out.add(i);
+			out.addByte(i);
 		out.addBytes( haxe.io.Bytes.ofString("ABCDEF"),1,3 );
 		out.addBytes( haxe.io.Bytes.ofString("ABCDEF"),1,3 );
 		var b = out.getBytes();
 		var b = out.getBytes();
-		var str = "\x01\x02\x03\x04\x05BCD";
+		var str = "ABCDEF\x01\x02\x03\x04\x05BCD";
 		eq( b.length, str.length );
 		eq( b.length, str.length );
 		for( i in 0...str.length )
 		for( i in 0...str.length )
 			eq( b.get(i), str.charCodeAt(i) );
 			eq( b.get(i), str.charCodeAt(i) );

+ 5 - 0
tests/unit/TestIO.hx

@@ -39,6 +39,9 @@ class TestIO extends Test {
 		#end
 		#end
 		o.writeByte(99);
 		o.writeByte(99);
 
 
+		var str = "Héllo World !";
+		o.writeString(str);
+
 		o.writeInt16(-12345);
 		o.writeInt16(-12345);
 		exc(function() o.writeInt16(1 << 15));
 		exc(function() o.writeInt16(1 << 15));
 		exc(function() o.writeInt16(-((1 << 15)+1)));
 		exc(function() o.writeInt16(-((1 << 15)+1)));
@@ -91,6 +94,8 @@ class TestIO extends Test {
 		#end
 		#end
 		eq( i.readByte(), 99 );
 		eq( i.readByte(), 99 );
 
 
+		eq( i.readString(haxe.io.Bytes.ofString(str).length), str );
+
 		eq( i.readInt16(), -12345 );
 		eq( i.readInt16(), -12345 );
 		eq( i.readInt24(), -1234567 );
 		eq( i.readInt24(), -1234567 );
 		eq( i.readInt31(), -123456789 );
 		eq( i.readInt31(), -123456789 );