Просмотр исходного кода

Merge branch 'development' of https://github.com/HaxeFoundation/haxe into development

Hugh 12 лет назад
Родитель
Сommit
3fd9a82329

+ 10 - 2
ast.ml

@@ -456,14 +456,22 @@ let parse_path s =
 
 let s_escape s =
 	let b = Buffer.create (String.length s) in
+	let utf8 = ref false in
 	for i = 0 to (String.length s) - 1 do
-		match s.[i] with
+		if !utf8 then begin
+			let c = s.[i] in
+			Buffer.add_char b c;
+			utf8 := int_of_char c >= 128;
+		end else match s.[i] with
 		| '\n' -> Buffer.add_string b "\\n"
 		| '\t' -> Buffer.add_string b "\\t"
 		| '\r' -> Buffer.add_string b "\\r"
 		| '"' -> Buffer.add_string b "\\\""
 		| '\\' -> Buffer.add_string b "\\\\"
-		| c -> Buffer.add_char b c
+		| c when int_of_char c < 32 -> Buffer.add_string b (Printf.sprintf "\\x%.2X" (int_of_char c))
+		| c ->
+			if int_of_char c >= 128 then utf8 := true;
+			Buffer.add_char b c
 	done;
 	Buffer.contents b
 

+ 1 - 3
genjs.ml

@@ -340,9 +340,7 @@ let is_dynamic_iterator ctx e =
 let gen_constant ctx p = function
 	| TInt i -> print ctx "%ld" i
 	| TFloat s -> spr ctx s
-	| TString s ->
-		if String.contains s '\000' then error "A String cannot contain \\0 characters" p;
-		print ctx "\"%s\"" (Ast.s_escape s)
+	| TString s -> print ctx "\"%s\"" (Ast.s_escape s)
 	| TBool b -> spr ctx (if b then "true" else "false")
 	| TNull -> spr ctx "null"
 	| TThis -> spr ctx (this ctx)

+ 1 - 1
libs

@@ -1 +1 @@
-Subproject commit 34232d03b0ec836170379a3f82afde51485f549f
+Subproject commit ff2e0f209eb9fcec663437e66b5f76b8e730130b

+ 62 - 0
std/cpp/_std/haxe/zip/Compress.hx

@@ -0,0 +1,62 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Compress {
+
+	var s : Dynamic;
+
+	public function new( level : Int ) : Void {
+		s = _deflate_init(level);
+	}
+
+	public function execute( 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 : FlushMode ) : Void {
+		_set_flush_mode(s,Std.string(f));
+	}
+
+	public function close() : Void {
+		_deflate_end(s);
+	}
+
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
+		var c = new Compress(level);
+		c.setFlushMode(FlushMode.FINISH);
+		var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length));
+		var r = c.execute(s,0,out,0);
+		c.close();
+		if( !r.done || r.read != s.length )
+			throw "Compression failed";
+		return out.sub(0,r.write);
+	}
+
+	static var _deflate_init = cpp.Lib.load("zlib","deflate_init",1);
+	static var _deflate_bound = cpp.Lib.load("zlib","deflate_bound",2);
+	static var _deflate_buffer = cpp.Lib.load("zlib","deflate_buffer",5);
+	static var _deflate_end = cpp.Lib.load("zlib","deflate_end",1);
+	static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2);
+
+}

+ 67 - 0
std/cpp/_std/haxe/zip/Uncompress.hx

@@ -0,0 +1,67 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Uncompress {
+	var s : Dynamic;
+
+	public function new( ?windowBits : Int ) : Void {
+		s = _inflate_init(windowBits);
+	}
+
+	public function execute( 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 : FlushMode ) : Void {
+		_set_flush_mode(s,untyped f.__Tag());
+	}
+
+	public function close() : Void {
+		_inflate_end(s);
+	}
+
+	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes {
+		var u = new Uncompress(null);
+		if( bufsize == null ) bufsize = 1 << 16; // 64K
+		var tmp = haxe.io.Bytes.alloc(bufsize);
+		var b = new haxe.io.BytesBuffer();
+		var pos = 0;
+		u.setFlushMode(FlushMode.SYNC);
+		while( true ) {
+			var r = u.execute(src,pos,tmp,0);
+			b.addBytes(tmp,0,r.write);
+			pos += r.read;
+			if( r.done )
+				break;
+		}
+		u.close();
+		return b.getBytes();
+	}
+
+	static var _inflate_init = cpp.Lib.load("zlib","inflate_init",1);
+	static var _inflate_buffer = cpp.Lib.load("zlib","inflate_buffer",5);
+	static var _inflate_end = cpp.Lib.load("zlib","inflate_end",1);
+	static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2);
+
+}

