This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -19,7 +19,10 @@ class Exception {
if(Std.isOfType(value, Exception)) {
return value;
} else {
return new ValueException(value, null, value);
var e = new ValueException(value, null, value);
// Undo automatic __shiftStack()
e.__unshiftStack();
return e;
}
}
@ -63,6 +66,12 @@ class Exception {
__skipStack++;
}
@:noCompletion
@:ifFeature("haxe.Exception.get_stack")
inline function __unshiftStack():Void {
__skipStack--;
}
function get_message():String {
return __exceptionMessage;
}

View File

@ -22,13 +22,8 @@
package haxe;
import haxe.Int64Helper;
@:notNull
@:include("cpp/Int64.h")
@:native("cpp::Int64Struct")
private extern class ___Int64 {
private extern class NativeInt64Helper {
@:native("_hx_int64_make")
static function make(high:Int32, low:Int32):__Int64;
@ -132,21 +127,21 @@ private extern class ___Int64 {
static function low(a:__Int64):Int32;
}
private typedef __Int64 = ___Int64;
private typedef __Int64 = cpp.Int64;
@:coreApi
@:transitive
abstract Int64(__Int64) from __Int64 to __Int64 {
@:notNull
abstract Int64(__Int64) from __Int64 from Int to __Int64 {
public #if !cppia inline #end function copy():Int64
return this;
public static #if !cppia inline #end function make(high:Int32, low:Int32):Int64 {
return __Int64.make(high, low);
return NativeInt64Helper.make(high, low);
}
@:from
public static #if !cppia inline #end function ofInt(x:Int):Int64 {
return __Int64.ofInt(x);
return x;
}
public static #if !cppia inline #end function toInt(x:Int64):Int {
@ -158,11 +153,11 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
@:deprecated('haxe.Int64.is() is deprecated. Use haxe.Int64.isInt64() instead')
inline public static function is(val:Dynamic):Bool {
return isInt64(val);
return val is cpp.Int64;
}
public static #if !cppia inline #end function isInt64(val:Dynamic):Bool
return __Int64.isInt64(val);
return val is cpp.Int64;
@:deprecated("Use high instead")
public static #if !cppia inline #end function getHigh(x:Int64):Int32
@ -173,22 +168,22 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
return x.low;
public static #if !cppia inline #end function isNeg(x:Int64):Bool
return __Int64.isNeg(x);
return NativeInt64Helper.isNeg(x);
public static #if !cppia inline #end function isZero(x:Int64):Bool
return __Int64.isZero(x);
return NativeInt64Helper.isZero(x);
public static #if !cppia inline #end function compare(a:Int64, b:Int64):Int
return __Int64.compare(a, b);
return NativeInt64Helper.compare(a, b);
public static #if !cppia inline #end function ucompare(a:Int64, b:Int64):Int
return __Int64.ucompare(a, b);
return NativeInt64Helper.ucompare(a, b);
public static #if !cppia inline #end function toStr(x:Int64):String
return x.toString();
return cast x.val;
private #if !cppia inline #end function toString():String
return __Int64.toString(this);
return cast this;
public static function parseString(sParam:String):Int64 {
return Int64Helper.parseString(sParam);
@ -201,7 +196,7 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
public static function divMod(dividend:Int64, divisor:Int64):{quotient:Int64, modulus:Int64} {
var q = dividend / divisor;
if (isZero(divisor))
if (divisor == 0)
throw "divide by zero";
var m = dividend - q * divisor;
@ -209,16 +204,16 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
return {quotient: q, modulus: m};
}
@:op(-A)
@:op(-A)
public static #if !cppia inline #end function neg(x:Int64):Int64
return __Int64.neg(x);
return NativeInt64Helper.neg(x);
@:op(++A) private inline function preIncrement():Int64 {
#if cppia
this = this + make(0, 1);
return this;
#else
return __Int64.preIncrement(this);
return NativeInt64Helper.preIncrement(this);
#end
}
@ -228,7 +223,7 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
this = this + make(0, 1);
return result;
#else
return __Int64.postIncrement(this);
return NativeInt64Helper.postIncrement(this);
#end
}
@ -237,7 +232,7 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
untyped this = this - make(0, 1);
return this;
#else
return __Int64.preDecrement(this);
return NativeInt64Helper.preDecrement(this);
#end
}
@ -247,35 +242,35 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
this = this - make(0, 1);
return result;
#else
return __Int64.postDecrement(this);
return NativeInt64Helper.postDecrement(this);
#end
}
@:op(A + B)
public static #if !cppia inline #end function add(a:Int64, b:Int64):Int64
return __Int64.add(a, b);
return NativeInt64Helper.add(a, b);
@:op(A + B)
@:commutative
private static #if !cppia inline #end function addInt(a:Int64, b:Int):Int64
return __Int64.addInt(a, b);
return NativeInt64Helper.addInt(a, b);
@:op(A - B)
public static #if !cppia inline #end function sub(a:Int64, b:Int64):Int64 {
return __Int64.sub(a, b);
return NativeInt64Helper.sub(a, b);
}
@:op(A - B)
private static #if !cppia inline #end function subInt(a:Int64, b:Int):Int64
return __Int64.subInt(a, b);
return NativeInt64Helper.subInt(a, b);
@:op(A - B)
private static #if !cppia inline #end function intSub(a:Int, b:Int64):Int64
return __Int64.intSub(a, b);
return NativeInt64Helper.intSub(a, b);
@:op(A * B)
public static #if !cppia inline #end function mul(a:Int64, b:Int64):Int64
return __Int64.mul(a, b);
return NativeInt64Helper.mul(a, b);
@:op(A * B)
@:commutative
@ -284,9 +279,9 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
@:op(A / B)
public static #if !cppia inline #end function div(a:Int64, b:Int64):Int64 {
if (__Int64.isZero(b))
if (NativeInt64Helper.isZero(b))
throw "divide by zero";
return __Int64.div(a, b);
return NativeInt64Helper.div(a, b);
}
@:op(A / B)
@ -299,9 +294,9 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
@:op(A % B)
public static #if !cppia inline #end function mod(a:Int64, b:Int64):Int64 {
if (__Int64.isZero(b))
if (NativeInt64Helper.isZero(b))
throw "divide by zero";
return __Int64.mod(a, b);
return NativeInt64Helper.mod(a, b);
}
@:op(A % B)
@ -314,16 +309,16 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
@:op(A == B)
public static #if !cppia inline #end function eq(a:Int64, b:Int64):Bool
return __Int64.eq(a, b);
return NativeInt64Helper.eq(a, b);
@:op(A == B)
@:commutative
private static #if !cppia inline #end function eqInt(a:Int64, b:Int):Bool
return __Int64.eqInt(a, b);
return NativeInt64Helper.eqInt(a, b);
@:op(A != B)
public static #if !cppia inline #end function neq(a:Int64, b:Int64):Bool
return __Int64.neq(a, b);
return NativeInt64Helper.neq(a, b);
@:op(A != B)
@:commutative
@ -380,39 +375,44 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
@:op(~A)
private static #if !cppia inline #end function complement(a:Int64):Int64
return __Int64.complement(a);
return NativeInt64Helper.complement(a);
@:op(A & B)
public static #if !cppia inline #end function and(a:Int64, b:Int64):Int64
return __Int64.bitAnd(a, b);
return NativeInt64Helper.bitAnd(a, b);
@:op(A | B)
public static #if !cppia inline #end function or(a:Int64, b:Int64):Int64
return __Int64.bitOr(a, b);
return NativeInt64Helper.bitOr(a, b);
@:op(A ^ B)
public static #if !cppia inline #end function xor(a:Int64, b:Int64):Int64
return __Int64.bitXor(a, b);
return NativeInt64Helper.bitXor(a, b);
@:op(A << B)
public static #if !cppia inline #end function shl(a:Int64, b:Int):Int64
return __Int64.shl(a, b);
return NativeInt64Helper.shl(a, b);
@:op(A >> B)
public static #if !cppia inline #end function shr(a:Int64, b:Int):Int64
return __Int64.shr(a, b);
return NativeInt64Helper.shr(a, b);
@:op(A >>> B)
public static #if !cppia inline #end function ushr(a:Int64, b:Int):Int64
return __Int64.ushr(a, b);
return NativeInt64Helper.ushr(a, b);
public var high(get, never):Int32;
private #if !cppia inline #end function get_high():Int32
return __Int64.high(this);
return NativeInt64Helper.high(this);
public var low(get, never):Int32;
private #if !cppia inline #end function get_low():Int32
return __Int64.low(this);
return NativeInt64Helper.low(this);
private var val(get, never):__Int64;
private #if !cppia inline #end function get_val():__Int64
return this;
}

