forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
94
Kha/Tools/macos/std/python/_std/haxe/Exception.hx
Normal file
94
Kha/Tools/macos/std/python/_std/haxe/Exception.hx
Normal file
@ -0,0 +1,94 @@
|
||||
package haxe;
|
||||
|
||||
import python.Exceptions.BaseException;
|
||||
import python.Exceptions.Exception in PyException;
|
||||
import python.lib.Traceback;
|
||||
import python.internal.UBuiltins;
|
||||
|
||||
private typedef PyStackItem = python.Tuple.Tuple4<String, Int, String, String>;
|
||||
|
||||
@:coreApi
|
||||
class Exception extends PyException {
|
||||
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 __exceptionStack:Null<CallStack>;
|
||||
@:noCompletion var __nativeStack:Array<PyStackItem>;
|
||||
@:noCompletion @:ifFeature("haxe.Exception.get_stack") var __skipStack:Int = 0;
|
||||
@:noCompletion var __nativeException:BaseException;
|
||||
@:noCompletion var __previousException:Null<Exception>;
|
||||
|
||||
static function caught(value:Any):Exception {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return value;
|
||||
} else if(Std.isOfType(value, BaseException)) {
|
||||
return new Exception(UBuiltins.str(value), null, value);
|
||||
} else {
|
||||
return new ValueException(value, null, value);
|
||||
}
|
||||
}
|
||||
|
||||
static function thrown(value:Any):Any {
|
||||
if(Std.isOfType(value, Exception)) {
|
||||
return (value:Exception).native;
|
||||
} else if(Std.isOfType(value, BaseException)) {
|
||||
return value;
|
||||
} else {
|
||||
var e = new ValueException(value);
|
||||
e.__shiftStack();
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
public function new(message:String, ?previous:Exception, ?native:Any) {
|
||||
super(message);
|
||||
this.__previousException = previous;
|
||||
if(native != null && Std.isOfType(native, BaseException)) {
|
||||
__nativeException = native;
|
||||
__nativeStack = NativeStackTrace.exceptionStack();
|
||||
} else {
|
||||
__nativeException = cast this;
|
||||
__nativeStack = NativeStackTrace.callStack();
|
||||
}
|
||||
}
|
||||
|
||||
function unwrap():Any {
|
||||
return __nativeException;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return message;
|
||||
}
|
||||
|
||||
public function details():String {
|
||||
return inline CallStack.exceptionToString(this);
|
||||
}
|
||||
|
||||
@:noCompletion
|
||||
@:ifFeature("haxe.Exception.get_stack")
|
||||
inline function __shiftStack():Void {
|
||||
__skipStack++;
|
||||
}
|
||||
|
||||
function get_message():String {
|
||||
return UBuiltins.str(this);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
35
Kha/Tools/macos/std/python/_std/haxe/Json.hx
Normal file
35
Kha/Tools/macos/std/python/_std/haxe/Json.hx
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import python.Syntax;
|
||||
|
||||
class Json {
|
||||
public static inline function parse(text:String):Dynamic {
|
||||
return python.lib.Json.loads(text, {object_hook: python.Lib.dictToAnon});
|
||||
}
|
||||
|
||||
public static inline function stringify(value:Dynamic, ?replacer:(key:Dynamic, value:Dynamic) -> Dynamic, ?space:String):String {
|
||||
return haxe.format.JsonPrinter.print(value, replacer, space);
|
||||
}
|
||||
}
|
46
Kha/Tools/macos/std/python/_std/haxe/NativeStackTrace.hx
Normal file
46
Kha/Tools/macos/std/python/_std/haxe/NativeStackTrace.hx
Normal file
@ -0,0 +1,46 @@
|
||||
package haxe;
|
||||
|
||||
import haxe.CallStack.StackItem;
|
||||
|
||||
private typedef NativeTrace = Array<python.Tuple.Tuple4<String, Int, String, String>>;
|
||||
|
||||
/**
|
||||
Do not use manually.
|
||||
**/
|
||||
@:dox(hide)
|
||||
@:noCompletion
|
||||
class NativeStackTrace {
|
||||
@:ifFeature('haxe.NativeStackTrace.exceptionStack')
|
||||
static public inline function saveStack(exception:Any):Void {
|
||||
}
|
||||
|
||||
static public inline function callStack():NativeTrace {
|
||||
var infos = python.lib.Traceback.extract_stack();
|
||||
infos.pop();
|
||||
infos.reverse();
|
||||
return infos;
|
||||
}
|
||||
|
||||
static public function exceptionStack():NativeTrace {
|
||||
var exc = python.lib.Sys.exc_info();
|
||||
if (exc._3 != null) {
|
||||
var infos = python.lib.Traceback.extract_tb(exc._3);
|
||||
infos.reverse();
|
||||
return infos;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
static public function toHaxe(native:NativeTrace, skip:Int = 0):Array<StackItem> {
|
||||
var stack = [];
|
||||
for(i in 0...native.length) {
|
||||
if(skip > i) {
|
||||
continue;
|
||||
}
|
||||
var elem = native[i];
|
||||
stack.push(FilePos(Method(null, elem._3), elem._1, elem._2));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
54
Kha/Tools/macos/std/python/_std/haxe/Resource.hx
Normal file
54
Kha/Tools/macos/std/python/_std/haxe/Resource.hx
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.BytesData;
|
||||
|
||||
@:coreApi class Resource {
|
||||
static var content:python.Dict<String, BytesData>;
|
||||
|
||||
static function getContent():python.Dict<String, BytesData> {
|
||||
if (content == null)
|
||||
content = untyped _hx_resources__();
|
||||
return content;
|
||||
}
|
||||
|
||||
public static inline function listNames():Array<String> {
|
||||
return python.internal.UBuiltins.list(getContent().keys());
|
||||
}
|
||||
|
||||
public static function getString(name:String):String {
|
||||
var bytes = getBytes(name);
|
||||
if (bytes != null)
|
||||
return bytes.toString();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getBytes(name:String):haxe.io.Bytes {
|
||||
var data = getContent().get(name, null);
|
||||
if (data == null)
|
||||
return null;
|
||||
return Bytes.ofData(data);
|
||||
}
|
||||
}
|
91
Kha/Tools/macos/std/python/_std/haxe/ds/IntMap.hx
Normal file
91
Kha/Tools/macos/std/python/_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;
|
||||
|
||||
import python.Dict;
|
||||
import python.Syntax;
|
||||
|
||||
class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
|
||||
private var h:Dict<Int, T>;
|
||||
|
||||
public function new():Void {
|
||||
h = new Dict();
|
||||
}
|
||||
|
||||
public function set(key:Int, value:T):Void {
|
||||
h.set(key, value);
|
||||
}
|
||||
|
||||
public inline function get(key:Int):Null<T> {
|
||||
return h.get(key, null);
|
||||
}
|
||||
|
||||
public inline function exists(key:Int):Bool {
|
||||
return h.hasKey(key);
|
||||
}
|
||||
|
||||
public function remove(key:Int):Bool {
|
||||
if (!h.hasKey(key))
|
||||
return false;
|
||||
Syntax.delete(Syntax.arrayAccess(h, key));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function keys():Iterator<Int> {
|
||||
return h.keys().iter();
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return h.values().iter();
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<Int, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():IntMap<T> {
|
||||
var copied = new IntMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(i);
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(i)));
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h.clear();
|
||||
}
|
||||
}
|
90
Kha/Tools/macos/std/python/_std/haxe/ds/ObjectMap.hx
Normal file
90
Kha/Tools/macos/std/python/_std/haxe/ds/ObjectMap.hx
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 python.Dict;
|
||||
|
||||
class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
|
||||
var h:Dict<K, V>;
|
||||
|
||||
public function new():Void {
|
||||
h = new Dict();
|
||||
}
|
||||
|
||||
public function set(key:K, value:V):Void {
|
||||
h.set(key, value);
|
||||
}
|
||||
|
||||
public inline function get(key:K):Null<V> {
|
||||
return h.get(key, null);
|
||||
}
|
||||
|
||||
public inline function exists(key:K):Bool {
|
||||
return h.hasKey(key);
|
||||
}
|
||||
|
||||
public function remove(key:K):Bool {
|
||||
var r = h.hasKey(key);
|
||||
if (r)
|
||||
h.remove(key);
|
||||
return r;
|
||||
}
|
||||
|
||||
public function keys():Iterator<K> {
|
||||
return h.keys().iter();
|
||||
}
|
||||
|
||||
public function iterator():Iterator<V> {
|
||||
return h.values().iter();
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<K, V> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():ObjectMap<K, V> {
|
||||
var copied = new ObjectMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
s.add("{");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(Std.string(i));
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(i)));
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h.clear();
|
||||
}
|
||||
}
|
92
Kha/Tools/macos/std/python/_std/haxe/ds/StringMap.hx
Normal file
92
Kha/Tools/macos/std/python/_std/haxe/ds/StringMap.hx
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 python.Syntax;
|
||||
import python.Dict;
|
||||
|
||||
class StringMap<T> implements haxe.Constraints.IMap<String, T> {
|
||||
private var h:Dict<String, T>;
|
||||
|
||||
public function new():Void {
|
||||
h = new Dict();
|
||||
}
|
||||
|
||||
public inline function set(key:String, value:T):Void {
|
||||
h.set(key, value);
|
||||
}
|
||||
|
||||
public inline function get(key:String):Null<T> {
|
||||
return h.get(key, null);
|
||||
}
|
||||
|
||||
public inline function exists(key:String):Bool {
|
||||
return h.hasKey(key);
|
||||
}
|
||||
|
||||
public function remove(key:String):Bool {
|
||||
var has = h.hasKey(key);
|
||||
if (has)
|
||||
h.remove(key);
|
||||
return has;
|
||||
}
|
||||
|
||||
public function keys():Iterator<String> {
|
||||
return h.keys().iter();
|
||||
}
|
||||
|
||||
public function iterator():Iterator<T> {
|
||||
return h.values().iter();
|
||||
}
|
||||
|
||||
@:runtime public inline function keyValueIterator():KeyValueIterator<String, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public function copy():StringMap<T> {
|
||||
var copied = new StringMap();
|
||||
for (key in keys())
|
||||
copied.set(key, get(key));
|
||||
return copied;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = new StringBuf();
|
||||
|
||||
s.add("{");
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s.add(i);
|
||||
s.add(" => ");
|
||||
s.add(Std.string(get(i)));
|
||||
if (it.hasNext())
|
||||
s.add(", ");
|
||||
}
|
||||
s.add("}");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
h.clear();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user