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

@ -17,6 +17,11 @@ abstract Rest<T>(NativeRest<T>) {
static public inline function of<T>(array:Array<T>):Rest<T>
return new Rest(@:privateAccess array.arr);
@:noDoc
@:from
static inline function ofNative<T>(array:NativeIndexedArray<T>):Rest<T>
return new Rest(array);
inline function new(a:NativeIndexedArray<T>):Void
this = a;

View File

@ -44,15 +44,18 @@ class Base64 {
public static inline function decode(str:String, complement = true):Bytes {
if (!complement) {
switch (strlen(str) % 3) {
case 1:
str += "==";
switch (strlen(str) % 4) {
case 2:
str += "==";
case 3:
str += "=";
default:
}
}
return Bytes.ofString(base64_decode(str, true));
return switch base64_decode(str, true) {
case false: throw new Exception("Base64.decode : invalid encoded string");
case s: Bytes.ofString(s);
}
}
public static inline function urlEncode(bytes:Bytes, complement = false):String {
@ -62,14 +65,17 @@ class Base64 {
public static inline function urlDecode(str:String, complement = false):Bytes {
if (complement) {
switch (strlen(str) % 3) {
case 1:
str += "==";
switch (strlen(str) % 4) {
case 2:
str += "==";
case 3:
str += "=";
default:
}
}
return Bytes.ofString(base64_decode(str_replace(URL_62_63, NORMAL_62_63, str), true));
return switch base64_decode(str_replace(URL_62_63, NORMAL_62_63, str), true) {
case false: throw new Exception("Base64.urlDecode : invalid encoded string");
case s: Bytes.ofString(s);
}
}
}

View File

@ -79,7 +79,7 @@ import php.NativeIndexedArray;
Global.array_push(parts, '$key => ' + Std.string(value));
});
return '{' + Global.implode(', ', parts) + '}';
return "[" + Global.implode(", ", parts) + "]";
}
public inline function clear():Void {

View File

@ -78,7 +78,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
}
public function toString():String {
var s = "{";
var s = "[";
var it = keys();
for (i in it) {
s += Std.string(i);
@ -87,7 +87,7 @@ class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
if (it.hasNext())
s += ", ";
}
return s + "}";
return s + "]";
}
public inline function clear():Void {

View File

@ -80,7 +80,7 @@ import haxe.Constraints;
Global.array_push(parts, '$key => ' + Std.string(value));
});
return '{' + Global.implode(', ', parts) + '}';
return "[" + Global.implode(", ", parts) + "]";
}
public inline function clear():Void {

View File

@ -28,19 +28,24 @@ private class PhpVectorData<T> {
public var length:Int;
public var data:NativeIndexedArray<T>;
public inline function new(length:Int) {
public inline function new(length:Int, data:NativeIndexedArray<T>) {
this.length = length;
data = new NativeIndexedArray();
this.data = data;
}
}
private typedef VectorData<T> = PhpVectorData<T>;
@:coreApi
abstract Vector<T>(VectorData<T>) {
public var length(get, never):Int;
public inline function new(length:Int) {
this = new VectorData(length);
extern overload public inline function new(length:Int) {
this = new VectorData(length, new NativeIndexedArray());
}
extern overload public inline function new(length:Int, defaultValue:T):Vector<T> {
this = new VectorData(length, Global.array_fill(0, length, defaultValue));
}
@:op([]) public inline function get(index:Int):T {
@ -55,6 +60,9 @@ abstract Vector<T>(VectorData<T>) {
return this.length;
}
public inline function fill(value:T):Void
this.data = Global.array_fill(0, length, value);
public static function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void {
if (src == dest) {
if (srcPos < destPos) {
@ -99,8 +107,7 @@ abstract Vector<T>(VectorData<T>) {
}
static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
var vectorData = new VectorData(array.length);
vectorData.data = @:privateAccess array.arr;
var vectorData = new VectorData(array.length, @:privateAccess array.arr);
return cast vectorData;
}
@ -127,7 +134,7 @@ abstract Vector<T>(VectorData<T>) {
return result;
}
public inline function sort<T>(f:T->T->Int):Void {
public inline function sort(f:T->T->Int):Void {
Global.usort(this.data, f);
}
}