View File

@ -0,0 +1,68 @@
package haxe.atomic;
#if cppia
extern
#end
abstract AtomicInt(cpp.Pointer<Int>) {
#if cppia
public function new(value:Int):Void;
public function add(b:Int):Int;
public function sub(b:Int):Int;
public function and(b:Int):Int;
public function or(b:Int):Int;
public function xor(b:Int):Int;
public function compareExchange(expected:Int, replacement:Int):Int;
public function exchange(value:Int):Int;
public function load():Int;
public function store(value:Int):Int;
#else
public #if !scriptable inline #end function new(value:Int) {
this = cpp.Pointer.ofArray([value]);
}
public #if !scriptable inline #end function add(b:Int):Int {
return untyped __cpp__("_hx_atomic_add({0}, {1})", this, b);
}
public #if !scriptable inline #end function sub(b:Int):Int {
return untyped __cpp__("_hx_atomic_sub({0}, {1})", this, b);
}
public #if !scriptable inline #end function and(b:Int):Int {
return untyped __cpp__("_hx_atomic_and({0}, {1})", this, b);
}
public #if !scriptable inline #end function or(b:Int):Int {
return untyped __cpp__("_hx_atomic_or({0}, {1})", this, b);
}
public #if !scriptable inline #end function xor(b:Int):Int {
return untyped __cpp__("_hx_atomic_xor({0}, {1})", this, b);
}
public #if !scriptable inline #end function compareExchange(expected:Int, replacement:Int):Int {
return untyped __cpp__("_hx_atomic_compare_exchange({0}, {1}, {2})", this, expected, replacement);
}
public #if !scriptable inline #end function exchange(value:Int):Int {
return untyped __cpp__("_hx_atomic_exchange({0}, {1})", this, value);
}
public #if !scriptable inline #end function load():Int {
return untyped __cpp__("_hx_atomic_load({0})", this);
}
public #if !scriptable inline #end function store(value:Int):Int {
return untyped __cpp__("_hx_atomic_store({0}, {1})", this, value);
}
#end
}

