forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
84
Kha/Tools/linux_x64/std/python/_std/sys/FileSystem.hx
Normal file
84
Kha/Tools/linux_x64/std/python/_std/sys/FileSystem.hx
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 sys;
|
||||
|
||||
import python.lib.Os;
|
||||
import python.lib.os.Path;
|
||||
|
||||
@:coreApi
|
||||
class FileSystem {
|
||||
public static function exists(path:String):Bool {
|
||||
return Path.exists(path);
|
||||
}
|
||||
|
||||
public static function stat(path:String):sys.FileStat {
|
||||
var s = Os.stat(path);
|
||||
return {
|
||||
gid: s.st_gid,
|
||||
uid: s.st_uid,
|
||||
atime: Date.fromTime(1000 * s.st_atime),
|
||||
mtime: Date.fromTime(1000 * s.st_mtime),
|
||||
ctime: Date.fromTime(1000 * s.st_ctime),
|
||||
size: s.st_size,
|
||||
dev: s.st_dev,
|
||||
ino: s.st_ino,
|
||||
nlink: s.st_nlink,
|
||||
rdev: python.internal.UBuiltins.getattr(s, "st_rdev", 0), // st_rdev is not available on Windows
|
||||
mode: s.st_mode
|
||||
}
|
||||
}
|
||||
|
||||
public static function rename(path:String, newPath:String):Void {
|
||||
Os.rename(path, newPath);
|
||||
}
|
||||
|
||||
public static function fullPath(relPath:String):String {
|
||||
return Path.realpath(relPath);
|
||||
}
|
||||
|
||||
public static function absolutePath(relPath:String):String {
|
||||
if (haxe.io.Path.isAbsolute(relPath))
|
||||
return relPath;
|
||||
return haxe.io.Path.join([Sys.getCwd(), relPath]);
|
||||
}
|
||||
|
||||
public static function isDirectory(path:String):Bool {
|
||||
return Path.isdir(path);
|
||||
}
|
||||
|
||||
public static function createDirectory(path:String):Void {
|
||||
Os.makedirs(path, 511, true);
|
||||
}
|
||||
|
||||
public static function deleteFile(path:String):Void {
|
||||
Os.remove(path);
|
||||
}
|
||||
|
||||
public static function deleteDirectory(path:String):Void {
|
||||
Os.rmdir(path);
|
||||
}
|
||||
|
||||
public static function readDirectory(path:String):Array<String> {
|
||||
return Os.listdir(path);
|
||||
}
|
||||
}
|
92
Kha/Tools/linux_x64/std/python/_std/sys/io/File.hx
Normal file
92
Kha/Tools/linux_x64/std/python/_std/sys/io/File.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 sys.io;
|
||||
|
||||
import python.io.IoTools;
|
||||
import sys.io.FileInput;
|
||||
|
||||
@:coreApi
|
||||
class File {
|
||||
public static function getContent(path:String):String {
|
||||
var f:python.lib.io.TextIOBase = cast python.lib.Builtins.open(path, "r", -1, "utf-8", null, "");
|
||||
var content = f.read(-1);
|
||||
f.close();
|
||||
return content;
|
||||
}
|
||||
|
||||
public static function saveContent(path:String, content:String):Void {
|
||||
var f:python.lib.io.TextIOBase = cast python.lib.Builtins.open(path, "w", -1, "utf-8", null, "");
|
||||
f.write(content);
|
||||
f.close();
|
||||
}
|
||||
|
||||
public static function getBytes(path:String):haxe.io.Bytes {
|
||||
var f:python.lib.io.RawIOBase = cast python.lib.Builtins.open(path, "rb", -1);
|
||||
var size = f.read(-1);
|
||||
var b = haxe.io.Bytes.ofData(size);
|
||||
f.close();
|
||||
return b;
|
||||
}
|
||||
|
||||
public static function saveBytes(path:String, bytes:haxe.io.Bytes):Void {
|
||||
var f:python.lib.io.RawIOBase = cast python.lib.Builtins.open(path, "wb", -1);
|
||||
f.write(bytes.getData());
|
||||
f.close();
|
||||
}
|
||||
|
||||
public static function read(path:String, binary:Bool = true):FileInput {
|
||||
var mode = if (binary) "rb" else "r";
|
||||
|
||||
var f = python.lib.Builtins.open(path, mode, -1, null, null, binary ? null : "");
|
||||
|
||||
return if (binary) IoTools.createFileInputFromBytes(cast f) else IoTools.createFileInputFromText(cast f);
|
||||
}
|
||||
|
||||
public static function write(path:String, binary:Bool = true):FileOutput {
|
||||
var mode = if (binary) "wb" else "w";
|
||||
var f = python.lib.Builtins.open(path, mode, -1, null, null, binary ? null : "");
|
||||
|
||||
return if (binary) IoTools.createFileOutputFromBytes(cast f) else IoTools.createFileOutputFromText(cast f);
|
||||
}
|
||||
|
||||
public static function append(path:String, binary:Bool = true):FileOutput {
|
||||
var mode = if (binary) "ab" else "a";
|
||||
var f = python.lib.Builtins.open(path, mode, -1, null, null, binary ? null : "");
|
||||
|
||||
return if (binary) IoTools.createFileOutputFromBytes(cast f) else IoTools.createFileOutputFromText(cast f);
|
||||
}
|
||||
|
||||
public static function update(path:String, binary:Bool = true):FileOutput {
|
||||
if (!FileSystem.exists(path)) {
|
||||
write(path).close();
|
||||
}
|
||||
var mode = if (binary) "rb+" else "r+";
|
||||
var f = python.lib.Builtins.open(path, mode, -1, null, null, binary ? null : "");
|
||||
|
||||
return if (binary) IoTools.createFileOutputFromBytes(cast f) else IoTools.createFileOutputFromText(cast f);
|
||||
}
|
||||
|
||||
public static function copy(srcPath:String, dstPath:String):Void {
|
||||
return python.lib.Shutil.copy(srcPath, dstPath);
|
||||
}
|
||||
}
|
120
Kha/Tools/linux_x64/std/python/_std/sys/io/FileInput.hx
Normal file
120
Kha/Tools/linux_x64/std/python/_std/sys/io/FileInput.hx
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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 sys.io;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.Encoding;
|
||||
import haxe.io.Input;
|
||||
import python.io.IFileInput;
|
||||
|
||||
class FileInput extends Input {
|
||||
var impl:IFileInput;
|
||||
|
||||
function new(impl:IFileInput) {
|
||||
this.impl = impl;
|
||||
}
|
||||
|
||||
override public function set_bigEndian(b:Bool) {
|
||||
return impl.bigEndian = b;
|
||||
}
|
||||
|
||||
public function seek(p:Int, pos:FileSeek):Void {
|
||||
return impl.seek(p, pos);
|
||||
}
|
||||
|
||||
public function tell():Int {
|
||||
return impl.tell();
|
||||
}
|
||||
|
||||
public function eof():Bool {
|
||||
return impl.eof();
|
||||
}
|
||||
|
||||
override public function readByte():Int {
|
||||
return impl.readByte();
|
||||
}
|
||||
|
||||
override public function readBytes(s:Bytes, pos:Int, len:Int):Int {
|
||||
return impl.readBytes(s, pos, len);
|
||||
}
|
||||
|
||||
override public function close():Void {
|
||||
impl.close();
|
||||
}
|
||||
|
||||
override public function readAll(?bufsize:Int):Bytes {
|
||||
return impl.readAll(bufsize);
|
||||
}
|
||||
|
||||
override public function readFullBytes(s:Bytes, pos:Int, len:Int):Void {
|
||||
impl.readFullBytes(s, pos, len);
|
||||
}
|
||||
|
||||
override public function read(nbytes:Int):Bytes {
|
||||
return impl.read(nbytes);
|
||||
}
|
||||
|
||||
override public function readUntil(end:Int):String {
|
||||
return impl.readUntil(end);
|
||||
}
|
||||
|
||||
override public function readLine():String {
|
||||
return impl.readLine();
|
||||
}
|
||||
|
||||
override public function readFloat():Float {
|
||||
return impl.readFloat();
|
||||
}
|
||||
|
||||
override public function readDouble():Float {
|
||||
return impl.readDouble();
|
||||
}
|
||||
|
||||
override public function readInt8():Int {
|
||||
return impl.readInt8();
|
||||
}
|
||||
|
||||
override public function readInt16():Int {
|
||||
return impl.readInt16();
|
||||
}
|
||||
|
||||
override public function readUInt16():Int {
|
||||
return impl.readUInt16();
|
||||
}
|
||||
|
||||
override public function readInt24():Int {
|
||||
return impl.readInt24();
|
||||
}
|
||||
|
||||
override public function readUInt24():Int {
|
||||
return impl.readUInt24();
|
||||
}
|
||||
|
||||
override public function readInt32():Int {
|
||||
return impl.readInt32();
|
||||
}
|
||||
|
||||
override public function readString(len:Int, ?encoding:Encoding):String {
|
||||
return impl.readString(len);
|
||||
}
|
||||
}
|
117
Kha/Tools/linux_x64/std/python/_std/sys/io/FileOutput.hx
Normal file
117
Kha/Tools/linux_x64/std/python/_std/sys/io/FileOutput.hx
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 sys.io;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.Encoding;
|
||||
import haxe.io.Input;
|
||||
import haxe.io.Output;
|
||||
import python.io.IFileOutput;
|
||||
|
||||
class FileOutput extends Output {
|
||||
var impl:IFileOutput;
|
||||
|
||||
function new(impl:IFileOutput) {
|
||||
this.impl = impl;
|
||||
}
|
||||
|
||||
public function seek(p:Int, pos:FileSeek):Void {
|
||||
return impl.seek(p, pos);
|
||||
}
|
||||
|
||||
public function tell():Int {
|
||||
return impl.tell();
|
||||
}
|
||||
|
||||
override public function set_bigEndian(b:Bool) {
|
||||
return impl.bigEndian = b;
|
||||
}
|
||||
|
||||
override public function writeByte(c:Int):Void {
|
||||
impl.writeByte(c);
|
||||
}
|
||||
|
||||
override public function writeBytes(s:Bytes, pos:Int, len:Int):Int {
|
||||
return impl.writeBytes(s, pos, len);
|
||||
}
|
||||
|
||||
override public function flush():Void {
|
||||
impl.flush();
|
||||
}
|
||||
|
||||
override public function close():Void {
|
||||
impl.close();
|
||||
}
|
||||
|
||||
override public function write(s:Bytes):Void {
|
||||
impl.write(s);
|
||||
}
|
||||
|
||||
override public function writeFullBytes(s:Bytes, pos:Int, len:Int):Void {
|
||||
impl.writeFullBytes(s, pos, len);
|
||||
}
|
||||
|
||||
override public function writeFloat(x:Float):Void {
|
||||
impl.writeFloat(x);
|
||||
}
|
||||
|
||||
override public function writeDouble(x:Float):Void {
|
||||
impl.writeDouble(x);
|
||||
}
|
||||
|
||||
override public function writeInt8(x:Int):Void {
|
||||
impl.writeInt8(x);
|
||||
}
|
||||
|
||||
override public function writeInt16(x:Int):Void {
|
||||
impl.writeInt16(x);
|
||||
}
|
||||
|
||||
override public function writeUInt16(x:Int):Void {
|
||||
impl.writeUInt16(x);
|
||||
}
|
||||
|
||||
override public function writeInt24(x:Int):Void {
|
||||
impl.writeInt24(x);
|
||||
}
|
||||
|
||||
override public function writeUInt24(x:Int):Void {
|
||||
impl.writeUInt24(x);
|
||||
}
|
||||
|
||||
override public function writeInt32(x:Int):Void {
|
||||
impl.writeInt32(x);
|
||||
}
|
||||
|
||||
override public function prepare(nbytes:Int):Void {
|
||||
impl.prepare(nbytes);
|
||||
}
|
||||
|
||||
override public function writeInput(i:Input, ?bufsize:Int):Void {
|
||||
impl.writeInput(i, bufsize);
|
||||
}
|
||||
|
||||
override public function writeString(s:String, ?encoding:Encoding):Void {
|
||||
impl.writeString(s);
|
||||
}
|
||||
}
|
82
Kha/Tools/linux_x64/std/python/_std/sys/io/Process.hx
Normal file
82
Kha/Tools/linux_x64/std/python/_std/sys/io/Process.hx
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 sys.io;
|
||||
|
||||
import python.io.IoTools;
|
||||
import python.lib.io.BufferedReader;
|
||||
import python.lib.io.BufferedWriter;
|
||||
import python.lib.io.TextIOWrapper;
|
||||
import python.lib.Subprocess;
|
||||
import python.lib.subprocess.Popen;
|
||||
|
||||
class Process {
|
||||
public var stdout(default, null):haxe.io.Input;
|
||||
public var stderr(default, null):haxe.io.Input;
|
||||
public var stdin(default, null):haxe.io.Output;
|
||||
|
||||
var p:Popen;
|
||||
|
||||
public function new(cmd:String, ?args:Array<String>, ?detached:Bool):Void {
|
||||
if (detached)
|
||||
throw "Detached process is not supported on this platform";
|
||||
p = Popen.create(args == null ? cmd : [cmd].concat(args), {
|
||||
shell: args == null,
|
||||
stdin: Subprocess.PIPE,
|
||||
stdout: Subprocess.PIPE,
|
||||
stderr: Subprocess.PIPE
|
||||
});
|
||||
this.stdout = IoTools.createFileInputFromText(new TextIOWrapper(new BufferedReader(p.stdout)));
|
||||
this.stderr = IoTools.createFileInputFromText(new TextIOWrapper(new BufferedReader(p.stderr)));
|
||||
this.stdin = IoTools.createFileOutputFromText(new TextIOWrapper(new BufferedWriter(p.stdin)));
|
||||
}
|
||||
|
||||
public function getPid():Int {
|
||||
return p.pid;
|
||||
}
|
||||
|
||||
public function exitCode(block:Bool = true):Null<Int> {
|
||||
if (block == false)
|
||||
return p.poll();
|
||||
return p.wait();
|
||||
}
|
||||
|
||||
public function close():Void {
|
||||
var ver = python.lib.Sys.version_info;
|
||||
if (ver[0] > 3 || (ver[0] == 3 && ver[1] >= 3)) // >= 3.3
|
||||
try {
|
||||
p.terminate();
|
||||
} catch (e:python.Exceptions.ProcessLookupError) {
|
||||
// it has already terminated
|
||||
}
|
||||
else
|
||||
try {
|
||||
p.terminate();
|
||||
} catch (e:python.Exceptions.OSError) {
|
||||
// it has already terminated
|
||||
}
|
||||
}
|
||||
|
||||
public function kill():Void {
|
||||
p.kill();
|
||||
}
|
||||
}
|
47
Kha/Tools/linux_x64/std/python/_std/sys/net/Host.hx
Normal file
47
Kha/Tools/linux_x64/std/python/_std/sys/net/Host.hx
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 sys.net;
|
||||
|
||||
class Host {
|
||||
public var host(default, null):String;
|
||||
public var ip(default, null):Int;
|
||||
|
||||
var name:String;
|
||||
|
||||
public function new(name:String):Void {
|
||||
host = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return name;
|
||||
}
|
||||
|
||||
public function reverse():String {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function localhost():String {
|
||||
return "";
|
||||
}
|
||||
}
|
201
Kha/Tools/linux_x64/std/python/_std/sys/net/Socket.hx
Normal file
201
Kha/Tools/linux_x64/std/python/_std/sys/net/Socket.hx
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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 sys.net;
|
||||
|
||||
import haxe.io.Error;
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.BytesData;
|
||||
import python.Exceptions;
|
||||
import python.Tuple;
|
||||
import python.lib.socket.Socket in PSocket;
|
||||
import python.lib.Socket in PSocketModule;
|
||||
import python.lib.socket.Address in PAddress;
|
||||
import python.lib.Select;
|
||||
|
||||
private class SocketInput extends haxe.io.Input {
|
||||
var __s:PSocket;
|
||||
|
||||
public function new(s) {
|
||||
__s = s;
|
||||
}
|
||||
|
||||
public override function readByte():Int {
|
||||
var r:BytesData;
|
||||
try {
|
||||
r = __s.recv(1, 0);
|
||||
} catch (e:BlockingIOError) {
|
||||
throw Blocked;
|
||||
}
|
||||
if (r.length == 0)
|
||||
throw new haxe.io.Eof();
|
||||
return python.Syntax.code("r[0]");
|
||||
}
|
||||
|
||||
public override function readBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
|
||||
var r;
|
||||
var data = buf.getData();
|
||||
try {
|
||||
r = __s.recv(len, 0);
|
||||
for (i in pos...(pos + r.length)) {
|
||||
data.set(i, r[i - pos]);
|
||||
}
|
||||
} catch (e:BlockingIOError) {
|
||||
throw Blocked;
|
||||
}
|
||||
if (r.length == 0)
|
||||
throw new haxe.io.Eof();
|
||||
return r.length;
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
if (__s != null)
|
||||
__s.close();
|
||||
}
|
||||
}
|
||||
|
||||
private class SocketOutput extends haxe.io.Output {
|
||||
var __s:PSocket;
|
||||
|
||||
public function new(s) {
|
||||
__s = s;
|
||||
}
|
||||
|
||||
public override function writeByte(c:Int) {
|
||||
try {
|
||||
__s.send(python.Syntax.code('bytes([c])'), 0);
|
||||
} catch (e:BlockingIOError) {
|
||||
throw Blocked;
|
||||
}
|
||||
}
|
||||
|
||||
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
|
||||
try {
|
||||
var data = buf.getData();
|
||||
var payload = python.Syntax.code("{0}[{1}:{1}+{2}]", data, pos, len);
|
||||
var r = __s.send(payload, 0);
|
||||
return r;
|
||||
} catch (e:BlockingIOError) {
|
||||
throw Blocked;
|
||||
}
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
if (__s != null)
|
||||
__s.close();
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi class Socket {
|
||||
var __s:PSocket;
|
||||
|
||||
public var input(default, null):haxe.io.Input;
|
||||
|
||||
public var output(default, null):haxe.io.Output;
|
||||
|
||||
public var custom:Dynamic;
|
||||
|
||||
public function new():Void {
|
||||
__initSocket();
|
||||
input = new SocketInput(__s);
|
||||
output = new SocketOutput(__s);
|
||||
}
|
||||
|
||||
function __initSocket():Void {
|
||||
__s = new PSocket();
|
||||
}
|
||||
|
||||
public function close():Void {
|
||||
__s.close();
|
||||
}
|
||||
|
||||
public function read():String {
|
||||
return input.readAll().toString();
|
||||
}
|
||||
|
||||
public function write(content:String):Void {
|
||||
output.writeString(content);
|
||||
}
|
||||
|
||||
public function connect(host:Host, port:Int):Void {
|
||||
var host_str = host.toString();
|
||||
__s.connect(Tuple2.make(host_str, port));
|
||||
}
|
||||
|
||||
public function listen(connections:Int):Void {
|
||||
__s.listen(connections);
|
||||
}
|
||||
|
||||
public function shutdown(read:Bool, write:Bool):Void
|
||||
__s.shutdown((read && write) ? PSocketModule.SHUT_RDWR : read ? PSocketModule.SHUT_RD : PSocketModule.SHUT_WR);
|
||||
|
||||
public function bind(host:Host, port:Int):Void {
|
||||
var host_str = host.toString();
|
||||
__s.bind(Tuple2.make(host_str, port));
|
||||
}
|
||||
|
||||
public function accept():Socket {
|
||||
var tp2:Tuple2<PSocket, PAddress> = __s.accept();
|
||||
var s = new Socket();
|
||||
s.__s = tp2._1;
|
||||
s.input = new SocketInput(s.__s);
|
||||
s.output = new SocketOutput(s.__s);
|
||||
return s;
|
||||
}
|
||||
|
||||
public function peer():{host:Host, port:Int} {
|
||||
var pn = __s.getpeername();
|
||||
return {host: new Host(pn._1), port: pn._2}
|
||||
}
|
||||
|
||||
public function host():{host:Host, port:Int} {
|
||||
var pn = __s.getsockname();
|
||||
return {host: new Host(pn._1), port: pn._2};
|
||||
}
|
||||
|
||||
public function setTimeout(timeout:Float):Void {
|
||||
__s.settimeout(timeout);
|
||||
}
|
||||
|
||||
public function waitForRead():Void {
|
||||
Select.select([this], [], []);
|
||||
}
|
||||
|
||||
public function setBlocking(b:Bool):Void {
|
||||
__s.setblocking(b);
|
||||
}
|
||||
|
||||
public function setFastSend(b:Bool):Void {
|
||||
__s.setsockopt(PSocketModule.SOL_TCP, PSocketModule.TCP_NODELAY, b);
|
||||
}
|
||||
|
||||
@:keep function fileno():Int
|
||||
return __s.fileno();
|
||||
|
||||
public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
|
||||
?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
|
||||
var t3 = Select.select(read, write, others, timeout);
|
||||
return {read: t3._1, write: t3._2, others: t3._3};
|
||||
}
|
||||
}
|
83
Kha/Tools/linux_x64/std/python/_std/sys/thread/Deque.hx
Normal file
83
Kha/Tools/linux_x64/std/python/_std/sys/thread/Deque.hx
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 sys.thread;
|
||||
|
||||
using python.internal.UBuiltins;
|
||||
|
||||
class Deque<T> {
|
||||
var deque:NativeDeque<T>;
|
||||
var lock:NativeCondition;
|
||||
|
||||
public function new() {
|
||||
deque = new NativeDeque<T>();
|
||||
lock = new NativeCondition();
|
||||
}
|
||||
|
||||
public function add(i:T) {
|
||||
lock.acquire();
|
||||
deque.append(i);
|
||||
lock.notify();
|
||||
lock.release();
|
||||
}
|
||||
|
||||
public function push(i:T) {
|
||||
lock.acquire();
|
||||
deque.appendleft(i);
|
||||
lock.notify();
|
||||
lock.release();
|
||||
}
|
||||
|
||||
public function pop(block:Bool):Null<T> {
|
||||
var ret = null;
|
||||
lock.acquire();
|
||||
if (block) {
|
||||
lock.wait_for(() -> deque.bool());
|
||||
ret = deque.popleft();
|
||||
} else if (deque.bool()) {
|
||||
ret = deque.popleft();
|
||||
}
|
||||
lock.release();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@:pythonImport("collections", "deque")
|
||||
@:native("deque")
|
||||
extern class NativeDeque<T> {
|
||||
function new();
|
||||
function append(x:T):Void;
|
||||
function appendleft(x:T):Void;
|
||||
function popleft():T;
|
||||
}
|
||||
|
||||
@:pythonImport("threading", "Condition")
|
||||
@:native("Condition")
|
||||
private extern class NativeCondition {
|
||||
function new(?lock:Dynamic);
|
||||
function acquire(blocking:Bool = true, timeout:Float = -1):Bool;
|
||||
function release():Void;
|
||||
function wait(?timeout:Float):Bool;
|
||||
function wait_for(predicate:()->Bool, ?timeout:Float):Bool;
|
||||
function notify(n:Int = 1):Void;
|
||||
function notify_all():Void;
|
||||
}
|
48
Kha/Tools/linux_x64/std/python/_std/sys/thread/Lock.hx
Normal file
48
Kha/Tools/linux_x64/std/python/_std/sys/thread/Lock.hx
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 sys.thread;
|
||||
|
||||
@:coreApi
|
||||
class Lock {
|
||||
final semaphore:NativeSemaphore;
|
||||
|
||||
public inline function new() {
|
||||
semaphore = new NativeSemaphore(0);
|
||||
}
|
||||
|
||||
public inline function wait(?timeout:Float):Bool {
|
||||
return semaphore.acquire(true, timeout);
|
||||
}
|
||||
|
||||
public inline function release():Void {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
|
||||
@:pythonImport("threading", "Semaphore")
|
||||
@:native("Lock")
|
||||
private extern class NativeSemaphore {
|
||||
function new(value:Int);
|
||||
function acquire(blocking:Bool = true, ?timeout:Float):Bool;
|
||||
function release():Void;
|
||||
}
|
51
Kha/Tools/linux_x64/std/python/_std/sys/thread/Mutex.hx
Normal file
51
Kha/Tools/linux_x64/std/python/_std/sys/thread/Mutex.hx
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 sys.thread;
|
||||
|
||||
@:coreApi
|
||||
class Mutex {
|
||||
final lock:NativeRLock;
|
||||
|
||||
inline public function new():Void {
|
||||
lock = new NativeRLock();
|
||||
}
|
||||
|
||||
inline public function acquire():Void {
|
||||
lock.acquire(true);
|
||||
}
|
||||
|
||||
inline public function tryAcquire():Bool {
|
||||
return lock.acquire(false);
|
||||
}
|
||||
|
||||
inline public function release():Void {
|
||||
lock.release();
|
||||
}
|
||||
}
|
||||
|
||||
@:pythonImport("threading", "RLock")
|
||||
private extern class NativeRLock {
|
||||
function new():Void;
|
||||
function acquire(blocking:Bool):Bool;
|
||||
function release():Void;
|
||||
}
|
175
Kha/Tools/linux_x64/std/python/_std/sys/thread/Thread.hx
Normal file
175
Kha/Tools/linux_x64/std/python/_std/sys/thread/Thread.hx
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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 sys.thread;
|
||||
|
||||
import haxe.ds.ObjectMap;
|
||||
|
||||
private typedef ThreadImpl = HxThread;
|
||||
|
||||
abstract Thread(ThreadImpl) from ThreadImpl {
|
||||
public var events(get,never):EventLoop;
|
||||
|
||||
public static inline function current():Thread {
|
||||
return HxThread.current();
|
||||
}
|
||||
|
||||
public static inline function create(callb:Void->Void):Thread {
|
||||
return HxThread.create(callb, false);
|
||||
}
|
||||
|
||||
public static inline function runWithEventLoop(job:()->Void):Void {
|
||||
HxThread.runWithEventLoop(job);
|
||||
}
|
||||
|
||||
public static inline function createWithEventLoop(job:()->Void):Thread {
|
||||
return HxThread.create(job, true);
|
||||
}
|
||||
|
||||
public static inline function readMessage(block:Bool):Dynamic {
|
||||
return HxThread.readMessage(block);
|
||||
}
|
||||
|
||||
public inline function sendMessage(msg:Dynamic):Void {
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
|
||||
function get_events():EventLoop {
|
||||
if(this.events == null)
|
||||
throw new NoEventLoopException();
|
||||
return this.events;
|
||||
}
|
||||
|
||||
@:keep
|
||||
static public function processEvents() {
|
||||
HxThread.current().events.loop();
|
||||
}
|
||||
}
|
||||
|
||||
private class HxThread {
|
||||
public var events(default,null):Null<EventLoop>;
|
||||
|
||||
final nativeThread:NativeThread;
|
||||
final messages = new Deque<Dynamic>();
|
||||
|
||||
static var threads:ObjectMap<NativeThread, HxThread>;
|
||||
static var threadsMutex:Mutex;
|
||||
static var mainThread:HxThread;
|
||||
|
||||
static function __init__() {
|
||||
threads = new ObjectMap();
|
||||
threadsMutex = new Mutex();
|
||||
mainThread = new HxThread(PyThreadingAPI.current_thread());
|
||||
mainThread.events = new EventLoop();
|
||||
}
|
||||
|
||||
private function new(t:NativeThread) {
|
||||
nativeThread = t;
|
||||
}
|
||||
|
||||
public function sendMessage(msg:Dynamic):Void {
|
||||
messages.add(msg);
|
||||
}
|
||||
|
||||
public static function current():HxThread {
|
||||
threadsMutex.acquire();
|
||||
var ct = PyThreadingAPI.current_thread();
|
||||
if (ct == PyThreadingAPI.main_thread()) {
|
||||
threadsMutex.release();
|
||||
return mainThread;
|
||||
}
|
||||
// If the current thread was not created via the haxe API, it can still be wrapped
|
||||
if (!threads.exists(ct)) {
|
||||
threads.set(ct, new HxThread(ct));
|
||||
}
|
||||
var t = threads.get(ct);
|
||||
threadsMutex.release();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static function create(callb:Void->Void, withEventLoop:Bool):HxThread {
|
||||
var nt:NativeThread = null;
|
||||
var t:HxThread = null;
|
||||
// Wrap the callback so it will clear the thread reference once the thread is finished
|
||||
var wrappedCallB = () -> {
|
||||
try {
|
||||
callb();
|
||||
if(withEventLoop)
|
||||
t.events.loop();
|
||||
} catch(e) {
|
||||
dropThread(nt);
|
||||
throw e;
|
||||
}
|
||||
dropThread(nt);
|
||||
}
|
||||
nt = new NativeThread(null, wrappedCallB);
|
||||
t = new HxThread(nt);
|
||||
if(withEventLoop)
|
||||
t.events = new EventLoop();
|
||||
threadsMutex.acquire();
|
||||
threads.set(nt, t);
|
||||
threadsMutex.release();
|
||||
nt.start();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static function runWithEventLoop(job:()->Void):Void {
|
||||
var thread = current();
|
||||
if(thread.events == null) {
|
||||
thread.events = new EventLoop();
|
||||
try {
|
||||
job();
|
||||
thread.events.loop();
|
||||
thread.events = null;
|
||||
} catch(e) {
|
||||
thread.events = null;
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
job();
|
||||
}
|
||||
}
|
||||
|
||||
static inline function dropThread(nt:NativeThread) {
|
||||
threadsMutex.acquire();
|
||||
threads.remove(nt);
|
||||
threadsMutex.release();
|
||||
}
|
||||
|
||||
public static function readMessage(block:Bool):Dynamic {
|
||||
return current().messages.pop(block);
|
||||
}
|
||||
}
|
||||
|
||||
@:pythonImport("threading", "Thread")
|
||||
@:native("Thread")
|
||||
private extern class NativeThread {
|
||||
function new(group:Dynamic, target:Void->Void);
|
||||
function start():Void;
|
||||
}
|
||||
|
||||
@:pythonImport("threading")
|
||||
@:native("threading")
|
||||
private extern class PyThreadingAPI {
|
||||
static function current_thread():NativeThread;
|
||||
static function main_thread():NativeThread;
|
||||
}
|
30
Kha/Tools/linux_x64/std/python/_std/sys/thread/Tls.hx
Normal file
30
Kha/Tools/linux_x64/std/python/_std/sys/thread/Tls.hx
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 sys.thread;
|
||||
|
||||
@:pythonImport("threading", "local")
|
||||
@:native("local")
|
||||
extern class Tls<T> {
|
||||
function new():Void;
|
||||
var value(default, default):T;
|
||||
}
|
Reference in New Issue
Block a user