Update Files
This commit is contained in:
171
Kha/Tools/linux_arm64/std/js/_std/haxe/Exception.hx
Normal file
171
Kha/Tools/linux_arm64/std/js/_std/haxe/Exception.hx
Normal file
@ -0,0 +1,171 @@
|
||||
package haxe;
|
||||
|
||||
import js.lib.Error;
|
||||
|
||||
@:coreApi
|
||||
class Exception extends NativeException {
|
||||
public var message(get,never):String;
|
||||
public var stack(get,never):CallStack;
|
||||
public var previous(get,never):Null<Exception>;
|
||||
public var native(get,never):Any;
|
||||
|
||||
@:ifFeature("haxe.Exception.get_stack")
|
||||
@:noCompletion var __skipStack:Int;
|
||||
@:noCompletion var __exceptionStack(get,set):Null<CallStack>;
|
||||
@:noCompletion var __nativeException:Any;
|
||||
@:noCompletion var __previousException:Null<Exception>;
|
||||
|
||||
static function caught(value:Any):Exception {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return value;
|
||||
} else if(Std.isOfType(value, Error)) {
|
||||
return new Exception((cast value:Error).message, null, value);
|
||||
} else {
|
||||
return new ValueException(value, null, value);
|
||||
}
|
||||
}
|
||||
|
||||
static function thrown(value:Any):Any {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return (value:Exception).native;
|
||||
} else if(Std.isOfType(value, Error)) {
|
||||
return value;
|
||||
} else {
|
||||
var e = new ValueException(value);
|
||||
untyped __feature__("haxe.Exception.get_stack", e.__shiftStack());
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
public function new(message:String, ?previous:Exception, ?native:Any) {
|
||||
super(message);
|
||||
(cast this).message = message;
|
||||
__previousException = previous;
|
||||
__nativeException = native != null ? native : this;
|
||||
untyped __feature__('haxe.Exception.stack', {
|
||||
__skipStack = 0;
|
||||
var old = js.Syntax.code('Error.prepareStackTrace');
|
||||
js.Syntax.code('Error.prepareStackTrace = function(e) { return e.stack; }');
|
||||
if(Std.isOfType(native, Error)) {
|
||||
(cast this).stack = native.stack;
|
||||
} else {
|
||||
var e:Error = null;
|
||||
if ((cast Error).captureStackTrace) {
|
||||
(cast Error).captureStackTrace(this, Exception);
|
||||
e = cast this;
|
||||
} else {
|
||||
e = new Error();
|
||||
//Internet Explorer provides call stack only if error was thrown
|
||||
if(js.Syntax.typeof(e.stack) == "undefined") {
|
||||
js.Syntax.code('try { throw {0}; } catch(_) {}', e);
|
||||
__skipStack++;
|
||||
}
|
||||
}
|
||||
(cast this).stack = e.stack;
|
||||
}
|
||||
js.Syntax.code('Error.prepareStackTrace = {0}', old);
|
||||
});
|
||||
}
|
||||
|
||||
function unwrap():Any {
|
||||
return __nativeException;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return message;
|
||||
}
|
||||
|
||||
public function details():String {
|
||||
return inline CallStack.exceptionToString(this);
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
@:ifFeature("haxe.Exception.get_stack")
|
||||
inline function __shiftStack():Void {
|
||||
__skipStack++;
|
||||
}
|
||||
|
||||
function get_message():String {
|
||||
return (cast this:Error).message;
|
||||
}
|
||||
|
||||
function get_previous():Null<Exception> {
|
||||
return __previousException;
|
||||
}
|
||||
|
||||
final function get_native():Any {
|
||||
return __nativeException;
|
||||
}
|
||||
|
||||
@:ifFeature('haxe.NativeStackTrace.exceptionStack')
|
||||
function get_stack():CallStack {
|
||||
return switch __exceptionStack {
|
||||
case null:
|
||||
__exceptionStack = NativeStackTrace.toHaxe(NativeStackTrace.normalize((cast this).stack), __skipStack);
|
||||
case s: s;
|
||||
}
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
function setProperty(name:String, value:Any):Void {
|
||||
try {
|
||||
js.lib.Object.defineProperty(this, name, {value:value});
|
||||
} catch(e:Exception) {
|
||||
js.Syntax.code('{0}[{1}] = {2}', this, name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function get___exceptionStack():CallStack {
|
||||
return (cast this).__exceptionStack;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function set___exceptionStack(value:CallStack):CallStack {
|
||||
setProperty('__exceptionStack', value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function get___skipStack():Int {
|
||||
return (cast this).__skipStack;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function set___skipStack(value:Int):Int {
|
||||
setProperty('__skipStack', value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function get___nativeException():Any {
|
||||
return (cast this).__nativeException;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function set___nativeException(value:Any):Any {
|
||||
setProperty('__nativeException', value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function get___previousException():Null<Exception> {
|
||||
return (cast this).__previousException;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
inline function set___previousException(value:Null<Exception>):Null<Exception> {
|
||||
setProperty('__previousException', value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@:dox(hide)
|
||||
@:noCompletion
|
||||
@:native('Error')
|
||||
private extern class NativeException {
|
||||
// private var message:String; //redefined in haxe.Exception
|
||||
// private var stack(default, null):String; //redefined in haxe.Exception
|
||||
|
||||
function new(?message:String);
|
||||
}
|
46
Kha/Tools/linux_arm64/std/js/_std/haxe/Json.hx
Normal file
46
Kha/Tools/linux_arm64/std/js/_std/haxe/Json.hx
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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
|
||||
#if !haxeJSON
|
||||
@:native("JSON")
|
||||
extern
|
||||
#end
|
||||
class Json {
|
||||
#if haxeJSON
|
||||
inline
|
||||
#end
|
||||
public static function parse(text:String):Dynamic
|
||||
#if !haxeJSON; #else {
|
||||
return haxe.format.JsonParser.parse(text);
|
||||
} #end
|
||||
|
||||
#if haxeJSON
|
||||
inline
|
||||
#end
|
||||
public static function stringify(value:Dynamic, ?replacer:(key:Dynamic, value:Dynamic) -> Dynamic, ?space:String):String
|
||||
#if !haxeJSON; #else {
|
||||
return haxe.format.JsonPrinter.print(value, replacer, space);
|
||||
} #end
|
||||
}
|
150
Kha/Tools/linux_arm64/std/js/_std/haxe/NativeStackTrace.hx
Normal file
150
Kha/Tools/linux_arm64/std/js/_std/haxe/NativeStackTrace.hx
Normal file
@ -0,0 +1,150 @@
|
||||
package haxe;
|
||||
|
||||
import js.Syntax;
|
||||
import js.lib.Error;
|
||||
import haxe.CallStack.StackItem;
|
||||
|
||||
// https://v8.dev/docs/stack-trace-api
|
||||
@:native("Error")
|
||||
private extern class V8Error {
|
||||
static var prepareStackTrace:(error:Error, structuredStackTrace:Array<V8CallSite>)->Any;
|
||||
}
|
||||
|
||||
typedef V8CallSite = {
|
||||
function getFunctionName():String;
|
||||
function getFileName():String;
|
||||
function getLineNumber():Int;
|
||||
function getColumnNumber():Int;
|
||||
}
|
||||
|
||||
/**
|
||||
Do not use manually.
|
||||
**/
|
||||
@:dox(hide)
|
||||
@:noCompletion
|
||||
@:allow(haxe.Exception)
|
||||
class NativeStackTrace {
|
||||
static var lastError:Error;
|
||||
|
||||
// support for source-map-support module
|
||||
@:noCompletion
|
||||
public static var wrapCallSite:V8CallSite->V8CallSite;
|
||||
|
||||
@:ifFeature('haxe.NativeStackTrace.exceptionStack')
|
||||
static public inline function saveStack(e:Error):Void {
|
||||
lastError = e;
|
||||
}
|
||||
|
||||
static public function callStack():Any {
|
||||
var e:Null<Error> = new Error('');
|
||||
var stack = tryHaxeStack(e);
|
||||
//Internet Explorer provides call stack only if error was thrown
|
||||
if(Syntax.typeof(stack) == "undefined") {
|
||||
try throw e catch(e:Exception) {}
|
||||
stack = e.stack;
|
||||
}
|
||||
return normalize(stack, 2);
|
||||
}
|
||||
|
||||
static public function exceptionStack():Any {
|
||||
return normalize(tryHaxeStack(lastError));
|
||||
}
|
||||
|
||||
static public function toHaxe(s:Null<Any>, skip:Int = 0):Array<StackItem> {
|
||||
if (s == null) {
|
||||
return [];
|
||||
} else if (Syntax.typeof(s) == "string") {
|
||||
// Return the raw lines in browsers that don't support prepareStackTrace
|
||||
var stack:Array<String> = (s:String).split("\n");
|
||||
if (stack[0] == "Error")
|
||||
stack.shift();
|
||||
var m = [];
|
||||
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);
|
||||
if (matched != null) {
|
||||
var path = matched[1].split(".");
|
||||
if(path[0] == "$hxClasses") {
|
||||
path.shift();
|
||||
}
|
||||
var meth = path.pop();
|
||||
var file = matched[2];
|
||||
var line = Std.parseInt(matched[3]);
|
||||
var column = Std.parseInt(matched[4]);
|
||||
m.push(FilePos(meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."), meth), file, line,
|
||||
column));
|
||||
} else {
|
||||
m.push(Module(StringTools.trim(line))); // A little weird, but better than nothing
|
||||
}
|
||||
}
|
||||
return m;
|
||||
} else if(skip > 0 && Syntax.code('Array.isArray({0})', s)) {
|
||||
return (s:Array<StackItem>).slice(skip);
|
||||
} else {
|
||||
return cast s;
|
||||
}
|
||||
}
|
||||
|
||||
static function tryHaxeStack(e:Null<Error>):Any {
|
||||
if (e == null) {
|
||||
return [];
|
||||
}
|
||||
// https://v8.dev/docs/stack-trace-api
|
||||
var oldValue = V8Error.prepareStackTrace;
|
||||
V8Error.prepareStackTrace = prepareHxStackTrace;
|
||||
var stack = e.stack;
|
||||
V8Error.prepareStackTrace = oldValue;
|
||||
return stack;
|
||||
}
|
||||
|
||||
static function prepareHxStackTrace(e:Error, callsites:Array<V8CallSite>):Any {
|
||||
var stack = [];
|
||||
for (site in callsites) {
|
||||
if (wrapCallSite != null)
|
||||
site = wrapCallSite(site);
|
||||
var method = null;
|
||||
var fullName = site.getFunctionName();
|
||||
if (fullName != null) {
|
||||
var idx = fullName.lastIndexOf(".");
|
||||
if (idx >= 0) {
|
||||
var className = fullName.substring(0, idx);
|
||||
var methodName = fullName.substring(idx + 1);
|
||||
method = Method(className, methodName);
|
||||
} else {
|
||||
method = Method(null, fullName);
|
||||
}
|
||||
}
|
||||
var fileName = site.getFileName();
|
||||
var fileAddr = fileName == null ? -1 : fileName.indexOf("file:");
|
||||
if (wrapCallSite != null && fileAddr > 0)
|
||||
fileName = fileName.substring(fileAddr + 6);
|
||||
stack.push(FilePos(method, fileName, site.getLineNumber(), site.getColumnNumber()));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
static function normalize(stack:Any, skipItems:Int = 0):Any {
|
||||
if(Syntax.code('Array.isArray({0})', stack) && skipItems > 0) {
|
||||
return (stack:Array<StackItem>).slice(skipItems);
|
||||
} else if(Syntax.typeof(stack) == "string") {
|
||||
switch (stack:String).substring(0, 6) {
|
||||
case 'Error:' | 'Error\n': skipItems += 1;
|
||||
case _:
|
||||
}
|
||||
return skipLines(stack, skipItems);
|
||||
} else {
|
||||
//nothing we can do
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
static function skipLines(stack:String, skip:Int, pos:Int = 0):String {
|
||||
return if(skip > 0) {
|
||||
pos = stack.indexOf('\n', pos);
|
||||
return pos < 0 ? '' : skipLines(stack, --skip, pos + 1);
|
||||
} else {
|
||||
return stack.substring(pos);
|
||||
}
|
||||
}
|
||||
}
|
100
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/IntMap.hx
Normal file
100
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/IntMap.hx
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.ds;
|
||||
|
||||
@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
|
||||
private var h:Dynamic;
|
||||
|
||||
public inline function new():Void {
|
||||
h = {};
|
||||
}
|
||||
|
||||
public inline function set(key:Int, value:T):Void {
|
||||
h[key] = value;
|
||||
}
|
||||
|
||||
public inline function get(key:Int):Null<T> {
|
||||
return h[key];
|
||||
}
|
||||
|
||||
public inline function exists(key:Int):Bool {
|
||||
return (cast h).hasOwnProperty(key);
|
||||
}
|
||||
|
||||
public function remove(key:Int):Bool {
|
||||
if (!(cast h).hasOwnProperty(key))
|
||||
return false;
|
||||
js.Syntax.delete(h, key);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function keys():Iterator<Int> {
|
||||
var a = [];
|
||||
js.Syntax.code("for( var key in {0} ) if({0}.hasOwnProperty(key)) {1}.push(+key)", h, a);
|
||||
return a.iterator();
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return untyped {
|
||||
ref: h,
|
||||
it: keys(),
|
||||
hasNext: function() {
|
||||
return __this__.it.hasNext();
|
||||
},
|
||||
next: function() {
|
||||
var i = __this__.it.next();
|
||||
return __this__.ref[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<Int, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():IntMap<T> {
|
||||
var copied = new IntMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(i);
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(i)));
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h = {};
|
||||
}
|
||||
}
|
132
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/ObjectMap.hx
Normal file
132
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/ObjectMap.hx
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C)2005-2019 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of h 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 h 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.ds;
|
||||
|
||||
import js.Syntax;
|
||||
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());
|
||||
}
|
||||
|
||||
static inline function getId(obj:{}):Int {
|
||||
return untyped obj.__id__;
|
||||
}
|
||||
|
||||
var h:{__keys__:{}};
|
||||
|
||||
public function new():Void {
|
||||
h = {__keys__: {}};
|
||||
}
|
||||
|
||||
public function set(key:K, value:V):Void {
|
||||
var id = getId(key);
|
||||
if(id == null) {
|
||||
id = assignId(key);
|
||||
}
|
||||
Syntax.code('{0}[{1}] = {2}', h, id, value);
|
||||
Syntax.code('{0}[{1}] = {2}', h.__keys__, id, key);
|
||||
}
|
||||
|
||||
public inline function get(key:K):Null<V> {
|
||||
return untyped h[getId(key)];
|
||||
}
|
||||
|
||||
public inline function exists(key:K):Bool {
|
||||
return untyped h.__keys__[getId(key)] != null;
|
||||
}
|
||||
|
||||
public function remove(key:K):Bool {
|
||||
var id = getId(key);
|
||||
if (untyped h.__keys__[id] == null)
|
||||
return false;
|
||||
js.Syntax.delete(h, id);
|
||||
js.Syntax.delete(h.__keys__, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function keys():Iterator<K> {
|
||||
var a = [];
|
||||
untyped {
|
||||
js.Syntax.code("for( var key in this.h.__keys__ ) {");
|
||||
if (h.hasOwnProperty(key))
|
||||
a.push(h.__keys__[key]);
|
||||
js.Syntax.code("}");
|
||||
}
|
||||
return a.iterator();
|
||||
}
|
||||
|
||||
public function iterator():Iterator<V> {
|
||||
return untyped {
|
||||
ref: h,
|
||||
it: keys(),
|
||||
hasNext: function() {
|
||||
return __this__.it.hasNext();
|
||||
},
|
||||
next: function() {
|
||||
var i = __this__.it.next();
|
||||
return __this__.ref[getId(i)];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<K, V> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():ObjectMap<K, V> {
|
||||
var copied = new ObjectMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(Std.string(i));
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(i)));
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h = {__keys__: {}};
|
||||
}
|
||||
}
|
312
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/StringMap.hx
Normal file
312
Kha/Tools/linux_arm64/std/js/_std/haxe/ds/StringMap.hx
Normal file
@ -0,0 +1,312 @@
|
||||
/*
|
||||
* 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.ds;
|
||||
|
||||
import js.lib.Object;
|
||||
import haxe.Constraints.IMap;
|
||||
import haxe.DynamicAccess;
|
||||
|
||||
#if (js_es >= 5)
|
||||
@:coreApi class StringMap<T> implements IMap<String, T> {
|
||||
var h:Dynamic;
|
||||
|
||||
public inline function new() {
|
||||
h = Object.create(null);
|
||||
}
|
||||
|
||||
public inline function exists(key:String):Bool {
|
||||
return Object.prototype.hasOwnProperty.call(h, key);
|
||||
}
|
||||
|
||||
public inline function get(key:String):Null<T> {
|
||||
return h[cast key];
|
||||
}
|
||||
|
||||
public inline function set(key:String, value:T):Void {
|
||||
h[cast key] = value;
|
||||
}
|
||||
|
||||
public inline function remove(key:String):Bool {
|
||||
return if (exists(key)) {
|
||||
js.Syntax.delete(h, key); true;
|
||||
} else {
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function keys():Iterator<String> {
|
||||
return new StringMapKeyIterator(h);
|
||||
}
|
||||
|
||||
public inline function iterator():Iterator<T> {
|
||||
return new StringMapValueIterator(h);
|
||||
}
|
||||
|
||||
public inline function keyValueIterator():KeyValueIterator<String, T> {
|
||||
return new StringMapKeyValueIterator(h);
|
||||
}
|
||||
|
||||
public inline function copy():StringMap<T> {
|
||||
return createCopy(h);
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h = Object.create(null);
|
||||
}
|
||||
|
||||
public inline function toString():String {
|
||||
return stringify(h);
|
||||
}
|
||||
|
||||
// impl
|
||||
static function createCopy<T>(h:Dynamic):StringMap<T> {
|
||||
var copy = new StringMap();
|
||||
js.Syntax.code("for (var key in {0}) {1}[key] = {0}[key]", h, copy.h);
|
||||
return copy;
|
||||
}
|
||||
|
||||
@:analyzer(no_optimize)
|
||||
static function stringify(h:Dynamic):String {
|
||||
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 + "}";
|
||||
}
|
||||
}
|
||||
|
||||
private class StringMapKeyIterator {
|
||||
final h:Dynamic;
|
||||
final keys:Array<String>;
|
||||
final length:Int;
|
||||
var current:Int;
|
||||
|
||||
public inline function new(h:Dynamic) {
|
||||
this.h = h;
|
||||
keys = Object.keys(h);
|
||||
length = keys.length;
|
||||
current = 0;
|
||||
}
|
||||
|
||||
public inline function hasNext():Bool {
|
||||
return current < length;
|
||||
}
|
||||
|
||||
public inline function next():String {
|
||||
return keys[current++];
|
||||
}
|
||||
}
|
||||
|
||||
private class StringMapValueIterator<T> {
|
||||
final h:Dynamic;
|
||||
final keys:Array<String>;
|
||||
final length:Int;
|
||||
var current:Int;
|
||||
|
||||
public inline function new(h:Dynamic) {
|
||||
this.h = h;
|
||||
keys = Object.keys(h);
|
||||
length = keys.length;
|
||||
current = 0;
|
||||
}
|
||||
|
||||
public inline function hasNext():Bool {
|
||||
return current < length;
|
||||
}
|
||||
|
||||
public inline function next():T {
|
||||
return h[cast keys[current++]];
|
||||
}
|
||||
}
|
||||
|
||||
private class StringMapKeyValueIterator<T> {
|
||||
final h:Dynamic;
|
||||
final keys:Array<String>;
|
||||
final length:Int;
|
||||
var current:Int;
|
||||
|
||||
public inline function new(h:Dynamic) {
|
||||
this.h = h;
|
||||
keys = Object.keys(h);
|
||||
length = keys.length;
|
||||
current = 0;
|
||||
}
|
||||
|
||||
public inline function hasNext():Bool {
|
||||
return current < length;
|
||||
}
|
||||
|
||||
public inline function next():{key:String, value:T} {
|
||||
var key = keys[current++];
|
||||
return {key: key, value: h[cast key]};
|
||||
}
|
||||
}
|
||||
#else
|
||||
private class StringMapIterator<T> {
|
||||
var map:StringMap<T>;
|
||||
var keys:Array<String>;
|
||||
var index:Int;
|
||||
var count:Int;
|
||||
|
||||
public inline function new(map:StringMap<T>, keys:Array<String>) {
|
||||
this.map = map;
|
||||
this.keys = keys;
|
||||
this.index = 0;
|
||||
this.count = keys.length;
|
||||
}
|
||||
|
||||
public inline function hasNext() {
|
||||
return index < count;
|
||||
}
|
||||
|
||||
public inline function next() {
|
||||
return map.get(keys[index++]);
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi class StringMap<T> implements haxe.Constraints.IMap<String, T> {
|
||||
private var h:Dynamic;
|
||||
private var rh:Dynamic;
|
||||
|
||||
public inline function new():Void {
|
||||
h = {};
|
||||
}
|
||||
|
||||
inline function isReserved(key:String):Bool {
|
||||
return js.Syntax.code("__map_reserved[{0}]", key) != null;
|
||||
}
|
||||
|
||||
public inline function set(key:String, value:T):Void {
|
||||
if (isReserved(key))
|
||||
setReserved(key, value);
|
||||
else
|
||||
h[cast key] = value;
|
||||
}
|
||||
|
||||
public inline function get(key:String):Null<T> {
|
||||
if (isReserved(key))
|
||||
return getReserved(key);
|
||||
return h[cast key];
|
||||
}
|
||||
|
||||
public inline function exists(key:String):Bool {
|
||||
if (isReserved(key))
|
||||
return existsReserved(key);
|
||||
return h.hasOwnProperty(key);
|
||||
}
|
||||
|
||||
function setReserved(key:String, value:T):Void {
|
||||
if (rh == null)
|
||||
rh = {};
|
||||
rh[cast "$" + key] = value;
|
||||
}
|
||||
|
||||
function getReserved(key:String):Null<T> {
|
||||
return rh == null ? null : rh[cast "$" + key];
|
||||
}
|
||||
|
||||
function existsReserved(key:String):Bool {
|
||||
if (rh == null)
|
||||
return false;
|
||||
return (cast rh).hasOwnProperty("$" + key);
|
||||
}
|
||||
|
||||
public function remove(key:String):Bool {
|
||||
if (isReserved(key)) {
|
||||
key = "$" + key;
|
||||
if (rh == null || !rh.hasOwnProperty(key))
|
||||
return false;
|
||||
js.Syntax.delete(rh, key);
|
||||
return true;
|
||||
} else {
|
||||
if (!h.hasOwnProperty(key))
|
||||
return false;
|
||||
js.Syntax.delete(h, key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function keys():Iterator<String> {
|
||||
return arrayKeys().iterator();
|
||||
}
|
||||
|
||||
function arrayKeys():Array<String> {
|
||||
var out = [];
|
||||
untyped {
|
||||
js.Syntax.code("for( var key in this.h ) {");
|
||||
if (h.hasOwnProperty(key))
|
||||
out.push(key);
|
||||
js.Syntax.code("}");
|
||||
}
|
||||
if (rh != null)
|
||||
untyped {
|
||||
js.Syntax.code("for( var key in this.rh ) {");
|
||||
if (key.charCodeAt(0) == "$".code)
|
||||
out.push(key.substr(1));
|
||||
js.Syntax.code("}");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public inline function iterator():Iterator<T> {
|
||||
return new StringMapIterator(this, arrayKeys());
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<String, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():StringMap<T> {
|
||||
var copied = new StringMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
var keys = arrayKeys();
|
||||
for (i in 0...keys.length) {
|
||||
var k = keys[i];
|
||||
s.add(k);
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(k)));
|
||||
if (i < keys.length - 1)
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h = {};
|
||||
rh = null;
|
||||
}
|
||||
|
||||
static function __init__():Void {
|
||||
js.Syntax.code("var __map_reserved = {};");
|
||||
}
|
||||
}
|
||||
#end
|
57
Kha/Tools/linux_arm64/std/js/_std/haxe/io/ArrayBufferView.hx
Normal file
57
Kha/Tools/linux_arm64/std/js/_std/haxe/io/ArrayBufferView.hx
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef ArrayBufferViewData = js.lib.ArrayBufferView;
|
||||
|
||||
abstract ArrayBufferView(ArrayBufferViewData) {
|
||||
public var buffer(get, never):haxe.io.Bytes;
|
||||
public var byteOffset(get, never):Int;
|
||||
public var byteLength(get, never):Int;
|
||||
|
||||
public inline function new(size:Int) {
|
||||
this = new js.lib.Uint8Array(size);
|
||||
}
|
||||
|
||||
inline function get_byteOffset()
|
||||
return this.byteOffset;
|
||||
|
||||
inline function get_byteLength()
|
||||
return this.byteLength;
|
||||
|
||||
inline function get_buffer():haxe.io.Bytes {
|
||||
return haxe.io.Bytes.ofData(this.buffer);
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int) {
|
||||
return fromData(new js.lib.Uint8Array(this.buffer, begin, length == null ? this.buffer.byteLength - begin : length));
|
||||
}
|
||||
|
||||
public inline function getData():ArrayBufferViewData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(a:ArrayBufferViewData):ArrayBufferView {
|
||||
return cast a;
|
||||
}
|
||||
}
|
272
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Bytes.hx
Normal file
272
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Bytes.hx
Normal file
@ -0,0 +1,272 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@:coreApi
|
||||
class Bytes {
|
||||
public var length(default, null):Int;
|
||||
|
||||
var b:js.lib.Uint8Array;
|
||||
var data:js.lib.DataView;
|
||||
|
||||
function new(data:BytesData) {
|
||||
this.length = data.byteLength;
|
||||
this.b = new js.lib.Uint8Array(data);
|
||||
untyped {
|
||||
b.bufferValue = data; // some impl does not return the same instance in .buffer
|
||||
data.hxBytes = this;
|
||||
data.bytes = this.b;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function get(pos:Int):Int {
|
||||
return b[pos];
|
||||
}
|
||||
|
||||
public inline function set(pos:Int, v:Int):Void {
|
||||
b[pos] = v;
|
||||
}
|
||||
|
||||
public function blit(pos:Int, src:Bytes, srcpos:Int, len:Int):Void {
|
||||
if (pos < 0 || srcpos < 0 || len < 0 || pos + len > length || srcpos + len > src.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (srcpos == 0 && len == src.b.byteLength)
|
||||
b.set(src.b, pos);
|
||||
else
|
||||
b.set(src.b.subarray(srcpos, srcpos + len), pos);
|
||||
}
|
||||
|
||||
public function fill(pos:Int, len:Int, value:Int):Void {
|
||||
for (i in 0...len)
|
||||
set(pos++, value);
|
||||
}
|
||||
|
||||
public function sub(pos:Int, len:Int):Bytes {
|
||||
if (pos < 0 || len < 0 || pos + len > length)
|
||||
throw Error.OutsideBounds;
|
||||
return new Bytes(b.buffer.slice(pos + b.byteOffset, pos + b.byteOffset + len));
|
||||
}
|
||||
|
||||
public function compare(other:Bytes):Int {
|
||||
var b1 = b;
|
||||
var b2 = other.b;
|
||||
var len = (length < other.length) ? length : other.length;
|
||||
for (i in 0...len)
|
||||
if (b1[i] != b2[i])
|
||||
return b1[i] - b2[i];
|
||||
return length - other.length;
|
||||
}
|
||||
|
||||
inline function initData():Void {
|
||||
if (data == null)
|
||||
data = new js.lib.DataView(b.buffer, b.byteOffset, b.byteLength);
|
||||
}
|
||||
|
||||
public function getDouble(pos:Int):Float {
|
||||
initData();
|
||||
return data.getFloat64(pos, true);
|
||||
}
|
||||
|
||||
public function getFloat(pos:Int):Float {
|
||||
initData();
|
||||
return data.getFloat32(pos, true);
|
||||
}
|
||||
|
||||
public function setDouble(pos:Int, v:Float):Void {
|
||||
initData();
|
||||
data.setFloat64(pos, v, true);
|
||||
}
|
||||
|
||||
public function setFloat(pos:Int, v:Float):Void {
|
||||
initData();
|
||||
data.setFloat32(pos, v, true);
|
||||
}
|
||||
|
||||
public function getUInt16(pos:Int):Int {
|
||||
initData();
|
||||
return data.getUint16(pos, true);
|
||||
}
|
||||
|
||||
public function setUInt16(pos:Int, v:Int):Void {
|
||||
initData();
|
||||
data.setUint16(pos, v, true);
|
||||
}
|
||||
|
||||
public function getInt32(pos:Int):Int {
|
||||
initData();
|
||||
return data.getInt32(pos, true);
|
||||
}
|
||||
|
||||
public function setInt32(pos:Int, v:Int):Void {
|
||||
initData();
|
||||
data.setInt32(pos, v, true);
|
||||
}
|
||||
|
||||
public function getInt64(pos:Int):haxe.Int64 {
|
||||
return Int64.make(getInt32(pos + 4), getInt32(pos));
|
||||
}
|
||||
|
||||
public function setInt64(pos:Int, v:haxe.Int64):Void {
|
||||
setInt32(pos, v.low);
|
||||
setInt32(pos + 4, v.high);
|
||||
}
|
||||
|
||||
public function getString(pos:Int, len:Int, ?encoding:Encoding):String {
|
||||
if (pos < 0 || len < 0 || pos + len > length)
|
||||
throw Error.OutsideBounds;
|
||||
if (encoding == null)
|
||||
encoding = UTF8;
|
||||
var s = "";
|
||||
var b = b;
|
||||
var i = pos;
|
||||
var max = pos + len;
|
||||
switch (encoding) {
|
||||
case UTF8:
|
||||
var debug = pos > 0;
|
||||
// utf8-decode and utf16-encode
|
||||
while (i < max) {
|
||||
var c = b[i++];
|
||||
if (c < 0x80) {
|
||||
if (c == 0)
|
||||
break;
|
||||
s += String.fromCharCode(c);
|
||||
} else if (c < 0xE0)
|
||||
s += String.fromCharCode(((c & 0x3F) << 6) | (b[i++] & 0x7F));
|
||||
else if (c < 0xF0) {
|
||||
var c2 = b[i++];
|
||||
s += String.fromCharCode(((c & 0x1F) << 12) | ((c2 & 0x7F) << 6) | (b[i++] & 0x7F));
|
||||
} else {
|
||||
var c2 = b[i++];
|
||||
var c3 = b[i++];
|
||||
var u = ((c & 0x0F) << 18) | ((c2 & 0x7F) << 12) | ((c3 & 0x7F) << 6) | (b[i++] & 0x7F);
|
||||
s += String.fromCharCode(u);
|
||||
}
|
||||
}
|
||||
case RawNative:
|
||||
while (i < max) {
|
||||
var c = b[i++] | (b[i++] << 8);
|
||||
s += String.fromCharCode(c);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@:deprecated("readString is deprecated, use getString instead")
|
||||
@:noCompletion
|
||||
public inline function readString(pos:Int, len:Int):String {
|
||||
return getString(pos, len);
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return getString(0, length);
|
||||
}
|
||||
|
||||
public function toHex():String {
|
||||
var s = new StringBuf();
|
||||
var chars = [];
|
||||
var str = "0123456789abcdef";
|
||||
for (i in 0...str.length)
|
||||
chars.push(str.charCodeAt(i));
|
||||
for (i in 0...length) {
|
||||
var c = get(i);
|
||||
s.addChar(chars[c >> 4]);
|
||||
s.addChar(chars[c & 15]);
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function getData():BytesData {
|
||||
return untyped b.bufferValue;
|
||||
}
|
||||
|
||||
public static inline function alloc(length:Int):Bytes {
|
||||
return new Bytes(new BytesData(length));
|
||||
}
|
||||
|
||||
public static function ofString(s:String, ?encoding:Encoding):Bytes {
|
||||
if (encoding == RawNative) {
|
||||
var buf = new js.lib.Uint8Array(s.length << 1);
|
||||
for (i in 0...s.length) {
|
||||
var c:Int = StringTools.fastCodeAt(s, i);
|
||||
buf[i << 1] = c & 0xFF;
|
||||
buf[(i << 1) | 1] = c >> 8;
|
||||
}
|
||||
return new Bytes(buf.buffer);
|
||||
}
|
||||
var a = new Array();
|
||||
// utf16-decode and utf8-encode
|
||||
var i = 0;
|
||||
while (i < s.length) {
|
||||
var c:Int = StringTools.fastCodeAt(s, i++);
|
||||
// surrogate pair
|
||||
if (0xD800 <= c && c <= 0xDBFF)
|
||||
c = (c - 0xD7C0 << 10) | (StringTools.fastCodeAt(s, i++) & 0x3FF);
|
||||
if (c <= 0x7F)
|
||||
a.push(c);
|
||||
else if (c <= 0x7FF) {
|
||||
a.push(0xC0 | (c >> 6));
|
||||
a.push(0x80 | (c & 63));
|
||||
} else if (c <= 0xFFFF) {
|
||||
a.push(0xE0 | (c >> 12));
|
||||
a.push(0x80 | ((c >> 6) & 63));
|
||||
a.push(0x80 | (c & 63));
|
||||
} else {
|
||||
a.push(0xF0 | (c >> 18));
|
||||
a.push(0x80 | ((c >> 12) & 63));
|
||||
a.push(0x80 | ((c >> 6) & 63));
|
||||
a.push(0x80 | (c & 63));
|
||||
}
|
||||
}
|
||||
return new Bytes(new js.lib.Uint8Array(a).buffer);
|
||||
}
|
||||
|
||||
public static function ofData(b:BytesData):Bytes {
|
||||
var hb = untyped b.hxBytes;
|
||||
if (hb != null)
|
||||
return hb;
|
||||
return new Bytes(b);
|
||||
}
|
||||
|
||||
public static function ofHex(s:String):Bytes {
|
||||
if ((s.length & 1) != 0)
|
||||
throw "Not a hex string (odd number of digits)";
|
||||
var a = new Array();
|
||||
var i = 0;
|
||||
var len = s.length >> 1;
|
||||
while (i < len) {
|
||||
var high = StringTools.fastCodeAt(s, i * 2);
|
||||
var low = StringTools.fastCodeAt(s, i * 2 + 1);
|
||||
high = (high & 0xF) + ((high & 0x40) >> 6) * 9;
|
||||
low = (low & 0xF) + ((low & 0x40) >> 6) * 9;
|
||||
a.push(((high << 4) | low) & 0xFF);
|
||||
i++;
|
||||
}
|
||||
|
||||
return new Bytes(new js.lib.Uint8Array(a).buffer);
|
||||
}
|
||||
|
||||
public inline static function fastGet(b:BytesData, pos:Int):Int {
|
||||
// this requires that we have wrapped it with haxe.io.Bytes beforehand
|
||||
return untyped b.bytes[pos];
|
||||
}
|
||||
}
|
127
Kha/Tools/linux_arm64/std/js/_std/haxe/io/BytesBuffer.hx
Normal file
127
Kha/Tools/linux_arm64/std/js/_std/haxe/io/BytesBuffer.hx
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@:coreApi
|
||||
class BytesBuffer {
|
||||
var buffer:js.lib.ArrayBuffer;
|
||||
var view:js.lib.DataView;
|
||||
var u8:js.lib.Uint8Array;
|
||||
var pos:Int;
|
||||
var size:Int;
|
||||
|
||||
public var length(get, never):Int;
|
||||
|
||||
public function new() {
|
||||
pos = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public function addByte(byte:Int):Void {
|
||||
if (pos == size)
|
||||
grow(1);
|
||||
view.setUint8(pos++, byte);
|
||||
}
|
||||
|
||||
public function add(src:Bytes):Void {
|
||||
if (pos + src.length > size)
|
||||
grow(src.length);
|
||||
if (size == 0)
|
||||
return;
|
||||
var sub = new js.lib.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset, src.length);
|
||||
u8.set(sub, pos);
|
||||
pos += src.length;
|
||||
}
|
||||
|
||||
public function addString(v:String, ?encoding:Encoding):Void {
|
||||
add(Bytes.ofString(v, encoding));
|
||||
}
|
||||
|
||||
public function addInt32(v:Int):Void {
|
||||
if (pos + 4 > size)
|
||||
grow(4);
|
||||
view.setInt32(pos, v, true);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
public function addInt64(v:haxe.Int64):Void {
|
||||
if (pos + 8 > size)
|
||||
grow(8);
|
||||
view.setInt32(pos, v.low, true);
|
||||
view.setInt32(pos + 4, v.high, true);
|
||||
pos += 8;
|
||||
}
|
||||
|
||||
public function addFloat(v:Float):Void {
|
||||
if (pos + 4 > size)
|
||||
grow(4);
|
||||
view.setFloat32(pos, v, true);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
public function addDouble(v:Float):Void {
|
||||
if (pos + 8 > size)
|
||||
grow(8);
|
||||
view.setFloat64(pos, v, true);
|
||||
pos += 8;
|
||||
}
|
||||
|
||||
public function addBytes(src:Bytes, pos:Int, len:Int):Void {
|
||||
if (pos < 0 || len < 0 || pos + len > src.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (this.pos + len > size)
|
||||
grow(len);
|
||||
if (size == 0)
|
||||
return;
|
||||
var sub = new js.lib.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset + pos, len);
|
||||
u8.set(sub, this.pos);
|
||||
this.pos += len;
|
||||
}
|
||||
|
||||
function grow(delta:Int):Void {
|
||||
var req = pos + delta;
|
||||
var nsize = size == 0 ? 16 : size;
|
||||
while (nsize < req)
|
||||
nsize = (nsize * 3) >> 1;
|
||||
var nbuf = new js.lib.ArrayBuffer(nsize);
|
||||
var nu8 = new js.lib.Uint8Array(nbuf);
|
||||
if (size > 0)
|
||||
nu8.set(u8);
|
||||
size = nsize;
|
||||
buffer = nbuf;
|
||||
u8 = nu8;
|
||||
view = new js.lib.DataView(buffer);
|
||||
}
|
||||
|
||||
public function getBytes():Bytes@:privateAccess {
|
||||
if (size == 0)
|
||||
return haxe.io.Bytes.alloc(0);
|
||||
var b = new Bytes(buffer);
|
||||
b.length = pos;
|
||||
return b;
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Float32Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Float32Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef Float32ArrayData = js.lib.Float32Array;
|
||||
|
||||
@:coreApi
|
||||
abstract Float32Array(Float32ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 4;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int):Void {
|
||||
this = new Float32ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):Float {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:Float):Float {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):Float32Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):Float32Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():Float32ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public inline static function fromData(d:Float32ArrayData):Float32Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<Float>, pos:Int = 0, ?length:Int):Float32Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new Float32ArrayData(a));
|
||||
var i = new Float32Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):Float32Array {
|
||||
if (length == null)
|
||||
length = (bytes.length - bytePos) >> 2;
|
||||
return fromData(new Float32ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Float64Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Float64Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef Float64ArrayData = js.lib.Float64Array;
|
||||
|
||||
@:coreApi
|
||||
abstract Float64Array(Float64ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 8;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int):Void {
|
||||
this = new Float64ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):Float {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:Float):Float {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):Float64Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):Float64Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():Float64ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(d:Float64ArrayData):Float64Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<Float>, pos:Int = 0, ?length:Int):Float64Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new Float64ArrayData(a));
|
||||
var i = new Float64Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):Float64Array {
|
||||
if (length == null)
|
||||
length = (bytes.length - bytePos) >> 3;
|
||||
return fromData(new Float64ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Int32Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/Int32Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef Int32ArrayData = js.lib.Int32Array;
|
||||
|
||||
@:coreApi
|
||||
abstract Int32Array(Int32ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 4;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int) {
|
||||
this = new Int32ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):Int {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:Int):Int {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):Int32Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):Int32Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():Int32ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(d:Int32ArrayData):Int32Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<Int>, pos:Int = 0, ?length:Int):Int32Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new Int32ArrayData(a));
|
||||
var i = new Int32Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):Int32Array {
|
||||
if (length == null)
|
||||
length = (bytes.length - bytePos) >> 2;
|
||||
return fromData(new Int32ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt16Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt16Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef UInt16ArrayData = js.lib.Uint16Array;
|
||||
|
||||
@:coreApi
|
||||
abstract UInt16Array(UInt16ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 2;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int) {
|
||||
this = new UInt16ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):Int {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:Int):Int {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):UInt16Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):UInt16Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():UInt16ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(d:UInt16ArrayData):UInt16Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<Int>, pos:Int = 0, ?length:Int):UInt16Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new UInt16ArrayData(a));
|
||||
var i = new UInt16Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):UInt16Array {
|
||||
if (length == null)
|
||||
length = (bytes.length - bytePos) >> 1;
|
||||
return fromData(new UInt16ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt32Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt32Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef UInt32ArrayData = js.lib.Uint32Array;
|
||||
|
||||
@:coreApi
|
||||
abstract UInt32Array(UInt32ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 4;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int) {
|
||||
this = new UInt32ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):UInt {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:UInt):UInt {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):UInt32Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):UInt32Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():UInt32ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(d:UInt32ArrayData):UInt32Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<UInt>, pos:Int = 0, ?length:Int):UInt32Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new UInt32ArrayData(a));
|
||||
var i = new UInt32Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):UInt32Array {
|
||||
if (length == null)
|
||||
length = (bytes.length - bytePos) >> 2;
|
||||
return fromData(new UInt32ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt8Array.hx
Normal file
88
Kha/Tools/linux_arm64/std/js/_std/haxe/io/UInt8Array.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef UInt8ArrayData = js.lib.Uint8Array;
|
||||
|
||||
@:coreApi
|
||||
abstract UInt8Array(UInt8ArrayData) {
|
||||
public static inline var BYTES_PER_ELEMENT = 1;
|
||||
|
||||
public var length(get, never):Int;
|
||||
public var view(get, never):ArrayBufferView;
|
||||
|
||||
public inline function new(elements:Int) {
|
||||
this = new UInt8ArrayData(elements);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function get_view():ArrayBufferView {
|
||||
return ArrayBufferView.fromData(this);
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function get(index:Int):Int {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:arrayAccess public inline function set(index:Int, value:Int):Int {
|
||||
return this[index] = value;
|
||||
}
|
||||
|
||||
public inline function sub(begin:Int, ?length:Int):UInt8Array {
|
||||
return fromData(this.subarray(begin, length == null ? this.length : begin + length));
|
||||
}
|
||||
|
||||
public inline function subarray(?begin:Int, ?end:Int):UInt8Array {
|
||||
return fromData(this.subarray(begin, end));
|
||||
}
|
||||
|
||||
public inline function getData():UInt8ArrayData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static inline function fromData(d:UInt8ArrayData):UInt8Array {
|
||||
return cast d;
|
||||
}
|
||||
|
||||
public static function fromArray(a:Array<Int>, pos:Int = 0, ?length:Int):UInt8Array {
|
||||
if (length == null)
|
||||
length = a.length - pos;
|
||||
if (pos < 0 || length < 0 || pos + length > a.length)
|
||||
throw Error.OutsideBounds;
|
||||
if (pos == 0 && length == a.length)
|
||||
return fromData(new UInt8ArrayData(a));
|
||||
var i = new UInt8Array(a.length);
|
||||
for (idx in 0...length)
|
||||
i[idx] = a[idx + pos];
|
||||
return i;
|
||||
}
|
||||
|
||||
public static function fromBytes(bytes:haxe.io.Bytes, bytePos:Int = 0, ?length:Int):UInt8Array {
|
||||
if (length == null)
|
||||
length = bytes.length - bytePos;
|
||||
return fromData(new UInt8ArrayData(bytes.getData(), bytePos, length));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user