+ 4 - 60
std/cpp/zip/Compress.hx

@@ -1,61 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package cpp.zip;
- 
-class Compress {
- 
-	var s : Dynamic;
- 
-	public function new( level : Int ) {
-		s = _deflate_init(level);
-	}
- 
-	public function execute( 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 ) {
-		_set_flush_mode(s,Std.string(f));
-	}
- 
-	public function close() {
-		_deflate_end(s);
-	}
- 
-	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
-		var c = new Compress(level);
-		c.setFlushMode(Flush.FINISH);
-		var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length));
-		var r = c.execute(s,0,out,0);
-		c.close();
-		if( !r.done || r.read != s.length )
-			throw "Compression failed";
-		return out.sub(0,r.write);
-	}
- 
-	static var _deflate_init = cpp.Lib.load("zlib","deflate_init",1);
-	static var _deflate_bound = cpp.Lib.load("zlib","deflate_bound",2);
-	static var _deflate_buffer = cpp.Lib.load("zlib","deflate_buffer",5);
-	static var _deflate_end = cpp.Lib.load("zlib","deflate_end",1);
-	static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2);
- 
-}
+
+#if (haxe_ver < 3.2)
+typedef Compress = haxe.zip.Compress;
+#end

+ 3 - 28
std/cpp/zip/Flush.hx

@@ -1,30 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package cpp.zip;
 
-enum Flush {
-	NO;
-	SYNC;
-	FULL;
-	FINISH;
-	BLOCK;
-}
+#if (haxe_ver < 3.2)
+typedef Flush = haxe.zip.FlushMode;
+#end

+ 3 - 64
std/cpp/zip/Uncompress.hx

@@ -1,66 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package cpp.zip;
 
-class Uncompress {
-	var s : Dynamic;
-
-	public function new( windowBits : Null<Int> ) {
-		s = _inflate_init(windowBits);
-	}
-
-	public function this_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 ) {
-		_set_flush_mode(s,untyped f.__Tag());
-	}
-
-	public function close() {
-		_inflate_end(s);
-	}
-
-	public static function run( src : haxe.io.Bytes, ?bufsize ) : haxe.io.Bytes {
-		var u = new Uncompress(null);
-		if( bufsize == null ) bufsize = 1 << 16; // 64K
-		var tmp = haxe.io.Bytes.alloc(bufsize);
-		var b = new haxe.io.BytesBuffer();
-		var pos = 0;
-		u.setFlushMode(Flush.SYNC);
-		while( true ) {
-			var r = u.this_run(src,pos,tmp,0);
-			b.addBytes(tmp,0,r.write);
-			pos += r.read;
-			if( r.done )
-				break;
-		}
-		u.close();
-		return b.getBytes();
-	}
-
-	static var _inflate_init = cpp.Lib.load("zlib","inflate_init",1);
-	static var _inflate_buffer = cpp.Lib.load("zlib","inflate_buffer",5);
-	static var _inflate_end = cpp.Lib.load("zlib","inflate_end",1);
-	static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2);
-
-}
+#if (haxe_ver < 3.2)
+typedef Uncompress = haxe.zip.Uncompress;
+#end

+ 55 - 0
std/flash/_std/haxe/zip/Compress.hx

@@ -0,0 +1,55 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Compress {
+
+	public function new( level : Int ) : Void {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : FlushMode ) : Void {
+	}
+
+	public function close() : Void {
+	}
+
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {		
+		if( s.length == 0 ) {
+			// Flash returns 0 bytes for 0 length compress (which can't be decoded on other platforms...)
+			var b = haxe.io.Bytes.alloc(8);
+			b.set(0,0x78);b.set(1,0xDA);b.set(2,0x03);
+			b.set(7,0x01);
+			return b;
+		}
+		var tmp = new flash.utils.ByteArray();
+		tmp.writeBytes(s.getData(),0,s.length);
+		tmp.compress();
+		return haxe.io.Bytes.ofData(tmp);
+	}
+
+}

+ 48 - 0
std/flash/_std/haxe/zip/Uncompress.hx

@@ -0,0 +1,48 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Uncompress {
+
+	public function new( ?windowBits : Int ) : Void {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : FlushMode ) : Void {
+	}
+
+	public function close() : Void {
+	}
+
+	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes {
+		var tmp = new flash.utils.ByteArray();
+		tmp.writeBytes(src.getData(),0,src.length);
+		tmp.uncompress();
+		return haxe.io.Bytes.ofData(tmp);
+	}
+
+}

+ 5 - 0
std/haxe/crypto/Adler32.hx

