forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -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));
|
||||
|
||||
Reference in New Issue
Block a user