forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
92
Kha/Tools/macos_arm64/std/hl/_std/haxe/Exception.hx
Normal file
92
Kha/Tools/macos_arm64/std/hl/_std/haxe/Exception.hx
Normal file
@ -0,0 +1,92 @@
|
||||
package haxe;
|
||||
|
||||
@:coreApi
|
||||
class Exception {
|
||||
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;
|
||||
|
||||
@:noCompletion var __exceptionMessage:String;
|
||||
@:noCompletion var __exceptionStack:Null<CallStack>;
|
||||
@:noCompletion var __nativeStack:hl.NativeArray<#if (hl_ver >= "1.12.0") haxe.NativeStackTrace.Symbol #else hl.Bytes #end>;
|
||||
@:noCompletion @:ifFeature("haxe.Exception.get_stack") var __skipStack:Int = 0;
|
||||
@:noCompletion var __nativeException:Any;
|
||||
@:noCompletion var __previousException:Null<Exception>;
|
||||
|
||||
static function caught(value:Any):Exception {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return value;
|
||||
} else {
|
||||
var e = new ValueException(value, null, value);
|
||||
// Undo automatic __shiftStack()
|
||||
e.__unshiftStack();
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
static function thrown(value:Any):Any {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return (value:Exception).native;
|
||||
} else {
|
||||
var e = new ValueException(value);
|
||||
e.__shiftStack();
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
public function new(message:String, ?previous:Exception, ?native:Any) {
|
||||
__exceptionMessage = message;
|
||||
__previousException = previous;
|
||||
if(native != null) {
|
||||
__nativeStack = NativeStackTrace.exceptionStack();
|
||||
__nativeException = native;
|
||||
} else {
|
||||
__nativeStack = NativeStackTrace.callStack();
|
||||
__nativeException = this;
|
||||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
@:ifFeature("haxe.Exception.get_stack")
|
||||
inline function __unshiftStack():Void {
|
||||
__skipStack--;
|
||||
}
|
||||
|
||||
function get_message():String {
|
||||
return __exceptionMessage;
|
||||
}
|
||||
|
||||
function get_previous():Null<Exception> {
|
||||
return __previousException;
|
||||
}
|
||||
|
||||
final function get_native():Any {
|
||||
return __nativeException;
|
||||
}
|
||||
|
||||
function get_stack():CallStack {
|
||||
return switch __exceptionStack {
|
||||
case null: __exceptionStack = NativeStackTrace.toHaxe(__nativeStack, __skipStack);
|
||||
case s: s;
|
||||
}
|
||||
}
|
||||
}
|
||||
608
Kha/Tools/macos_arm64/std/hl/_std/haxe/Int64.hx
Normal file
608
Kha/Tools/macos_arm64/std/hl/_std/haxe/Int64.hx
Normal file
@ -0,0 +1,608 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
using haxe.Int64;
|
||||
|
||||
#if (hl_ver >= version("1.12.0") && !hl_legacy32)
|
||||
|
||||
import haxe.Int64Helper;
|
||||
|
||||
private typedef __Int64 = hl.I64;
|
||||
|
||||
@:coreApi
|
||||
@:transitive
|
||||
abstract Int64(__Int64) from __Int64 to __Int64 {
|
||||
|
||||
static var MASK : hl.I64 = {
|
||||
var v : hl.I64 = 0xFFFF;
|
||||
v | (v << 16);
|
||||
}
|
||||
|
||||
public static inline function make(high:Int32, low:Int32):Int64 {
|
||||
var h : hl.I64 = high;
|
||||
var l : hl.I64 = low;
|
||||
return cast ((h << 32) | (l&MASK));
|
||||
}
|
||||
|
||||
private inline function new(x:__Int64)
|
||||
this = x;
|
||||
|
||||
private var val(get, set):__Int64;
|
||||
|
||||
inline function get_val():__Int64
|
||||
return this;
|
||||
|
||||
inline function set_val(x:__Int64):__Int64
|
||||
return this = x;
|
||||
|
||||
public var high(get, never):Int32;
|
||||
|
||||
inline function get_high():Int32
|
||||
return cast(this >> 32);
|
||||
|
||||
public var low(get, never):Int32;
|
||||
|
||||
inline function get_low():Int32
|
||||
return cast this;
|
||||
|
||||
public inline function copy():Int64
|
||||
return new Int64(this);
|
||||
|
||||
@:from public static inline function ofInt(x:Int):Int64
|
||||
return cast x;
|
||||
|
||||
@:deprecated('haxe.Int64.is() is deprecated. Use haxe.Int64.isInt64() instead')
|
||||
inline public static function is(val:Dynamic):Bool
|
||||
return isInt64(val);
|
||||
|
||||
inline public static function isInt64(val:Dynamic):Bool
|
||||
return hl.Type.getDynamic(val).kind == HI64;
|
||||
|
||||
public static inline function toInt(x:Int64):Int {
|
||||
if (x.val < 0x80000000 || x.val > 0x7FFFFFFF)
|
||||
throw "Overflow";
|
||||
return cast x.val;
|
||||
}
|
||||
|
||||
public static inline function getHigh(x:Int64):Int32
|
||||
return cast(x.val >> 32);
|
||||
|
||||
public static inline function getLow(x:Int64):Int32
|
||||
return cast(x.val);
|
||||
|
||||
public static inline function isNeg(x:Int64):Bool
|
||||
return x.val < 0;
|
||||
|
||||
public static inline function isZero(x:Int64):Bool
|
||||
return x.val == 0;
|
||||
|
||||
public static inline function compare(a:Int64, b:Int64):Int {
|
||||
if (a.val < b.val)
|
||||
return -1;
|
||||
if (a.val > b.val)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static inline function ucompare(a:Int64, b:Int64):Int {
|
||||
if (a.val < 0)
|
||||
return (b.val < 0) ? compare(a, b) : 1;
|
||||
return (b.val < 0) ? -1 : compare(a, b);
|
||||
}
|
||||
|
||||
public static inline function toStr(x:Int64):String
|
||||
return '${x.val}';
|
||||
|
||||
public static inline function divMod(dividend:Int64, divisor:Int64):{quotient:Int64, modulus:Int64}
|
||||
return {quotient: dividend / divisor, modulus: dividend % divisor};
|
||||
|
||||
private inline function toString():String
|
||||
return '$this';
|
||||
|
||||
public static function parseString(sParam:String):Int64 {
|
||||
// can this be done?: return new Int64( java.lang.Long.LongClass.parseLong( sParam ) );
|
||||
return Int64Helper.parseString(sParam);
|
||||
}
|
||||
|
||||
public static function fromFloat(f:Float):Int64 {
|
||||
return Int64Helper.fromFloat(f);
|
||||
}
|
||||
|
||||
@:op(-A) public static function neg(x:Int64):Int64
|
||||
return -x.val;
|
||||
|
||||
@:op(++A) private inline function preIncrement():Int64
|
||||
return ++this;
|
||||
|
||||
@:op(A++) private inline function postIncrement():Int64
|
||||
return this++;
|
||||
|
||||
@:op(--A) private inline function preDecrement():Int64
|
||||
return --this;
|
||||
|
||||
@:op(A--) private inline function postDecrement():Int64
|
||||
return this--;
|
||||
|
||||
@:op(A + B) public static inline function add(a:Int64, b:Int64):Int64
|
||||
return a.val + b.val;
|
||||
|
||||
@:op(A + B) @:commutative private static inline function addInt(a:Int64, b:Int):Int64
|
||||
return a.val + b;
|
||||
|
||||
@:op(A - B) public static inline function sub(a:Int64, b:Int64):Int64
|
||||
return a.val - b.val;
|
||||
|
||||
@:op(A - B) private static inline function subInt(a:Int64, b:Int):Int64
|
||||
return a.val - b;
|
||||
|
||||
@:op(A - B) private static inline function intSub(a:Int, b:Int64):Int64
|
||||
return (a:hl.I64) - b.val;
|
||||
|
||||
@:op(A * B) public static inline function mul(a:Int64, b:Int64):Int64
|
||||
return a.val * b.val;
|
||||
|
||||
@:op(A * B) @:commutative private static inline function mulInt(a:Int64, b:Int):Int64
|
||||
return a.val * b;
|
||||
|
||||
@:op(A / B) public static inline function div(a:Int64, b:Int64):Int64
|
||||
return a.val / b.val;
|
||||
|
||||
@:op(A / B) private static inline function divInt(a:Int64, b:Int):Int64
|
||||
return a.val / b;
|
||||
|
||||
@:op(A / B) private static inline function intDiv(a:Int, b:Int64):Int64
|
||||
return (a:hl.I64) / b.val;
|
||||
|
||||
@:op(A % B) public static inline function mod(a:Int64, b:Int64):Int64
|
||||
return a.val % b.val;
|
||||
|
||||
@:op(A % B) private static inline function modInt(a:Int64, b:Int):Int64
|
||||
return a.val % b;
|
||||
|
||||
@:op(A % B) private static inline function intMod(a:Int, b:Int64):Int64
|
||||
return (a:hl.I64) % b.val;
|
||||
|
||||
@:op(A == B) public static inline function eq(a:Int64, b:Int64):Bool
|
||||
return a.val == b.val;
|
||||
|
||||
@:op(A == B) @:commutative private static inline function eqInt(a:Int64, b:Int):Bool
|
||||
return a.val == b;
|
||||
|
||||
@:op(A != B) public static inline function neq(a:Int64, b:Int64):Bool
|
||||
return a.val != b.val;
|
||||
|
||||
@:op(A != B) @:commutative private static inline function neqInt(a:Int64, b:Int):Bool
|
||||
return a.val != (b:hl.I64);
|
||||
|
||||
@:op(A < B) private static inline function lt(a:Int64, b:Int64):Bool
|
||||
return a.val < b.val;
|
||||
|
||||
@:op(A < B) private static inline function ltInt(a:Int64, b:Int):Bool
|
||||
return a.val < b;
|
||||
|
||||
@:op(A < B) private static inline function intLt(a:Int, b:Int64):Bool
|
||||
return (a:hl.I64) < b.val;
|
||||
|
||||
@:op(A <= B) private static inline function lte(a:Int64, b:Int64):Bool
|
||||
return a.val <= b.val;
|
||||
|
||||
@:op(A <= B) private static inline function lteInt(a:Int64, b:Int):Bool
|
||||
return a.val <= b;
|
||||
|
||||
@:op(A <= B) private static inline function intLte(a:Int, b:Int64):Bool
|
||||
return (a:hl.I64) <= b.val;
|
||||
|
||||
@:op(A > B) private static inline function gt(a:Int64, b:Int64):Bool
|
||||
return a.val > b.val;
|
||||
|
||||
@:op(A > B) private static inline function gtInt(a:Int64, b:Int):Bool
|
||||
return a.val > b;
|
||||
|
||||
@:op(A > B) private static inline function intGt(a:Int, b:Int64):Bool
|
||||
return (a:hl.I64) > b.val;
|
||||
|
||||
@:op(A >= B) private static inline function gte(a:Int64, b:Int64):Bool
|
||||
return a.val >= b.val;
|
||||
|
||||
@:op(A >= B) private static inline function gteInt(a:Int64, b:Int):Bool
|
||||
return a.val >= b;
|
||||
|
||||
@:op(A >= B) private static inline function intGte(a:Int, b:Int64):Bool
|
||||
return (a:hl.I64) >= b.val;
|
||||
|
||||
@:op(~A) private static inline function complement(x:Int64):Int64
|
||||
return ~x.val;
|
||||
|
||||
@:op(A & B) public static inline function and(a:Int64, b:Int64):Int64
|
||||
return a.val & b.val;
|
||||
|
||||
@:op(A | B) public static inline function or(a:Int64, b:Int64):Int64
|
||||
return a.val | b.val;
|
||||
|
||||
@:op(A ^ B) public static inline function xor(a:Int64, b:Int64):Int64
|
||||
return a.val ^ b.val;
|
||||
|
||||
@:op(A << B) public static inline function shl(a:Int64, b:Int):Int64
|
||||
return a.val << b;
|
||||
|
||||
@:op(A >> B) public static inline function shr(a:Int64, b:Int):Int64
|
||||
return a.val >> b;
|
||||
|
||||
@:op(A >>> B) public static inline function ushr(a:Int64, b:Int):Int64
|
||||
return a.val >>> b;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@:transitive
|
||||
abstract Int64(__Int64) from __Int64 to __Int64 {
|
||||
private inline function new(x:__Int64)
|
||||
this = x;
|
||||
|
||||
public inline function copy():Int64
|
||||
return make(high, low);
|
||||
|
||||
public static inline function make(high:Int32, low:Int32):Int64
|
||||
return new Int64(new __Int64(high, low));
|
||||
|
||||
@:from public static inline function ofInt(x:Int):Int64
|
||||
return make(x >> 31, x);
|
||||
|
||||
public static inline function toInt(x:Int64):Int {
|
||||
if (x.high != x.low >> 31)
|
||||
throw "Overflow";
|
||||
|
||||
return x.low;
|
||||
}
|
||||
|
||||
@:deprecated('haxe.Int64.is() is deprecated. Use haxe.Int64.isInt64() instead')
|
||||
inline public static function is(val:Dynamic):Bool {
|
||||
return isInt64(val);
|
||||
}
|
||||
|
||||
inline public static function isInt64(val:Dynamic):Bool
|
||||
return Std.isOfType(val, __Int64);
|
||||
|
||||
@:deprecated("Use high instead")
|
||||
public static inline function getHigh(x:Int64):Int32
|
||||
return x.high;
|
||||
|
||||
@:deprecated("Use low instead")
|
||||
public static inline function getLow(x:Int64):Int32
|
||||
return x.low;
|
||||
|
||||
public static inline function isNeg(x:Int64):Bool
|
||||
return x.high < 0;
|
||||
|
||||
public static inline function isZero(x:Int64):Bool
|
||||
return x == 0;
|
||||
|
||||
public static inline function compare(a:Int64, b:Int64):Int {
|
||||
var v = a.high - b.high;
|
||||
v = if (v != 0) v else Int32.ucompare(a.low, b.low);
|
||||
return a.high < 0 ? (b.high < 0 ? v : -1) : (b.high >= 0 ? v : 1);
|
||||
}
|
||||
|
||||
public static inline function ucompare(a:Int64, b:Int64):Int {
|
||||
var v = Int32.ucompare(a.high, b.high);
|
||||
return if (v != 0) v else Int32.ucompare(a.low, b.low);
|
||||
}
|
||||
|
||||
public static inline function toStr(x:Int64):String
|
||||
return x.toString();
|
||||
|
||||
function toString():String {
|
||||
var i:Int64 = cast this;
|
||||
if (i == 0)
|
||||
return "0";
|
||||
var str = "";
|
||||
var neg = false;
|
||||
if (i.isNeg()) {
|
||||
neg = true;
|
||||
// i = -i; cannot negate here as --9223372036854775808 = -9223372036854775808
|
||||
}
|
||||
var ten:Int64 = 10;
|
||||
while (i != 0) {
|
||||
var r = i.divMod(ten);
|
||||
if (r.modulus.isNeg()) {
|
||||
str = Int64.neg(r.modulus).low + str;
|
||||
i = Int64.neg(r.quotient);
|
||||
} else {
|
||||
str = r.modulus.low + str;
|
||||
i = r.quotient;
|
||||
}
|
||||
}
|
||||
if (neg)
|
||||
str = "-" + str;
|
||||
return str;
|
||||
}
|
||||
|
||||
public static inline function parseString(sParam:String):Int64 {
|
||||
return Int64Helper.parseString(sParam);
|
||||
}
|
||||
|
||||
public static inline function fromFloat(f:Float):Int64 {
|
||||
return Int64Helper.fromFloat(f);
|
||||
}
|
||||
|
||||
public static function divMod(dividend:Int64, divisor:Int64):{quotient:Int64, modulus:Int64} {
|
||||
// Handle special cases of 0 and 1
|
||||
if (divisor.high == 0) {
|
||||
switch (divisor.low) {
|
||||
case 0:
|
||||
throw "divide by zero";
|
||||
case 1:
|
||||
return {quotient: dividend.copy(), modulus: 0};
|
||||
}
|
||||
}
|
||||
|
||||
var divSign = dividend.isNeg() != divisor.isNeg();
|
||||
|
||||
var modulus = dividend.isNeg() ? -dividend : dividend.copy();
|
||||
divisor = divisor.isNeg() ? -divisor : divisor;
|
||||
|
||||
var quotient:Int64 = 0;
|
||||
var mask:Int64 = 1;
|
||||
|
||||
while (!divisor.isNeg()) {
|
||||
var cmp = ucompare(divisor, modulus);
|
||||
divisor <<= 1;
|
||||
mask <<= 1;
|
||||
if (cmp >= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
while (mask != 0) {
|
||||
if (ucompare(modulus, divisor) >= 0) {
|
||||
quotient |= mask;
|
||||
modulus -= divisor;
|
||||
}
|
||||
mask >>>= 1;
|
||||
divisor >>>= 1;
|
||||
}
|
||||
|
||||
if (divSign)
|
||||
quotient = -quotient;
|
||||
if (dividend.isNeg())
|
||||
modulus = -modulus;
|
||||
|
||||
return {
|
||||
quotient: quotient,
|
||||
modulus: modulus
|
||||
};
|
||||
}
|
||||
|
||||
@:op(-A) public static inline function neg(x:Int64):Int64 {
|
||||
var high = ~x.high;
|
||||
var low = -x.low;
|
||||
if (low == 0)
|
||||
high++;
|
||||
return make(high, low);
|
||||
}
|
||||
|
||||
@:op(++A) private inline function preIncrement():Int64 {
|
||||
this = copy();
|
||||
this.low++;
|
||||
if (this.low == 0)
|
||||
this.high++;
|
||||
return cast this;
|
||||
}
|
||||
|
||||
@:op(A++) private inline function postIncrement():Int64 {
|
||||
var ret = this;
|
||||
preIncrement();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@:op(--A) private inline function preDecrement():Int64 {
|
||||
this = copy();
|
||||
if (this.low == 0)
|
||||
this.high--;
|
||||
this.low--;
|
||||
return cast this;
|
||||
}
|
||||
|
||||
@:op(A--) private inline function postDecrement():Int64 {
|
||||
var ret = this;
|
||||
preDecrement();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@:op(A + B) public static inline function add(a:Int64, b:Int64):Int64 {
|
||||
var high = a.high + b.high;
|
||||
var low = a.low + b.low;
|
||||
if (Int32.ucompare(low, a.low) < 0)
|
||||
high++;
|
||||
return make(high, low);
|
||||
}
|
||||
|
||||
@:op(A + B) @:commutative private static inline function addInt(a:Int64, b:Int):Int64
|
||||
return add(a, b);
|
||||
|
||||
@:op(A - B) public static inline function sub(a:Int64, b:Int64):Int64 {
|
||||
var high = a.high - b.high;
|
||||
var low = a.low - b.low;
|
||||
if (Int32.ucompare(a.low, b.low) < 0)
|
||||
high--;
|
||||
return make(high, low);
|
||||
}
|
||||
|
||||
@:op(A - B) private static inline function subInt(a:Int64, b:Int):Int64
|
||||
return sub(a, b);
|
||||
|
||||
@:op(A - B) private static inline function intSub(a:Int, b:Int64):Int64
|
||||
return sub(a, b);
|
||||
|
||||
@:op(A * B)
|
||||
public static #if !lua inline #end function mul(a:Int64, b:Int64):Int64 {
|
||||
var mask = 0xFFFF;
|
||||
var al = a.low & mask, ah = a.low >>> 16;
|
||||
var bl = b.low & mask, bh = b.low >>> 16;
|
||||
var p00 = al * bl;
|
||||
var p10 = ah * bl;
|
||||
var p01 = al * bh;
|
||||
var p11 = ah * bh;
|
||||
var low = p00;
|
||||
var high = p11 + (p01 >>> 16) + (p10 >>> 16);
|
||||
p01 <<= 16;
|
||||
low += p01;
|
||||
if (Int32.ucompare(low, p01) < 0)
|
||||
high++;
|
||||
p10 <<= 16;
|
||||
low += p10;
|
||||
if (Int32.ucompare(low, p10) < 0)
|
||||
high++;
|
||||
high += a.low * b.high + a.high * b.low;
|
||||
return make(high, low);
|
||||
}
|
||||
|
||||
@:op(A * B) @:commutative private static inline function mulInt(a:Int64, b:Int):Int64
|
||||
return mul(a, b);
|
||||
|
||||
@:op(A / B) public static inline function div(a:Int64, b:Int64):Int64
|
||||
return divMod(a, b).quotient;
|
||||
|
||||
@:op(A / B) private static inline function divInt(a:Int64, b:Int):Int64
|
||||
return div(a, b);
|
||||
|
||||
@:op(A / B) private static inline function intDiv(a:Int, b:Int64):Int64
|
||||
return div(a, b).toInt();
|
||||
|
||||
@:op(A % B) public static inline function mod(a:Int64, b:Int64):Int64
|
||||
return divMod(a, b).modulus;
|
||||
|
||||
@:op(A % B) private static inline function modInt(a:Int64, b:Int):Int64
|
||||
return mod(a, b).toInt();
|
||||
|
||||
@:op(A % B) private static inline function intMod(a:Int, b:Int64):Int64
|
||||
return mod(a, b).toInt();
|
||||
|
||||
@:op(A == B) public static inline function eq(a:Int64, b:Int64):Bool
|
||||
return a.high == b.high && a.low == b.low;
|
||||
|
||||
@:op(A == B) @:commutative private static inline function eqInt(a:Int64, b:Int):Bool
|
||||
return eq(a, b);
|
||||
|
||||
@:op(A != B) public static inline function neq(a:Int64, b:Int64):Bool
|
||||
return a.high != b.high || a.low != b.low;
|
||||
|
||||
@:op(A != B) @:commutative private static inline function neqInt(a:Int64, b:Int):Bool
|
||||
return neq(a, b);
|
||||
|
||||
@:op(A < B) private static inline function lt(a:Int64, b:Int64):Bool
|
||||
return compare(a, b) < 0;
|
||||
|
||||
@:op(A < B) private static inline function ltInt(a:Int64, b:Int):Bool
|
||||
return lt(a, b);
|
||||
|
||||
@:op(A < B) private static inline function intLt(a:Int, b:Int64):Bool
|
||||
return lt(a, b);
|
||||
|
||||
@:op(A <= B) private static inline function lte(a:Int64, b:Int64):Bool
|
||||
return compare(a, b) <= 0;
|
||||
|
||||
@:op(A <= B) private static inline function lteInt(a:Int64, b:Int):Bool
|
||||
return lte(a, b);
|
||||
|
||||
@:op(A <= B) private static inline function intLte(a:Int, b:Int64):Bool
|
||||
return lte(a, b);
|
||||
|
||||
@:op(A > B) private static inline function gt(a:Int64, b:Int64):Bool
|
||||
return compare(a, b) > 0;
|
||||
|
||||
@:op(A > B) private static inline function gtInt(a:Int64, b:Int):Bool
|
||||
return gt(a, b);
|
||||
|
||||
@:op(A > B) private static inline function intGt(a:Int, b:Int64):Bool
|
||||
return gt(a, b);
|
||||
|
||||
@:op(A >= B) private static inline function gte(a:Int64, b:Int64):Bool
|
||||
return compare(a, b) >= 0;
|
||||
|
||||
@:op(A >= B) private static inline function gteInt(a:Int64, b:Int):Bool
|
||||
return gte(a, b);
|
||||
|
||||
@:op(A >= B) private static inline function intGte(a:Int, b:Int64):Bool
|
||||
return gte(a, b);
|
||||
|
||||
@:op(~A) private static inline function complement(a:Int64):Int64
|
||||
return make(~a.high, ~a.low);
|
||||
|
||||
@:op(A & B) public static inline function and(a:Int64, b:Int64):Int64
|
||||
return make(a.high & b.high, a.low & b.low);
|
||||
|
||||
@:op(A | B) public static inline function or(a:Int64, b:Int64):Int64
|
||||
return make(a.high | b.high, a.low | b.low);
|
||||
|
||||
@:op(A ^ B) public static inline function xor(a:Int64, b:Int64):Int64
|
||||
return make(a.high ^ b.high, a.low ^ b.low);
|
||||
|
||||
@:op(A << B) public static inline function shl(a:Int64, b:Int):Int64 {
|
||||
b &= 63;
|
||||
return if (b == 0) a.copy() else if (b < 32) make((a.high << b) | (a.low >>> (32 - b)), a.low << b) else make(a.low << (b - 32), 0);
|
||||
}
|
||||
|
||||
@:op(A >> B) public static inline function shr(a:Int64, b:Int):Int64 {
|
||||
b &= 63;
|
||||
return if (b == 0) a.copy() else if (b < 32) make(a.high >> b, (a.high << (32 - b)) | (a.low >>> b)); else make(a.high >> 31, a.high >> (b - 32));
|
||||
}
|
||||
|
||||
@:op(A >>> B) public static inline function ushr(a:Int64, b:Int):Int64 {
|
||||
b &= 63;
|
||||
return if (b == 0) a.copy() else if (b < 32) make(a.high >>> b, (a.high << (32 - b)) | (a.low >>> b)); else make(0, a.high >>> (b - 32));
|
||||
}
|
||||
|
||||
public var high(get, never):Int32;
|
||||
|
||||
private inline function get_high()
|
||||
return this.high;
|
||||
|
||||
private inline function set_high(x)
|
||||
return this.high = x;
|
||||
|
||||
public var low(get, never):Int32;
|
||||
|
||||
private inline function get_low()
|
||||
return this.low;
|
||||
|
||||
private inline function set_low(x)
|
||||
return this.low = x;
|
||||
}
|
||||
|
||||
private typedef __Int64 = ___Int64;
|
||||
|
||||
private class ___Int64 {
|
||||
public var high:Int32;
|
||||
public var low:Int32;
|
||||
|
||||
public inline function new(high, low) {
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
return Int64.toStr(cast this);
|
||||
}
|
||||
|
||||
#end
|
||||
107
Kha/Tools/macos_arm64/std/hl/_std/haxe/NativeStackTrace.hx
Normal file
107
Kha/Tools/macos_arm64/std/hl/_std/haxe/NativeStackTrace.hx
Normal file
@ -0,0 +1,107 @@
|
||||
package haxe;
|
||||
|
||||
import hl.NativeArray;
|
||||
import hl.Bytes;
|
||||
import haxe.CallStack.StackItem;
|
||||
|
||||
typedef Symbol = #if (hl_ver >= version("1.12.0")) hl.Abstract<"hl_symbol"> #else hl.Bytes #end
|
||||
|
||||
/**
|
||||
Do not use manually.
|
||||
**/
|
||||
@:dox(hide)
|
||||
@:noCompletion
|
||||
class NativeStackTrace {
|
||||
@:ifFeature('haxe.NativeStackTrace.exceptionStack')
|
||||
static public inline function saveStack(exception:Any):Void {
|
||||
}
|
||||
|
||||
#if (hl_ver >= version("1.12.0") )
|
||||
|
||||
static public function exceptionStack():NativeArray<Symbol> {
|
||||
var count = exceptionStackRaw(null);
|
||||
var arr = new NativeArray(count);
|
||||
exceptionStackRaw(arr);
|
||||
return arr;
|
||||
}
|
||||
|
||||
static public inline function callStack():NativeArray<Symbol> {
|
||||
var count = callStackRaw(null);
|
||||
var arr = new NativeArray(count);
|
||||
callStackRaw(arr);
|
||||
// This will avoid errors when compiling hl/c on unix
|
||||
// See https://github.com/HaxeFoundation/haxe/pull/11382 for long term fix
|
||||
if (arr.length == 0) return arr;
|
||||
return arr.sub(1, arr.length - 1);
|
||||
}
|
||||
|
||||
@:hlNative("std", "exception_stack_raw")
|
||||
static function exceptionStackRaw( arr : NativeArray<Symbol> ) : Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "call_stack_raw")
|
||||
static function callStackRaw( arr : NativeArray<Symbol> ) : Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std","resolve_symbol")
|
||||
static function resolveSymbol( sym : Symbol, buf : hl.Bytes, bufLen : hl.Ref<Int> ) : hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@:hlNative("std", "exception_stack")
|
||||
static public function exceptionStack():NativeArray<Bytes> {
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: implement in hashlink like `exceptionStack`
|
||||
static public function callStack():NativeArray<Bytes> {
|
||||
var stack:NativeArray<Bytes> = try {
|
||||
throw new Exception('', null, 'stack');
|
||||
} catch (e:Exception) {
|
||||
exceptionStack();
|
||||
}
|
||||
var skip = 1;
|
||||
for(i in 0...stack.length - 1) {
|
||||
var s = @:privateAccess String.fromUCS2(stack[i]);
|
||||
if(s.indexOf('NativeStackTrace.callStack') < 0) {
|
||||
break;
|
||||
}
|
||||
skip++;
|
||||
}
|
||||
return skip < stack.length ? stack.sub(skip, stack.length - skip) : stack;
|
||||
}
|
||||
|
||||
#end
|
||||
|
||||
static public function toHaxe(native:NativeArray<Symbol>, skip:Int=0 ):Array<StackItem> {
|
||||
var stack = [];
|
||||
var r = ~/^([A-Za-z0-9.$_]+)\.([~A-Za-z0-9_]+(\.[0-9]+)?)\((.+):([0-9]+)\)$/;
|
||||
var r_fun = ~/^fun\$([0-9]+)\((.+):([0-9]+)\)$/;
|
||||
#if (hl_ver >= version("1.12.0"))
|
||||
var maxLen = 1024;
|
||||
var tmpBuf = @:privateAccess hl.Bytes.alloc(maxLen);
|
||||
#end
|
||||
for (i in 0...native.length-1) {
|
||||
if( i < skip ) continue;
|
||||
#if (hl_ver >= version("1.12.0"))
|
||||
var len = maxLen;
|
||||
var bytes = resolveSymbol(native[i],tmpBuf,len);
|
||||
if( bytes == null ) continue;
|
||||
#else
|
||||
var bytes = native[i];
|
||||
#end
|
||||
var str = @:privateAccess String.fromUCS2(bytes);
|
||||
if (r.match(str))
|
||||
stack.push(FilePos(Method(r.matched(1), r.matched(2)), r.matched(4), Std.parseInt(r.matched(5))));
|
||||
else if (r_fun.match(str))
|
||||
stack.push(FilePos(LocalFunction(Std.parseInt(r_fun.matched(1))), r_fun.matched(2), Std.parseInt(r_fun.matched(3))));
|
||||
else
|
||||
stack.push(Module(str));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
56
Kha/Tools/macos_arm64/std/hl/_std/haxe/Resource.hx
Normal file
56
Kha/Tools/macos_arm64/std/hl/_std/haxe/Resource.hx
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
private class ResourceContent {
|
||||
public var name:hl.Bytes;
|
||||
public var data:hl.Bytes;
|
||||
public var dataLen:Int;
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
class Resource {
|
||||
static var content:hl.NativeArray<ResourceContent>;
|
||||
|
||||
public static function listNames():Array<String> {
|
||||
return [for (x in content) @:privateAccess String.fromUCS2(x.name)];
|
||||
}
|
||||
|
||||
public static function getString(name:String):String {
|
||||
for (x in content)
|
||||
if (x.name.compare(0, @:privateAccess name.bytes, 0, (name.length + 1) << 1) == 0)
|
||||
return @:privateAccess String.fromUTF8(x.data);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getBytes(name:String):haxe.io.Bytes {
|
||||
for (x in content)
|
||||
if (x.name.compare(0, @:privateAccess name.bytes, 0, (name.length + 1) << 1) == 0)
|
||||
return @:privateAccess new haxe.io.Bytes(x.data, x.dataLen);
|
||||
return null;
|
||||
}
|
||||
|
||||
static function __init__():Void {
|
||||
content = untyped $resources();
|
||||
}
|
||||
}
|
||||
49
Kha/Tools/macos_arm64/std/hl/_std/haxe/atomic/AtomicInt.hx
Normal file
49
Kha/Tools/macos_arm64/std/hl/_std/haxe/atomic/AtomicInt.hx
Normal file
@ -0,0 +1,49 @@
|
||||
package haxe.atomic;
|
||||
|
||||
#if (hl_ver < version("1.13.0") && !doc_gen)
|
||||
#error "Atomic operations require HL 1.13+"
|
||||
#end
|
||||
import hl.Atomics;
|
||||
|
||||
abstract AtomicInt(hl.NativeArray<Int>) {
|
||||
public inline function new(value:Int):Void {
|
||||
this = new hl.NativeArray(1);
|
||||
this[0] = value;
|
||||
}
|
||||
|
||||
public inline function add(b:Int):Int {
|
||||
return Atomics.add32(this.getRef(), b);
|
||||
}
|
||||
|
||||
public inline function sub(b:Int):Int {
|
||||
return Atomics.sub32(this.getRef(), b);
|
||||
}
|
||||
|
||||
public inline function and(b:Int):Int {
|
||||
return Atomics.and32(this.getRef(), b);
|
||||
}
|
||||
|
||||
public inline function or(b:Int):Int {
|
||||
return Atomics.or32(this.getRef(), b);
|
||||
}
|
||||
|
||||
public inline function xor(b:Int):Int {
|
||||
return Atomics.xor32(this.getRef(), b);
|
||||
}
|
||||
|
||||
public inline function compareExchange(expected:Int, replacement:Int):Int {
|
||||
return Atomics.compareExchange32(this.getRef(), expected, replacement);
|
||||
}
|
||||
|
||||
public inline function exchange(value:Int):Int {
|
||||
return Atomics.exchange32(this.getRef(), value);
|
||||
}
|
||||
|
||||
public inline function load():Int {
|
||||
return Atomics.load32(this.getRef());
|
||||
}
|
||||
|
||||
public inline function store(value:Int):Int {
|
||||
return Atomics.store32(this.getRef(), value);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package haxe.atomic;
|
||||
|
||||
#if (hl_ver < version("1.13.0") && !doc_gen)
|
||||
#error "Atomic operations require HL 1.13+"
|
||||
#end
|
||||
import hl.Atomics;
|
||||
|
||||
// use hl.NativeArray<Dynamic> instead of hl.NativeArray<T>
|
||||
// so that the compiler doesn't get confused and emit hl.Ref.make(this.getRef())
|
||||
abstract AtomicObject<T:{}>(hl.NativeArray<Dynamic>) {
|
||||
public inline function new(value:T):Void {
|
||||
this = new hl.NativeArray(1);
|
||||
this[0] = value;
|
||||
}
|
||||
|
||||
public inline function compareExchange(expected:T, replacement:T):T {
|
||||
return Atomics.compareExchangePtr(this.getRef(), expected, replacement);
|
||||
}
|
||||
|
||||
public inline function exchange(value:T):T {
|
||||
return Atomics.exchangePtr(this.getRef(), value);
|
||||
}
|
||||
|
||||
public inline function load():T {
|
||||
return Atomics.loadPtr(this.getRef());
|
||||
}
|
||||
|
||||
public inline function store(value:T):T {
|
||||
return Atomics.storePtr(this.getRef(), value);
|
||||
}
|
||||
}
|
||||
37
Kha/Tools/macos_arm64/std/hl/_std/haxe/crypto/Md5.hx
Normal file
37
Kha/Tools/macos_arm64/std/hl/_std/haxe/crypto/Md5.hx
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 {
|
||||
var out = haxe.io.Bytes.alloc(16);
|
||||
@:privateAccess hl.Format.digest(out.b, s.bytes, s.length, 256);
|
||||
return out.toHex();
|
||||
}
|
||||
|
||||
public static function make(b:haxe.io.Bytes):haxe.io.Bytes {
|
||||
var out = haxe.io.Bytes.alloc(16);
|
||||
@:privateAccess hl.Format.digest(out.b, b.b, b.length, 0);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
37
Kha/Tools/macos_arm64/std/hl/_std/haxe/crypto/Sha1.hx
Normal file
37
Kha/Tools/macos_arm64/std/hl/_std/haxe/crypto/Sha1.hx
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 Sha1 {
|
||||
public static function encode(s:String):String {
|
||||
var out = haxe.io.Bytes.alloc(20);
|
||||
@:privateAccess hl.Format.digest(out.b, s.bytes, s.length, 256 | 1);
|
||||
return out.toHex();
|
||||
}
|
||||
|
||||
public static function make(b:haxe.io.Bytes):haxe.io.Bytes {
|
||||
var out = haxe.io.Bytes.alloc(20);
|
||||
@:privateAccess hl.Format.digest(out.b, b.b, b.length, 1);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
91
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/IntMap.hx
Normal file
91
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/IntMap.hx
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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> {
|
||||
var h:hl.types.IntMap;
|
||||
|
||||
public function new():Void {
|
||||
h = new hl.types.IntMap();
|
||||
}
|
||||
|
||||
public function set(key:Int, value:T):Void {
|
||||
@:privateAccess h.set(key, value);
|
||||
}
|
||||
|
||||
public function get(key:Int):Null<T> {
|
||||
return @:privateAccess h.get(key);
|
||||
}
|
||||
|
||||
public function exists(key:Int):Bool {
|
||||
return @:privateAccess h.exists(key);
|
||||
}
|
||||
|
||||
public function remove(key:Int):Bool {
|
||||
return @:privateAccess h.remove(key);
|
||||
}
|
||||
|
||||
public function keys():Iterator<Int> {
|
||||
return new hl.NativeArray.NativeArrayIterator<Int>(h.keysArray());
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return h.iterator();
|
||||
}
|
||||
|
||||
@: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();
|
||||
var keys = h.keysArray();
|
||||
var values = h.valuesArray();
|
||||
s.addChar("[".code);
|
||||
for (i in 0...keys.length) {
|
||||
if (i > 0)
|
||||
s.add(", ");
|
||||
s.add(keys[i]);
|
||||
s.add(" => ");
|
||||
s.add(values[i]);
|
||||
}
|
||||
s.addChar("]".code);
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
#if (hl_ver >= version("1.11.0"))
|
||||
@:privateAccess h.clear();
|
||||
#else
|
||||
h = new hl.types.IntMap();
|
||||
#end
|
||||
}
|
||||
}
|
||||
91
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/ObjectMap.hx
Normal file
91
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/ObjectMap.hx
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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 ObjectMap<K:{}, T> implements haxe.Constraints.IMap<K, T> {
|
||||
var h:hl.types.ObjectMap;
|
||||
|
||||
public function new():Void {
|
||||
h = new hl.types.ObjectMap();
|
||||
}
|
||||
|
||||
public function set(key:K, value:T):Void {
|
||||
@:privateAccess h.set(key, value);
|
||||
}
|
||||
|
||||
public function get(key:K):Null<T> {
|
||||
return @:privateAccess h.get(key);
|
||||
}
|
||||
|
||||
public function exists(key:K):Bool {
|
||||
return @:privateAccess h.exists(key);
|
||||
}
|
||||
|
||||
public function remove(key:K):Bool {
|
||||
return @:privateAccess h.remove(key);
|
||||
}
|
||||
|
||||
public function keys():Iterator<K> {
|
||||
return new hl.NativeArray.NativeArrayIterator<K>(cast h.keysArray());
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return h.iterator();
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<K, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():ObjectMap<K, T> {
|
||||
var copied = new ObjectMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
var keys = h.keysArray();
|
||||
var values = h.valuesArray();
|
||||
s.addChar("[".code);
|
||||
for (i in 0...keys.length) {
|
||||
if (i > 0)
|
||||
s.add(", ");
|
||||
s.add(keys[i]);
|
||||
s.add(" => ");
|
||||
s.add(values[i]);
|
||||
}
|
||||
s.addChar("]".code);
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
#if (hl_ver >= version("1.11.0"))
|
||||
@:privateAccess h.clear();
|
||||
#else
|
||||
h = new hl.types.ObjectMap();
|
||||
#end
|
||||
}
|
||||
}
|
||||
119
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/StringMap.hx
Normal file
119
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/StringMap.hx
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
private class StringMapKeysIterator {
|
||||
var arr:hl.NativeArray<hl.Bytes>;
|
||||
var pos:Int;
|
||||
var length:Int;
|
||||
|
||||
public inline function new(h:hl.types.BytesMap) {
|
||||
this.arr = h.keysArray();
|
||||
pos = 0;
|
||||
length = arr.length;
|
||||
}
|
||||
|
||||
public inline function hasNext() {
|
||||
return pos < length;
|
||||
}
|
||||
|
||||
public inline function next() @:privateAccess {
|
||||
var b = arr[pos++];
|
||||
return String.fromUCS2(b);
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
class StringMap<T> implements haxe.Constraints.IMap<String, T> {
|
||||
var h:hl.types.BytesMap;
|
||||
|
||||
public function new():Void {
|
||||
h = new hl.types.BytesMap();
|
||||
}
|
||||
|
||||
public function set(key:String, value:T):Void {
|
||||
@:privateAccess h.set(key.bytes, value);
|
||||
}
|
||||
|
||||
public function get(key:String):Null<T> {
|
||||
if (key == null)
|
||||
return null;
|
||||
return @:privateAccess h.get(key.bytes);
|
||||
}
|
||||
|
||||
public function exists(key:String):Bool {
|
||||
if (key == null)
|
||||
return false;
|
||||
return @:privateAccess h.exists(key.bytes);
|
||||
}
|
||||
|
||||
public function remove(key:String):Bool {
|
||||
if (key == null)
|
||||
return false;
|
||||
return @:privateAccess h.remove(key.bytes);
|
||||
}
|
||||
|
||||
public function keys():Iterator<String> {
|
||||
return new StringMapKeysIterator(h);
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return h.iterator();
|
||||
}
|
||||
|
||||
@: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();
|
||||
var keys = h.keysArray();
|
||||
var values = h.valuesArray();
|
||||
s.addChar("[".code);
|
||||
for (i in 0...keys.length) {
|
||||
if (i > 0)
|
||||
s.add(", ");
|
||||
var k = keys[i];
|
||||
@:privateAccess s.__add(k, 0, (@:privateAccess k.ucs2Length(0)) << 1);
|
||||
s.add(" => ");
|
||||
s.add(values[i]);
|
||||
}
|
||||
s.addChar("]".code);
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
#if (hl_ver >= version("1.11.0"))
|
||||
@:privateAccess h.clear();
|
||||
#else
|
||||
h = new hl.types.BytesMap();
|
||||
#end
|
||||
}
|
||||
}
|
||||
99
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/Vector.hx
Normal file
99
Kha/Tools/macos_arm64/std/hl/_std/haxe/ds/Vector.hx
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
private typedef VectorData<T> = Array<T>
|
||||
|
||||
@:coreApi
|
||||
abstract Vector<T>(VectorData<T>) {
|
||||
extern overload public inline function new(length:Int) {
|
||||
this = [];
|
||||
if (length > 0)
|
||||
this[length - 1] = @:nullSafety(Off) cast null;
|
||||
}
|
||||
|
||||
extern overload public inline function new(length:Int, defaultValue:T):Vector<T> {
|
||||
this = [
|
||||
for (i in 0...length) defaultValue
|
||||
];
|
||||
}
|
||||
|
||||
@:op([]) public inline function get(index:Int):T {
|
||||
return this[index];
|
||||
}
|
||||
|
||||
@:op([]) public inline function set(index:Int, val:T):T {
|
||||
return this[index] = val;
|
||||
}
|
||||
|
||||
public var length(get, never):Int;
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public inline function fill(value:T):Void
|
||||
for (i in 0...length) this[i] = value;
|
||||
|
||||
public static inline function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void {
|
||||
(cast dest : hl.types.ArrayBase.ArrayAccess).blit(destPos, (cast src : hl.types.ArrayBase.ArrayAccess), srcPos, len);
|
||||
}
|
||||
|
||||
public inline function toArray():Array<T> {
|
||||
return this.copy();
|
||||
}
|
||||
|
||||
public inline function toData():VectorData<T>
|
||||
return this;
|
||||
|
||||
static public inline function fromData<T>(data:VectorData<T>):Vector<T>
|
||||
return cast data;
|
||||
|
||||
static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
|
||||
return cast array.copy();
|
||||
}
|
||||
|
||||
public inline function copy<T>():Vector<T> {
|
||||
return cast this.copy();
|
||||
}
|
||||
|
||||
public inline function join<T>(sep:String):String {
|
||||
return this.join(sep);
|
||||
}
|
||||
|
||||
public inline function sort(f:T->T->Int):Void {
|
||||
this.sort(f);
|
||||
}
|
||||
|
||||
public inline function map<S>(f:T->S):Vector<S> {
|
||||
var length = length;
|
||||
var r = new Vector<S>(length);
|
||||
var i = 0;
|
||||
var len = length;
|
||||
for (i in 0...len) {
|
||||
var v = f(get(i));
|
||||
r.set(i, v);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
253
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/Bytes.hx
Normal file
253
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/Bytes.hx
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* 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:hl.Bytes;
|
||||
|
||||
function new(b:hl.Bytes, length:Int):Void {
|
||||
this.b = b;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
inline function out(pos:Int):Bool {
|
||||
return (pos : UInt) >= (length : UInt);
|
||||
}
|
||||
|
||||
inline function outRange(pos:Int, len:Int):Bool {
|
||||
return pos < 0 || len < 0 || ((pos + len) : UInt) > (length : UInt);
|
||||
}
|
||||
|
||||
public function get(pos:Int):Int {
|
||||
return if (out(pos)) 0 else b[pos];
|
||||
}
|
||||
|
||||
public function set(pos:Int, v:Int):Void {
|
||||
if (out(pos))
|
||||
throw Error.OutsideBounds;
|
||||
b[pos] = v;
|
||||
}
|
||||
|
||||
public function blit(pos:Int, src:Bytes, srcpos:Int, len:Int):Void {
|
||||
if (outRange(pos, len) || src.outRange(srcpos, len))
|
||||
throw Error.OutsideBounds;
|
||||
b.blit(pos, src.b, srcpos, len);
|
||||
}
|
||||
|
||||
public function fill(pos:Int, len:Int, value:Int):Void {
|
||||
if (outRange(pos, len))
|
||||
throw Error.OutsideBounds;
|
||||
b.fill(pos, len, value);
|
||||
}
|
||||
|
||||
public function sub(pos:Int, len:Int):Bytes {
|
||||
if (outRange(pos, len))
|
||||
throw Error.OutsideBounds;
|
||||
return new Bytes(b.sub(pos, len), len);
|
||||
}
|
||||
|
||||
public function compare(other:Bytes):Int {
|
||||
var len = length < other.length ? length : other.length;
|
||||
var r = b.compare(0, other.b, 0, len);
|
||||
if (r == 0)
|
||||
r = length - other.length;
|
||||
return r;
|
||||
}
|
||||
|
||||
#if hl_check_align
|
||||
static var alignBuffer:hl.Bytes = new hl.Bytes(8);
|
||||
#end
|
||||
|
||||
public function getDouble(pos:Int):Float {
|
||||
if (out(pos + 7))
|
||||
return 0.;
|
||||
#if hl_check_align
|
||||
return if (pos & 3 == 0) b.getF64(pos) else {
|
||||
alignBuffer.blit(0, b, pos, 8);
|
||||
alignBuffer.getF64(0);
|
||||
}
|
||||
#else
|
||||
return b.getF64(pos);
|
||||
#end
|
||||
}
|
||||
|
||||
public function getFloat(pos:Int):Float {
|
||||
if (out(pos + 3))
|
||||
return 0.;
|
||||
#if hl_check_align
|
||||
return if (pos & 3 == 0) b.getF32(pos) else {
|
||||
alignBuffer.blit(0, b, pos, 4);
|
||||
alignBuffer.getF32(0);
|
||||
}
|
||||
#else
|
||||
return b.getF32(pos);
|
||||
#end
|
||||
}
|
||||
|
||||
public function setDouble(pos:Int, v:Float):Void {
|
||||
if (out(pos + 7))
|
||||
throw Error.OutsideBounds;
|
||||
#if hl_check_align
|
||||
if (pos & 7 == 0)
|
||||
b.setF64(pos, v);
|
||||
else {
|
||||
alignBuffer.setF64(0, v);
|
||||
b.blit(pos, alignBuffer, 0, 8);
|
||||
}
|
||||
#else
|
||||
b.setF64(pos, v);
|
||||
#end
|
||||
}
|
||||
|
||||
public function setFloat(pos:Int, v:Float):Void {
|
||||
if (out(pos + 3))
|
||||
throw Error.OutsideBounds;
|
||||
#if hl_check_align
|
||||
if (pos & 3 == 0)
|
||||
b.setF32(pos, v);
|
||||
else {
|
||||
alignBuffer.setF32(0, v);
|
||||
b.blit(pos, alignBuffer, 0, 4);
|
||||
}
|
||||
#else
|
||||
b.setF32(pos, v);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getUInt16(pos:Int):Int {
|
||||
return if (out(pos + 1)) 0 else b.getUI16(pos);
|
||||
}
|
||||
|
||||
public inline function setUInt16(pos:Int, v:Int):Void {
|
||||
if (out(pos + 1))
|
||||
throw Error.OutsideBounds;
|
||||
b.setUI16(pos, v);
|
||||
}
|
||||
|
||||
public function getInt32(pos:Int):Int {
|
||||
return if (out(pos + 3)) 0 else b.getI32(pos);
|
||||
}
|
||||
|
||||
public function getInt64(pos:Int):haxe.Int64 {
|
||||
if (out(pos + 7))
|
||||
return haxe.Int64.ofInt(0);
|
||||
return haxe.Int64.make(b.getI32(pos + 4), b.getI32(pos));
|
||||
}
|
||||
|
||||
public function setInt32(pos:Int, v:Int):Void {
|
||||
if (out(pos + 3))
|
||||
throw Error.OutsideBounds;
|
||||
b.setI32(pos, v);
|
||||
}
|
||||
|
||||
public inline function setInt64(pos:Int, v:haxe.Int64):Void {
|
||||
setInt32(pos + 4, v.high);
|
||||
setInt32(pos, v.low);
|
||||
}
|
||||
|
||||
public function getString(pos:Int, len:Int, ?encoding:Encoding):String {
|
||||
if (outRange(pos, len))
|
||||
throw Error.OutsideBounds;
|
||||
|
||||
var b = new hl.Bytes(len + 2);
|
||||
b.blit(0, this.b, pos, len);
|
||||
b[len] = 0;
|
||||
b[len + 1] = 0;
|
||||
return @:privateAccess (encoding == RawNative ? String.fromUCS2(b) : String.fromUTF8(b));
|
||||
}
|
||||
|
||||
@: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 new haxe.io.BytesData(b, length);
|
||||
}
|
||||
|
||||
public static function alloc(length:Int):Bytes {
|
||||
var b = new hl.Bytes(length);
|
||||
b.fill(0, length, 0);
|
||||
return new Bytes(b, length);
|
||||
}
|
||||
|
||||
public static function ofString(s:String, ?encoding:Encoding):Bytes@:privateAccess {
|
||||
if (encoding == null)
|
||||
encoding = UTF8;
|
||||
return switch (encoding) {
|
||||
case RawNative:
|
||||
return new Bytes(s.bytes.sub(0, s.length << 1), s.length << 1);
|
||||
case UTF8:
|
||||
var size = 0;
|
||||
var b = s.bytes.utf16ToUtf8(s.length, size);
|
||||
return new Bytes(b, size);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ofData(b:BytesData):Bytes {
|
||||
return new Bytes(b.bytes, b.length);
|
||||
}
|
||||
|
||||
public static function ofHex(s:String):Bytes {
|
||||
var len = s.length;
|
||||
if ((len & 1) != 0)
|
||||
throw "Not a hex string (odd number of digits)";
|
||||
var l = len >> 1;
|
||||
var b = new hl.Bytes(l);
|
||||
for (i in 0...l) {
|
||||
var high = s.charCodeAt(i * 2);
|
||||
var low = s.charCodeAt(i * 2 + 1);
|
||||
high = (high & 0xf) + ((high & 0x40) >> 6) * 9;
|
||||
low = (low & 0xf) + ((low & 0x40) >> 6) * 9;
|
||||
b.setUI8(i, ((high << 4) | low) & 0xff);
|
||||
}
|
||||
|
||||
return new Bytes(b, l);
|
||||
}
|
||||
|
||||
public inline static function fastGet(b:BytesData, pos:Int):Int {
|
||||
return b[pos];
|
||||
}
|
||||
}
|
||||
131
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/BytesBuffer.hx
Normal file
131
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/BytesBuffer.hx
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 b:hl.Bytes;
|
||||
var pos:Int;
|
||||
var size:Int;
|
||||
|
||||
public var length(get, never):Int;
|
||||
|
||||
public function new() {
|
||||
pos = 0;
|
||||
size = 16; // ensure increment of 8
|
||||
b = new hl.Bytes(size);
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public inline function addByte(byte:Int):Void {
|
||||
if (pos == size)
|
||||
__expand(0);
|
||||
b[pos++] = byte;
|
||||
}
|
||||
|
||||
function __expand(req:Int):Void {
|
||||
var nsize = (size * 3) >> 1;
|
||||
if (nsize < req)
|
||||
nsize = req;
|
||||
var b2 = new hl.Bytes(nsize);
|
||||
b2.blit(0, b, 0, pos);
|
||||
b = b2;
|
||||
size = nsize;
|
||||
}
|
||||
|
||||
function __add(b:hl.Bytes, bpos:Int, blen:Int):Void {
|
||||
if (pos + blen > size)
|
||||
__expand(pos + blen);
|
||||
this.b.blit(pos, b, bpos, blen);
|
||||
pos += blen;
|
||||
}
|
||||
|
||||
public inline function add(src:Bytes):Void {
|
||||
__add(@:privateAccess src.b, 0, src.length);
|
||||
}
|
||||
|
||||
public inline function addString(v:String, ?encoding:Encoding):Void {
|
||||
var len = 0;
|
||||
@:privateAccess (encoding == RawNative ? __add(v.bytes, 0, v.length << 1) : __add(v.bytes.utf16ToUtf8(0, len), 0, len));
|
||||
}
|
||||
|
||||
public inline function addInt32(v:Int):Void {
|
||||
if (pos + 4 > size)
|
||||
__expand(0);
|
||||
b.setI32(pos, v);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
public inline function addInt64(v:haxe.Int64):Void {
|
||||
if (pos + 8 > size)
|
||||
__expand(0);
|
||||
b.setI32(pos, v.low);
|
||||
b.setI32(pos + 4, v.high);
|
||||
pos += 8;
|
||||
}
|
||||
|
||||
public inline function addFloat(v:Float):Void {
|
||||
if (pos + 4 > size)
|
||||
__expand(0);
|
||||
#if hl_check_align
|
||||
if (pos & 3 == 0)
|
||||
b.setF32(pos, v);
|
||||
else @:privateAccess {
|
||||
haxe.io.Bytes.alignBuffer.setF32(0, v);
|
||||
b.blit(pos, haxe.io.Bytes.alignBuffer, 0, 4);
|
||||
}
|
||||
#else
|
||||
b.setF32(pos, v);
|
||||
#end
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
public inline function addDouble(v:Float):Void {
|
||||
if (pos + 8 > size)
|
||||
__expand(0);
|
||||
#if hl_check_align
|
||||
if (pos & 7 == 0)
|
||||
b.setF64(pos, v);
|
||||
else @:privateAccess {
|
||||
haxe.io.Bytes.alignBuffer.setF64(0, v);
|
||||
b.blit(pos, haxe.io.Bytes.alignBuffer, 0, 8);
|
||||
}
|
||||
#else
|
||||
b.setF64(pos, v);
|
||||
#end
|
||||
pos += 8;
|
||||
}
|
||||
|
||||
public inline function addBytes(src:Bytes, pos:Int, len:Int):Void {
|
||||
if (pos < 0 || len < 0 || pos + len > src.length)
|
||||
throw Error.OutsideBounds;
|
||||
__add(@:privateAccess src.b, pos, len);
|
||||
}
|
||||
|
||||
public function getBytes():Bytes {
|
||||
return @:privateAccess new haxe.io.Bytes(b, pos);
|
||||
}
|
||||
}
|
||||
59
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/FPHelper.hx
Normal file
59
Kha/Tools/macos_arm64/std/hl/_std/haxe/io/FPHelper.hx
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 FPHelper {
|
||||
// note : this is not thread safe, use TLS when available
|
||||
static var i64tmp = Int64.ofInt(0);
|
||||
static var helper = new hl.Bytes(8);
|
||||
|
||||
public static function i32ToFloat(i:Int):Single {
|
||||
helper.setI32(0, i);
|
||||
return helper.getF32(0);
|
||||
}
|
||||
|
||||
public static function floatToI32(f:Single):Int {
|
||||
helper.setF32(0, f);
|
||||
return helper.getI32(0);
|
||||
}
|
||||
|
||||
public static function i64ToDouble(low:Int, high:Int):Float {
|
||||
helper.setI32(0, low);
|
||||
helper.setI32(4, high);
|
||||
return helper.getF64(0);
|
||||
}
|
||||
|
||||
public static function doubleToI64(v:Float):Int64 {
|
||||
helper.setF64(0, v);
|
||||
#if (hl_ver >= version("1.12.0") && !hl_legacy32)
|
||||
return Int64.make(helper.getI32(4),helper.getI32(0));
|
||||
#else
|
||||
var i64 = i64tmp;
|
||||
@:privateAccess {
|
||||
i64.set_low(helper.getI32(0));
|
||||
i64.set_high(helper.getI32(4));
|
||||
}
|
||||
return i64;
|
||||
#end
|
||||
}
|
||||
}
|
||||
75
Kha/Tools/macos_arm64/std/hl/_std/haxe/zip/Compress.hx
Normal file
75
Kha/Tools/macos_arm64/std/hl/_std/haxe/zip/Compress.hx
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.zip;
|
||||
|
||||
private typedef Deflater = hl.Abstract<"fmt_zip">;
|
||||
|
||||
@:coreApi @:hlNative("fmt")
|
||||
class Compress {
|
||||
var s:Deflater;
|
||||
|
||||
public function new(level:Int):Void {
|
||||
s = deflate_init(level);
|
||||
}
|
||||
|
||||
public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
|
||||
var read = 0, write = 0;
|
||||
var done = deflate_buffer(s, src.getData(), srcPos, src.length, dst.getData(), dstPos, dst.length, read, write);
|
||||
return {done: done, read: read, write: write};
|
||||
}
|
||||
|
||||
public function setFlushMode(f:FlushMode):Void {
|
||||
@:privateAccess Uncompress.zip_flush_mode(cast s, f.getIndex());
|
||||
}
|
||||
|
||||
public function close():Void {
|
||||
@:privateAccess Uncompress.zip_end(cast s);
|
||||
}
|
||||
|
||||
public static function run(s:haxe.io.Bytes, level:Int):haxe.io.Bytes {
|
||||
var c = new Compress(level);
|
||||
c.setFlushMode(FlushMode.FINISH);
|
||||
var out = haxe.io.Bytes.alloc(deflate_bound(c.s, s.length));
|
||||
var r = c.execute(s, 0, out, 0);
|
||||
c.close();
|
||||
if (!r.done || r.read != s.length)
|
||||
throw "Compression failed";
|
||||
if (r.write < out.length * 0.66)
|
||||
return out.sub(0, r.write);
|
||||
@:privateAccess out.length = r.write;
|
||||
return out;
|
||||
}
|
||||
|
||||
static function deflate_init(level:Int):Deflater {
|
||||
return null;
|
||||
}
|
||||
|
||||
static function deflate_buffer(i:Deflater, bytes:hl.Bytes, bytesPos:Int, bytesLen:Int, dst:hl.Bytes, dstPos:Int, dstLen:Int, read:hl.Ref<Int>,
|
||||
write:hl.Ref<Int>):Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function deflate_bound(i:Deflater, length:Int):Int {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
80
Kha/Tools/macos_arm64/std/hl/_std/haxe/zip/Uncompress.hx
Normal file
80
Kha/Tools/macos_arm64/std/hl/_std/haxe/zip/Uncompress.hx
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.zip;
|
||||
|
||||
private typedef Inflater = hl.Abstract<"fmt_zip">;
|
||||
|
||||
@:coreApi @:hlNative("fmt")
|
||||
class Uncompress {
|
||||
var s:Inflater;
|
||||
|
||||
public function new(?windowBits:Int):Void {
|
||||
s = inflate_init(windowBits);
|
||||
}
|
||||
|
||||
public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
|
||||
var read = 0, write = 0;
|
||||
var done = inflate_buffer(s, src.getData(), srcPos, src.length, dst.getData(), dstPos, dst.length, read, write);
|
||||
return {done: done, read: read, write: write};
|
||||
}
|
||||
|
||||
public function setFlushMode(f:FlushMode):Void {
|
||||
zip_flush_mode(s, f.getIndex());
|
||||
}
|
||||
|
||||
public function close():Void {
|
||||
zip_end(s);
|
||||
}
|
||||
|
||||
public static function run(src:haxe.io.Bytes, ?bufsize:Int):haxe.io.Bytes {
|
||||
var u = new Uncompress(null);
|
||||
if (bufsize == null)
|
||||
bufsize = 1 << 16; // 64K
|
||||
var tmp = haxe.io.Bytes.alloc(bufsize);
|
||||
var b = new haxe.io.BytesBuffer();
|
||||
var pos = 0;
|
||||
u.setFlushMode(FlushMode.SYNC);
|
||||
while (true) {
|
||||
var r = u.execute(src, pos, tmp, 0);
|
||||
b.addBytes(tmp, 0, r.write);
|
||||
pos += r.read;
|
||||
if (r.done)
|
||||
break;
|
||||
}
|
||||
u.close();
|
||||
return b.getBytes();
|
||||
}
|
||||
|
||||
static function inflate_init(bits:Int):Inflater {
|
||||
return null;
|
||||
}
|
||||
|
||||
static function inflate_buffer(i:Inflater, bytes:hl.Bytes, bytesPos:Int, bytesLen:Int, dst:hl.Bytes, dstPos:Int, dstLen:Int, read:hl.Ref<Int>,
|
||||
write:hl.Ref<Int>):Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function zip_end(i:Inflater):Void {}
|
||||
|
||||
static function zip_flush_mode(i:Inflater, flush:Int):Void {}
|
||||
}
|
||||
Reference in New Issue
Block a user