Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions std/haxe/Resource.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
}
}
2 changes: 0 additions & 2 deletions std/haxe/Timer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 0 additions & 13 deletions std/haxe/crypto/Md5.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -277,5 +265,4 @@ class Md5 {
}
return [a, b, c, d];
}
#end
}
38 changes: 0 additions & 38 deletions std/haxe/format/JsonPrinter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ class JsonPrinter {
}

function quote(s:String) {
#if neko
if (s.length != neko.Utf8.length(s)) {
quoteUtf8(s);
return;
}
#end
addChar('"'.code);
var i = 0;
#if hl
Expand Down Expand Up @@ -257,36 +251,4 @@ class JsonPrinter {
addChar('"'.code);
}

#if neko
function quoteUtf8(s:String) {
var u = new neko.Utf8();
neko.Utf8.iter(s, function(c) {
switch (c) {
case '\\'.code, '"'.code:
u.addChar('\\'.code);
u.addChar(c);
case '\n'.code:
u.addChar('\\'.code);
u.addChar('n'.code);
case '\r'.code:
u.addChar('\\'.code);
u.addChar('r'.code);
case '\t'.code:
u.addChar('\\'.code);
u.addChar('t'.code);
case 8:
u.addChar('\\'.code);
u.addChar('b'.code);
case 12:
u.addChar('\\'.code);
u.addChar('f'.code);
default:
u.addChar(c);
}
});
buf.add('"');
buf.add(u.toString());
buf.add('"');
}
#end
}
5 changes: 0 additions & 5 deletions std/haxe/io/StringInput.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 53 additions & 0 deletions std/neko/_std/haxe/Resource.hx
Original file line number Diff line number Diff line change
@@ -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 changes: 36 additions & 0 deletions std/neko/_std/haxe/crypto/Md5.hx
Original file line number Diff line number Diff line change
@@ -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);
}
Loading