浏览代码

Neko soft deprecate : split off conditional compilation into separate impl (#9350)

* split off neko haxe/Resource.hx into separate impl

* split off more unique neko conditionals into separate implementations

* fix return type on neko haxe.Resource

* strip comments from neko/_std/haxe/format/JsonPrinter.hx

* revert neko JsonPrinter.hx
Justin Donaldson 5 年之前
父节点
当前提交
b40d5ce6f8

+ 0 - 13
std/haxe/Resource.hx

@@ -50,14 +50,10 @@ class Resource {
 	public static function getString(name:String):String {
 		for (x in content)
 			if (x.name == name) {
-				#if neko
-				return new String(x.data);
-				#else
 				if (x.str != null)
 					return x.str;
 				var b:haxe.io.Bytes = haxe.crypto.Base64.decode(x.data);
 				return b.toString();
-				#end
 			}
 		return null;
 	}
@@ -71,23 +67,14 @@ class Resource {
 	public static function getBytes(name:String):haxe.io.Bytes {
 		for (x in content)
 			if (x.name == name) {
-				#if neko
-				return haxe.io.Bytes.ofData(cast x.data);
-				#else
 				if (x.str != null)
 					return haxe.io.Bytes.ofString(x.str);
 				return haxe.crypto.Base64.decode(x.data);
-				#end
 			}
 		return null;
 	}
 
 	static function __init__() {
-		#if neko
-		var tmp = untyped __resources__();
-		content = untyped Array.new1(tmp, __dollar__asize(tmp));
-		#else
 		content = untyped __resources__();
-		#end
 	}
 }

+ 0 - 2
std/haxe/Timer.hx

@@ -172,8 +172,6 @@ class Timer {
 	public static inline function stamp():Float {
 		#if flash
 		return flash.Lib.getTimer() / 1000;
-		#elseif (neko || php)
-		return Sys.time();
 		#elseif js
 		#if nodejs
 		var hrtime = js.Syntax.code('process.hrtime()'); // [seconds, remaining nanoseconds]

+ 0 - 13
std/haxe/crypto/Md5.hx

@@ -27,19 +27,12 @@ package haxe.crypto;
 **/
 class Md5 {
 	public static function encode(s:String):String {
-		#if neko
-		return untyped new String(base_encode(make_md5(s.__s), "0123456789abcdef".__s));
-		#else
 		var m = new Md5();
 		var h = m.doEncode(str2blks(s));
 		return m.hex(h);
-		#end
 	}
 
 	public static function make(b:haxe.io.Bytes):haxe.io.Bytes {
-		#if neko
-		return haxe.io.Bytes.ofData(make_md5(b.getData()));
-		#else
 		var h = new Md5().doEncode(bytes2blks(b));
 		var out = haxe.io.Bytes.alloc(16);
 		var p = 0;
@@ -50,13 +43,8 @@ class Md5 {
 			out.set(p++, h[i] >>> 24);
 		}
 		return out;
-		#end
 	}
 
-	#if neko
-	static var base_encode = neko.Lib.load("std", "base_encode", 2);
-	static var make_md5 = neko.Lib.load("std", "make_md5", 1);
-	#else
 	/*
 	 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 	 * Digest Algorithm, as defined in RFC 1321.
@@ -277,5 +265,4 @@ class Md5 {
 		}
 		return [a, b, c, d];
 	}
-	#end
 }

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

@@ -24,11 +24,6 @@ package haxe.io;
 
 class StringInput extends BytesInput {
 	public function new(s:String) {
-		#if neko
-		// don't copy the string
-		super(neko.Lib.bytesReference(s));
-		#else
 		super(haxe.io.Bytes.ofString(s));
-		#end
 	}
 }

+ 53 - 0
std/neko/_std/haxe/Resource.hx

@@ -0,0 +1,53 @@
+/*
+ * Copyright (C)2005-2019 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;
+
+@:coreApi
+class Resource {
+	static var content:Array<{name:String, data:String, str:String}>;
+
+	public static function listNames():Array<String> {
+		return [for (x in content) x.name];
+	}
+
+	public static function getString(name:String):String {
+		for (x in content)
+			if (x.name == name) {
+				return new String(x.data);
+			}
+		return null;
+	}
+
+	public static function getBytes(name:String):haxe.io.Bytes {
+		for (x in content)
+			if (x.name == name) {
+				return haxe.io.Bytes.ofData(cast x.data);
+			}
+		return null;
+	}
+
+	static function __init__() : Void {
+		var tmp = untyped __resources__();
+		content = untyped Array.new1(tmp, __dollar__asize(tmp));
+	}
+}

+ 36 - 0
std/neko/_std/haxe/crypto/Md5.hx

@@ -0,0 +1,36 @@
+/*
+ * Copyright (C)2005-2019 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.crypto;
+
+class Md5 {
+	public static function encode(s:String):String {
+		return untyped new String(base_encode(make_md5(s.__s), "0123456789abcdef".__s));
+	}
+
+	public static function make(b:haxe.io.Bytes):haxe.io.Bytes {
+		return haxe.io.Bytes.ofData(make_md5(b.getData()));
+	}
+
+	static var base_encode = neko.Lib.load("std", "base_encode", 2);
+	static var make_md5 = neko.Lib.load("std", "make_md5", 1);
+}

+ 29 - 0
std/neko/_std/haxe/io/StringInput.hx

@@ -0,0 +1,29 @@
+/*
+ * Copyright (C)2005-2019 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.io;
+
+class StringInput extends BytesInput {
+	public function new(s:String) {
+		super(neko.Lib.bytesReference(s));
+	}
+}