forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
45
Kha/Tools/linux_x64/std/eval/NativeString.hx
Normal file
45
Kha/Tools/linux_x64/std/eval/NativeString.hx
Normal file
@ -0,0 +1,45 @@
|
||||
package eval;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
@:coreType abstract NativeString {
|
||||
/** String length */
|
||||
public var length(get,never):Int;
|
||||
function get_length():Int;
|
||||
|
||||
@:from static public function fromString(s:String):NativeString;
|
||||
|
||||
@:from static public function fromBytes(b:Bytes):NativeString;
|
||||
|
||||
/**
|
||||
Returns a character at the specified `index`.
|
||||
|
||||
Throws an exception if `index` is outside of the string bounds.
|
||||
**/
|
||||
public function char(index:Int):String;
|
||||
|
||||
/**
|
||||
Returns a character code at the specified `index`.
|
||||
|
||||
Throws an exception if `index` is outside of the string bounds.
|
||||
**/
|
||||
public function code(index:Int):Int;
|
||||
|
||||
/**
|
||||
Returns a fresh string up to `length` characters long, containing the
|
||||
substring that starts at position `start`.
|
||||
|
||||
If `length` is not specified the all characters from `start` to the end
|
||||
of this string are returned.
|
||||
|
||||
Throws an exception if `index` is outside of the string bounds.
|
||||
**/
|
||||
public function sub(start:Int, ?length:Int):NativeString;
|
||||
|
||||
public function toString():String;
|
||||
|
||||
public function toBytes():Bytes;
|
||||
|
||||
@:op(A + B)
|
||||
public function concat(s:NativeString):NativeString;
|
||||
}
|
34
Kha/Tools/linux_x64/std/eval/Vector.hx
Normal file
34
Kha/Tools/linux_x64/std/eval/Vector.hx
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 eval;
|
||||
|
||||
extern class Vector<T> implements ArrayAccess<T> {
|
||||
function new(size:Int):Void;
|
||||
var length(default, null):Int;
|
||||
function blit<T>(srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void;
|
||||
function toArray():Array<T>;
|
||||
static function fromArrayCopy<T>(array:Array<T>):Vector<T>;
|
||||
function copy<T>():Vector<T>;
|
||||
function join<T>(sep:String):String;
|
||||
function map<S>(f:T->S):Vector<S>;
|
||||
}
|
37
Kha/Tools/linux_x64/std/eval/_std/EReg.hx
Normal file
37
Kha/Tools/linux_x64/std/eval/_std/EReg.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.
|
||||
*/
|
||||
// We need this class so that calls to the empty standard implementations
|
||||
// don't get optimized away.
|
||||
@:coreApi
|
||||
extern class EReg {
|
||||
function new(r:String, opt:String):Void;
|
||||
function match(s:String):Bool;
|
||||
function matched(n:Int):String;
|
||||
function matchedLeft():String;
|
||||
function matchedRight():String;
|
||||
function matchedPos():{pos:Int, len:Int};
|
||||
function matchSub(s:String, pos:Int, len:Int = -1):Bool;
|
||||
function split(s:String):Array<String>;
|
||||
function replace(s:String, by:String):String;
|
||||
function map(s:String, f:EReg->String):String;
|
||||
static function escape(s:String):String;
|
||||
}
|
31
Kha/Tools/linux_x64/std/eval/_std/StringBuf.hx
Normal file
31
Kha/Tools/linux_x64/std/eval/_std/StringBuf.hx
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@:coreApi
|
||||
extern class StringBuf {
|
||||
var length(get, never):Int;
|
||||
function new():Void;
|
||||
private function get_length():Int;
|
||||
function add<T>(x:T):Void;
|
||||
function addChar(c:Int):Void;
|
||||
function addSub(s:String, pos:Int, ?len:Int):Void;
|
||||
function toString():String;
|
||||
}
|
96
Kha/Tools/linux_x64/std/eval/_std/Sys.hx
Normal file
96
Kha/Tools/linux_x64/std/eval/_std/Sys.hx
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import haxe.SysTools;
|
||||
|
||||
@:require(sys)
|
||||
@:coreApi
|
||||
class Sys {
|
||||
extern static public function print(v:Dynamic):Void;
|
||||
|
||||
extern static public function println(v:Dynamic):Void;
|
||||
|
||||
extern static public function args():Array<String>;
|
||||
|
||||
extern static public function getEnv(s:String):String;
|
||||
|
||||
extern static public function putEnv(s:String, v:String):Void;
|
||||
|
||||
extern static public function environment():Map<String, String>;
|
||||
|
||||
extern static public function sleep(seconds:Float):Void;
|
||||
|
||||
extern static public function setTimeLocale(loc:String):Bool;
|
||||
|
||||
extern static public function getCwd():String;
|
||||
|
||||
extern static public function setCwd(s:String):Void;
|
||||
|
||||
extern static public function systemName():String;
|
||||
|
||||
extern static function _command(cmd:String):Int;
|
||||
|
||||
static public function command(cmd:String, ?args:Array<String>):Int {
|
||||
if (args == null) {
|
||||
return _command(cmd);
|
||||
} else {
|
||||
switch (systemName()) {
|
||||
case "Windows":
|
||||
cmd = [
|
||||
for (a in [StringTools.replace(cmd, "/", "\\")].concat(args))
|
||||
SysTools.quoteWinArg(a, true)
|
||||
].join(" ");
|
||||
return _command(cmd);
|
||||
case _:
|
||||
cmd = [cmd].concat(args).map(SysTools.quoteUnixArg).join(" ");
|
||||
return _command(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public function executablePath():String {
|
||||
return programPath();
|
||||
}
|
||||
|
||||
extern static public function exit(code:Int):Void;
|
||||
|
||||
extern static public function time():Float;
|
||||
|
||||
extern static public function cpuTime():Float;
|
||||
|
||||
extern static public function programPath():String;
|
||||
|
||||
extern static public function getChar(echo:Bool):Int;
|
||||
|
||||
extern static public function stdin():haxe.io.Input;
|
||||
|
||||
extern static public function stdout():haxe.io.Output;
|
||||
|
||||
extern static public function stderr():haxe.io.Output;
|
||||
|
||||
static function __init__():Void {
|
||||
// This nonsense causes the classes to be loaded. Otherwise they might not make
|
||||
// it into the interpreter, and then stderr() et. al. don't work.
|
||||
var _ = (null : sys.io.FileOutput);
|
||||
var _ = (null : sys.io.FileInput);
|
||||
}
|
||||
}
|
89
Kha/Tools/linux_x64/std/eval/_std/haxe/Exception.hx
Normal file
89
Kha/Tools/linux_x64/std/eval/_std/haxe/Exception.hx
Normal file
@ -0,0 +1,89 @@
|
||||
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:CallStack;
|
||||
@: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 {
|
||||
return new ValueException(value, null, value);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@:ifFeature("haxe.Exception.thrown")
|
||||
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 __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 = if(__skipStack > 0) {
|
||||
__nativeStack.asArray().slice(__skipStack);
|
||||
} else {
|
||||
__nativeStack;
|
||||
}
|
||||
case s: s;
|
||||
}
|
||||
}
|
||||
}
|
32
Kha/Tools/linux_x64/std/eval/_std/haxe/NativeStackTrace.hx
Normal file
32
Kha/Tools/linux_x64/std/eval/_std/haxe/NativeStackTrace.hx
Normal file
@ -0,0 +1,32 @@
|
||||
package haxe;
|
||||
|
||||
import haxe.CallStack.StackItem;
|
||||
|
||||
/**
|
||||
Do not use manually.
|
||||
**/
|
||||
@:dox(hide)
|
||||
@:noCompletion
|
||||
class NativeStackTrace {
|
||||
@:ifFeature('haxe.NativeStackTrace.exceptionStack')
|
||||
static public inline function saveStack(exception:Any):Void {
|
||||
}
|
||||
|
||||
static public function callStack():Array<StackItem> {
|
||||
return _callStack();
|
||||
}
|
||||
|
||||
//implemented in the compiler
|
||||
static function _callStack():Array<StackItem> {
|
||||
return null;
|
||||
}
|
||||
|
||||
//implemented in the compiler
|
||||
static public function exceptionStack():Array<StackItem> {
|
||||
return null;
|
||||
}
|
||||
|
||||
static public inline function toHaxe(stack:Array<StackItem>, skip:Int = 0):Array<StackItem> {
|
||||
return skip > 0 ? stack.slice(skip) : stack;
|
||||
}
|
||||
}
|
30
Kha/Tools/linux_x64/std/eval/_std/haxe/Resource.hx
Normal file
30
Kha/Tools/linux_x64/std/eval/_std/haxe/Resource.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 haxe;
|
||||
|
||||
@:coreApi
|
||||
extern class Resource {
|
||||
static function listNames():Array<String>;
|
||||
static function getString(name:String):String;
|
||||
static function getBytes(name:String):haxe.io.Bytes;
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/_std/haxe/Utf8.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/_std/haxe/Utf8.hx
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@:coreApi
|
||||
@:deprecated('haxe.Utf8 is deprecated. Use UnicodeString instead.')
|
||||
extern class Utf8 {
|
||||
function new(?size:Int):Void;
|
||||
function addChar(c:Int):Void;
|
||||
function toString():String;
|
||||
static function iter(s:String, chars:Int->Void):Void;
|
||||
static function encode(s:String):String;
|
||||
static function decode(s:String):String;
|
||||
static function charCodeAt(s:String, index:Int):Int;
|
||||
static function validate(s:String):Bool;
|
||||
static function length(s:String):Int;
|
||||
static function compare(a:String, b:String):Int;
|
||||
static function sub(s:String, pos:Int, len:Int):String;
|
||||
}
|
58
Kha/Tools/linux_x64/std/eval/_std/haxe/io/Bytes.hx
Normal file
58
Kha/Tools/linux_x64/std/eval/_std/haxe/io/Bytes.hx
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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
|
||||
extern class Bytes {
|
||||
function new(length:Int, b:BytesData):Void;
|
||||
var length(default, null):Int;
|
||||
function get(pos:Int):Int;
|
||||
function set(pos:Int, v:Int):Void;
|
||||
function blit(pos:Int, src:Bytes, srcpos:Int, len:Int):Void;
|
||||
function fill(pos:Int, len:Int, value:Int):Void;
|
||||
function sub(pos:Int, len:Int):Bytes;
|
||||
function compare(other:Bytes):Int;
|
||||
function getDouble(pos:Int):Float;
|
||||
function getFloat(pos:Int):Float;
|
||||
function setDouble(pos:Int, v:Float):Void;
|
||||
function setFloat(pos:Int, v:Float):Void;
|
||||
function getUInt16(pos:Int):Int;
|
||||
function setUInt16(pos:Int, v:Int):Void;
|
||||
function getInt32(pos:Int):Int;
|
||||
function getInt64(pos:Int):haxe.Int64;
|
||||
function setInt32(pos:Int, v:Int):Void;
|
||||
function setInt64(pos:Int, v:haxe.Int64):Void;
|
||||
function getString(pos:Int, len:Int, ?encoding:Encoding):String;
|
||||
function toString():String;
|
||||
function toHex():String;
|
||||
function getData():BytesData;
|
||||
static function alloc(length:Int):Bytes;
|
||||
@:pure
|
||||
static function ofString(s:String, ?encoding:Encoding):Bytes;
|
||||
static function ofData(b:BytesData):Bytes;
|
||||
static function ofHex(s:String):Bytes;
|
||||
static function fastGet(b:BytesData, pos:Int):Int;
|
||||
static function __init__():Void {
|
||||
haxe.io.Error;
|
||||
}
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/_std/haxe/io/BytesBuffer.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/_std/haxe/io/BytesBuffer.hx
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
extern class BytesBuffer {
|
||||
var length(get, never):Int;
|
||||
function new():Void;
|
||||
private function get_length():Int;
|
||||
function addByte(byte:Int):Void;
|
||||
function add(src:Bytes):Void;
|
||||
function addString(v:String, ?encoding:Encoding):Void;
|
||||
function addInt32(v:Int):Void;
|
||||
function addInt64(v:haxe.Int64):Void;
|
||||
function addFloat(v:Float):Void;
|
||||
function addDouble(v:Float):Void;
|
||||
function addBytes(src:Bytes, pos:Int, len:Int):Void;
|
||||
function getBytes():Bytes;
|
||||
}
|
34
Kha/Tools/linux_x64/std/eval/_std/haxe/io/BytesData.hx
Normal file
34
Kha/Tools/linux_x64/std/eval/_std/haxe/io/BytesData.hx
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@:forward
|
||||
private abstract NativeBytesDataAbstract(Bytes) from Bytes to Bytes {
|
||||
@:arrayAccess public inline function get(i:Int)
|
||||
return this.get(i);
|
||||
|
||||
@:arrayAccess public inline function set(i:Int, v:Dynamic)
|
||||
this.set(i, v);
|
||||
}
|
||||
|
||||
typedef BytesData = NativeBytesDataAbstract;
|
31
Kha/Tools/linux_x64/std/eval/_std/haxe/zip/Compress.hx
Normal file
31
Kha/Tools/linux_x64/std/eval/_std/haxe/zip/Compress.hx
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
extern class Compress {
|
||||
function new(level:Int):Void;
|
||||
function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, wriet:Int};
|
||||
function setFlushMode(f:FlushMode):Void;
|
||||
function close():Void;
|
||||
static function run(s:haxe.io.Bytes, level:Int):haxe.io.Bytes;
|
||||
}
|
31
Kha/Tools/linux_x64/std/eval/_std/haxe/zip/Uncompress.hx
Normal file
31
Kha/Tools/linux_x64/std/eval/_std/haxe/zip/Uncompress.hx
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
extern class Uncompress {
|
||||
function new(?windowBits:Int):Void;
|
||||
function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int};
|
||||
function setFlushMode(f:FlushMode):Void;
|
||||
function close():Void;
|
||||
static function run(src:haxe.io.Bytes, ?bufsize:Int):haxe.io.Bytes;
|
||||
}
|
10
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Config.hx
Normal file
10
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Config.hx
Normal file
@ -0,0 +1,10 @@
|
||||
package mbedtls;
|
||||
|
||||
extern class Config {
|
||||
function new():Void;
|
||||
|
||||
function authmode(authmode:SslAuthmode):Void;
|
||||
function ca_chain(ca_chain:X509Crt):Void;
|
||||
function defaults(endpoint:SslEndpoint, transport:SslTransport, preset:SslPreset):Int;
|
||||
function rng<T>(p_rng:T):Void;
|
||||
}
|
10
Kha/Tools/linux_x64/std/eval/_std/mbedtls/CtrDrbg.hx
Normal file
10
Kha/Tools/linux_x64/std/eval/_std/mbedtls/CtrDrbg.hx
Normal file
@ -0,0 +1,10 @@
|
||||
package mbedtls;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
extern class CtrDrbg {
|
||||
function new():Void;
|
||||
|
||||
function random(output:Bytes, output_len:Int):Int;
|
||||
function seed(entropy:Entropy, ?custom:String):Int;
|
||||
}
|
5
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Entropy.hx
Normal file
5
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Entropy.hx
Normal file
@ -0,0 +1,5 @@
|
||||
package mbedtls;
|
||||
|
||||
extern class Entropy {
|
||||
function new():Void;
|
||||
}
|
5
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Error.hx
Normal file
5
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Error.hx
Normal file
@ -0,0 +1,5 @@
|
||||
package mbedtls;
|
||||
|
||||
class Error {
|
||||
extern static public function strerror(code:Int):String;
|
||||
}
|
12
Kha/Tools/linux_x64/std/eval/_std/mbedtls/PkContext.hx
Normal file
12
Kha/Tools/linux_x64/std/eval/_std/mbedtls/PkContext.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package mbedtls;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
extern class PkContext {
|
||||
function new():Void;
|
||||
|
||||
function parse_key(key:Bytes, ?pwd:String):Int;
|
||||
function parse_keyfile(path:String, ?password:String):Int;
|
||||
function parse_public_key(key:Bytes):Int;
|
||||
function parse_public_keyfile(path:String):Int;
|
||||
}
|
15
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Ssl.hx
Normal file
15
Kha/Tools/linux_x64/std/eval/_std/mbedtls/Ssl.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package mbedtls;
|
||||
|
||||
import mbedtls.X509Crt;
|
||||
import haxe.io.Bytes;
|
||||
|
||||
extern class Ssl {
|
||||
function new():Void;
|
||||
|
||||
function get_peer_cert():Null<X509Crt>;
|
||||
function handshake():Int;
|
||||
function read(buf:Bytes, pos:Int, len:Int):Int;
|
||||
function set_hostname(hostname:String):Int;
|
||||
function setup(conf:Config):Int;
|
||||
function write(buf:Bytes, pos:Int, len:Int):Int;
|
||||
}
|
8
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslAuthmode.hx
Normal file
8
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslAuthmode.hx
Normal file
@ -0,0 +1,8 @@
|
||||
package mbedtls;
|
||||
|
||||
@:native("mbedtls.SslAuthmode")
|
||||
extern enum abstract SslAuthmode(Int) {
|
||||
var SSL_VERIFY_NONE;
|
||||
var SSL_VERIFY_OPTIONAL;
|
||||
var SSL_VERIFY_REQUIRED;
|
||||
}
|
7
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslEndpoint.hx
Normal file
7
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslEndpoint.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package mbedtls;
|
||||
|
||||
@:native("mbedtls.SslEndpoint")
|
||||
extern enum abstract SslEndpoint(Int) {
|
||||
var SSL_IS_CLIENT;
|
||||
var SSL_IS_SERVER;
|
||||
}
|
7
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslPreset.hx
Normal file
7
Kha/Tools/linux_x64/std/eval/_std/mbedtls/SslPreset.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package mbedtls;
|
||||
|
||||
@:native("mbedtls.SslPreset")
|
||||
extern enum abstract SslPreset(Int) {
|
||||
var SSL_PRESET_DEFAULT;
|
||||
var SSL_PRESET_SUITEB;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package mbedtls;
|
||||
|
||||
@:native("mbedtls.SslTransport")
|
||||
extern enum abstract SslTransport(Int) {
|
||||
var SSL_TRANSPORT_STREAM;
|
||||
var SSL_TRANSPORT_DATAGRAM;
|
||||
}
|
12
Kha/Tools/linux_x64/std/eval/_std/mbedtls/X509Crt.hx
Normal file
12
Kha/Tools/linux_x64/std/eval/_std/mbedtls/X509Crt.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package mbedtls;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
extern class X509Crt {
|
||||
function new():Void;
|
||||
|
||||
function next():Null<X509Crt>;
|
||||
function parse(buf:Bytes):Int;
|
||||
function parse_file(path:String):Int;
|
||||
function parse_path(path:String):Int;
|
||||
}
|
52
Kha/Tools/linux_x64/std/eval/_std/sys/FileSystem.hx
Normal file
52
Kha/Tools/linux_x64/std/eval/_std/sys/FileSystem.hx
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
// This class is here so it re-shadows other FileSystem classes in macros,
|
||||
// e.g. from hxnodejs.
|
||||
@:coreApi
|
||||
class FileSystem {
|
||||
extern static public function exists(path:String):Bool;
|
||||
|
||||
extern static public function rename(path:String, newPath:String):Void;
|
||||
|
||||
extern static public function stat(path:String):FileStat;
|
||||
|
||||
extern static public function fullPath(relPath:String):String;
|
||||
|
||||
static public function absolutePath(relPath:String):String {
|
||||
if (haxe.io.Path.isAbsolute(relPath))
|
||||
return relPath;
|
||||
return haxe.io.Path.join([Sys.getCwd(), relPath]);
|
||||
}
|
||||
|
||||
extern static public function isDirectory(path:String):Bool;
|
||||
|
||||
extern static public function createDirectory(path:String):Void;
|
||||
|
||||
extern static public function deleteFile(path:String):Void;
|
||||
|
||||
extern static public function deleteDirectory(path:String):Void;
|
||||
|
||||
extern static public function readDirectory(path:String):Array<String>;
|
||||
}
|
50
Kha/Tools/linux_x64/std/eval/_std/sys/io/File.hx
Normal file
50
Kha/Tools/linux_x64/std/eval/_std/sys/io/File.hx
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@:coreApi
|
||||
class File {
|
||||
extern static public function getContent(path:String):String;
|
||||
|
||||
extern static public function saveContent(path:String, content:String):Void;
|
||||
|
||||
extern static public function getBytes(path:String):haxe.io.Bytes;
|
||||
|
||||
extern static public function saveBytes(path:String, bytes:haxe.io.Bytes):Void;
|
||||
|
||||
extern static public function read(path:String, binary:Bool = true):FileInput;
|
||||
|
||||
extern static public function write(path:String, binary:Bool = true):FileOutput;
|
||||
|
||||
extern static public function append(path:String, binary:Bool = true):FileOutput;
|
||||
|
||||
extern static public function update(path:String, binary:Bool = true):FileOutput;
|
||||
|
||||
static public function copy(srcPath:String, dstPath:String):Void {
|
||||
var s = read(srcPath, true);
|
||||
var d = write(dstPath, true);
|
||||
d.writeInput(s);
|
||||
s.close();
|
||||
d.close();
|
||||
}
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/_std/sys/io/FileInput.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/_std/sys/io/FileInput.hx
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
// This class is not extern because externs overriding non-externs messes with DCE
|
||||
@:coreApi
|
||||
class FileInput extends haxe.io.Input {
|
||||
extern public override function close():Void;
|
||||
|
||||
extern public function eof():Bool;
|
||||
|
||||
extern public function seek(p:Int, pos:FileSeek):Void;
|
||||
|
||||
extern public function tell():Int;
|
||||
|
||||
extern public override function readByte():Int;
|
||||
|
||||
extern public override function readBytes(bytes:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/_std/sys/io/FileOutput.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/_std/sys/io/FileOutput.hx
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
// This class is not extern because externs overriding non-externs messes with DCE
|
||||
@:coreApi
|
||||
class FileOutput extends haxe.io.Output {
|
||||
extern public override function close():Void;
|
||||
|
||||
extern public override function flush():Void;
|
||||
|
||||
extern public function seek(p:Int, pos:FileSeek):Void;
|
||||
|
||||
extern public function tell():Int;
|
||||
|
||||
extern public override function writeByte(c:Int):Void;
|
||||
|
||||
extern public override function writeBytes(bytes:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
}
|
133
Kha/Tools/linux_x64/std/eval/_std/sys/io/Process.hx
Normal file
133
Kha/Tools/linux_x64/std/eval/_std/sys/io/Process.hx
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
private extern class NativeProcess {
|
||||
function new(cmd:String, ?args:Array<String>):Void;
|
||||
|
||||
function close():Void;
|
||||
function exitCode():Int;
|
||||
function getPid():Int;
|
||||
function kill():Void;
|
||||
|
||||
function readStderr(bytes:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
function readStdout(bytes:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
|
||||
function closeStdin():Void;
|
||||
function writeStdin(bytes:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
}
|
||||
|
||||
private class Stdin extends haxe.io.Output {
|
||||
var proc:NativeProcess;
|
||||
var buf:haxe.io.Bytes;
|
||||
|
||||
public function new(proc:NativeProcess) {
|
||||
this.proc = proc;
|
||||
buf = haxe.io.Bytes.alloc(1);
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
proc.closeStdin();
|
||||
}
|
||||
|
||||
public override function writeByte(c:Int) {
|
||||
buf.set(0, c);
|
||||
writeBytes(buf, 0, 1);
|
||||
}
|
||||
|
||||
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int) {
|
||||
try {
|
||||
return proc.writeStdin(buf, pos, len);
|
||||
} catch (e:Dynamic) {
|
||||
throw new haxe.io.Eof();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Stdout extends haxe.io.Input {
|
||||
var proc:NativeProcess;
|
||||
var out:Bool;
|
||||
var buf:haxe.io.Bytes;
|
||||
|
||||
public function new(proc:NativeProcess, out:Bool) {
|
||||
this.proc = proc;
|
||||
this.out = out;
|
||||
buf = haxe.io.Bytes.alloc(1);
|
||||
}
|
||||
|
||||
public override function readByte() {
|
||||
if (readBytes(buf, 0, 1) == 0)
|
||||
throw haxe.io.Error.Blocked;
|
||||
return buf.get(0);
|
||||
}
|
||||
|
||||
public override function readBytes(bytes:haxe.io.Bytes, pos:Int, len:Int):Int {
|
||||
try {
|
||||
if (out) {
|
||||
return proc.readStdout(bytes, pos, len);
|
||||
} else {
|
||||
return proc.readStderr(bytes, pos, len);
|
||||
}
|
||||
} catch (e:Dynamic) {
|
||||
throw new haxe.io.Eof();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
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 proc:NativeProcess;
|
||||
|
||||
public function new(cmd:String, ?args:Array<String>, ?detached:Bool):Void {
|
||||
if (detached) {
|
||||
throw "Detached process is not supported on this platform";
|
||||
}
|
||||
proc = new NativeProcess(cmd, args);
|
||||
stdout = new Stdout(proc, true);
|
||||
stderr = new Stdout(proc, false);
|
||||
stdin = new Stdin(proc);
|
||||
}
|
||||
|
||||
public inline function getPid():Int {
|
||||
return proc.getPid();
|
||||
}
|
||||
|
||||
public function exitCode(block:Bool = true):Null<Int> {
|
||||
if (block == false)
|
||||
throw "Non blocking exitCode() not supported on this platform";
|
||||
return proc.exitCode();
|
||||
}
|
||||
|
||||
public inline function close():Void {
|
||||
proc.close();
|
||||
}
|
||||
|
||||
public inline function kill():Void {
|
||||
proc.kill();
|
||||
}
|
||||
}
|
53
Kha/Tools/linux_x64/std/eval/_std/sys/net/Host.hx
Normal file
53
Kha/Tools/linux_x64/std/eval/_std/sys/net/Host.hx
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public function new(name:String) {
|
||||
host = name;
|
||||
init(resolve(name));
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
return hostToString(ip);
|
||||
}
|
||||
|
||||
public function reverse() {
|
||||
return hostReverse(ip);
|
||||
}
|
||||
|
||||
function init(ip:Int) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
extern static public function localhost();
|
||||
|
||||
extern static function hostReverse(ip:Int);
|
||||
|
||||
extern static function hostToString(ip:Int);
|
||||
|
||||
extern static function resolve(name:String);
|
||||
}
|
191
Kha/Tools/linux_x64/std/eval/_std/sys/net/Socket.hx
Normal file
191
Kha/Tools/linux_x64/std/eval/_std/sys/net/Socket.hx
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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 eval.vm.NativeSocket;
|
||||
|
||||
private class SocketOutput extends haxe.io.Output {
|
||||
var socket:NativeSocket;
|
||||
|
||||
public function new(socket:NativeSocket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public override function writeByte(c:Int) {
|
||||
try {
|
||||
socket.sendChar(c);
|
||||
} catch (e:Dynamic) {
|
||||
if (e == "Blocking")
|
||||
throw Blocked;
|
||||
else if (e == "EOF")
|
||||
throw new haxe.io.Eof();
|
||||
else
|
||||
throw Custom(e);
|
||||
}
|
||||
}
|
||||
|
||||
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int) {
|
||||
return try {
|
||||
socket.send(buf, pos, len);
|
||||
} catch (e:Dynamic) {
|
||||
if (e == "Blocking")
|
||||
throw Blocked;
|
||||
else
|
||||
throw Custom(e);
|
||||
}
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
private class SocketInput extends haxe.io.Input {
|
||||
var socket:NativeSocket;
|
||||
|
||||
public function new(socket:NativeSocket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public override function readByte() {
|
||||
return try {
|
||||
socket.receiveChar();
|
||||
} catch (e:Dynamic) {
|
||||
if (e == "Blocking")
|
||||
throw Blocked;
|
||||
else
|
||||
throw new haxe.io.Eof();
|
||||
}
|
||||
}
|
||||
|
||||
public override function readBytes(buf:haxe.io.Bytes, pos:Int, len:Int) {
|
||||
var r;
|
||||
try {
|
||||
r = socket.receive(buf, pos, len);
|
||||
} catch (e:Dynamic) {
|
||||
if (e == "Blocking")
|
||||
throw Blocked;
|
||||
else
|
||||
throw Custom(e);
|
||||
}
|
||||
if (r == 0)
|
||||
throw new haxe.io.Eof();
|
||||
return r;
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
class Socket {
|
||||
public var input(default, null):haxe.io.Input;
|
||||
public var output(default, null):haxe.io.Output;
|
||||
public var custom:Dynamic;
|
||||
|
||||
@:ifFeature("sys.net.Socket.select") var socket:NativeSocket;
|
||||
|
||||
public function new() {
|
||||
init(new NativeSocket());
|
||||
}
|
||||
|
||||
private function init(socket:NativeSocket):Void {
|
||||
this.socket = socket;
|
||||
input = new SocketInput(socket);
|
||||
output = new SocketOutput(socket);
|
||||
}
|
||||
|
||||
public function close():Void {
|
||||
socket.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 {
|
||||
socket.connect(host.ip, port);
|
||||
}
|
||||
|
||||
public function listen(connections:Int):Void {
|
||||
socket.listen(connections);
|
||||
}
|
||||
|
||||
public function shutdown(read:Bool, write:Bool):Void {
|
||||
socket.shutdown(read, write);
|
||||
}
|
||||
|
||||
public function bind(host:Host, port:Int):Void {
|
||||
socket.bind(host.ip, port);
|
||||
}
|
||||
|
||||
public function accept():Socket {
|
||||
var nativeSocket = socket.accept();
|
||||
var socket:Socket = Type.createEmptyInstance(Socket);
|
||||
socket.init(nativeSocket);
|
||||
return socket;
|
||||
}
|
||||
|
||||
@:access(sys.net.Host.init)
|
||||
public function peer():{host:Host, port:Int} {
|
||||
var info = socket.peer();
|
||||
var host:Host = Type.createEmptyInstance(Host);
|
||||
host.init(info.ip);
|
||||
return {host: host, port: info.port};
|
||||
}
|
||||
|
||||
@:access(sys.net.Host.init)
|
||||
public function host():{host:Host, port:Int} {
|
||||
var info = socket.host();
|
||||
var host:Host = Type.createEmptyInstance(Host);
|
||||
host.init(info.ip);
|
||||
return {host: host, port: info.port};
|
||||
}
|
||||
|
||||
public function setTimeout(timeout:Float):Void {
|
||||
socket.setTimeout(timeout);
|
||||
}
|
||||
|
||||
public function waitForRead():Void {
|
||||
select([this], null, null, -1);
|
||||
}
|
||||
|
||||
public function setBlocking(b:Bool):Void {} // TODO: Don't know how to implement this...
|
||||
|
||||
public function setFastSend(b:Bool):Void {
|
||||
socket.setFastSend(b);
|
||||
}
|
||||
|
||||
public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
|
||||
?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
|
||||
return NativeSocket.select(read, write, others, timeout);
|
||||
}
|
||||
}
|
102
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Certificate.hx
Normal file
102
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Certificate.hx
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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.ssl;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import sys.ssl.Mbedtls;
|
||||
import mbedtls.X509Crt;
|
||||
|
||||
@:coreApi
|
||||
class Certificate {
|
||||
var native:X509Crt;
|
||||
|
||||
function new(native:X509Crt) {
|
||||
this.native = native;
|
||||
}
|
||||
|
||||
public static function loadFile(file:String):Certificate {
|
||||
var cert = new X509Crt();
|
||||
cert.parse_file(file);
|
||||
return new Certificate(cert);
|
||||
}
|
||||
|
||||
public static function loadPath(path:String):Certificate {
|
||||
var cert = new X509Crt();
|
||||
cert.parse_path(path);
|
||||
return new Certificate(cert);
|
||||
}
|
||||
|
||||
public static function fromString(str:String):Certificate {
|
||||
var cert = new X509Crt();
|
||||
trace(mbedtls.Error.strerror(cert.parse(Bytes.ofString(str))));
|
||||
return new Certificate(cert);
|
||||
}
|
||||
|
||||
public static function loadDefaults():Certificate {
|
||||
var cert = new X509Crt();
|
||||
Mbedtls.loadDefaultCertificates(cert);
|
||||
return new Certificate(cert);
|
||||
}
|
||||
|
||||
public var commonName(get, null):Null<String>;
|
||||
|
||||
public var altNames(get, null):Array<String>;
|
||||
|
||||
public var notBefore(get, null):Date;
|
||||
|
||||
public var notAfter(get, null):Date;
|
||||
|
||||
extern public function subject(field:String):Null<String>;
|
||||
|
||||
extern public function issuer(field:String):Null<String>;
|
||||
|
||||
public function next():Null<Certificate> {
|
||||
var cert = native.next();
|
||||
if (cert == null) {
|
||||
return null;
|
||||
}
|
||||
return new Certificate(cert);
|
||||
}
|
||||
|
||||
public function add(pem:String):Void {
|
||||
native.parse(Bytes.ofString(pem));
|
||||
}
|
||||
|
||||
public function addDER(der:Bytes):Void {
|
||||
native.parse(der);
|
||||
}
|
||||
|
||||
private function get_commonName():Null<String> {
|
||||
return subject("CN");
|
||||
}
|
||||
|
||||
extern private function get_altNames():Array<String>;
|
||||
|
||||
extern private function get_notBefore():Date;
|
||||
|
||||
extern private function get_notAfter():Date;
|
||||
|
||||
private inline function getNative():X509Crt {
|
||||
return native;
|
||||
}
|
||||
}
|
69
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Key.hx
Normal file
69
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Key.hx
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.ssl;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import mbedtls.PkContext;
|
||||
|
||||
@:coreApi
|
||||
class Key {
|
||||
var native:PkContext;
|
||||
|
||||
function new() {
|
||||
native = new PkContext();
|
||||
}
|
||||
|
||||
static public function loadFile(file:String, ?isPublic:Bool, ?pass:String):Key {
|
||||
var key = new Key();
|
||||
var code = if (isPublic) {
|
||||
key.native.parse_public_keyfile(file);
|
||||
} else {
|
||||
key.native.parse_keyfile(file, pass);
|
||||
}
|
||||
if (code != 0) {
|
||||
throw(mbedtls.Error.strerror(code));
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
static function parse(data:Bytes, isPublic:Bool, ?pass:String):Key {
|
||||
var key = new Key();
|
||||
var code = if (isPublic) {
|
||||
key.native.parse_public_key(data);
|
||||
} else {
|
||||
key.native.parse_key(data);
|
||||
}
|
||||
if (code != 0) {
|
||||
throw(mbedtls.Error.strerror(code));
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
static public function readPEM(data:String, isPublic:Bool, ?pass:String):Key {
|
||||
return parse(Bytes.ofString(data), isPublic, pass);
|
||||
}
|
||||
|
||||
static public function readDER(data:haxe.io.Bytes, isPublic:Bool):Key {
|
||||
return parse(data, isPublic);
|
||||
}
|
||||
}
|
66
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Mbedtls.hx
Normal file
66
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Mbedtls.hx
Normal file
@ -0,0 +1,66 @@
|
||||
package sys.ssl;
|
||||
|
||||
import eval.vm.NativeSocket;
|
||||
import mbedtls.Ssl;
|
||||
import mbedtls.Entropy;
|
||||
import mbedtls.CtrDrbg;
|
||||
import mbedtls.X509Crt;
|
||||
|
||||
class Mbedtls {
|
||||
static var entropy:Null<Entropy>;
|
||||
static var ctr:Null<CtrDrbg>;
|
||||
|
||||
static public function getDefaultEntropy() {
|
||||
if (entropy == null) {
|
||||
entropy = new Entropy();
|
||||
}
|
||||
return entropy;
|
||||
}
|
||||
|
||||
static public function getDefaultCtrDrbg() {
|
||||
if (ctr == null) {
|
||||
ctr = new CtrDrbg();
|
||||
ctr.seed(getDefaultEntropy());
|
||||
}
|
||||
return ctr;
|
||||
}
|
||||
|
||||
static public function loadDefaultCertificates(certificate:X509Crt) {
|
||||
if (loadDefaults(certificate) == 0) {
|
||||
return;
|
||||
}
|
||||
var defPaths = switch (Sys.systemName()) {
|
||||
case "Linux":
|
||||
[
|
||||
"/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
|
||||
"/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
|
||||
"/etc/ssl/ca-bundle.pem", // OpenSUSE
|
||||
"/etc/pki/tls/cacert.pem", // OpenELEC
|
||||
"/etc/ssl/certs", // SLES10/SLES11
|
||||
"/system/etc/security/cacerts" // Android
|
||||
];
|
||||
case "BSD":
|
||||
[
|
||||
"/usr/local/share/certs/ca-root-nss.crt", // FreeBSD/DragonFly
|
||||
"/etc/ssl/cert.pem", // OpenBSD
|
||||
"/etc/openssl/certs/ca-certificates.crt", // NetBSD
|
||||
];
|
||||
case "Android":
|
||||
["/system/etc/security/cacerts"];
|
||||
default:
|
||||
[];
|
||||
}
|
||||
for (path in defPaths) {
|
||||
if (sys.FileSystem.exists(path)) {
|
||||
if (sys.FileSystem.isDirectory(path))
|
||||
certificate.parse_path(path);
|
||||
else
|
||||
certificate.parse_file(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern static public function setSocket(ssl:Ssl, socket:NativeSocket):Int;
|
||||
|
||||
extern static function loadDefaults(certificate:X509Crt):Int;
|
||||
}
|
206
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Socket.hx
Normal file
206
Kha/Tools/linux_x64/std/eval/_std/sys/ssl/Socket.hx
Normal file
@ -0,0 +1,206 @@
|
||||
package sys.ssl;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import eval.vm.NativeSocket;
|
||||
import mbedtls.Config;
|
||||
import mbedtls.Ssl;
|
||||
|
||||
private class SocketInput extends haxe.io.Input {
|
||||
@:allow(sys.ssl.Socket) private var socket:Socket;
|
||||
var readBuf:Bytes;
|
||||
|
||||
public function new(s:Socket) {
|
||||
this.socket = s;
|
||||
readBuf = Bytes.alloc(1);
|
||||
}
|
||||
|
||||
public override function readByte() {
|
||||
socket.handshake();
|
||||
var r = @:privateAccess socket.ssl.read(readBuf, 0, 1);
|
||||
if (r == -1)
|
||||
throw haxe.io.Error.Blocked;
|
||||
else if (r < 0)
|
||||
throw new haxe.io.Eof();
|
||||
return readBuf.get(0);
|
||||
}
|
||||
|
||||
public override function readBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
|
||||
if (pos < 0 || len < 0 || ((pos + len) : UInt) > (buf.length : UInt))
|
||||
throw haxe.io.Error.OutsideBounds;
|
||||
socket.handshake();
|
||||
var r = @:privateAccess socket.ssl.read(buf, pos, len);
|
||||
if (r == -1)
|
||||
throw haxe.io.Error.Blocked;
|
||||
else if (r <= 0)
|
||||
throw new haxe.io.Eof();
|
||||
return r;
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
if (socket != null)
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
private class SocketOutput extends haxe.io.Output {
|
||||
@:allow(sys.ssl.Socket) private var socket:Socket;
|
||||
var writeBuf:Bytes;
|
||||
|
||||
public function new(s:Socket) {
|
||||
this.socket = s;
|
||||
writeBuf = Bytes.alloc(1);
|
||||
}
|
||||
|
||||
public override function writeByte(c:Int) {
|
||||
socket.handshake();
|
||||
writeBuf.set(0, c);
|
||||
var r = @:privateAccess socket.ssl.write(writeBuf, 0, 1);
|
||||
if (r == -1)
|
||||
throw haxe.io.Error.Blocked;
|
||||
else if (r < 0)
|
||||
throw new haxe.io.Eof();
|
||||
}
|
||||
|
||||
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
|
||||
if (pos < 0 || len < 0 || ((pos + len) : UInt) > (buf.length : UInt))
|
||||
throw haxe.io.Error.OutsideBounds;
|
||||
socket.handshake();
|
||||
var r = @:privateAccess socket.ssl.write(buf, pos, len);
|
||||
if (r == -1)
|
||||
throw haxe.io.Error.Blocked;
|
||||
else if (r < 0)
|
||||
throw new haxe.io.Eof();
|
||||
return r;
|
||||
}
|
||||
|
||||
public override function close() {
|
||||
super.close();
|
||||
if (socket != null)
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
class Socket extends sys.net.Socket {
|
||||
public static var DEFAULT_VERIFY_CERT:Null<Bool> = true;
|
||||
|
||||
public static var DEFAULT_CA:Null<Certificate>;
|
||||
|
||||
private var conf:Config;
|
||||
private var ssl:Ssl;
|
||||
|
||||
public var verifyCert:Null<Bool>;
|
||||
|
||||
private var caCert:Null<Certificate>;
|
||||
private var hostname:String;
|
||||
|
||||
private var handshakeDone:Bool;
|
||||
private var isBlocking:Bool = true;
|
||||
|
||||
override function init(socket:NativeSocket):Void {
|
||||
this.socket = socket;
|
||||
input = new SocketInput(this);
|
||||
output = new SocketOutput(this);
|
||||
if (DEFAULT_VERIFY_CERT && DEFAULT_CA == null) {
|
||||
DEFAULT_CA = Certificate.loadDefaults();
|
||||
}
|
||||
verifyCert = DEFAULT_VERIFY_CERT;
|
||||
caCert = DEFAULT_CA;
|
||||
}
|
||||
|
||||
public override function connect(host:sys.net.Host, port:Int):Void {
|
||||
conf = buildConfig(false);
|
||||
ssl = new Ssl();
|
||||
ssl.setup(conf);
|
||||
Mbedtls.setSocket(ssl, socket);
|
||||
handshakeDone = false;
|
||||
if (hostname == null)
|
||||
hostname = host.host;
|
||||
if (hostname != null)
|
||||
ssl.set_hostname(hostname);
|
||||
socket.connect(host.ip, port);
|
||||
if (isBlocking)
|
||||
handshake();
|
||||
}
|
||||
|
||||
public function handshake():Void {
|
||||
if (!handshakeDone) {
|
||||
var r = ssl.handshake();
|
||||
if (r == 0)
|
||||
handshakeDone = true;
|
||||
else if (r == -1)
|
||||
throw haxe.io.Error.Blocked;
|
||||
else
|
||||
throw mbedtls.Error.strerror(r);
|
||||
}
|
||||
}
|
||||
|
||||
override function setBlocking(b:Bool):Void {
|
||||
super.setBlocking(b);
|
||||
isBlocking = b;
|
||||
}
|
||||
|
||||
public function setCA(cert:Certificate):Void {
|
||||
caCert = cert;
|
||||
}
|
||||
|
||||
public function setHostname(name:String):Void {
|
||||
hostname = name;
|
||||
}
|
||||
|
||||
public override function close():Void {
|
||||
super.close();
|
||||
var input:SocketInput = cast input;
|
||||
var output:SocketOutput = cast output;
|
||||
@:privateAccess input.socket = output.socket = null;
|
||||
input.close();
|
||||
output.close();
|
||||
}
|
||||
|
||||
public override function bind(host:sys.net.Host, port:Int):Void {
|
||||
conf = buildConfig(true);
|
||||
|
||||
socket.bind(host.ip, port);
|
||||
}
|
||||
|
||||
public override function accept():Socket {
|
||||
var c = socket.accept();
|
||||
var cssl = new Ssl();
|
||||
cssl.setup(conf);
|
||||
Mbedtls.setSocket(cssl, c);
|
||||
|
||||
var s = Type.createEmptyInstance(sys.ssl.Socket);
|
||||
s.socket = c;
|
||||
s.ssl = cssl;
|
||||
s.input = new SocketInput(s);
|
||||
s.output = new SocketOutput(s);
|
||||
s.handshakeDone = false;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public function addSNICertificate(cbServernameMatch:String->Bool, cert:Certificate, key:Key):Void {
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
|
||||
public function peerCertificate():Certificate {
|
||||
return @:privateAccess new Certificate(ssl.get_peer_cert());
|
||||
}
|
||||
|
||||
public function setCertificate(cert:Certificate, key:Key):Void {
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
|
||||
private function buildConfig(server:Bool):Config {
|
||||
var conf = new Config();
|
||||
conf.defaults(server ? SSL_IS_SERVER : SSL_IS_CLIENT, SSL_TRANSPORT_STREAM, SSL_PRESET_DEFAULT);
|
||||
conf.rng(Mbedtls.getDefaultCtrDrbg());
|
||||
|
||||
if (caCert != null) {
|
||||
conf.ca_chain(@:privateAccess caCert.getNative());
|
||||
}
|
||||
conf.authmode(if (verifyCert) SSL_VERIFY_REQUIRED else if (verifyCert == null) SSL_VERIFY_OPTIONAL else SSL_VERIFY_NONE);
|
||||
return conf;
|
||||
}
|
||||
}
|
140
Kha/Tools/linux_x64/std/eval/_std/sys/thread/EventLoop.hx
Normal file
140
Kha/Tools/linux_x64/std/eval/_std/sys/thread/EventLoop.hx
Normal file
@ -0,0 +1,140 @@
|
||||
package sys.thread;
|
||||
|
||||
import eval.luv.Loop;
|
||||
import eval.luv.Async;
|
||||
import eval.luv.Timer as LuvTimer;
|
||||
|
||||
@:coreApi
|
||||
enum NextEventTime {
|
||||
Now;
|
||||
Never;
|
||||
AnyTime(time:Null<Float>);
|
||||
At(time:Float);
|
||||
}
|
||||
|
||||
abstract EventHandler(RegularEvent) from RegularEvent to RegularEvent {}
|
||||
|
||||
private class RegularEvent {
|
||||
public var timer:Null<LuvTimer>;
|
||||
public var event:()->Void;
|
||||
|
||||
public function new(e:()->Void) {
|
||||
event = e;
|
||||
}
|
||||
|
||||
public function run() {
|
||||
event();
|
||||
}
|
||||
}
|
||||
|
||||
@:coreApi
|
||||
class EventLoop {
|
||||
@:allow(eval.luv.Loop)
|
||||
final handle:Loop;
|
||||
|
||||
final mutex = new Mutex();
|
||||
final oneTimeEvents = new Array<Null<()->Void>>();
|
||||
var oneTimeEventsIdx = 0;
|
||||
final wakeup:Async;
|
||||
var promisedEventsCount = 0;
|
||||
var pending:Array<()->Void> = [];
|
||||
var looping = false;
|
||||
|
||||
public function new():Void {
|
||||
handle = Loop.init().resolve();
|
||||
wakeup = Async.init(handle, consumePending).resolve();
|
||||
wakeup.unref();
|
||||
}
|
||||
|
||||
public function repeat(event:()->Void, intervalMs:Int):EventHandler {
|
||||
var e = new RegularEvent(event);
|
||||
mutex.acquire();
|
||||
pending.push(() -> {
|
||||
e.timer = LuvTimer.init(handle).resolve();
|
||||
e.timer.start(e.run, intervalMs, intervalMs < 1 ? 1 : intervalMs).resolve();
|
||||
});
|
||||
mutex.release();
|
||||
wakeup.send();
|
||||
return e;
|
||||
}
|
||||
|
||||
public function cancel(eventHandler:EventHandler):Void {
|
||||
mutex.acquire();
|
||||
(eventHandler:RegularEvent).event = noop;
|
||||
pending.push(() -> {
|
||||
var timer = (eventHandler:RegularEvent).timer;
|
||||
timer.stop().resolve();
|
||||
timer.close(noop);
|
||||
});
|
||||
mutex.release();
|
||||
wakeup.send();
|
||||
}
|
||||
static final noop = function() {}
|
||||
|
||||
public function promise():Void {
|
||||
mutex.acquire();
|
||||
++promisedEventsCount;
|
||||
pending.push(refUnref);
|
||||
mutex.release();
|
||||
wakeup.send();
|
||||
}
|
||||
|
||||
public function run(event:()->Void):Void {
|
||||
mutex.acquire();
|
||||
pending.push(event);
|
||||
mutex.release();
|
||||
wakeup.send();
|
||||
}
|
||||
|
||||
public function runPromised(event:()->Void):Void {
|
||||
mutex.acquire();
|
||||
--promisedEventsCount;
|
||||
pending.push(refUnref);
|
||||
pending.push(event);
|
||||
mutex.release();
|
||||
wakeup.send();
|
||||
}
|
||||
|
||||
function refUnref():Void {
|
||||
if(promisedEventsCount > 0) {
|
||||
wakeup.ref();
|
||||
} else {
|
||||
wakeup.unref();
|
||||
}
|
||||
}
|
||||
|
||||
public function progress():NextEventTime {
|
||||
//TODO: throw if loop is already running
|
||||
if((handle:Loop).run(NOWAIT)) {
|
||||
return AnyTime(null);
|
||||
} else {
|
||||
return Never;
|
||||
}
|
||||
}
|
||||
|
||||
public function wait(?timeout:Float):Bool {
|
||||
//TODO: throw if loop is already running
|
||||
if(timeout == null) {
|
||||
var timer = LuvTimer.init(handle).resolve();
|
||||
timer.start(() -> {
|
||||
timer.stop().resolve();
|
||||
timer.close(() -> {});
|
||||
}, Std.int(timeout * 1000));
|
||||
return (handle:Loop).run(ONCE);
|
||||
} else {
|
||||
return (handle:Loop).run(ONCE);
|
||||
}
|
||||
}
|
||||
|
||||
public function loop():Void {
|
||||
//TODO: throw if loop is already running
|
||||
consumePending();
|
||||
(handle:Loop).run(DEFAULT);
|
||||
}
|
||||
|
||||
function consumePending(?_:Async):Void {
|
||||
var p = pending;
|
||||
pending = [];
|
||||
for(fn in p) fn();
|
||||
}
|
||||
}
|
105
Kha/Tools/linux_x64/std/eval/_std/sys/thread/Thread.hx
Normal file
105
Kha/Tools/linux_x64/std/eval/_std/sys/thread/Thread.hx
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 eval.vm.NativeThread;
|
||||
|
||||
private typedef ThreadImpl = NativeThread;
|
||||
|
||||
abstract Thread(ThreadImpl) from ThreadImpl {
|
||||
public var events(get,never):EventLoop;
|
||||
|
||||
static function __init__() {
|
||||
NativeThread.self().events = new EventLoop();
|
||||
}
|
||||
|
||||
inline function new(h:NativeThread):Void {
|
||||
this = h;
|
||||
}
|
||||
|
||||
public inline function sendMessage(msg:Dynamic):Void {
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static inline function current():Thread {
|
||||
return new Thread(NativeThread.self());
|
||||
}
|
||||
|
||||
public static inline function create(job:()->Void):Thread {
|
||||
return new Thread(new NativeThread(job));
|
||||
}
|
||||
|
||||
public static function runWithEventLoop(job:()->Void):Void {
|
||||
var thread = NativeThread.self();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static inline function createWithEventLoop(job:()->Void):Thread {
|
||||
return new Thread(new NativeThread(() -> {
|
||||
var thread = NativeThread.self();
|
||||
thread.events = new EventLoop();
|
||||
job();
|
||||
thread.events.loop();
|
||||
}));
|
||||
}
|
||||
|
||||
public static inline function readMessage(block:Bool):Dynamic {
|
||||
return NativeThread.readMessage(block);
|
||||
}
|
||||
|
||||
public static inline function yield():Void {
|
||||
NativeThread.yield();
|
||||
}
|
||||
|
||||
@:op(A == B)
|
||||
public inline function equals(other:Thread):Bool {
|
||||
return getHandle().id() == other.getHandle().id();
|
||||
}
|
||||
|
||||
inline function getHandle():NativeThread {
|
||||
return this;
|
||||
}
|
||||
|
||||
function get_events():EventLoop {
|
||||
if(this.events == null)
|
||||
throw new NoEventLoopException();
|
||||
return this.events;
|
||||
}
|
||||
|
||||
@:keep
|
||||
static function processEvents():Void {
|
||||
NativeThread.self().events.loop();
|
||||
}
|
||||
}
|
117
Kha/Tools/linux_x64/std/eval/integers/Int64.hx
Normal file
117
Kha/Tools/linux_x64/std/eval/integers/Int64.hx
Normal file
@ -0,0 +1,117 @@
|
||||
package eval.integers;
|
||||
|
||||
/**
|
||||
Signed 64-bit integer type and operations.
|
||||
**/
|
||||
@:coreType abstract Int64 {
|
||||
/** The greatest representable Int64 value. */
|
||||
extern static public final MAX:Int64;
|
||||
/** The smallest representable Int64 value. */
|
||||
extern static public final MIN:Int64;
|
||||
/** The integer `0` */
|
||||
extern static public final ZERO:Int64;
|
||||
/** The integer `1` */
|
||||
extern static public final ONE:Int64;
|
||||
|
||||
/**
|
||||
Convert the given int value to Int64.
|
||||
**/
|
||||
static public function ofInt(i:Int):Int64;
|
||||
|
||||
/**
|
||||
Parse the given string value to Int64.
|
||||
Throws if the given string is not a valid representation of Int64.
|
||||
**/
|
||||
static public function ofString(s:String):Int64;
|
||||
|
||||
/**
|
||||
Convert `haxe.Int64` to `eval.integers.Int64`
|
||||
**/
|
||||
@:from static public function ofHxInt64(hx:haxe.Int64):Int64;
|
||||
|
||||
/**
|
||||
Returns the greater of `a` and `b`.
|
||||
**/
|
||||
static public function max(a:Int64, b:Int64):Int64;
|
||||
|
||||
/**
|
||||
Returns the lesser of `a` and `b`.
|
||||
**/
|
||||
static public function min(a:Int64, b:Int64):Int64;
|
||||
|
||||
/**
|
||||
Compare given values.
|
||||
Returns `0` if the values are equal.
|
||||
Returns negative integer if `a` is lesser than `b`.
|
||||
Returns positive integer if `a` is greater than `b`.
|
||||
**/
|
||||
static public function compare(a:Int64, b:Int64):Int;
|
||||
|
||||
/**
|
||||
Convert to an integer value.
|
||||
The 64-bit signed integer is taken modulo 2{^32}, i.e. the top 32 bits
|
||||
are lost during the conversion.
|
||||
**/
|
||||
public function toInt():Int;
|
||||
|
||||
/**
|
||||
Convert to an unsigned integer value.
|
||||
**/
|
||||
public function toUInt64():UInt64;
|
||||
|
||||
/**
|
||||
Convert to `haxe.Int64`.
|
||||
**/
|
||||
@:to public function toHxInt64():haxe.Int64;
|
||||
|
||||
/**
|
||||
Return the string representation of this value.
|
||||
**/
|
||||
public function toString():String;
|
||||
|
||||
/**
|
||||
Successor.
|
||||
**/
|
||||
public function successor():String;
|
||||
|
||||
/**
|
||||
Predecessor.
|
||||
**/
|
||||
public function predecessor():String;
|
||||
|
||||
/**
|
||||
Integer remainder.
|
||||
Throws if the divisor is zero.
|
||||
**/
|
||||
public function remainder(u:Int64):Int64;
|
||||
|
||||
function add(u:Int64):Int64;
|
||||
function sub(u:Int64):Int64;
|
||||
function mul(u:Int64):Int64;
|
||||
function div(u:Int64):Int64;
|
||||
function logand(u:Int64):Int64;
|
||||
function logor(u:Int64):Int64;
|
||||
function logxor(u:Int64):Int64;
|
||||
function shift_left(i:Int):Int64;
|
||||
function shift_right(i:Int):Int64;
|
||||
function lognot():Int64;
|
||||
|
||||
@:op(A + B) inline function _add(u:Int64):Int64 return this.add(u);
|
||||
@:op(A - B) inline function _sub(u:Int64):Int64 return this.sub(u);
|
||||
@:op(A * B) inline function _mul(u:Int64):Int64 return this.mul(u);
|
||||
@:op(A / B) inline function _div(u:Int64):Int64 return this.div(u);
|
||||
@:op(A % B) inline function _mod(u:Int64):Int64 return this.remainder(u);
|
||||
@:op(A & B) inline function _logand(u:Int64):Int64 return this.logand(u);
|
||||
@:op(A | B) inline function _logor(u:Int64):Int64 return this.logor(u);
|
||||
@:op(A ^ B) inline function _logxor(u:Int64):Int64 return this.logxor(u);
|
||||
@:op(A << B) inline function _shift_left(i:Int):Int64 return this.shift_left(i);
|
||||
@:op(A >> B) inline function _shift_right(i:Int):Int64 return this.shift_right(i);
|
||||
@:op(~A) inline function _lognot():Int64 return this.lognot();
|
||||
|
||||
@:op(A != B) static inline function eq(a:Int64, b:Int64):Bool return compare(a, b) != 0;
|
||||
@:op(A == B) static inline function ne(a:Int64, b:Int64):Bool return compare(a, b) == 0;
|
||||
@:op(A < B) static inline function lt(a:Int64, b:Int64):Bool return compare(a, b) < 0;
|
||||
@:op(A > B) static inline function gt(a:Int64, b:Int64):Bool return compare(a, b) > 0;
|
||||
@:op(A <= B) static inline function lte(a:Int64, b:Int64):Bool return compare(a, b) <= 0;
|
||||
@:op(A >= B) static inline function gte(a:Int64, b:Int64):Bool return compare(a, b) >= 0;
|
||||
}
|
110
Kha/Tools/linux_x64/std/eval/integers/UInt64.hx
Normal file
110
Kha/Tools/linux_x64/std/eval/integers/UInt64.hx
Normal file
@ -0,0 +1,110 @@
|
||||
package eval.integers;
|
||||
|
||||
/**
|
||||
Unsigned 64-bit integer type and operations.
|
||||
**/
|
||||
@:coreType abstract UInt64 {
|
||||
/** The greatest representable UInt64 value. */
|
||||
extern static public final MAX:UInt64;
|
||||
/** The integer `0` */
|
||||
extern static public final ZERO:UInt64;
|
||||
/** The integer `1` */
|
||||
extern static public final ONE:UInt64;
|
||||
|
||||
/**
|
||||
Convert the given int value to an unsigned integer.
|
||||
**/
|
||||
static public function ofInt(i:Int):UInt64;
|
||||
|
||||
/**
|
||||
Parse the given string value to an unsigned integer.
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> development
|
||||
Throws if the given string is not a valid representation of an unsigned
|
||||
integer.
|
||||
**/
|
||||
static public function ofString(s:String):UInt64;
|
||||
|
||||
/**
|
||||
Returns the greater of `a` and `b`.
|
||||
**/
|
||||
static public function max(a:UInt64, b:UInt64):UInt64;
|
||||
|
||||
/**
|
||||
Returns the lesser of `a` and `b`.
|
||||
**/
|
||||
static public function min(a:UInt64, b:UInt64):UInt64;
|
||||
|
||||
/**
|
||||
Compare given values.
|
||||
Returns `0` if the values are equal.
|
||||
Returns negative integer if `a` is lesser than `b`.
|
||||
Returns positive integer if `a` is greater than `b`.
|
||||
**/
|
||||
static public function compare(a:UInt64, b:UInt64):Int;
|
||||
|
||||
/**
|
||||
Convert to an integer value.
|
||||
The 64-bit unsigned integer is taken modulo 2{^32}, i.e. the top 32 bits
|
||||
are lost during the conversion.
|
||||
**/
|
||||
public function toInt():Int;
|
||||
|
||||
/**
|
||||
Convert to a signed integer value.
|
||||
**/
|
||||
public function toInt64():Int64;
|
||||
|
||||
/**
|
||||
Return the string representation of this value.
|
||||
**/
|
||||
public function toString():String;
|
||||
|
||||
/**
|
||||
Successor.
|
||||
**/
|
||||
public function successor():String;
|
||||
|
||||
/**
|
||||
Predecessor.
|
||||
**/
|
||||
public function predecessor():String;
|
||||
|
||||
/**
|
||||
Integer remainder.
|
||||
Throws if the divisor is zero.
|
||||
**/
|
||||
public function remainder(u:UInt64):UInt64;
|
||||
|
||||
function add(u:UInt64):UInt64;
|
||||
function sub(u:UInt64):UInt64;
|
||||
function mul(u:UInt64):UInt64;
|
||||
function div(u:UInt64):UInt64;
|
||||
function logand(u:UInt64):UInt64;
|
||||
function logor(u:UInt64):UInt64;
|
||||
function logxor(u:UInt64):UInt64;
|
||||
function shift_left(i:Int):UInt64;
|
||||
function shift_right(i:Int):UInt64;
|
||||
function lognot():UInt64;
|
||||
|
||||
@:op(A + B) inline function _add(u:UInt64):UInt64 return this.add(u);
|
||||
@:op(A - B) inline function _sub(u:UInt64):UInt64 return this.sub(u);
|
||||
@:op(A * B) inline function _mul(u:UInt64):UInt64 return this.mul(u);
|
||||
@:op(A / B) inline function _div(u:UInt64):UInt64 return this.div(u);
|
||||
@:op(A % B) inline function _mod(u:UInt64):UInt64 return this.remainder(u);
|
||||
@:op(A & B) inline function _logand(u:UInt64):UInt64 return this.logand(u);
|
||||
@:op(A | B) inline function _logor(u:UInt64):UInt64 return this.logor(u);
|
||||
@:op(A ^ B) inline function _logxor(u:UInt64):UInt64 return this.logxor(u);
|
||||
@:op(A << B) inline function _shift_left(i:Int):UInt64 return this.shift_left(i);
|
||||
@:op(A >> B) inline function _shift_right(i:Int):UInt64 return this.shift_right(i);
|
||||
@:op(~A) inline function _lognot():UInt64 return this.lognot();
|
||||
|
||||
@:op(A != B) static inline function eq(a:UInt64, b:UInt64):Bool return compare(a, b) != 0;
|
||||
@:op(A == B) static inline function ne(a:UInt64, b:UInt64):Bool return compare(a, b) == 0;
|
||||
@:op(A < B) static inline function lt(a:UInt64, b:UInt64):Bool return compare(a, b) < 0;
|
||||
@:op(A > B) static inline function gt(a:UInt64, b:UInt64):Bool return compare(a, b) > 0;
|
||||
@:op(A <= B) static inline function lte(a:UInt64, b:UInt64):Bool return compare(a, b) <= 0;
|
||||
@:op(A >= B) static inline function gte(a:UInt64, b:UInt64):Bool return compare(a, b) >= 0;
|
||||
}
|
21
Kha/Tools/linux_x64/std/eval/luv/Async.hx
Normal file
21
Kha/Tools/linux_x64/std/eval/luv/Async.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Inter-loop communication.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Async
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Async to Handle {
|
||||
/**
|
||||
Allocates and initializes an async handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop, callback:(async:Async)->Void):Result<Async>;
|
||||
|
||||
/**
|
||||
Triggers a call to the handle's callback by the handle's loop.
|
||||
**/
|
||||
public function send():Result<Result.NoData>;
|
||||
}
|
23
Kha/Tools/linux_x64/std/eval/luv/Barrier.hx
Normal file
23
Kha/Tools/linux_x64/std/eval/luv/Barrier.hx
Normal file
@ -0,0 +1,23 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Barriers.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Barrier
|
||||
**/
|
||||
@:coreType abstract Barrier {
|
||||
/**
|
||||
Allocates and initializes a barrier.
|
||||
**/
|
||||
static public function init(count:Int):Result<Barrier>;
|
||||
|
||||
/**
|
||||
Cleans up a barrier.
|
||||
**/
|
||||
public function destroy():Void;
|
||||
|
||||
/**
|
||||
Waits on a barrier.
|
||||
**/
|
||||
public function wait():Bool;
|
||||
}
|
120
Kha/Tools/linux_x64/std/eval/luv/Buffer.hx
Normal file
120
Kha/Tools/linux_x64/std/eval/luv/Buffer.hx
Normal file
@ -0,0 +1,120 @@
|
||||
package eval.luv;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
/**
|
||||
Data buffers.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Buffer
|
||||
**/
|
||||
@:coreType abstract Buffer {
|
||||
/**
|
||||
Allocates a fresh buffer of the given size.
|
||||
**/
|
||||
static public function create(size:Int):Buffer;
|
||||
|
||||
/**
|
||||
Creates a buffer from a string.
|
||||
**/
|
||||
@:from static public function fromNativeString(s:NativeString):Buffer;
|
||||
|
||||
/**
|
||||
Creates a buffer from a string.
|
||||
**/
|
||||
@:from static public function fromString(s:String):Buffer;
|
||||
|
||||
/**
|
||||
Creates a buffer from bytes.
|
||||
**/
|
||||
@:from static public function fromBytes(b:Bytes):Buffer;
|
||||
|
||||
/**
|
||||
Evaluates to the sum of the sizes of the buffers in the array.
|
||||
**/
|
||||
static public function totalSize(buffers:Array<Buffer>):Int;
|
||||
|
||||
/**
|
||||
`Buffer.drop(buffers, count)` drops the first `count` bytes from `buffers`.
|
||||
|
||||
For example, if `buffers` contains two buffers of size 16, `Buffer.drop(buffers, 18)`
|
||||
will evaluate to an array that has lost the reference to the first buffer,
|
||||
and contains only a view into the second buffer of size 14.
|
||||
**/
|
||||
static public function drop(buffers:Array<Buffer>, count:Int):Array<Buffer>;
|
||||
|
||||
/**
|
||||
Evaluates to the size of the buffer.
|
||||
**/
|
||||
public function size():Int;
|
||||
|
||||
/**
|
||||
Retrieve a byte at the given index.
|
||||
**/
|
||||
@:arrayAccess public function get(index:Int):Int;
|
||||
|
||||
/**
|
||||
Retrieve a byte at the given index without a bounds check.
|
||||
**/
|
||||
public function unsafeGet(index:Int):Int;
|
||||
|
||||
/**
|
||||
Set byte value at the given index.
|
||||
**/
|
||||
@:arrayAccess public function set(index:Int, byte:Int):Int;
|
||||
|
||||
/**
|
||||
Set byte value at the given index without a bounds check.
|
||||
**/
|
||||
public function unsafeSet(index:Int, byte:Int):Int;
|
||||
|
||||
/**
|
||||
Creates a view into buffer that starts at the given `offset` and has the given `length`.
|
||||
|
||||
No data is copied.
|
||||
**/
|
||||
public function sub(offset:Int, length:Int):Buffer;
|
||||
|
||||
/**
|
||||
Copies data from this buffer to destination.
|
||||
|
||||
The amount of data copied is the minimum of the two buffers' size.
|
||||
**/
|
||||
public function blit(destination:Buffer):Void;
|
||||
|
||||
/**
|
||||
Fills the given buffer with the given byte.
|
||||
**/
|
||||
public function fill(byte:Int):Void;
|
||||
|
||||
/**
|
||||
Creates a string with the same contents as the buffer.
|
||||
**/
|
||||
public function toString():String;
|
||||
|
||||
/**
|
||||
Creates a native string with the same contents as the buffer.
|
||||
**/
|
||||
public function toNativeString():NativeString;
|
||||
|
||||
/**
|
||||
Creates a `haxe.io.Bytes` instance with the same contents as this buffer.
|
||||
**/
|
||||
public function toBytes():Bytes;
|
||||
|
||||
/**
|
||||
Copies data from a buffer to bytes buffer.
|
||||
**/
|
||||
public function blitToBytes(destination:Bytes, destinationOffset:Int):Void;
|
||||
|
||||
/**
|
||||
Copies data from bytes to a buffer.
|
||||
**/
|
||||
public function blitFromBytes(source:Bytes, sourceOffset:Int):Void;
|
||||
|
||||
/**
|
||||
Copies data from bytes to a buffer.
|
||||
|
||||
Note: `sourceOffset` is not a character offset but a byte offset.
|
||||
**/
|
||||
public function blitFromString(source:NativeString, sourceOffset:Int):Void;
|
||||
}
|
26
Kha/Tools/linux_x64/std/eval/luv/Check.hx
Normal file
26
Kha/Tools/linux_x64/std/eval/luv/Check.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Post-I/O callback.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Check
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Check to Handle {
|
||||
/**
|
||||
Allocate and initialize a check handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<Check>;
|
||||
|
||||
/**
|
||||
Starts the handle with the given callback.
|
||||
**/
|
||||
public function start(callback:()->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Stops the handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/luv/Condition.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/luv/Condition.hx
Normal file
@ -0,0 +1,39 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Condition variables.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Condition
|
||||
**/
|
||||
@:coreType abstract Condition {
|
||||
/**
|
||||
Allocates and initializes a condition variable.
|
||||
**/
|
||||
static public function init():Result<Condition>;
|
||||
|
||||
/**
|
||||
Cleans up a condition variable.
|
||||
**/
|
||||
public function destroy():Void;
|
||||
|
||||
/**
|
||||
Signals a condition variable.
|
||||
**/
|
||||
public function signal():Void;
|
||||
|
||||
/**
|
||||
Signals a condition variable, waking all waiters.
|
||||
**/
|
||||
public function broadcast():Void;
|
||||
|
||||
/**
|
||||
Waits on a condition variable.
|
||||
**/
|
||||
public function wait(mutex:Mutex):Void;
|
||||
|
||||
/**
|
||||
Waits on a condition variable with a timeout.
|
||||
The timeout is given in nanoseconds.
|
||||
**/
|
||||
public function timedWait(mutex:Mutex, timeout:Int):Void;
|
||||
}
|
34
Kha/Tools/linux_x64/std/eval/luv/ConnectedUdp.hx
Normal file
34
Kha/Tools/linux_x64/std/eval/luv/ConnectedUdp.hx
Normal file
@ -0,0 +1,34 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.luv.SockAddr;
|
||||
|
||||
/**
|
||||
Connected UDP sockets.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/UDP/Connected
|
||||
**/
|
||||
@:forward
|
||||
@:using(eval.luv.Handle)
|
||||
abstract ConnectedUdp(Udp) to Udp to Handle {
|
||||
/**
|
||||
Removes the peer address assigned to the given socket.
|
||||
**/
|
||||
extern public function disconnect():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Retrieves the peer address assigned to the given socket.
|
||||
**/
|
||||
extern public function getPeerName():Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Like `eval.luv.UDP.send`, but the remote address used is the peer address
|
||||
assigned to the socket.
|
||||
**/
|
||||
extern public function send(data:Array<Buffer>, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Like `eval.luv.UDP.trySend`, but the remote address used is the peer address
|
||||
assigned to the socket.
|
||||
**/
|
||||
extern public function trySend(data:Array<Buffer>):Result<Result.NoData>;
|
||||
}
|
73
Kha/Tools/linux_x64/std/eval/luv/Dir.hx
Normal file
73
Kha/Tools/linux_x64/std/eval/luv/Dir.hx
Normal file
@ -0,0 +1,73 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.luv.File;
|
||||
|
||||
enum abstract DirentKind(Int) {
|
||||
var UNKNOWN = 0;
|
||||
var FILE = 1;
|
||||
var DIR = 2;
|
||||
var LINK = 3;
|
||||
var FIFO = 4;
|
||||
var SOCKET = 5;
|
||||
var CHAR = 6;
|
||||
var BLOCK = 7;
|
||||
}
|
||||
|
||||
typedef Dirent = {
|
||||
var kind:DirentKind;
|
||||
var name:NativeString;
|
||||
}
|
||||
|
||||
typedef DirectoryScan = {
|
||||
/**
|
||||
Retrieves the next directory entry.
|
||||
**/
|
||||
function next():Null<Dirent>;
|
||||
|
||||
/**
|
||||
Cleans up after a directory scan.
|
||||
**/
|
||||
function end():Void;
|
||||
}
|
||||
|
||||
/**
|
||||
@see https://aantron.github.io/luv/luv/Luv/File#module-Dir
|
||||
**/
|
||||
@:coreType abstract Dir {
|
||||
/**
|
||||
Opens the directory at the given path for listing.
|
||||
**/
|
||||
static public function open(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<Dir>)->Void):Void;
|
||||
|
||||
/**
|
||||
Closes the directory.
|
||||
**/
|
||||
public function close(loop:Loop, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves a directory entry.
|
||||
**/
|
||||
public function read(loop:Loop, ?numberOfEntries:Int, ?request:FileRequest, callback:(result:Result<Array<Dirent>>)->Void):Void;
|
||||
|
||||
/**
|
||||
Begins directory listing.
|
||||
**/
|
||||
static public function scan(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<DirectoryScan>)->Void):Void;
|
||||
}
|
||||
|
||||
/**
|
||||
Synchronous version of `eval.luv.Dir` API
|
||||
**/
|
||||
extern class DirSync {
|
||||
@:inheritDoc(eval.luv.Dir.open)
|
||||
static public function open(loop:Loop, path:NativeString):Result<Dir>;
|
||||
|
||||
@:inheritDoc(eval.luv.Dir.close)
|
||||
static public function close(dir:Dir, loop:Loop):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.Dir.read)
|
||||
static public function read(dir:Dir, loop:Loop, ?numberOfEntries:Int):Result<Array<Dirent>>;
|
||||
|
||||
@:inheritDoc(eval.luv.Dir.scan)
|
||||
static public function scan(loop:Loop, path:NativeString):Result<DirectoryScan>;
|
||||
}
|
69
Kha/Tools/linux_x64/std/eval/luv/Dns.hx
Normal file
69
Kha/Tools/linux_x64/std/eval/luv/Dns.hx
Normal file
@ -0,0 +1,69 @@
|
||||
package eval.luv;
|
||||
|
||||
@:forward
|
||||
abstract AddrInfoRequest(Request) to Request {}
|
||||
|
||||
typedef AddrInfo = {
|
||||
var family:SockAddr.AddressFamily;
|
||||
var sockType:SockAddr.SocketType;
|
||||
var protocol:Int;
|
||||
var addr:SockAddr;
|
||||
var ?canonName:String;
|
||||
}
|
||||
|
||||
typedef AddrInfoOptions = {
|
||||
var ?request:AddrInfoRequest;
|
||||
var ?family:SockAddr.AddressFamily;
|
||||
var ?sockType:SockAddr.SocketType;
|
||||
var ?protocol:Int;
|
||||
var ?flags:Array<AddrInfoFlag>;
|
||||
}
|
||||
|
||||
enum abstract AddrInfoFlag(Int) {
|
||||
var PASSIVE = 0;
|
||||
var CANONNAME = 1;
|
||||
var NUMERICHOST = 2;
|
||||
var NUMERICSERV = 3;
|
||||
var V4MAPPED = 4;
|
||||
var ALL = 5;
|
||||
var ADDRCONFIG = 6;
|
||||
}
|
||||
|
||||
@:forward
|
||||
abstract NameInfoRequest(Request) to Request {}
|
||||
|
||||
enum abstract NameInfoFlag(Int) {
|
||||
var NAMEREQD = 0;
|
||||
var DGRAM = 1;
|
||||
var NOFQDN = 2;
|
||||
var NUMERICHOST = 3;
|
||||
var NUMERICSERV = 4;
|
||||
}
|
||||
|
||||
typedef NameInfoOptions = {
|
||||
var ?request:NameInfoRequest;
|
||||
var ?flags:Array<NameInfoFlag>;
|
||||
}
|
||||
|
||||
/**
|
||||
DNS queries.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Dns
|
||||
**/
|
||||
extern class Dns {
|
||||
|
||||
static function createAddrRequest():AddrInfoRequest;
|
||||
|
||||
static function createNameRequest():NameInfoRequest;
|
||||
|
||||
/**
|
||||
Retrieves addresses.
|
||||
Either `node` or `service` may be `null` but not both.
|
||||
**/
|
||||
static function getAddrInfo(loop:Loop, node:Null<String>, service:Null<String>, ?options:AddrInfoOptions, callback:(result:Result<Array<AddrInfo>>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves host names.
|
||||
**/
|
||||
static function getNameInfo(loop:Loop, addr:SockAddr, ?options:NameInfoOptions, callback:(result:Result<{hostName:String, service:String}>)->Void):Void;
|
||||
}
|
23
Kha/Tools/linux_x64/std/eval/luv/Env.hx
Normal file
23
Kha/Tools/linux_x64/std/eval/luv/Env.hx
Normal file
@ -0,0 +1,23 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Environment variables.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Env
|
||||
**/
|
||||
extern class Env {
|
||||
/**
|
||||
Retrieves the value of an environment variable.
|
||||
**/
|
||||
static function getEnv(name:String):Result<NativeString>;
|
||||
|
||||
/**
|
||||
Sets an environment variable.
|
||||
**/
|
||||
static function setEnv(name:String, value:NativeString):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Retrieves all environment variables.
|
||||
**/
|
||||
static function environ():Result<Map<String,NativeString>>;
|
||||
}
|
424
Kha/Tools/linux_x64/std/eval/luv/File.hx
Normal file
424
Kha/Tools/linux_x64/std/eval/luv/File.hx
Normal file
@ -0,0 +1,424 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.Int64;
|
||||
import eval.integers.UInt64;
|
||||
|
||||
@:forward
|
||||
abstract FileRequest(Request) to Request {}
|
||||
|
||||
enum abstract FileOpenFlag(Int) {
|
||||
var RDONLY = 0;
|
||||
var WRONLY = 1;
|
||||
var RDWR = 2;
|
||||
var CREAT = 3;
|
||||
var EXCL = 4;
|
||||
var EXLOCK = 5;
|
||||
var NOCTTY = 6;
|
||||
var NOFOLLOW = 7;
|
||||
var TEMPORARY = 8;
|
||||
var TRUNC = 9;
|
||||
var APPEND = 10;
|
||||
var DIRECT = 11;
|
||||
var DSYNC = 12;
|
||||
var FILEMAP = 13;
|
||||
var NOATIME = 14;
|
||||
var NONBLOCK = 15;
|
||||
var RANDOM = 16;
|
||||
var SEQUENTIAL = 17;
|
||||
var SHORT_LIVED = 18;
|
||||
var SYMLINK = 19;
|
||||
var SYNC = 20;
|
||||
}
|
||||
|
||||
/**
|
||||
Permission bits.
|
||||
@see https://aantron.github.io/luv/luv/Luv/File/Mode
|
||||
**/
|
||||
enum FileMode {
|
||||
IRWXU;
|
||||
IRUSR;
|
||||
IWUSR;
|
||||
IXUSR;
|
||||
IRWXG;
|
||||
IRGRP;
|
||||
IWGRP;
|
||||
IXGRP;
|
||||
IRWXO;
|
||||
IROTH;
|
||||
IWOTH;
|
||||
IXOTH;
|
||||
ISUID;
|
||||
ISGID;
|
||||
ISVTX;
|
||||
IFMT;
|
||||
IFREG;
|
||||
IFDIR;
|
||||
IFBLK;
|
||||
IFCHR;
|
||||
IFLNK;
|
||||
IFIFO;
|
||||
NUMERIC(mode:Int);
|
||||
}
|
||||
|
||||
/**
|
||||
Abstract type for a bit field of permissions bits, i.e., an `int` in which
|
||||
multiple bits may be set. These bit fields are returned by operations such
|
||||
as `eval.luv.File.stat`
|
||||
**/
|
||||
@:coreType abstract FileModeNumeric {}
|
||||
|
||||
typedef FileStatTimeSpec = {
|
||||
var sec:Int64;
|
||||
var nsec:Int64;
|
||||
}
|
||||
|
||||
typedef FileStat = {
|
||||
var dev:UInt64;
|
||||
var mode:FileModeNumeric;
|
||||
var nlink:UInt64;
|
||||
var uid:UInt64;
|
||||
var gid:UInt64;
|
||||
var rdev:UInt64;
|
||||
var ino:UInt64;
|
||||
var size:UInt64;
|
||||
var blksize:UInt64;
|
||||
var blocks:UInt64;
|
||||
var flags:UInt64;
|
||||
var gen:UInt64;
|
||||
var atim:FileStatTimeSpec;
|
||||
var mtim:FileStatTimeSpec;
|
||||
var ctim:FileStatTimeSpec;
|
||||
var birthtim:FileStatTimeSpec;
|
||||
}
|
||||
|
||||
typedef FileStatFs = {
|
||||
var type:UInt64;
|
||||
var bsize:UInt64;
|
||||
var blocks:UInt64;
|
||||
var bfree:UInt64;
|
||||
var bavail:UInt64;
|
||||
var files:UInt64;
|
||||
var ffree:UInt64;
|
||||
var fspare:Array<UInt64>;
|
||||
}
|
||||
|
||||
enum abstract FileCopyFlag(Int) {
|
||||
var COPYFILE_EXCL = 0;
|
||||
var COPYFILE_FICLONE = 1;
|
||||
var COPYFILE_FICLONE_FORCE = 2;
|
||||
}
|
||||
|
||||
enum abstract FileAccessFlag(Int) {
|
||||
var F_OK = 0;
|
||||
var R_OK = 1;
|
||||
var W_OK = 2;
|
||||
var X_OK = 3;
|
||||
}
|
||||
|
||||
enum abstract FileSymlinkFlag(Int) {
|
||||
var SYMLINK_DIR = 0;
|
||||
var SYMLINK_JUNCTION = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Files.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/File
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract File to Handle {
|
||||
|
||||
extern static public final stdin:File;
|
||||
extern static public final stdout:File;
|
||||
extern static public final stderr:File;
|
||||
|
||||
static public function createRequest():FileRequest;
|
||||
|
||||
/**
|
||||
Checks whether all the bits in `mask` are set in `bits`.
|
||||
|
||||
For example, if `bits` is equal to octal 0o644, then
|
||||
`eval.luv.File.testMode [IRUSR] bits` evaluates to `true`.
|
||||
**/
|
||||
static public function testMode(mask:Array<FileMode>, bits:FileModeNumeric):Bool;
|
||||
|
||||
/**
|
||||
Opens the file at the given path.
|
||||
The default value of the `mode` argument is equal to octal `0o644`.
|
||||
**/
|
||||
static public function open(loop:Loop, path:NativeString, flags:Array<FileOpenFlag>, ?mode:Array<FileMode>, ?request:FileRequest, callback:(result:Result<File>)->Void):Void;
|
||||
|
||||
/**
|
||||
Closes the file.
|
||||
**/
|
||||
public function close(loop:Loop, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Reads from the file.
|
||||
|
||||
The incoming data is written consecutively to into the given buffers.
|
||||
The number of bytes that the operation tries to read is the total length
|
||||
of the buffers.
|
||||
|
||||
End of file is indicated by `Result.Ok(0)`. Note that this is different
|
||||
from `eval.luv.Stream.readStart`.
|
||||
**/
|
||||
public function read(loop:Loop, fileOffset:Int64, buffers:Array<Buffer>, ?request:FileRequest, callback:(result:Result<UInt64>)->Void):Void;
|
||||
|
||||
/**
|
||||
Writes to the file.
|
||||
**/
|
||||
public function write(loop:Loop, fileOffset:Int64, buffers:Array<Buffer>, ?request:FileRequest, callback:(result:Result<UInt64>)->Void):Void;
|
||||
|
||||
/**
|
||||
Deletes the file at the given path.
|
||||
**/
|
||||
static public function unlink(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Moves the file at the given path to the path given by `toPath`
|
||||
**/
|
||||
static public function rename(loop:Loop, path:NativeString, toPath:NativeString, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Creates a temporary file with name based on the given pattern.
|
||||
**/
|
||||
static public function mkstemp(loop:Loop, pattern:NativeString, ?request:FileRequest, callback:(result:Result<{name:NativeString,file:File}>)->Void):Void;
|
||||
|
||||
/**
|
||||
Creates a temporary directory with name based on the given pattern.
|
||||
**/
|
||||
static public function mkdtemp(loop:Loop, pattern:NativeString, ?request:FileRequest, callback:(result:Result<NativeString>)->Void):Void;
|
||||
|
||||
/**
|
||||
Creates a directory.
|
||||
**/
|
||||
static public function mkdir(loop:Loop, path:NativeString, ?mode:Array<FileMode>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Deletes a directory.
|
||||
**/
|
||||
static public function rmdir(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves status information for the file at the given path.
|
||||
**/
|
||||
static public function stat(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<FileStat>)->Void):Void;
|
||||
|
||||
/**
|
||||
Like `eval.luv.File.stat`, but does not dereference symlinks.
|
||||
**/
|
||||
static public function lstat(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<FileStat>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves status information for this file.
|
||||
**/
|
||||
public function fstat(loop:Loop, ?request:FileRequest, callback:(result:Result<FileStat>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves status information for the filesystem containing the given path.
|
||||
**/
|
||||
static public function statFs(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<FileStatFs>)->Void):Void;
|
||||
|
||||
/**
|
||||
Flushes file changes to storage.
|
||||
**/
|
||||
public function fsync(loop:Loop, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Like `eval.luv.File.fsync`, but may omit some metadata.
|
||||
**/
|
||||
public function fdataSync(loop:Loop, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Truncates the given file to the given length.
|
||||
**/
|
||||
public function ftruncate(loop:Loop, length:Int64, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Copies the file at the given path to the path given by `toPath`.
|
||||
**/
|
||||
static public function copyFile(loop:Loop, path:NativeString, toPath:NativeString, ?flags:Array<FileCopyFlag>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Transfers data between file descriptors.
|
||||
**/
|
||||
public function sendFile(loop:Loop, toFile:File, offset:Int64, length:UInt64, ?request:FileRequest, callback:(result:Result<UInt64>)->Void):Void;
|
||||
|
||||
/**
|
||||
Checks whether the calling process can access the file at the given path.
|
||||
**/
|
||||
static public function access(loop:Loop, path:NativeString, flags:Array<FileAccessFlag>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Changes permissions of the file at the given path.
|
||||
**/
|
||||
static public function chmod(loop:Loop, path:NativeString, mode:Array<FileMode>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Changes permissions of the file.
|
||||
**/
|
||||
public function fchmod(loop:Loop, mode:Array<FileMode>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Sets timestamps of the file at the given path.
|
||||
**/
|
||||
static public function utime(loop:Loop, path:NativeString, atime:Float, mtime:Float, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Sets timestamps of the file.
|
||||
**/
|
||||
public function futime(loop:Loop, atime:Float, mtime:Float, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Sets timestamps of the file at the given path without dereferencing symlinks.
|
||||
**/
|
||||
static public function lutime(loop:Loop, path:NativeString, atime:Float, mtime:Float, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Hardlinks a file at the location given by `link`.
|
||||
**/
|
||||
static public function link(loop:Loop, path:NativeString, link:NativeString, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Symlinks a file at the location given by `link`.
|
||||
**/
|
||||
static public function symlink(loop:Loop, path:NativeString, link:NativeString, ?flags:Array<FileSymlinkFlag>, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Reads the target path of a symlink.
|
||||
**/
|
||||
static public function readLink(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<NativeString>)->Void):Void;
|
||||
|
||||
/**
|
||||
Resolves a real absolute path to the given file.
|
||||
**/
|
||||
static public function realPath(loop:Loop, path:NativeString, ?request:FileRequest, callback:(result:Result<NativeString>)->Void):Void;
|
||||
|
||||
/**
|
||||
Changes owneship of the file at the given path.
|
||||
**/
|
||||
static public function chown(loop:Loop, path:NativeString, uid:Int, gid:Int, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Changes owneship of the file at the given path. without dereferencing symlinks.
|
||||
**/
|
||||
static public function lchown(loop:Loop, path:NativeString, uid:Int, gid:Int, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Changes owneship of the file.
|
||||
**/
|
||||
public function fchown(loop:Loop, uid:Int, gid:Int, ?request:FileRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Returns the integer representation of `eval.luv.File`.
|
||||
|
||||
`eval.luv.File` is defined as an integer file descriptor by libuv on all
|
||||
platforms at the moment. This is a convenience function for interoperability
|
||||
with `eval.luv.Process`, the API of which assumes that files are represented
|
||||
by integers.
|
||||
**/
|
||||
public function toInt():Int;
|
||||
}
|
||||
|
||||
/**
|
||||
Synchronous version of `eval.luv.File` API
|
||||
**/
|
||||
extern class FileSync {
|
||||
@:inheritDoc(eval.luv.File.open)
|
||||
static function open(path:NativeString, flags:Array<FileOpenFlag>, ?mode:Array<FileMode>):Result<File>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.close)
|
||||
static function close(file:File):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.read)
|
||||
static function read(file:File, fileOffset:Int64, buffers:Array<Buffer>):Result<UInt64>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.write)
|
||||
static function write(file:File, fileOffset:Int64, buffers:Array<Buffer>):Result<UInt64>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.unlink)
|
||||
static function unlink(path:NativeString):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.rename)
|
||||
static function rename(path:NativeString, toPath:NativeString):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.mkstemp)
|
||||
static function mkstemp(pattern:NativeString):Result<{name:NativeString,file:File}>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.mkdtemp)
|
||||
static function mkdtemp(pattern:NativeString):Result<NativeString>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.mkdir)
|
||||
static function mkdir(path:NativeString, ?mode:Array<FileMode>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.rmdir)
|
||||
static function rmdir(path:NativeString):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.stat)
|
||||
static function stat(path:NativeString):Result<FileStat>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.lstat)
|
||||
static function lstat(path:NativeString):Result<FileStat>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.fstat)
|
||||
static function fstat(file:File):Result<FileStat>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.statFs)
|
||||
static function statFs(path:NativeString):Result<FileStatFs>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.fsync)
|
||||
static function fsync(file:File):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.fdataSync)
|
||||
static function fdataSync(file:File):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.ftruncate)
|
||||
static function ftruncate(file:File, length:Int64):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.copyFile)
|
||||
static function copyFile(path:NativeString, toPath:NativeString, ?flags:Array<FileCopyFlag>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.sendFile)
|
||||
static function sendFile(file:File, toFile:File, offset:Int64, length:UInt64):Result<UInt64>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.access)
|
||||
static function access(path:NativeString, flags:Array<FileAccessFlag>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.chmod)
|
||||
static function chmod(path:NativeString, mode:Array<FileMode>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.fchmod)
|
||||
static function fchmod(file:File, mode:Array<FileMode>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.utime)
|
||||
static function utime(path:NativeString, atime:Float, mtime:Float):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.futime)
|
||||
static function futime(file:File, atime:Float, mtime:Float):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.lutime)
|
||||
static function lutime(path:NativeString, atime:Float, mtime:Float):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.link)
|
||||
static function link(path:NativeString, link:NativeString):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.symlink)
|
||||
static function symlink(path:NativeString, link:NativeString, ?flags:Array<FileSymlinkFlag>):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.readLink)
|
||||
static function readLink(path:NativeString):Result<NativeString>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.realPath)
|
||||
static function realPath(path:NativeString):Result<NativeString>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.chown)
|
||||
static function chown(path:NativeString, uid:Int, gid:Int):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.lchown)
|
||||
static function lchown(path:NativeString, uid:Int, gid:Int):Result<Result.NoData>;
|
||||
|
||||
@:inheritDoc(eval.luv.File.fchown)
|
||||
static function fchown(file:File, uid:Int, gid:Int):Result<Result.NoData>;
|
||||
|
||||
}
|
36
Kha/Tools/linux_x64/std/eval/luv/FsEvent.hx
Normal file
36
Kha/Tools/linux_x64/std/eval/luv/FsEvent.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package eval.luv;
|
||||
|
||||
enum abstract FsEventType(Int) {
|
||||
var RENAME = 0;
|
||||
var CHANGE = 1;
|
||||
}
|
||||
|
||||
enum abstract FsEventFlag(Int) {
|
||||
var FS_EVENT_WATCH_ENTRY = 0;
|
||||
var FS_EVENT_STAT = 1;
|
||||
var FS_EVENT_RECURSIVE = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
Filesystem events.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/FS_event
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract FsEvent to Handle {
|
||||
/**
|
||||
Allocates and initializes an FS event handle.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<FsEvent>;
|
||||
|
||||
/**
|
||||
Starts the handle and watches the given path for changes.
|
||||
**/
|
||||
public function start(path:NativeString, ?flags:Array<FsEventFlag>, callback:(result:Result<{file:NativeString,events:Array<FsEventType>}>)->Void):Void;
|
||||
|
||||
/**
|
||||
Stops the handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
|
||||
}
|
30
Kha/Tools/linux_x64/std/eval/luv/FsPoll.hx
Normal file
30
Kha/Tools/linux_x64/std/eval/luv/FsPoll.hx
Normal file
@ -0,0 +1,30 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.luv.File;
|
||||
|
||||
/**
|
||||
Filesystem polling.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/FS_poll
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract FsPoll to Handle {
|
||||
/**
|
||||
Allocates and initializes an FS polling handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<FsPoll>;
|
||||
|
||||
/**
|
||||
Starts the handle and polls the given path for changes.
|
||||
|
||||
The default value of `interval` is 2000 (milliseconds).
|
||||
**/
|
||||
public function start(path:NativeString, ?interval:Int, callback:(result:Result<{previous:FileStat,current:FileStat}>)->Void):Void;
|
||||
|
||||
/**
|
||||
Stops the handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
}
|
85
Kha/Tools/linux_x64/std/eval/luv/Handle.hx
Normal file
85
Kha/Tools/linux_x64/std/eval/luv/Handle.hx
Normal file
@ -0,0 +1,85 @@
|
||||
package eval.luv;
|
||||
|
||||
@:coreType abstract SocketHandle {}
|
||||
|
||||
/**
|
||||
Handles.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle
|
||||
**/
|
||||
@:coreType abstract Handle {
|
||||
/**
|
||||
Closes the given handle.
|
||||
**/
|
||||
extern static public function close(handle:Handle, callback:()->Void):Void;
|
||||
|
||||
/**
|
||||
Returns `true` if the handle is active, `false` otherwise.
|
||||
**/
|
||||
static public function isActive(handle:Handle):Bool;
|
||||
|
||||
/**
|
||||
Returns `true` if the handle is closing or closed, `false` otherwise.
|
||||
|
||||
Note: This function should only be used between the initialization of
|
||||
the handle and the arrival of the close callback.
|
||||
**/
|
||||
static public function isClosing(handle:Handle):Bool;
|
||||
|
||||
/**
|
||||
Reference the given handle.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-ref
|
||||
**/
|
||||
static public function ref(handle:Handle):Void;
|
||||
|
||||
/**
|
||||
Un-reference the given handle.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-unref
|
||||
**/
|
||||
static public function unref(handle:Handle):Void;
|
||||
|
||||
/**
|
||||
Returns `true` if the handle referenced, `false` otherwise.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-has_ref
|
||||
**/
|
||||
static public function hasRef(handle:Handle):Bool;
|
||||
|
||||
/**
|
||||
Gets the size of the OS send buffer for a socket.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-send_buffer_size
|
||||
**/
|
||||
static public function sendBufferSize(handle:SocketHandle):Result<Int>;
|
||||
|
||||
/**
|
||||
Sets the size of the OS send buffer for a socket.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-set_send_buffer_size
|
||||
**/
|
||||
static public function setSendBufferSize(handle:SocketHandle, size:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Gets the size of the OS receive buffer for a socket.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-recv_buffer_size
|
||||
**/
|
||||
static public function recvBufferSize(handle:SocketHandle):Result<Int>;
|
||||
|
||||
/**
|
||||
Sets the size of the OS receive buffer for a socket.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Handle/#val-set_recv_buffer_size
|
||||
**/
|
||||
static public function setRecvBufferSize(handle:SocketHandle, size:Int):Result<Result.NoData>;
|
||||
|
||||
// TODO
|
||||
// /**
|
||||
// Retrieves the file descriptor associated with the handle.
|
||||
|
||||
// @see https://aantron.github.io/luv/luv/Luv/Handle/#val-fileno
|
||||
// **/
|
||||
// static public function fileno(handle:FileNo):Result<OsFd>;
|
||||
}
|
26
Kha/Tools/linux_x64/std/eval/luv/Idle.hx
Normal file
26
Kha/Tools/linux_x64/std/eval/luv/Idle.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Per-iteration callback.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Idle
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Idle to Handle {
|
||||
/**
|
||||
Allocate and initialize an idle handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<Idle>;
|
||||
|
||||
/**
|
||||
Starts the handle with the given callback.
|
||||
**/
|
||||
public function start(callback:()->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Stops the handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
}
|
93
Kha/Tools/linux_x64/std/eval/luv/Loop.hx
Normal file
93
Kha/Tools/linux_x64/std/eval/luv/Loop.hx
Normal file
@ -0,0 +1,93 @@
|
||||
package eval.luv;
|
||||
|
||||
enum abstract RunMode(Int) {
|
||||
/** Runs the event loop until there are no more active and referenced handles or requests. */
|
||||
var DEFAULT = 0;
|
||||
/** Poll for i/o once. Note that this mode blocks if there are no pending callbacks. */
|
||||
var ONCE = 1;
|
||||
/** Poll for i/o once but don't block if there are no pending callbacks. */
|
||||
var NOWAIT = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
Configuration options.
|
||||
@see http://docs.libuv.org/en/v1.x/loop.html#c.uv_loop_configure
|
||||
**/
|
||||
enum abstract LoopOption<T>(Int) {
|
||||
extern static public final sigprof:Int;
|
||||
|
||||
var LOOP_BLOCK_SIGNAL:LoopOption<Int> = 0;
|
||||
var METRICS_IDLE_TIME:LoopOption<Result.NoData> = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Event loops.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Loop
|
||||
|
||||
Haxe event loops define an implicit cast to libuv loops. That is, you can use
|
||||
`sys.thread.Thread.current().events` in any place where `eval.luv.Loop` is
|
||||
expected.
|
||||
**/
|
||||
@:coreType abstract Loop {
|
||||
@:from
|
||||
static inline function fromHaxeEventLoop(events:sys.thread.EventLoop):Loop {
|
||||
return events.handle;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the default event loop.
|
||||
**/
|
||||
static public function defaultLoop():Loop;
|
||||
|
||||
/**
|
||||
Allocates and initializes a new event loop.
|
||||
**/
|
||||
static public function init():Result<Loop>;
|
||||
|
||||
/**
|
||||
Releases any state libuv is holding on to.
|
||||
|
||||
Normally there's no need to do this manually.
|
||||
|
||||
Warning! Only call `Loop.libraryShutdown()` once.
|
||||
Warning! Don’t call `Loop.libraryShutdown()` when there are still event loops or I/O requests active.
|
||||
Warning! Don’t call libuv functions after calling `Loop.libraryShutdown()`.
|
||||
**/
|
||||
static public function libraryShutdown():Void;
|
||||
|
||||
/**
|
||||
Runs an event loop.
|
||||
**/
|
||||
public function run(mode:RunMode):Bool;
|
||||
|
||||
/**
|
||||
Releases resources associated with an event loop.
|
||||
**/
|
||||
public function close():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Indicates whether the loop is monitoring any activity.
|
||||
**/
|
||||
public function alive():Bool;
|
||||
|
||||
/**
|
||||
Stops an event loop as soon as possible.
|
||||
**/
|
||||
public function stop():Void;
|
||||
|
||||
/**
|
||||
Returns the cached loop timestamp.
|
||||
**/
|
||||
public function now():eval.integers.UInt64;
|
||||
|
||||
/**
|
||||
Updates the cached loop timestamp.
|
||||
**/
|
||||
public function updateTime():Void;
|
||||
|
||||
/**
|
||||
Sets the loop option.
|
||||
**/
|
||||
public function configure<T>(option:LoopOption<T>, value:T):Result<Result.NoData>;
|
||||
}
|
19
Kha/Tools/linux_x64/std/eval/luv/LuvException.hx
Normal file
19
Kha/Tools/linux_x64/std/eval/luv/LuvException.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Exceptions thrown by functions in `eval.luv` package.
|
||||
**/
|
||||
class LuvException extends haxe.Exception {
|
||||
/**
|
||||
The error.
|
||||
**/
|
||||
public final error:UVError;
|
||||
|
||||
/**
|
||||
Instantiates an error with given message and position.
|
||||
**/
|
||||
public function new(error:UVError, ?message:String, ?previous:haxe.Exception) {
|
||||
super(message == null ? error.toString() : message, previous);
|
||||
this.error = error;
|
||||
}
|
||||
}
|
13
Kha/Tools/linux_x64/std/eval/luv/Metrics.hx
Normal file
13
Kha/Tools/linux_x64/std/eval/luv/Metrics.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Metrics.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Metrics
|
||||
**/
|
||||
extern class Metrics {
|
||||
/**
|
||||
Retrieves the amount of time the loop has been blocked waiting in the kernel.
|
||||
**/
|
||||
static function idleTime(loop:Loop):eval.integers.UInt64;
|
||||
}
|
35
Kha/Tools/linux_x64/std/eval/luv/Mutex.hx
Normal file
35
Kha/Tools/linux_x64/std/eval/luv/Mutex.hx
Normal file
@ -0,0 +1,35 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Mutexes.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Mutex
|
||||
**/
|
||||
@:coreType abstract Mutex {
|
||||
/**
|
||||
Allocates and initializes a mutex.
|
||||
**/
|
||||
static public function init(?recursive:Bool):Result<Mutex>;
|
||||
|
||||
/**
|
||||
Cleans up a mutex.
|
||||
**/
|
||||
public function destroy():Void;
|
||||
|
||||
/**
|
||||
Takes the mutex.
|
||||
|
||||
The calling thread is blocked until it obtains the mutex.
|
||||
**/
|
||||
public function lock():Void;
|
||||
|
||||
/**
|
||||
Tries to take the mutex without blocking.
|
||||
**/
|
||||
public function tryLock():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Releases the mutex.
|
||||
**/
|
||||
public function unlock():Void;
|
||||
}
|
36
Kha/Tools/linux_x64/std/eval/luv/Network.hx
Normal file
36
Kha/Tools/linux_x64/std/eval/luv/Network.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package eval.luv;
|
||||
|
||||
typedef InterfaceAddress = {
|
||||
var name:String;
|
||||
var isInternal:Bool;
|
||||
var physical:NativeString;
|
||||
var address:SockAddr;
|
||||
var netmask:SockAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
Network interfaces and hostname.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Network
|
||||
**/
|
||||
extern class Network {
|
||||
/**
|
||||
Lists network interface addresses.
|
||||
**/
|
||||
static function interfaceAddresses():Result<Array<InterfaceAddress>>;
|
||||
|
||||
/**
|
||||
Retrieves a network interface name.
|
||||
**/
|
||||
static function ifIndexToName(index:Int):Result<String>;
|
||||
|
||||
/**
|
||||
Retrieves a network interface identifier suitable for use in an IPv6 scoped address.
|
||||
**/
|
||||
static function ifIndexToIid(index:Int):Result<String>;
|
||||
|
||||
/**
|
||||
Evaluates to the system's hostname.
|
||||
**/
|
||||
static function getHostName():Result<String>;
|
||||
}
|
18
Kha/Tools/linux_x64/std/eval/luv/Once.hx
Normal file
18
Kha/Tools/linux_x64/std/eval/luv/Once.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Once-only initialization.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Once
|
||||
**/
|
||||
@:coreType abstract Once {
|
||||
/**
|
||||
Allocates and initializes a once-only barrier.
|
||||
**/
|
||||
static public function init():Result<Once>;
|
||||
|
||||
/**
|
||||
Guards the given callback to be called only once.
|
||||
**/
|
||||
public function once(callback:()->Void):Void;
|
||||
}
|
6
Kha/Tools/linux_x64/std/eval/luv/OsFd.hx
Normal file
6
Kha/Tools/linux_x64/std/eval/luv/OsFd.hx
Normal file
@ -0,0 +1,6 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
@see https://aantron.github.io/luv/luv/Luv/Os_fd/Fd
|
||||
**/
|
||||
@:coreType abstract OsFd {}
|
6
Kha/Tools/linux_x64/std/eval/luv/OsSocket.hx
Normal file
6
Kha/Tools/linux_x64/std/eval/luv/OsSocket.hx
Normal file
@ -0,0 +1,6 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
@see https://aantron.github.io/luv/luv/Luv/Os_fd/Socket
|
||||
**/
|
||||
@:coreType abstract OsSocket {}
|
21
Kha/Tools/linux_x64/std/eval/luv/Passwd.hx
Normal file
21
Kha/Tools/linux_x64/std/eval/luv/Passwd.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package eval.luv;
|
||||
|
||||
typedef PasswdData = {
|
||||
var username:String;
|
||||
var uid:Int;
|
||||
var gid:Int;
|
||||
var shell:Null<String>;
|
||||
var homedir:NativeString;
|
||||
}
|
||||
|
||||
/**
|
||||
Current user information.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Passwd
|
||||
**/
|
||||
extern class Passwd {
|
||||
/**
|
||||
Gets passwd entry for the current user.
|
||||
**/
|
||||
static function getPasswd():Result<PasswdData>;
|
||||
}
|
37
Kha/Tools/linux_x64/std/eval/luv/Path.hx
Normal file
37
Kha/Tools/linux_x64/std/eval/luv/Path.hx
Normal file
@ -0,0 +1,37 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.Int64;
|
||||
import eval.integers.UInt64;
|
||||
|
||||
/**
|
||||
Relevant directories.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Path
|
||||
**/
|
||||
extern class Path {
|
||||
/**
|
||||
Evaluates to the executable's path.
|
||||
It's always the path to the Haxe compiler.
|
||||
**/
|
||||
static function exePath():Result<NativeString>;
|
||||
|
||||
/**
|
||||
Evaluates to the current working directory.
|
||||
**/
|
||||
static function cwd():Result<NativeString>;
|
||||
|
||||
/**
|
||||
Changes the current working directory.
|
||||
**/
|
||||
static function chdir(dir:NativeString):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Evaluates to the path of the home directory.
|
||||
**/
|
||||
static function homedir():Result<NativeString>;
|
||||
|
||||
/**
|
||||
Evaluates to the path of the temporary directory.
|
||||
**/
|
||||
static function tmpdir():Result<NativeString>;
|
||||
}
|
18
Kha/Tools/linux_x64/std/eval/luv/Pid.hx
Normal file
18
Kha/Tools/linux_x64/std/eval/luv/Pid.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Process ids.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Pid
|
||||
**/
|
||||
extern class Pid {
|
||||
/**
|
||||
Evaluates to the pid of the current process.
|
||||
**/
|
||||
static function getPid():Int;
|
||||
|
||||
/**
|
||||
Evaluates to the pid of the parent process.
|
||||
**/
|
||||
static function getPPid():Int;
|
||||
}
|
77
Kha/Tools/linux_x64/std/eval/luv/Pipe.hx
Normal file
77
Kha/Tools/linux_x64/std/eval/luv/Pipe.hx
Normal file
@ -0,0 +1,77 @@
|
||||
package eval.luv;
|
||||
|
||||
enum abstract PipeMode(Int) {
|
||||
var READ = 0;
|
||||
var WRITE = 1;
|
||||
var READ_WRITE = 2;
|
||||
}
|
||||
|
||||
enum ReceiveHandle {
|
||||
NONE;
|
||||
TCP(associate:(tcp:Tcp)->Result<Result.NoData>);
|
||||
PIPE(associate:(pipe:Pipe)->Result<Result.NoData>);
|
||||
}
|
||||
|
||||
/**
|
||||
Pipes
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Pipe
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:using(eval.luv.Stream)
|
||||
@:coreType abstract Pipe to Handle to Stream to Stream.TStream<Pipe> to Handle.SocketHandle {
|
||||
/**
|
||||
Allocates and initializes a pipe.
|
||||
|
||||
The pipe is not yet connected to anything at this point.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop, forHandlePassing:Bool = false):Result<Pipe>;
|
||||
|
||||
/**
|
||||
Assigns a pipe a name or an address.
|
||||
**/
|
||||
public function bind(nameOrAddress:NativeString):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Connects to the pipe at the given name or address.
|
||||
**/
|
||||
public function connect(target:NativeString, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Retrieves the name or address assigned to the pipe.
|
||||
**/
|
||||
public function getSockName():Result<NativeString>;
|
||||
|
||||
/**
|
||||
Retrieves the name or address of the pipe's peer.
|
||||
**/
|
||||
public function getPeerName():Result<NativeString>;
|
||||
|
||||
/**
|
||||
Set the number of pending pipe instance handles when the pipe server is
|
||||
waiting for connections.
|
||||
**/
|
||||
public function pendingInstances(amount:Int):Void;
|
||||
|
||||
/**
|
||||
Receives a file descriptor over the given pipe.
|
||||
|
||||
File descriptors are sent using the `sendHandle` argument of `eval.luv.Stream.write2`.
|
||||
On the receiving end, call `eval.luv.Stream.readStart`. When that function
|
||||
calls its callback, there may be file descriptors in the pipe, in addition
|
||||
to the ordinary data provided to the callback.
|
||||
|
||||
To check, call this function `eval.luv.Pipe.recieveHandle` in a loop until
|
||||
it returns `NONE`. Each time it returns `TCP(associate)` or `PIPE(associate)`,
|
||||
create an appropriate handle using either `eval.luv.TCP.init` or `eval.uv.Pipe.init`,
|
||||
and call `associate` to receive the file descriptor and associate it with handle.
|
||||
**/
|
||||
public function receiveHandle():ReceiveHandle;
|
||||
|
||||
/**
|
||||
Sets pipe permissions.
|
||||
**/
|
||||
public function chmod(mode:PipeMode):Result<Result.NoData>;
|
||||
}
|
26
Kha/Tools/linux_x64/std/eval/luv/Prepare.hx
Normal file
26
Kha/Tools/linux_x64/std/eval/luv/Prepare.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Pre-I/O callback.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Prepare
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Prepare to Handle {
|
||||
/**
|
||||
Allocate and initialize a prepare handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<Prepare>;
|
||||
|
||||
/**
|
||||
Starts the handle with the given callback.
|
||||
**/
|
||||
public function start(callback:()->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Stops the handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
}
|
89
Kha/Tools/linux_x64/std/eval/luv/Process.hx
Normal file
89
Kha/Tools/linux_x64/std/eval/luv/Process.hx
Normal file
@ -0,0 +1,89 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.Int64;
|
||||
|
||||
/**
|
||||
File descriptor redirections for use with `eval.luv.Process.spawn`
|
||||
**/
|
||||
@:coreType abstract Redirection {}
|
||||
|
||||
/**
|
||||
Options for spawning the process.
|
||||
**/
|
||||
typedef ProcessOptions = {
|
||||
var ?onExit:(p:Process, exitStatus:Int64, termSignal:Int)->Void;
|
||||
var ?environment:Map<String,NativeString>;
|
||||
var ?workingDirectory:NativeString;
|
||||
var ?redirect:Array<Redirection>;
|
||||
var ?uid:Int;
|
||||
var ?gid:Int;
|
||||
var ?windowsVerbatimArguments:Bool;
|
||||
var ?detached:Bool;
|
||||
var ?windowsHide:Bool;
|
||||
var ?windowsHideConsole:Bool;
|
||||
var ?windowsHideGui:Bool;
|
||||
}
|
||||
|
||||
/**
|
||||
Subprocesses.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Process
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Process to Handle {
|
||||
extern static public final stdin:Int;
|
||||
extern static public final stdout:Int;
|
||||
extern static public final stderr:Int;
|
||||
|
||||
/**
|
||||
Causes `fd` in the child to be connected to `toParentPipe` in the parent.
|
||||
|
||||
Binds `UV_CREATE_PIPE`.
|
||||
|
||||
`readableInChild` sets `UV_READABLE_PIPE`, and `writableInChild` sets `UV_WRITABLE_PIPE`.
|
||||
|
||||
`overlapped` sets `UV_OVERLAPPED_PIPE`.
|
||||
**/
|
||||
static public function toParentPipe(fd:Int, parentPipe:Pipe, readableInChild:Bool, writableInChild:Bool, overlapped:Bool):Redirection;
|
||||
|
||||
/**
|
||||
Causes `fd` in the child to be connected to the same device or peer as `fromParentFd` in the parent.
|
||||
|
||||
Binds `UV_INHERIT_FD`
|
||||
**/
|
||||
static public function inheritFd(fd:Int, fromParentFd:Int):Redirection;
|
||||
|
||||
/**
|
||||
Same as `eval.luv.Process.inheritFd`, but takes an `eval.luv.Stream` for the parent file descriptor.
|
||||
|
||||
Binds `UV_INHERIT_STREAM`.
|
||||
**/
|
||||
static public function inheritStream(fd:Int, fromParentStream:Stream):Redirection;
|
||||
|
||||
/**
|
||||
Starts a process.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function spawn(loop:Loop, cmd:NativeString, args:Array<NativeString>, ?options:ProcessOptions):Result<Process>;
|
||||
|
||||
/**
|
||||
Disables (tries) file descriptor inheritance for inherited descriptors.
|
||||
**/
|
||||
static public function disableStdioInheritance():Void;
|
||||
|
||||
/**
|
||||
Sends the given signal to the process with the given pid.
|
||||
**/
|
||||
static public function killPid(pid:Int, sigNum:Signal.SigNum):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sends the given signal to the process.
|
||||
**/
|
||||
public function kill(sigNum:Signal.SigNum):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Evaluates to the pid of the process.
|
||||
**/
|
||||
public function pid():Int;
|
||||
}
|
26
Kha/Tools/linux_x64/std/eval/luv/Random.hx
Normal file
26
Kha/Tools/linux_x64/std/eval/luv/Random.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package eval.luv;
|
||||
|
||||
@:forward
|
||||
abstract RandomRequest(Request) to Request {}
|
||||
|
||||
/**
|
||||
System entropy source.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Random
|
||||
**/
|
||||
extern class Random {
|
||||
|
||||
static function createRequest():RandomRequest;
|
||||
|
||||
/**
|
||||
Fills the given buffer with bits from the system entropy source.
|
||||
**/
|
||||
static function random(loop:Loop, buffer:Buffer, ?request:RandomRequest, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
}
|
||||
|
||||
extern class RandomSync {
|
||||
/**
|
||||
Fills the given buffer with bits from the system entropy source.
|
||||
**/
|
||||
static function random(buffer:Buffer):Result<Result.NoData>;
|
||||
}
|
13
Kha/Tools/linux_x64/std/eval/luv/Request.hx
Normal file
13
Kha/Tools/linux_x64/std/eval/luv/Request.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Requests.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Request
|
||||
**/
|
||||
@:coreType abstract Request {
|
||||
/**
|
||||
Tries to cancel a pending request.
|
||||
**/
|
||||
public function cancel():Result<Result.NoData>;
|
||||
}
|
78
Kha/Tools/linux_x64/std/eval/luv/Resource.hx
Normal file
78
Kha/Tools/linux_x64/std/eval/luv/Resource.hx
Normal file
@ -0,0 +1,78 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.UInt64;
|
||||
import eval.integers.Int64;
|
||||
|
||||
typedef RUsage = {
|
||||
var utime:{sec:Int64, usec:Int64};
|
||||
var stime:{sec:Int64, usec:Int64};
|
||||
var maxrss:UInt64;
|
||||
var ixrss:UInt64;
|
||||
var idrss:UInt64;
|
||||
var isrss:UInt64;
|
||||
var minflt:UInt64;
|
||||
var majflt:UInt64;
|
||||
var nswap:UInt64;
|
||||
var inblock:UInt64;
|
||||
var oublock:UInt64;
|
||||
var msgsnd:UInt64;
|
||||
var msgrcv:UInt64;
|
||||
var nsignals:UInt64;
|
||||
var nvcsw:UInt64;
|
||||
var nivcsw:UInt64;
|
||||
}
|
||||
|
||||
/**
|
||||
Resource usage.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Resource
|
||||
**/
|
||||
extern class Resource {
|
||||
/**
|
||||
Evaluates to the current uptime.
|
||||
**/
|
||||
static function uptime():Result<Float>;
|
||||
|
||||
/**
|
||||
Evaluates to the load average.
|
||||
**/
|
||||
static function loadAvg():Array<Float>;
|
||||
|
||||
/**
|
||||
Evaluates to the amount of free memory, in bytes.
|
||||
**/
|
||||
static function freeMemory():UInt64;
|
||||
|
||||
/**
|
||||
Evaluates to the total amount of memory, in bytes.
|
||||
**/
|
||||
static function totalMemory():UInt64;
|
||||
|
||||
/**
|
||||
Gets the amount of memory available to the process (in bytes) based on
|
||||
limits imposed by the OS.
|
||||
If there is no such constraint returns `null`
|
||||
**/
|
||||
static function constrainedMemory():Null<UInt64>;
|
||||
|
||||
/**
|
||||
Evaluates to the priority of the process with the given pid.
|
||||
**/
|
||||
static function getPriority(pid:Int):Result<Int>;
|
||||
|
||||
/**
|
||||
Sets the priority of the process with the given pid.
|
||||
**/
|
||||
static function setPriority(pid:Int, priority:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Evaluates to the resident set size for the current process.
|
||||
**/
|
||||
static function residentSetMemory(pid:Int):Result<UInt64>;
|
||||
|
||||
/**
|
||||
Gets the resource usage measures for the current process.
|
||||
**/
|
||||
static function getRUsage():Result<RUsage>;
|
||||
|
||||
}
|
40
Kha/Tools/linux_x64/std/eval/luv/Result.hx
Normal file
40
Kha/Tools/linux_x64/std/eval/luv/Result.hx
Normal file
@ -0,0 +1,40 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Outcome of an operation.
|
||||
**/
|
||||
@:using(eval.luv.Result.ResultTools)
|
||||
enum Result<T> {
|
||||
/** Operation completed successfully. **/
|
||||
Ok(value:T);
|
||||
/** Operation failed. **/
|
||||
Error(e:UVError);
|
||||
}
|
||||
|
||||
enum abstract NoData(Dynamic) {
|
||||
var NoData = null;
|
||||
}
|
||||
|
||||
class ResultTools {
|
||||
/**
|
||||
Returns the result value on success or throws `eval.luv.LuvException`
|
||||
on failure.
|
||||
**/
|
||||
static public inline function resolve<T>(result:Result<T>):T {
|
||||
switch result {
|
||||
case Ok(v): return v;
|
||||
case Error(e): throw new LuvException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Returns `true` if the result is `Ok`.
|
||||
Returns `false` if the result is `Error`.
|
||||
**/
|
||||
static public inline function isOk<T>(result:Result<T>):Bool {
|
||||
return switch result {
|
||||
case Ok(_): true;
|
||||
case Error(_): false;
|
||||
}
|
||||
}
|
||||
}
|
48
Kha/Tools/linux_x64/std/eval/luv/RwLock.hx
Normal file
48
Kha/Tools/linux_x64/std/eval/luv/RwLock.hx
Normal file
@ -0,0 +1,48 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Read-write locks.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Rwlock
|
||||
**/
|
||||
@:coreType abstract RwLock {
|
||||
/**
|
||||
Allocates and initializes a read-write lock.
|
||||
**/
|
||||
static public function init():Result<RwLock>;
|
||||
|
||||
/**
|
||||
Cleans up a read-write lock.
|
||||
**/
|
||||
public function destroy():Void;
|
||||
|
||||
/**
|
||||
Takes a read-write lock for reading (shared access).
|
||||
**/
|
||||
public function rdLock():Void;
|
||||
|
||||
/**
|
||||
Tries to take a read-write lock for reading without blocking.
|
||||
**/
|
||||
public function rdTryLock():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Releases a read-write lock after it was taken for reading.
|
||||
**/
|
||||
public function rdUnlock():Void;
|
||||
|
||||
/**
|
||||
Takes a read-write lock for writing (exclusive access).
|
||||
**/
|
||||
public function wrLock():Void;
|
||||
|
||||
/**
|
||||
Tries to take a read-write lock for writing without blocking.
|
||||
**/
|
||||
public function wrTryLock():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Releases a read-write lock after it was taken for writing.
|
||||
**/
|
||||
public function wrUnlock():Void;
|
||||
}
|
33
Kha/Tools/linux_x64/std/eval/luv/Semaphore.hx
Normal file
33
Kha/Tools/linux_x64/std/eval/luv/Semaphore.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Semaphores.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Semaphore
|
||||
**/
|
||||
@:coreType abstract Semaphore {
|
||||
/**
|
||||
Allocates and initializes a read-write lock.
|
||||
**/
|
||||
static public function init(value:Int):Result<Semaphore>;
|
||||
|
||||
/**
|
||||
Cleans up a semaphore.
|
||||
**/
|
||||
public function destroy():Void;
|
||||
|
||||
/**
|
||||
Increments a semaphore.
|
||||
**/
|
||||
public function post():Void;
|
||||
|
||||
/**
|
||||
Decrements a semaphore.
|
||||
**/
|
||||
public function wait():Void;
|
||||
|
||||
/**
|
||||
Tries to decrement a semaphore without blocking.
|
||||
**/
|
||||
public function tryWait():Result<Result.NoData>;
|
||||
}
|
57
Kha/Tools/linux_x64/std/eval/luv/Signal.hx
Normal file
57
Kha/Tools/linux_x64/std/eval/luv/Signal.hx
Normal file
@ -0,0 +1,57 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
For the moment, the signals exposed are those that are both present on Unix
|
||||
and present or emulated by libuv on Windows.
|
||||
|
||||
You can also provide a plain integer signal code instead of the values of
|
||||
this enum.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Signal#signals
|
||||
**/
|
||||
extern enum abstract SigNum(Int) from Int to Int {
|
||||
var SIGABRT;
|
||||
var SIGFPE;
|
||||
var SIGHUP;
|
||||
var SIGILL;
|
||||
var SIGINT;
|
||||
var SIGKILL;
|
||||
var SIGSEGV;
|
||||
var SIGTERM;
|
||||
var SIGWINCH;
|
||||
}
|
||||
|
||||
/**
|
||||
Signals.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Signal
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Signal to Handle {
|
||||
/**
|
||||
Allocates and initializes a signal handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<Signal>;
|
||||
|
||||
/**
|
||||
Starts the signal handle.
|
||||
**/
|
||||
public function start(sigNum:SigNum, callback:()->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Like `eval.luv.Signal.start`, but the handle is stopped after one callback call.
|
||||
**/
|
||||
public function startOneshot(sigNum:SigNum, callback:()->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Stops the signal handle.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Evaluates to the signal number associated with the handle.
|
||||
**/
|
||||
public function signum():Int;
|
||||
}
|
47
Kha/Tools/linux_x64/std/eval/luv/SockAddr.hx
Normal file
47
Kha/Tools/linux_x64/std/eval/luv/SockAddr.hx
Normal file
@ -0,0 +1,47 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Network address families.
|
||||
**/
|
||||
enum AddressFamily {
|
||||
UNSPEC;
|
||||
INET;
|
||||
INET6;
|
||||
OTHER(i:Int);
|
||||
}
|
||||
|
||||
/**
|
||||
Socket types.
|
||||
**/
|
||||
enum SocketType {
|
||||
STREAM;
|
||||
DGRAM;
|
||||
RAW;
|
||||
OTHER(i:Int);
|
||||
}
|
||||
|
||||
/**
|
||||
Binds `struct sockaddr`.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Sockaddr
|
||||
**/
|
||||
@:coreType abstract SockAddr {
|
||||
/** Extracts the port in a network address. */
|
||||
public var port(get,never):Null<Int>;
|
||||
function get_port():Null<Int>;
|
||||
|
||||
/**
|
||||
Converts a string and port number to an IPv4 struct sockaddr.
|
||||
**/
|
||||
static public function ipv4(host:String, port:Int):Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Converts a string and port number to an IPv6 struct sockaddr.
|
||||
**/
|
||||
static public function ipv6(host:String, port:Int):Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Converts a network address to a string.
|
||||
**/
|
||||
public function toString():String;
|
||||
}
|
111
Kha/Tools/linux_x64/std/eval/luv/Stream.hx
Normal file
111
Kha/Tools/linux_x64/std/eval/luv/Stream.hx
Normal file
@ -0,0 +1,111 @@
|
||||
package eval.luv;
|
||||
|
||||
@:coreType abstract TStream<T> to Stream {}
|
||||
// typedef TStream<T> = Stream;
|
||||
|
||||
enum SendHandle {
|
||||
TCP(tcp:Tcp);
|
||||
PIPE(pipe:Pipe);
|
||||
}
|
||||
|
||||
/**
|
||||
Streams.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Stream
|
||||
**/
|
||||
@:coreType abstract Stream to Handle {
|
||||
/**
|
||||
Shuts down the write side of the stream.
|
||||
**/
|
||||
extern static public function shutdown(stream:Stream, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Starts listening for incoming connections.
|
||||
|
||||
`backlog` indicates the number of connections the kernel might queue.
|
||||
When a new incoming connection is received the `callback` is called.
|
||||
**/
|
||||
extern static public function listen(stream:Stream, callback:(result:Result<Result.NoData>)->Void, ?backlog:Int):Void;
|
||||
|
||||
/**
|
||||
This call is used in conjunction with `Stream.listen()` to accept incoming
|
||||
connections. Call this function after receiving a `callback` of `listen(callback)`
|
||||
to accept the connection. Before calling this function the client handle
|
||||
must be initialized.
|
||||
|
||||
When the `callback` of `listen(callback)` is called it is guaranteed that
|
||||
this function will complete successfully the first time.
|
||||
|
||||
`client` should be a freshly-initialized stream.
|
||||
**/
|
||||
extern static public function accept<T>(server:TStream<T>, client:TStream<T>):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Calls the `callback` whenever data is available on the stream.
|
||||
|
||||
The amount of data read is equal to the length of the buffer passed to
|
||||
the `callback`. `allocate` is called immediately before each call to the
|
||||
main `callback`, to create buffer, into which the data will be read.
|
||||
|
||||
The end of the stream (typically, when the remote peer closes or shuts down
|
||||
the connection) is indicated by `UVError.UV_EOF` being passed to the `callback`.
|
||||
Note that this behavior is different from `eval.luv.File.read`.
|
||||
|
||||
Zero-length reads are possible, and do not indicate the end of stream. Instead,
|
||||
they usually indicate `UVError.UV_EAGAIN` inside libuv; libuv still calls the
|
||||
`callback` in order to give the C user a chance to deallocate the data buffer.
|
||||
This is not usually an issue in OCaml (which is the backend for eval target of
|
||||
Haxe), so a wrapper of this function can usually simply ignore zero-length reads.
|
||||
It is then also safe to convert `UVError.UV_EOF` to zero-length reads in a
|
||||
higher-level API, for consistency with reading files, and in accordance with OS
|
||||
API convention.
|
||||
|
||||
To read only once, call `eval.luv.Stream.readStop` immediately, in the `callback`.
|
||||
Otherwise, the main callback will be called repeatedly.
|
||||
**/
|
||||
extern static public function readStart(stream:Stream, callback:(result:Result<Buffer>)->Void, ?allocate:(size:Int)->Buffer):Void;
|
||||
|
||||
/**
|
||||
Stops reading.
|
||||
**/
|
||||
extern static public function readStop(stream:Stream):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Writes the given buffer to the stream.
|
||||
|
||||
The second argument passed to the `callback` is the number of bytes written.
|
||||
libuv has an internal queue of writes, in part to implement retry. This means
|
||||
that writes can be partial at the libuv API level, so it is possible to receive
|
||||
both an `UVError` result, and for some data to have been successfully written.
|
||||
**/
|
||||
extern static public function write(stream:Stream, data:Array<Buffer>, callback:(result:Result<Result.NoData>, bytesWritten:Int)->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Like `eval.luv.Stream.write`, but allows sending a TCP socket or pipe over the
|
||||
stream.
|
||||
**/
|
||||
extern static public function write2(stream:TStream<Pipe>, data:Array<Buffer>, sendHandle:SendHandle, callback:(result:Result<Result.NoData>, bytesWritten:Int)->Void):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Same as `eval.luv.Stream.write()`, but won’t queue a write request if it can’t
|
||||
be completed immediately.
|
||||
|
||||
Returns the number of bytes written.
|
||||
**/
|
||||
extern static public function tryWrite(stream:Stream, data:Array<Buffer>):Result<Int>;
|
||||
|
||||
/**
|
||||
Indicates whether the stream is readable (has data).
|
||||
**/
|
||||
extern static public function isReadable(stream:Stream):Bool;
|
||||
|
||||
/**
|
||||
Indicates whether the stream is writable (has space in buffers).
|
||||
**/
|
||||
extern static public function isWritable(stream:Stream):Bool;
|
||||
|
||||
/**
|
||||
Sets the blocking mode of the stream.
|
||||
**/
|
||||
extern static public function setBlocking(stream:Stream, block:Bool):Result<Result.NoData>;
|
||||
}
|
39
Kha/Tools/linux_x64/std/eval/luv/SystemInfo.hx
Normal file
39
Kha/Tools/linux_x64/std/eval/luv/SystemInfo.hx
Normal file
@ -0,0 +1,39 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.UInt64;
|
||||
|
||||
typedef CpuInfo = {
|
||||
var model:String;
|
||||
var speed:Int;
|
||||
var times:{
|
||||
var user:UInt64;
|
||||
var nice:UInt64;
|
||||
var sys:UInt64;
|
||||
var idle:UInt64;
|
||||
var irq:UInt64;
|
||||
};
|
||||
}
|
||||
|
||||
typedef Uname = {
|
||||
var sysname:String;
|
||||
var release:String;
|
||||
var version:String;
|
||||
var machine:String;
|
||||
}
|
||||
|
||||
/**
|
||||
System information.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/System_info
|
||||
**/
|
||||
extern class SystemInfo {
|
||||
/**
|
||||
Gets information about the CPUs on the system.
|
||||
**/
|
||||
static function cpuInfo():Result<Array<CpuInfo>>;
|
||||
|
||||
/**
|
||||
Gets information about the CPUs on the system.
|
||||
**/
|
||||
static function uname():Result<Uname>;
|
||||
}
|
62
Kha/Tools/linux_x64/std/eval/luv/Tcp.hx
Normal file
62
Kha/Tools/linux_x64/std/eval/luv/Tcp.hx
Normal file
@ -0,0 +1,62 @@
|
||||
package eval.luv;
|
||||
|
||||
import haxe.ds.Option;
|
||||
import eval.luv.SockAddr;
|
||||
|
||||
/**
|
||||
TCP sockets.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/TCP
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:using(eval.luv.Stream)
|
||||
@:coreType abstract Tcp to Handle to Stream to Stream.TStream<Tcp> to Handle.SocketHandle {
|
||||
/**
|
||||
Allocates and initializes a TCP stream.
|
||||
|
||||
The stream is not yet connected or listening.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop, ?domain:AddressFamily):Result<Tcp>;
|
||||
|
||||
/**
|
||||
Sets TCP_NODELAY.
|
||||
**/
|
||||
public function noDelay(enable:Bool):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets the TCP keepalive.
|
||||
**/
|
||||
public function keepAlive(value:Option<Int>):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets simultaneous accept.
|
||||
**/
|
||||
public function simultaneousAccepts(value:Bool):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Assigns an address to the TCP socket.
|
||||
**/
|
||||
public function bind(addr:SockAddr, ipv6Only:Bool = false):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Retrieves the address assigned to the TCP socket.
|
||||
**/
|
||||
public function getSockName():Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Retrieves the address of the TCP socket's peer.
|
||||
**/
|
||||
public function getPeerName():Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Connects to a host.
|
||||
**/
|
||||
public function connect(addr:SockAddr, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Resets the connection.
|
||||
**/
|
||||
public function closeReset(callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
}
|
34
Kha/Tools/linux_x64/std/eval/luv/Thread.hx
Normal file
34
Kha/Tools/linux_x64/std/eval/luv/Thread.hx
Normal file
@ -0,0 +1,34 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Threads.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Thread
|
||||
|
||||
`eval.luv` integrates libuv with the OCaml runtime lock. This means that, as
|
||||
in any other OCaml program, two threads cannot be running OCaml code at the
|
||||
same time. Thus, two threads cannot be running Haxe code at the same time
|
||||
because eval interpreter is written in OCaml.
|
||||
However, `eval.luv` releases the lock when calling a potentially-blocking libuv API,
|
||||
so that other threads can run while the calling thread is blocked. In particular,
|
||||
the lock is released during calls to `eval.luv.Loop.run`, which means that other
|
||||
threads can run in between when you make a call to a non-blocking API, and when
|
||||
its callback is called by libuv.
|
||||
**/
|
||||
@:coreType abstract Thread {
|
||||
/**
|
||||
Returns the representation of the calling thread.
|
||||
**/
|
||||
static public function self():Thread;
|
||||
|
||||
/**
|
||||
Starts a new thread, which will run the given function.
|
||||
**/
|
||||
static public function create(fn:()->Void, ?stackSize:Int):Result<Thread>;
|
||||
|
||||
/**
|
||||
Waits for the thread to terminate.
|
||||
**/
|
||||
public function join():Result<Result.NoData>;
|
||||
|
||||
}
|
31
Kha/Tools/linux_x64/std/eval/luv/ThreadPool.hx
Normal file
31
Kha/Tools/linux_x64/std/eval/luv/ThreadPool.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package eval.luv;
|
||||
|
||||
@:forward
|
||||
abstract ThreadPoolRequest(Request) to Request {}
|
||||
|
||||
/**
|
||||
Thread pool.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Thread_pool
|
||||
**/
|
||||
extern class ThreadPool {
|
||||
|
||||
static function createRequest():ThreadPoolRequest;
|
||||
|
||||
/**
|
||||
Schedules a function to be called by a thread in the thread pool.
|
||||
|
||||
`work` is the function that will be called in the thread pool.
|
||||
`callback` will be called by the `loop` after `work` completes, or
|
||||
immediately, in case there is an error scheduling `work`.
|
||||
**/
|
||||
static function queueWork(loop:Loop, ?request:ThreadPoolRequest, work:()->Void, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Sets thread pool size.
|
||||
|
||||
This function should be called as soon during process startup as possible.
|
||||
**/
|
||||
static function setSize(size:Int, ?ifNotAlreadySet:Bool):Void;
|
||||
|
||||
}
|
27
Kha/Tools/linux_x64/std/eval/luv/Time.hx
Normal file
27
Kha/Tools/linux_x64/std/eval/luv/Time.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package eval.luv;
|
||||
|
||||
import eval.integers.Int64;
|
||||
import eval.integers.UInt64;
|
||||
|
||||
/**
|
||||
Current time.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Time
|
||||
**/
|
||||
extern class Time {
|
||||
/**
|
||||
Get time.
|
||||
**/
|
||||
static function getTimeOfDay():Result<{sec:Int64, usec:Int}>;
|
||||
|
||||
/**
|
||||
Samples the high-resolution timer.
|
||||
**/
|
||||
static function hrTime():UInt64;
|
||||
|
||||
/**
|
||||
Suspends the calling thread for at least the given number of milliseconds.
|
||||
**/
|
||||
static function sleep(duration:Int):Void;
|
||||
|
||||
}
|
40
Kha/Tools/linux_x64/std/eval/luv/Timer.hx
Normal file
40
Kha/Tools/linux_x64/std/eval/luv/Timer.hx
Normal file
@ -0,0 +1,40 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Timers.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Timer
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Timer to Handle {
|
||||
/** The timer repeat interval. */
|
||||
public var repeat(get,set):Int;
|
||||
function get_repeat():Int;
|
||||
function set_repeat(v:Int):Int;
|
||||
|
||||
/** Evaluates to the time until the timer expires, or zero if it has already expired. */
|
||||
public var dueIn(get,never):Int;
|
||||
function get_dueIn():Int;
|
||||
|
||||
/**
|
||||
Allocate and initialize an idle handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop):Result<Timer>;
|
||||
|
||||
/**
|
||||
Starts a timer.
|
||||
**/
|
||||
public function start(callback:()->Void, timeoutMs:Int, ?repeatMs:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Stops a timer.
|
||||
**/
|
||||
public function stop():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Restarts a timer.
|
||||
**/
|
||||
public function again():Result<Result.NoData>;
|
||||
}
|
63
Kha/Tools/linux_x64/std/eval/luv/Tty.hx
Normal file
63
Kha/Tools/linux_x64/std/eval/luv/Tty.hx
Normal file
@ -0,0 +1,63 @@
|
||||
package eval.luv;
|
||||
|
||||
enum abstract TtyMode(Int) {
|
||||
var NORMAL = 0;
|
||||
var RAW = 1;
|
||||
var IO = 2;
|
||||
}
|
||||
|
||||
enum abstract VTermState(Int) {
|
||||
var SUPPORTED = 0;
|
||||
var UNSUPPORTED = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Consoles.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Tty
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:using(eval.luv.Stream)
|
||||
@:coreType abstract Tty to Handle to Stream to Stream.TStream<Tty> {
|
||||
/**
|
||||
To be called when the program exits.
|
||||
Resets TTY settings to default values for the next process to take over.
|
||||
**/
|
||||
static public function resetMode():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Controls whether console virtual terminal sequences are processed by libuv
|
||||
or console. Useful in particular for enabling ConEmu support of ANSI X3.64
|
||||
and Xterm 256 colors. Otherwise Windows10 consoles are usually detected
|
||||
automatically.
|
||||
|
||||
This function is only meaningful on Windows systems. On Unix it is silently
|
||||
ignored.
|
||||
**/
|
||||
static public function setVTermState(state:VTermState):Void;
|
||||
|
||||
/**
|
||||
Get the current state of whether console virtual terminal sequences are
|
||||
handled by libuv or the console.
|
||||
|
||||
This function is not implemented on Unix, where it returns `UVError.UV_ENOTSUP`.
|
||||
**/
|
||||
static public function getVTermState():Result<VTermState>;
|
||||
|
||||
/**
|
||||
Allocates and initializes a TTY handle.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop, file:File):Result<Tty>;
|
||||
|
||||
/**
|
||||
Sets the TTY's mode.
|
||||
**/
|
||||
public function setMode(mode:TtyMode):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Retrieves the current window size.
|
||||
**/
|
||||
public function getWinSize():Result<{width:Int, height:Int}>;
|
||||
}
|
187
Kha/Tools/linux_x64/std/eval/luv/UVError.hx
Normal file
187
Kha/Tools/linux_x64/std/eval/luv/UVError.hx
Normal file
@ -0,0 +1,187 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Error handling.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Error
|
||||
**/
|
||||
enum abstract UVError(Int) {
|
||||
/** argument list too long */
|
||||
var UV_E2BIG = 0;
|
||||
/** permission denied */
|
||||
var UV_EACCES = 1;
|
||||
/** address already in use */
|
||||
var UV_EADDRINUSE = 2;
|
||||
/** address not available */
|
||||
var UV_EADDRNOTAVAIL = 3;
|
||||
/** address family not supported */
|
||||
var UV_EAFNOSUPPORT = 4;
|
||||
/** resource temporarily unavailable */
|
||||
var UV_EAGAIN = 5;
|
||||
/** address family not supported */
|
||||
var UV_EAI_ADDRFAMILY = 6;
|
||||
/** temporary failure */
|
||||
var UV_EAI_AGAIN = 7;
|
||||
/** bad ai_flags value */
|
||||
var UV_EAI_BADFLAGS = 8;
|
||||
/** invalid value for hints */
|
||||
var UV_EAI_BADHINTS = 9;
|
||||
/** request canceled */
|
||||
var UV_EAI_CANCELED = 10;
|
||||
/** permanent failure */
|
||||
var UV_EAI_FAIL = 11;
|
||||
/** ai_family not supported */
|
||||
var UV_EAI_FAMILY = 12;
|
||||
/** out of memory */
|
||||
var UV_EAI_MEMORY = 13;
|
||||
/** no address */
|
||||
var UV_EAI_NODATA = 14;
|
||||
/** unknown node or service */
|
||||
var UV_EAI_NONAME = 15;
|
||||
/** argument buffer overflow */
|
||||
var UV_EAI_OVERFLOW = 16;
|
||||
/** resolved protocol is unknown */
|
||||
var UV_EAI_PROTOCOL = 17;
|
||||
/** service not available for socket type */
|
||||
var UV_EAI_SERVICE = 18;
|
||||
/** socket type not supported */
|
||||
var UV_EAI_SOCKTYPE = 19;
|
||||
/** connection already in progress */
|
||||
var UV_EALREADY = 20;
|
||||
/** bad file descriptor */
|
||||
var UV_EBADF = 21;
|
||||
/** resource busy or locked */
|
||||
var UV_EBUSY = 22;
|
||||
/** operation canceled */
|
||||
var UV_ECANCELED = 23;
|
||||
/** invalid Unicode character */
|
||||
// var UV_ECHARSET = 24; // not defined in Luv ocaml library
|
||||
/** software caused connection abort */
|
||||
var UV_ECONNABORTED = 25;
|
||||
/** connection refused */
|
||||
var UV_ECONNREFUSED = 26;
|
||||
/** connection reset by peer */
|
||||
var UV_ECONNRESET = 27;
|
||||
/** destination address required */
|
||||
var UV_EDESTADDRREQ = 28;
|
||||
/** file already exists */
|
||||
var UV_EEXIST = 29;
|
||||
/** bad address in system call argument */
|
||||
var UV_EFAULT = 30;
|
||||
/** file too large */
|
||||
var UV_EFBIG = 31;
|
||||
/** host is unreachable */
|
||||
var UV_EHOSTUNREACH = 32;
|
||||
/** interrupted system call */
|
||||
var UV_EINTR = 33;
|
||||
/** invalid argument */
|
||||
var UV_EINVAL = 34;
|
||||
/** i/o error */
|
||||
var UV_EIO = 35;
|
||||
/** socket is already connected */
|
||||
var UV_EISCONN = 36;
|
||||
/** illegal operation on a directory */
|
||||
var UV_EISDIR = 37;
|
||||
/** too many symbolic links encountered */
|
||||
var UV_ELOOP = 38;
|
||||
/** too many open files */
|
||||
var UV_EMFILE = 39;
|
||||
/** message too long */
|
||||
var UV_EMSGSIZE = 40;
|
||||
/** name too long */
|
||||
var UV_ENAMETOOLONG = 41;
|
||||
/** network is down */
|
||||
var UV_ENETDOWN = 42;
|
||||
/** network is unreachable */
|
||||
var UV_ENETUNREACH = 43;
|
||||
/** file table overflow */
|
||||
var UV_ENFILE = 44;
|
||||
/** no buffer space available */
|
||||
var UV_ENOBUFS = 45;
|
||||
/** no such device */
|
||||
var UV_ENODEV = 46;
|
||||
/** no such file or directory */
|
||||
var UV_ENOENT = 47;
|
||||
/** not enough memory */
|
||||
var UV_ENOMEM = 48;
|
||||
/** machine is not on the network */
|
||||
var UV_ENONET = 49;
|
||||
/** protocol not available */
|
||||
var UV_ENOPROTOOPT = 50;
|
||||
/** no space left on device */
|
||||
var UV_ENOSPC = 51;
|
||||
/** function not implemented */
|
||||
var UV_ENOSYS = 52;
|
||||
/** socket is not connected */
|
||||
var UV_ENOTCONN = 53;
|
||||
/** not a directory */
|
||||
var UV_ENOTDIR = 54;
|
||||
/** directory not empty */
|
||||
var UV_ENOTEMPTY = 55;
|
||||
/** socket operation on non-socket */
|
||||
var UV_ENOTSOCK = 56;
|
||||
/** operation not supported on socket */
|
||||
var UV_ENOTSUP = 57;
|
||||
/** operation not permitted */
|
||||
var UV_EPERM = 58;
|
||||
/** broken pipe */
|
||||
var UV_EPIPE = 59;
|
||||
/** protocol error */
|
||||
var UV_EPROTO = 60;
|
||||
/** protocol not supported */
|
||||
var UV_EPROTONOSUPPORT = 61;
|
||||
/** protocol wrong type for socket */
|
||||
var UV_EPROTOTYPE = 62;
|
||||
/** result too large */
|
||||
var UV_ERANGE = 63;
|
||||
/** read-only file system */
|
||||
var UV_EROFS = 64;
|
||||
/** cannot send after transport endpoint shutdown */
|
||||
var UV_ESHUTDOWN = 65;
|
||||
/** invalid seek */
|
||||
var UV_ESPIPE = 66;
|
||||
/** no such process */
|
||||
var UV_ESRCH = 67;
|
||||
/** connection timed out */
|
||||
var UV_ETIMEDOUT = 68;
|
||||
/** text file is busy */
|
||||
var UV_ETXTBSY = 69;
|
||||
/** cross-device link not permitted */
|
||||
var UV_EXDEV = 70;
|
||||
/** unknown error */
|
||||
var UV_UNKNOWN = 71;
|
||||
/** end of file */
|
||||
var UV_EOF = 72;
|
||||
/** no such device or address */
|
||||
var UV_ENXIO = 73;
|
||||
/** too many links */
|
||||
var UV_EMLINK = 74;
|
||||
/** inappropriate ioctl for device */
|
||||
var UV_ENOTTY = 75;
|
||||
/** inappropriate file type or format */
|
||||
var UV_EFTYPE = 76;
|
||||
/** illegal byte sequence */
|
||||
var UV_EILSEQ = 77;
|
||||
|
||||
/**
|
||||
Converts a system error code to a libuv error.
|
||||
**/
|
||||
extern static public function translateSysError(code:Int):UVError;
|
||||
|
||||
/**
|
||||
Setup a callback for unhandled exceptions.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Error#val-set_on_unhandled_exception
|
||||
**/
|
||||
extern static public function setOnUnhandledException(callback:(e:haxe.Exception)->Void):Void;
|
||||
|
||||
/**
|
||||
Returns the name of the given error.
|
||||
**/
|
||||
extern public function errName():String;
|
||||
|
||||
/**
|
||||
Returns the error message corresponding to the given error.
|
||||
**/
|
||||
extern public function toString():String;
|
||||
}
|
121
Kha/Tools/linux_x64/std/eval/luv/Udp.hx
Normal file
121
Kha/Tools/linux_x64/std/eval/luv/Udp.hx
Normal file
@ -0,0 +1,121 @@
|
||||
package eval.luv;
|
||||
|
||||
import haxe.ds.Option;
|
||||
import eval.luv.SockAddr;
|
||||
|
||||
enum abstract UdpMembership(Int) {
|
||||
var LEAVE_GROUP = 0;
|
||||
var JOIN_GROUP = 1;
|
||||
}
|
||||
|
||||
enum abstract RecvFlag(Int) {
|
||||
var PARTIAL = 0;
|
||||
var MMSG_CHUNK = 1;
|
||||
var MMSG_FREE = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
UDP sockets.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/UDP
|
||||
**/
|
||||
@:using(eval.luv.Handle)
|
||||
@:coreType abstract Udp to Handle to Handle.SocketHandle {
|
||||
/**
|
||||
Allocates and initializes a UDP socket.
|
||||
|
||||
The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
|
||||
**/
|
||||
static public function init(loop:Loop, ?domain:AddressFamily, recvmmsg:Bool = false):Result<Udp>;
|
||||
|
||||
/**
|
||||
Assigns an address to the UDP socket.
|
||||
**/
|
||||
public function bind(addr:SockAddr, ipv6Only:Bool = false, reuseAddr:Bool = false):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Assigns a peer address to the socket.
|
||||
**/
|
||||
public function connect(addr:SockAddr):Result<ConnectedUdp>;
|
||||
|
||||
/**
|
||||
Retrieves the address assigned to the UDP socket.
|
||||
**/
|
||||
public function getSockName():Result<SockAddr>;
|
||||
|
||||
/**
|
||||
Sets multicast group membership.
|
||||
**/
|
||||
public function setMembership(group:String, interfaceName:String, membership:UdpMembership):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets source-specific multicast group membership.
|
||||
**/
|
||||
public function setSourceMembership(group:String, interfaceName:String, source:String, membership:UdpMembership):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Set multicast loopback.
|
||||
**/
|
||||
public function setMulticastLoop(value:Bool):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Set multicast TTL.
|
||||
**/
|
||||
public function setMulticastTtl(value:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets the interface to be used for multicast.
|
||||
**/
|
||||
public function setMulticastInterface(value:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets broadcast.
|
||||
**/
|
||||
public function setBroadcast(value:Bool):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sets the TTL.
|
||||
**/
|
||||
public function setTtl(value:Int):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Sends a datagram.
|
||||
|
||||
For connected UDP sockets, see `eval.luv.UDP.Connected.send`.
|
||||
**/
|
||||
public function send(data:Array<Buffer>, addr:SockAddr, callback:(result:Result<Result.NoData>)->Void):Void;
|
||||
|
||||
/**
|
||||
Like `eval.luv.UDP.send`, but only attempts to send the datagram immediately.
|
||||
**/
|
||||
public function trySend(data:Array<Buffer>, addr:SockAddr):Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Calls `callback` whenever a datagram is received on the UDP socket.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/UDP/index.html#val-recv_start
|
||||
**/
|
||||
public function recvStart(callback:(result:Result<{data:Buffer, addr:Option<SockAddr>, flags:Array<RecvFlag>}>, ?allocate:(size:Int)->Buffer)->Void):Void;
|
||||
|
||||
/**
|
||||
Stops the callback provided to `eval.luv.UDP.recvStart`.
|
||||
**/
|
||||
public function recvStop():Result<Result.NoData>;
|
||||
|
||||
/**
|
||||
Evaluates to true if and only if the UDP was created with `recvmmsg = true`
|
||||
and the platform supports recvmmsg(2).
|
||||
**/
|
||||
public function usingRecvmmsg():Bool;
|
||||
|
||||
/**
|
||||
Number of bytes queued for sending. This field strictly shows how much
|
||||
information is currently queued.
|
||||
**/
|
||||
public function getSendQueueSize():Int;
|
||||
|
||||
/**
|
||||
Number of send requests currently in the queue awaiting to be processed.
|
||||
**/
|
||||
public function getSendQueueCount():Int;
|
||||
}
|
44
Kha/Tools/linux_x64/std/eval/luv/Version.hx
Normal file
44
Kha/Tools/linux_x64/std/eval/luv/Version.hx
Normal file
@ -0,0 +1,44 @@
|
||||
package eval.luv;
|
||||
|
||||
/**
|
||||
Version information for the vendored libuv.
|
||||
|
||||
@see https://aantron.github.io/luv/luv/Luv/Version
|
||||
**/
|
||||
extern class Version {
|
||||
/**
|
||||
Returns the libuv version as a string.
|
||||
**/
|
||||
static function string():String;
|
||||
|
||||
/**
|
||||
libuv major version number.
|
||||
**/
|
||||
static final major:Int;
|
||||
|
||||
/**
|
||||
libuv minor version number.
|
||||
**/
|
||||
static final minor:Int;
|
||||
|
||||
/**
|
||||
libuv patch version number.
|
||||
**/
|
||||
static final patch:Int;
|
||||
|
||||
/**
|
||||
`true` if the libuv version is a release, and `false` if it is a development version.
|
||||
This does not depend on Haxe compilation arguments and will almost always be `true`.
|
||||
**/
|
||||
static final isRelease:Bool;
|
||||
|
||||
/**
|
||||
libuv version suffix for development releases.
|
||||
**/
|
||||
static final suffix:String;
|
||||
|
||||
/**
|
||||
libuv version packed into a single integer.
|
||||
**/
|
||||
static final hex:Int;
|
||||
}
|
64
Kha/Tools/linux_x64/std/eval/vm/Context.hx
Normal file
64
Kha/Tools/linux_x64/std/eval/vm/Context.hx
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 eval.vm;
|
||||
|
||||
extern class Context {
|
||||
static function addBreakpoint(file:String, line:Int):Void;
|
||||
static function breakHere():Void;
|
||||
static function callMacroApi(s:String):Dynamic;
|
||||
|
||||
/**
|
||||
Loads and returns a plugin from file `filePath`.
|
||||
|
||||
If Haxe is built natively, the extension automatically defaults to `.cmxs`,
|
||||
even if a different extension is provided in `filePath`. In bytecode mode,
|
||||
the default extension is `.cmo`.
|
||||
|
||||
Sample plugin:
|
||||
|
||||
```ocaml
|
||||
open EvalValue
|
||||
open EvalContext
|
||||
open EvalEncode
|
||||
|
||||
let add_int = vfun2 (fun v1 v2 -> match v1,v2 with
|
||||
| VInt32 i1,VInt32 i2 -> vint32 (Int32.add i1 i2)
|
||||
| _ -> exc_string "Expected int + int"
|
||||
)
|
||||
;;
|
||||
EvalStdLib.StdContext.register ["add_int",add_int]
|
||||
```
|
||||
|
||||
Usage from Haxe:
|
||||
|
||||
```haxe
|
||||
var module:TestPlugin = eval.vm.Context.loadPlugin("testPlugin.cmo");
|
||||
trace(module.add_int(4, 3));
|
||||
```
|
||||
|
||||
Plugins have to be compiled with the same OCaml version as the Haxe compiler
|
||||
and using the same Haxe version. If a plugin cannot be loaded, an exception
|
||||
of type `String` is thrown.
|
||||
**/
|
||||
static function loadPlugin<T>(filePath:String):T;
|
||||
}
|
233
Kha/Tools/linux_x64/std/eval/vm/Gc.hx
Normal file
233
Kha/Tools/linux_x64/std/eval/vm/Gc.hx
Normal file
@ -0,0 +1,233 @@
|
||||
/*
|
||||
* 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 eval.vm;
|
||||
|
||||
/**
|
||||
The memory management counters are returned in a stat record.
|
||||
The total amount of memory allocated by the program since it was started is (in words) minor_words + major_words - promoted_words. Multiply by the word size (4 on a 32-bit machine, 8 on a 64-bit machine) to get the number of bytes.
|
||||
**/
|
||||
typedef Stat = {
|
||||
/**
|
||||
Number of words allocated in the minor heap since the program was started. This number is accurate in byte-code programs, but only an approximation in programs compiled to native code.
|
||||
**/
|
||||
var minor_words:Float;
|
||||
|
||||
/**
|
||||
Number of words allocated in the minor heap that survived a minor collection and were moved to the major heap since the program was started.
|
||||
**/
|
||||
var promoted_words:Float;
|
||||
|
||||
/**
|
||||
Number of words allocated in the major heap, including the promoted words, since the program was started.
|
||||
**/
|
||||
var major_words:Float;
|
||||
|
||||
/**
|
||||
Number of minor collections since the program was started.
|
||||
**/
|
||||
var minor_collections:Float;
|
||||
|
||||
/**
|
||||
Number of major collection cycles completed since the program was started.
|
||||
**/
|
||||
var major_collections:Float;
|
||||
|
||||
/**
|
||||
Total size of the major heap, in words.
|
||||
**/
|
||||
var heap_words:Int;
|
||||
|
||||
/**
|
||||
Number of contiguous pieces of memory that make up the major heap.
|
||||
**/
|
||||
var heap_chunks:Int;
|
||||
|
||||
/**
|
||||
Number of words of live data in the major heap, including the header words.
|
||||
**/
|
||||
var live_words:Int;
|
||||
|
||||
/**
|
||||
Number of live blocks in the major heap.
|
||||
**/
|
||||
var live_blocks:Int;
|
||||
|
||||
/**
|
||||
Number of words in the free list.
|
||||
**/
|
||||
var free_words:Int;
|
||||
|
||||
/**
|
||||
Number of blocks in the free list.
|
||||
**/
|
||||
var free_blocks:Int;
|
||||
|
||||
/**
|
||||
Size (in words) of the largest block in the free list.
|
||||
**/
|
||||
var largest_free:Int;
|
||||
|
||||
/**
|
||||
Number of wasted words due to fragmentation. These are 1-words free blocks placed between two live blocks. They are not available for allocation.
|
||||
**/
|
||||
var fragments:Int;
|
||||
|
||||
/**
|
||||
Number of heap compactions since the program was started.
|
||||
**/
|
||||
var compactions:Int;
|
||||
|
||||
/**
|
||||
Maximum size reached by the major heap, in words.
|
||||
**/
|
||||
var top_heap_words:Int;
|
||||
|
||||
/**
|
||||
Current size of the stack, in words.
|
||||
**/
|
||||
var stack_size:Int;
|
||||
}
|
||||
|
||||
/**
|
||||
The GC parameters are given as a control record. Note that these parameters can also be initialised by setting the OCAMLRUNPARAM environment variable. See the documentation of ocamlrun.
|
||||
**/
|
||||
typedef Control = {
|
||||
/**
|
||||
The size (in words) of the minor heap. Changing this parameter will trigger a minor collection. Default: 256k.
|
||||
**/
|
||||
var minor_heap_size:Int;
|
||||
|
||||
/**
|
||||
How much to add to the major heap when increasing it. If this number is less than or equal to 1000, it is a percentage of the current heap size (i.e. setting it to 100 will double the heap size at each increase). If it is more than 1000, it is a fixed number of words that will be added to the heap. Default: 15.
|
||||
**/
|
||||
var major_heap_increment:Int;
|
||||
|
||||
/**
|
||||
The major GC speed is computed from this parameter. This is the memory that will be "wasted" because the GC does not immediatly collect unreachable blocks. It is expressed as a percentage of the memory used for live data. The GC will work more (use more CPU time and collect blocks more eagerly) if space_overhead is smaller. Default: 80.
|
||||
**/
|
||||
var space_overhead:Int;
|
||||
|
||||
/**
|
||||
This value controls the GC messages on standard error output. It is a sum of some of the following flags, to print messages on the corresponding events:
|
||||
* 0x001 Start of major GC cycle.
|
||||
* 0x002 Minor collection and major GC slice.
|
||||
* 0x004 Growing and shrinking of the heap.
|
||||
* 0x008 Resizing of stacks and memory manager tables.
|
||||
* 0x010 Heap compaction.
|
||||
* 0x020 Change of GC parameters.
|
||||
* 0x040 Computation of major GC slice size.
|
||||
* 0x080 Calling of finalisation functions.
|
||||
* 0x100 Bytecode executable and shared library search at start-up.
|
||||
* 0x200 Computation of compaction-triggering condition.
|
||||
* 0x400 Output GC statistics at program exit. Default: 0.
|
||||
**/
|
||||
var verbose:Int;
|
||||
|
||||
/**
|
||||
Heap compaction is triggered when the estimated amount of "wasted" memory is more than max_overhead percent of the amount of live data. If max_overhead is set to 0, heap compaction is triggered at the end of each major GC cycle (this setting is intended for testing purposes only). If max_overhead >= 1000000, compaction is never triggered. If compaction is permanently disabled, it is strongly suggested to set allocation_policy to 1. Default: 500.
|
||||
**/
|
||||
var max_overhead:Int;
|
||||
|
||||
/**
|
||||
The maximum size of the stack (in words). This is only relevant to the byte-code runtime, as the native code runtime uses the operating system's stack. Default: 1024k.
|
||||
**/
|
||||
var stack_limit:Int;
|
||||
|
||||
/**
|
||||
The policy used for allocating in the heap. Possible values are 0 and 1. 0 is the next-fit policy, which is quite fast but can result in fragmentation. 1 is the first-fit policy, which can be slower in some cases but can be better for programs with fragmentation problems. Default: 0.
|
||||
**/
|
||||
var allocation_policy:Int;
|
||||
}
|
||||
|
||||
/**
|
||||
Memory management control and statistics; finalised values.
|
||||
**/
|
||||
extern class Gc {
|
||||
/**
|
||||
Return the total number of bytes allocated since the program was started. It is returned as a float to avoid overflow problems with int on 32-bit machines.
|
||||
**/
|
||||
static function allocated_bytes():Float;
|
||||
|
||||
/**
|
||||
Perform a full major collection and compact the heap. Note that heap compaction is a lengthy operation.
|
||||
**/
|
||||
static function compact():Void;
|
||||
|
||||
/**
|
||||
Return (minor_words, promoted_words, major_words). This function is as fast as quick_stat.
|
||||
**/
|
||||
static function counters():{minor_words:Float, promoted_words:Float, major_words:Float};
|
||||
|
||||
/**
|
||||
Registers f as a finalisation function for v. v must be heap-allocated. f will be called with v as argument at some point between the first time v becomes unreachable (including through weak pointers) and the time v is collected by the GC. Several functions can be registered for the same value, or even several instances of the same function. Each instance will be called once (or never, if the program terminates before v becomes unreachable).
|
||||
The GC will call the finalisation functions in the order of deallocation. When several values become unreachable at the same time (i.e. during the same GC cycle), the finalisation functions will be called in the reverse order of the corresponding calls to finalise. If finalise is called in the same order as the values are allocated, that means each value is finalised before the values it depends upon. Of course, this becomes false if additional dependencies are introduced by assignments.
|
||||
|
||||
In the presence of multiple OCaml threads it should be assumed that any particular finaliser may be executed in any of the threads.
|
||||
**/
|
||||
static function finalise<T>(f:T->Void, v:T):Void;
|
||||
|
||||
/**
|
||||
Do a minor collection, finish the current major collection cycle, and perform a complete new cycle. This will collect all currently unreachable blocks.
|
||||
**/
|
||||
static function full_major():Void;
|
||||
|
||||
/**
|
||||
Return the current values of the GC parameters in a control record.
|
||||
**/
|
||||
static function get():Control;
|
||||
|
||||
/**
|
||||
Do a minor collection and finish the current major collection cycle.
|
||||
**/
|
||||
static function major():Void;
|
||||
|
||||
/**
|
||||
Do a minor collection and a slice of major collection. n is the size of the slice: the GC will do enough work to free (on average) n words of memory. If n = 0, the GC will try to do enough work to ensure that the next automatic slice has no work to do. This function returns an unspecified integer (currently: 0).
|
||||
**/
|
||||
static function major_slice():Void;
|
||||
|
||||
/**
|
||||
Trigger a minor collection.
|
||||
**/
|
||||
static function minor():Void;
|
||||
|
||||
/**
|
||||
Print the current values of the memory management counters (in human-readable form) into the channel argument.
|
||||
**/
|
||||
static function print_stat(out_channel:haxe.io.Output):Void;
|
||||
|
||||
/**
|
||||
Same as stat except that live_words, live_blocks, free_words, free_blocks, largest_free, and fragments are set to 0. This function is much faster than stat because it does not need to go through the heap.
|
||||
**/
|
||||
static function quick_stat():Stat;
|
||||
|
||||
/**
|
||||
Changes the GC parameters according to the control record r.
|
||||
**/
|
||||
static function set(r:Control):Void;
|
||||
|
||||
/**
|
||||
Return the current values of the memory management counters in a stat record. This function examines every heap block to get the statistics.
|
||||
**/
|
||||
static function stat():Stat;
|
||||
}
|
46
Kha/Tools/linux_x64/std/eval/vm/NativeSocket.hx
Normal file
46
Kha/Tools/linux_x64/std/eval/vm/NativeSocket.hx
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 eval.vm;
|
||||
|
||||
import sys.net.Socket;
|
||||
|
||||
extern class NativeSocket {
|
||||
function new():Void;
|
||||
function accept():NativeSocket;
|
||||
function bind(host:Int, port:Int):Void;
|
||||
function close():Void;
|
||||
function connect(host:Int, port:Int):Void;
|
||||
function host():{ip:Int, port:Int};
|
||||
function listen(connections:Int):Void;
|
||||
function peer():{ip:Int, port:Int};
|
||||
function receive(buf:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
function receiveChar():Int;
|
||||
function send(buf:haxe.io.Bytes, pos:Int, len:Int):Int;
|
||||
function sendChar(char:Int):Void;
|
||||
function setFastSend(b:Bool):Void;
|
||||
function setTimeout(timeout:Float):Void;
|
||||
function shutdown(read:Bool, write:Bool):Void;
|
||||
|
||||
static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
|
||||
?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>};
|
||||
}
|
82
Kha/Tools/linux_x64/std/eval/vm/NativeThread.hx
Normal file
82
Kha/Tools/linux_x64/std/eval/vm/NativeThread.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 eval.vm;
|
||||
|
||||
extern class NativeThread {
|
||||
/**
|
||||
Creates a new thread that executes function `f`.
|
||||
|
||||
Exceptions caused while executing `f` are printed to stderr and are not
|
||||
propagated to the parent thread.
|
||||
**/
|
||||
function new(f:Void->Void):Void;
|
||||
|
||||
/**
|
||||
Return the identifier of the given thread. A thread identifier is an integer
|
||||
that identifies uniquely the thread. It can be used to build data structures
|
||||
indexed by threads.
|
||||
**/
|
||||
function id():Int;
|
||||
|
||||
/**
|
||||
Terminate prematurely the thread whose handle is given. This functionality is
|
||||
available only with bytecode-level threads.
|
||||
**/
|
||||
function kill():Int;
|
||||
|
||||
/**
|
||||
Suspends the execution of the calling thread for `f` seconds. The other program
|
||||
threads continue to run during this time.
|
||||
**/
|
||||
static function delay(f:Float):Void;
|
||||
|
||||
/**
|
||||
Terminate prematurely the currently executing thread.
|
||||
**/
|
||||
static function exit():Void;
|
||||
|
||||
/**
|
||||
Suspends the execution of the calling thread until the thread `thread` has
|
||||
terminated.
|
||||
**/
|
||||
static function join(thread:NativeThread):Void;
|
||||
|
||||
/**
|
||||
Return the thread currently executing.
|
||||
**/
|
||||
static function self():NativeThread;
|
||||
|
||||
/**
|
||||
Re-schedule the calling thread without suspending it. This function can be used
|
||||
to give scheduling hints, telling the scheduler that now is a good time to switch
|
||||
to other threads.
|
||||
**/
|
||||
static function yield():Void;
|
||||
|
||||
static function readMessage<T>(block:Bool):T;
|
||||
|
||||
function sendMessage<T>(msg:T):Void;
|
||||
|
||||
@:allow(sys.thread.Thread)
|
||||
private var events(get,set):Null<sys.thread.EventLoop>;
|
||||
}
|
Reference in New Issue
Block a user