@@ -50,6 +50,10 @@ class Adler32 {
 		return a.a1 == a1 && a.a2 == a2;
 	}
 
+	public function toString() {
+		return StringTools.hex(a2,8) + StringTools.hex(a1,8);
+	}
+	
 	public static function read( i : haxe.io.Input ) {
 		var a = new Adler32();
 		var a2a = i.readByte();
@@ -66,5 +70,6 @@ class Adler32 {
 		a.update(b,0,b.length);
 		return a.get();
 	}
+	
 
 }

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

@@ -95,6 +95,23 @@ class Bytes {
 			b1[i+pos] = b2[i+srcpos];
 		#end
 	}
+	
+	public function fill( pos : Int, len : Int, value : Int ) {
+		#if flash9
+		var v4 = value&0xFF;
+		v4 |= v4<<8;
+		v4 |= v4<<16;
+		b.position = pos;
+		for( i in 0...len>>2 )
+			b.writeUnsignedInt(v4);		
+		pos += len&~3;
+		for( i in 0...len&3 )
+			set(pos++,value);
+		#else
+		for( i in 0...len )
+			set(pos++, value);
+		#end
+	}
 
 	public function sub( pos : Int, len : Int ) : Bytes {
 		#if !neko

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

@@ -116,7 +116,7 @@ class BytesBuffer {
 		#if neko
 		try untyped StringBuf.__add_sub(b,src.getData(),pos,len) catch( e : Dynamic ) throw Error.OutsideBounds;
 		#elseif flash9
-		b.writeBytes(src.getData(),pos,len);
+		if( len > 0 ) b.writeBytes(src.getData(),pos,len);
 		#elseif php
 		b += untyped __call__("substr", src.b, pos, len);
 		#elseif cs

+ 45 - 0
std/haxe/zip/Compress.hx

@@ -0,0 +1,45 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+class Compress {
+
+	public function new( level : Int ) {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : FlushMode ) {
+	}
+
+	public function close() {
+	}
+
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
+		throw "Not implemented for this platform";
+		return null;
+	}
+
+}

+ 30 - 0
std/haxe/zip/FlushMode.hx

@@ -0,0 +1,30 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+enum FlushMode {
+	NO;
+	SYNC;
+	FULL;
+	FINISH;
+	BLOCK;
+}

+ 1 - 5
std/haxe/zip/Tools.hx

@@ -26,17 +26,13 @@ class Tools {
 	public static function compress( f : Entry, level : Int ) {
 		if( f.compressed )
 			return;
-		#if neko
 		// this should be optimized with a temp buffer
 		// that would discard the first two bytes
 		// (in order to prevent 2x mem usage for large files)
-		var data = neko.zip.Compress.run( f.data, level );
+		var data = haxe.zip.Compress.run( f.data, level );
 		f.compressed = true;
 		f.data = data.sub(2,data.length-6);
 		f.dataSize = f.data.length;
-		#else
-		throw "No compress support";
-		#end
 	}
 
 }

+ 44 - 0
std/haxe/zip/Uncompress.hx

@@ -0,0 +1,44 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+class Uncompress {
+
+	public function new( ?windowBits : Int ) {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : FlushMode ) {
+	}
+
+	public function close() {
+	}
+
+	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes {
+		return InflateImpl.run(new haxe.io.BytesInput(src),bufsize);
+	}
+
+}

+ 62 - 0
std/neko/_std/haxe/zip/Compress.hx

@@ -0,0 +1,62 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Compress {
+
+	var s : Dynamic;
+
+	public function new( level : Int ) : Void {
+		s = _deflate_init(level);
+	}
+
+	public function execute( 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 : FlushMode ) : Void {
+		_set_flush_mode(s,untyped Std.string(f).__s);
+	}
+
+	public function close() : Void {
+		_deflate_end(s);
+	}
+
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
+		var c = new Compress(level);
+		c.setFlushMode(FlushMode.FINISH);
+		var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length));
+		var r = c.execute(s,0,out,0);
+		c.close();
+		if( !r.done || r.read != s.length )
+			throw "Compression failed";
+		return out.sub(0,r.write);
+	}
+
+	static var _deflate_init = neko.Lib.load("zlib","deflate_init",1);
+	static var _deflate_bound = neko.Lib.load("zlib","deflate_bound",2);
+	static var _deflate_buffer = neko.Lib.load("zlib","deflate_buffer",5);
+	static var _deflate_end = neko.Lib.load("zlib","deflate_end",1);
+	static var _set_flush_mode = neko.Lib.load("zlib","set_flush_mode",2);
+
+}

+ 68 - 0
std/neko/_std/haxe/zip/Uncompress.hx