View File

@ -35,6 +35,7 @@ package haxe.ds;
inline void set(int key, float value) { __int_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(int key, double value) { __int_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(int key, ::String value) { __int_hash_set_string(HX_MAP_THIS,key,value); }
inline void set(int key, cpp::Int64 value) { __int_hash_set_int64(HX_MAP_THIS,key,value); }
template<typename V, typename H>
inline void set(int key, const ::cpp::Struct<V,H> &value) {__int_hash_set(HX_MAP_THIS,key,value); }
@ -50,6 +51,7 @@ package haxe.ds;
inline int get_int(int key) { return __int_hash_get_int(h,key); }
inline Float get_float(int key) { return __int_hash_get_float(h,key); }
inline String get_string(int key) { return __int_hash_get_string(h,key); }
inline cpp::Int64 get_int64(int key) { return __int_hash_get_int64(h,key); }
")
@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
@:ifFeature("haxe.ds.IntMap.*")
@ -123,6 +125,10 @@ package haxe.ds;
untyped __int_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt64(key:Int, val:haxe.Int64):Void {
untyped __int_hash_set_int64(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:Int):String {
return untyped __int_hash_get_string(h, key);
}
@ -138,5 +144,9 @@ package haxe.ds;
private function getFloat(key:Int):Float {
return untyped __int_hash_get_float(h, key);
}
private function getInt64(key:Int):haxe.Int64 {
return untyped __int_hash_get_int64(h, key);
}
#end
}

View File

@ -0,0 +1,209 @@
/*
* 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 haxe.Int64;
import haxe.ds.StringMap;
import haxe.ds.IntMap;
import haxe.ds.HashMap;
import haxe.ds.ObjectMap;
import haxe.ds.WeakMap;
import haxe.ds.EnumValueMap;
import haxe.Constraints.IMap;
import cpp.Int64Map;
/**
Map allows key to value mapping for arbitrary value types, and many key
types.
This is a multi-type abstract, it is instantiated as one of its
specialization types depending on its type parameters.
A Map can be instantiated without explicit type parameters. Type inference
will then determine the type parameters from the usage.
Maps can also be created with `[key1 => value1, key2 => value2]` syntax.
Map is an abstract type, it is not available at runtime.
@see https://haxe.org/manual/std-Map.html
**/
@:transitive
@:multiType(@:followWithAbstracts K)
abstract Map<K, V>(IMap<K, V>) {
/**
Creates a new Map.
This becomes a constructor call to one of the specialization types in
the output. The rules for that are as follows:
1. if `K` is a `String`, `haxe.ds.StringMap` is used
2. if `K` is an `Int`, `haxe.ds.IntMap` is used
3. if `K` is an `EnumValue`, `haxe.ds.EnumValueMap` is used
4. if `K` is any other class or structure, `haxe.ds.ObjectMap` is used
5. if `K` is any other type, it causes a compile-time error
(Cpp) Map does not use weak keys on `ObjectMap` by default.
**/
public function new();
/**
Maps `key` to `value`.
If `key` already has a mapping, the previous value disappears.
If `key` is `null`, the result is unspecified.
**/
public inline function set(key:K, value:V)
this.set(key, value);
/**
Returns the current mapping of `key`.
If no such mapping exists, `null` is returned.
Note that a check like `map.get(key) == null` can hold for two reasons:
1. the map has no mapping for `key`
2. the map has a mapping with a value of `null`
If it is important to distinguish these cases, `exists()` should be
used.
If `key` is `null`, the result is unspecified.
**/
@:arrayAccess public inline function get(key:K)
return this.get(key);
/**
Returns true if `key` has a mapping, false otherwise.
If `key` is `null`, the result is unspecified.
**/
public inline function exists(key:K)
return this.exists(key);
/**
Removes the mapping of `key` and returns true if such a mapping existed,
false otherwise.
If `key` is `null`, the result is unspecified.
**/
public inline function remove(key:K)
return this.remove(key);
/**
Returns an Iterator over the keys of `this` Map.
The order of keys is undefined.
**/
public inline function keys():Iterator<K> {
return this.keys();
}
/**
Returns an Iterator over the values of `this` Map.
The order of values is undefined.
**/
public inline function iterator():Iterator<V> {
return this.iterator();
}
/**
Returns an Iterator over the keys and values of `this` Map.
The order of values is undefined.
**/
public inline function keyValueIterator():KeyValueIterator<K, V> {
return this.keyValueIterator();
}
/**
Returns a shallow copy of `this` map.
The order of values is undefined.
**/
public inline function copy():Map<K, V> {
return cast this.copy();
}
/**
Returns a String representation of `this` Map.
The exact representation depends on the platform and key-type.
**/
public inline function toString():String {
return this.toString();
}
/**
Removes all keys from `this` Map.
**/
public inline function clear():Void {
this.clear();
}
@:arrayAccess @:noCompletion public inline function arrayWrite(k:K, v:V):V {
this.set(k, v);
return v;
}
@:to static inline function toStringMap<K:String, V>(t:IMap<K, V>):StringMap<V> {
return new StringMap<V>();
}
@:to static inline function toIntMap<K:Int, V>(t:IMap<K, V>):IntMap<V> {
return new IntMap<V>();
}
@:noDoc
@:to static inline function toInt64Map<K:Int64, V>(t:IMap<K, V>):Int64Map<V> {
return new Int64Map<V>();
}
@:to static inline function toEnumValueMapMap<K:EnumValue, V>(t:IMap<K, V>):EnumValueMap<K, V> {
return new EnumValueMap<K, V>();
}
@:to static inline function toObjectMap<K:{}, V>(t:IMap<K, V>):ObjectMap<K, V> {
return new ObjectMap<K, V>();
}
@:from static inline function fromStringMap<V>(map:StringMap<V>):Map<String, V> {
return cast map;
}
@:from static inline function fromIntMap<V>(map:IntMap<V>):Map<Int, V> {
return cast map;
}
@:noDoc
@:from static inline function fromInt64Map<V>(map:Int64Map<V>):Map<Int64, V> {
return cast map;
}
@:from static inline function fromObjectMap<K:{}, V>(map:ObjectMap<K, V>):Map<K, V> {
return cast map;
}
}

View File

@ -35,6 +35,7 @@ package haxe.ds;
inline void set(Dynamic key, float value) { __object_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, double value) { __object_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, ::String value) { __object_hash_set_string(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, cpp::Int64 value) { __object_hash_set_int64(HX_MAP_THIS,key,value); }
template<typename V, typename H>
@ -48,7 +49,7 @@ package haxe.ds;
inline int get_int(Dynamic key) { return __object_hash_get_int(h,key); }
inline Float get_float(Dynamic key) { return __object_hash_get_float(h,key); }
inline String get_string(Dynamic key) { return __object_hash_get_string(h,key); }
inline cpp::Int64 get_int64(Dynamic key) { return __object_hash_get_int64(h,key); }
")
@:coreApi
class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
@ -123,6 +124,10 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
untyped __object_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt64(key:Dynamic, val:haxe.Int64):Void {
untyped __object_hash_set_int64(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:Dynamic):String {
return untyped __object_hash_get_string(h, key);
}
@ -138,5 +143,9 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
private function getFloat(key:Dynamic):Float {
return untyped __object_hash_get_float(h, key);
}
private function getInt64(key:Dynamic):haxe.Int64 {
return untyped __object_hash_get_int64(h, key);
}
#end
}

View File

@ -35,6 +35,7 @@ package haxe.ds;
inline void set(String key, float value) { __string_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(String key, double value) { __string_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(String key, ::String value) { __string_hash_set_string(HX_MAP_THIS,key,value); }
inline void set(String key, cpp::Int64 value) { __string_hash_set_int64(HX_MAP_THIS,key,value); }
template<typename V, typename H>
inline void set(String key, const ::cpp::Struct<V,H> &value) {__string_hash_set(HX_MAP_THIS,key,value); }
@ -50,6 +51,7 @@ package haxe.ds;
inline int get_int(String key) { return __string_hash_get_int(h,key); }
inline Float get_float(String key) { return __string_hash_get_float(h,key); }
inline String get_string(String key) { return __string_hash_get_string(h,key); }
inline cpp::Int64 get_int64(String key) { return __string_hash_get_int64(h,key); }
")
@:coreApi class StringMap<T> implements haxe.Constraints.IMap<String, T> {
@:ifFeature("haxe.ds.StringMap.*")
@ -123,6 +125,10 @@ package haxe.ds;
untyped __string_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt64(key:String, val:haxe.Int64):Void {
untyped __string_hash_set_int64(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:String):String {
return untyped __string_hash_get_string(h, key);
}
@ -138,5 +144,9 @@ package haxe.ds;
private function getFloat(key:String):Float {
return untyped __string_hash_get_float(h, key);
}
private function getInt64(key:String):haxe.Int64 {
return untyped __string_hash_get_int64(h, key);
}
#end
}

View File

@ -35,6 +35,7 @@ package haxe.ds;
inline void set(Dynamic key, float value) { __object_hash_set_float(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, double value) { __object_hash_set_float(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, ::String value) { __object_hash_set_string(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, cpp::Int64 value) { __object_hash_set_int64(HX_MAP_THIS,key,value,true); }
template<typename V, typename H>
inline void set(Dynamic key, const ::cpp::Struct<V,H> &value) {__object_hash_set(HX_MAP_THIS,key,value,true); }