forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -79,12 +79,8 @@
|
||||
return (a == b) ? 0 : (((cast a) > (cast b)) ? 1 : -1);
|
||||
}
|
||||
|
||||
public static function compareMethods(f1:Dynamic, f2:Dynamic):Bool {
|
||||
if (f1 == f2)
|
||||
return true;
|
||||
if (!isFunction(f1) || !isFunction(f2))
|
||||
return false;
|
||||
return f1.scope == f2.scope && f1.method == f2.method && f1.method != null;
|
||||
public static inline function compareMethods(f1:Dynamic, f2:Dynamic):Bool {
|
||||
return f1 == f2;
|
||||
}
|
||||
|
||||
@:access(js.Boot)
|
||||
|
||||
@ -54,17 +54,24 @@ import js.Syntax;
|
||||
|
||||
@:pure
|
||||
public static function parseInt(x:String):Null<Int> {
|
||||
if(x != null) {
|
||||
for(i in 0...x.length) {
|
||||
var c = StringTools.fastCodeAt(x, i);
|
||||
if(c <= 8 || (c >= 14 && c != ' '.code && c != '-'.code)) {
|
||||
var nc = StringTools.fastCodeAt(x, i + 1);
|
||||
var v = js.Lib.parseInt(x, (nc == "x".code || nc == "X".code) ? 16 : 10);
|
||||
return Math.isNaN(v) ? null : cast v;
|
||||
}
|
||||
#if (js_es >= 5)
|
||||
final v = js.Lib.parseInt(x);
|
||||
#else
|
||||
// before ES5, octal was supported in some implementations, so we need to explicitly use base 10 or 16
|
||||
if (x == null)
|
||||
return null;
|
||||
var v:Float = Math.NaN;
|
||||
for (i => c in StringTools.keyValueIterator(x)) {
|
||||
if ((c <= 8 || c >= 14) && !(c == ' '.code || c == '-'.code || c == '+'.code)) {
|
||||
final nc = js.Syntax.code("{0}[{1}]", x, i + 1);
|
||||
v = js.Lib.parseInt(x, c == '0'.code && (nc == "x" || nc == "X") ? 16 : 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
#end
|
||||
if (Math.isNaN(v))
|
||||
return null;
|
||||
return cast v;
|
||||
}
|
||||
|
||||
public static inline function parseFloat(x:String):Float {
|
||||
@ -77,7 +84,7 @@ import js.Syntax;
|
||||
|
||||
static function __init__():Void
|
||||
untyped {
|
||||
__feature__("js.Boot.getClass", String.prototype.__class__ = __feature__("Type.resolveClass", $hxClasses["String"] = String, String));
|
||||
__feature__("js.Boot.getClass", Object.defineProperty(String.prototype, "__class__", {value: __feature__("Type.resolveClass", $hxClasses["String"] = String, String), enumerable: false, writable: true}));
|
||||
__feature__("js.Boot.isClass", String.__name__ = __feature__("Type.getClassName", "String", true));
|
||||
__feature__("Type.resolveClass", $hxClasses["Array"] = Array);
|
||||
__feature__("js.Boot.isClass", Array.__name__ = __feature__("Type.getClassName", "Array", true));
|
||||
|
||||
@ -62,7 +62,7 @@ class NativeStackTrace {
|
||||
for (i in 0...stack.length) {
|
||||
if(skip > i) continue;
|
||||
var line = stack[i];
|
||||
var matched:Null<Array<String>> = Syntax.code('{0}.match(/^ at ([A-Za-z0-9_. ]+) \\(([^)]+):([0-9]+):([0-9]+)\\)$/)', line);
|
||||
var matched:Null<Array<String>> = Syntax.code("{0}.match(/^ at ([$A-Za-z0-9_. ]+) \\(([^)]+):([0-9]+):([0-9]+)\\)$/)", line);
|
||||
if (matched != null) {
|
||||
var path = matched[1].split(".");
|
||||
if(path[0] == "$hxClasses") {
|
||||
|
||||
50
Kha/Tools/windows_x64/std/js/_std/haxe/atomic/AtomicInt.hx
Normal file
50
Kha/Tools/windows_x64/std/js/_std/haxe/atomic/AtomicInt.hx
Normal file
@ -0,0 +1,50 @@
|
||||
package haxe.atomic;
|
||||
|
||||
import js.lib.Atomics;
|
||||
|
||||
abstract AtomicInt(js.lib.Int32Array) {
|
||||
public inline function new(value:Int) {
|
||||
this = new js.lib.Int32Array(new js.lib.SharedArrayBuffer(js.lib.Int32Array.BYTES_PER_ELEMENT));
|
||||
this[0] = value;
|
||||
}
|
||||
|
||||
private function asArray():js.lib.Int32Array {
|
||||
return this;
|
||||
}
|
||||
|
||||
public inline function add(b:Int):Int {
|
||||
return Atomics.add(asArray(), 0, b);
|
||||
}
|
||||
|
||||
public inline function sub(b:Int):Int {
|
||||
return Atomics.sub(asArray(), 0, b);
|
||||
}
|
||||
|
||||
public inline function and(b:Int):Int {
|
||||
return Atomics.and(asArray(), 0, b);
|
||||
}
|
||||
|
||||
public inline function or(b:Int):Int {
|
||||
return Atomics.or(asArray(), 0, b);
|
||||
}
|
||||
|
||||
public inline function xor(b:Int):Int {
|
||||
return Atomics.xor(asArray(), 0, b);
|
||||
}
|
||||
|
||||
public inline function compareExchange(expected:Int, replacement:Int):Int {
|
||||
return Atomics.compareExchange(asArray(), 0, expected, replacement);
|
||||
}
|
||||
|
||||
public inline function exchange(value:Int):Int {
|
||||
return Atomics.exchange(asArray(), 0, value);
|
||||
}
|
||||
|
||||
public inline function load():Int {
|
||||
return Atomics.load(asArray(), 0);
|
||||
}
|
||||
|
||||
public inline function store(value:Int):Int {
|
||||
return Atomics.store(asArray(), 0, value);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ package haxe.ds;
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
s.add("[");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(i);
|
||||
@ -90,7 +90,7 @@ package haxe.ds;
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
s.add("]");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
|
||||
@ -27,13 +27,6 @@ import js.Lib;
|
||||
|
||||
@:coreApi
|
||||
class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
|
||||
static var count:Int;
|
||||
|
||||
// initialize count through __init__ magic, because these are generated
|
||||
// before normal static initializations for which ObjectMap should be ready to use
|
||||
// see https://github.com/HaxeFoundation/haxe/issues/6792
|
||||
static inline function __init__():Void
|
||||
count = 0;
|
||||
|
||||
static inline function assignId(obj:{}):Int {
|
||||
return Syntax.code('({0}.__id__ = {1})', obj, Lib.getNextHaxeUID());
|
||||
@ -113,7 +106,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
s.add("[");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(Std.string(i));
|
||||
@ -122,7 +115,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
s.add("]");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
|
||||
@ -87,12 +87,12 @@ import haxe.DynamicAccess;
|
||||
|
||||
@:analyzer(no_optimize)
|
||||
static function stringify(h:Dynamic):String {
|
||||
var s = "{", first = true;
|
||||
var s = "[", first = true;
|
||||
js.Syntax.code("for (var key in {0}) {", h);
|
||||
js.Syntax.code("\tif ({0}) {0} = false; else {1} += ',';", first, s);
|
||||
js.Syntax.code("\t{0} += key + ' => ' + {1}({2}[key]);", s, Std.string, h);
|
||||
js.Syntax.code("}");
|
||||
return s + "}";
|
||||
return s + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ private class StringMapIterator<T> {
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
s.add("[");
|
||||
var keys = arrayKeys();
|
||||
for (i in 0...keys.length) {
|
||||
var k = keys[i];
|
||||
@ -296,7 +296,7 @@ private class StringMapIterator<T> {
|
||||
if (i < keys.length - 1)
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
s.add("]");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user