@@ -0,0 +1,68 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+@:coreApi
+class Uncompress {
+
+	var s : Dynamic;
+
+	public function new( ?windowBits : Int ) : Void {
+		s = _inflate_init(windowBits);
+	}
+
+	public function execute( 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 : FlushMode ) : Void {
+		_set_flush_mode(s,untyped Std.string(f).__s);
+	}
+
+	public function close() : Void {
+		_inflate_end(s);
+	}
+
+	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes {
+		var u = new Uncompress(null);
+		if( bufsize == null ) bufsize = 1 << 16; // 64K
+		var tmp = haxe.io.Bytes.alloc(bufsize);
+		var b = new haxe.io.BytesBuffer();
+		var pos = 0;
+		u.setFlushMode(FlushMode.SYNC);
+		while( true ) {
+			var r = u.execute(src,pos,tmp,0);
+			b.addBytes(tmp,0,r.write);
+			pos += r.read;
+			if( r.done )
+				break;
+		}
+		u.close();
+		return b.getBytes();
+	}
+
+	static var _inflate_init = neko.Lib.load("zlib","inflate_init",1);
+	static var _inflate_buffer = neko.Lib.load("zlib","inflate_buffer",5);
+	static var _inflate_end = neko.Lib.load("zlib","inflate_end",1);
+	static var _set_flush_mode = neko.Lib.load("zlib","set_flush_mode",2);
+
+}

+ 3 - 59
std/neko/zip/Compress.hx

@@ -1,61 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package neko.zip;
 
-class Compress {
-
-	var s : Dynamic;
-
-	public function new( level : Int ) {
-		s = _deflate_init(level);
-	}
-
-	public function execute( 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 ) {
-		_set_flush_mode(s,untyped Std.string(f).__s);
-	}
-
-	public function close() {
-		_deflate_end(s);
-	}
-
-	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
-		var c = new Compress(level);
-		c.setFlushMode(Flush.FINISH);
-		var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length));
-		var r = c.execute(s,0,out,0);
-		c.close();
-		if( !r.done || r.read != s.length )
-			throw "Compression failed";
-		return out.sub(0,r.write);
-	}
-
-	static var _deflate_init = neko.Lib.load("zlib","deflate_init",1);
-	static var _deflate_bound = neko.Lib.load("zlib","deflate_bound",2);
-	static var _deflate_buffer = neko.Lib.load("zlib","deflate_buffer",5);
-	static var _deflate_end = neko.Lib.load("zlib","deflate_end",1);
-	static var _set_flush_mode = neko.Lib.load("zlib","set_flush_mode",2);
-
-}
+#if (haxe_ver < 3.2)
+typedef Compress = haxe.zip.Compress;
+#end

+ 3 - 28
std/neko/zip/Flush.hx

@@ -1,30 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package neko.zip;
 
-enum Flush {
-	NO;
-	SYNC;
-	FULL;
-	FINISH;
-	BLOCK;
-}
+#if (haxe_ver < 3.2)
+typedef Flush = haxe.zip.FlushMode;
+#end

+ 3 - 65
std/neko/zip/Uncompress.hx

@@ -1,67 +1,5 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
 package neko.zip;
 
-class Uncompress {
-
-	var s : Dynamic;
-
-	public function new( windowBits : Int ) {
-		s = _inflate_init(windowBits);
-	}
-
-	public function execute( 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 ) {
-		_set_flush_mode(s,untyped Std.string(f).__s);
-	}
-
-	public function close() {
-		_inflate_end(s);
-	}
-
-	public static function run( src : haxe.io.Bytes, ?bufsize ) : haxe.io.Bytes {
-		var u = new Uncompress(null);
-		if( bufsize == null ) bufsize = 1 << 16; // 64K
-		var tmp = haxe.io.Bytes.alloc(bufsize);
-		var b = new haxe.io.BytesBuffer();
-		var pos = 0;
-		u.setFlushMode(Flush.SYNC);
-		while( true ) {
-			var r = u.execute(src,pos,tmp,0);
-			b.addBytes(tmp,0,r.write);
-			pos += r.read;
-			if( r.done )
-				break;
-		}
-		u.close();
-		return b.getBytes();
-	}
-
-	static var _inflate_init = neko.Lib.load("zlib","inflate_init",1);
-	static var _inflate_buffer = neko.Lib.load("zlib","inflate_buffer",5);
-	static var _inflate_end = neko.Lib.load("zlib","inflate_end",1);
-	static var _set_flush_mode = neko.Lib.load("zlib","set_flush_mode",2);
-
-}
+#if (haxe_ver < 3.2)
+typedef Uncompress = haxe.zip.Uncompress;
+#end