Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View 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 cpp;
extern class ArrayBase {
// Length is number of elements
var length(default, null):Int;
function getElementSize():Int;
function getByteCount():Int;
function getBase():RawPointer<Char>;
}

View File

@ -0,0 +1,44 @@
/*
* 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 cpp;
@:scalar @:coreType
extern abstract AtomicInt from(Int) to(Int) {
/**
Returns true if exchange took place.
**/
@:native("_hx_atomic_exchange_if")
public static function exchangeIf(ioValue:Pointer<AtomicInt>, test:Int, newVal:Int):Bool;
/**
Returns value before increment.
**/
@:native("_hx_atomic_inc")
public static function atomicInc(ioValue:Pointer<AtomicInt>):Int;
/**
Returns value before decrement.
**/
@:native("_hx_atomic_dec")
public static function atomicDec(ioValue:Pointer<AtomicInt>):Int;
}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
extern class AutoCast {}

View File

@ -0,0 +1,72 @@
/*
* 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 cpp;
@:noPackageRestrict @:callable
typedef CallableData<T> = T;
/**
The generator intercepts this type and converts it to a cpp.Function<T> on cpp.
**/
@:noPackageRestrict
@:callable
#if cpp
extern
#end
abstract Callable<T>(CallableData<T>) {
inline public function new(inValue:T)
this = inValue;
public var call(get, never):CallableData<T>;
inline function get_call():CallableData<T>
return this;
#if cpp
@:from
inline static public function fromFunction<F>(func:Function<F, cpp.abi.Abi>):Callable<F>
return new Callable<F>(cast func);
@:to
inline public function toFunction():Function<T, cpp.abi.Abi>
return cast this;
inline public static function getProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):Function<T, ABI>
return Function.getProcAddress(inModule, inFunction);
inline public static function fromStaticFunction<T>(inStaticFunction:T):Callable<T>
return Function.fromStaticFunction(inStaticFunction);
inline public function lt(inOther:Callable<T>):Bool
return toFunction().lt(inOther.toFunction());
inline public function leq(inOther:Callable<T>):Bool
return toFunction().leq(inOther.toFunction());
inline public function gt(inOther:Callable<T>):Bool
return toFunction().gt(inOther.toFunction());
inline public function geq(inOther:Callable<T>):Bool
return toFunction().geq(inOther.toFunction());
#end
}

View File

@ -0,0 +1,36 @@
/*
* 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 cpp;
abstract CastCharStar(RawPointer<Char>) to(RawPointer<Char>) {
inline function new(s:String)
this = cast untyped s.__s;
@:from
static public inline function fromString(s:String)
return new CastCharStar(s);
@:to
public inline function toPointer()
return this;
}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Char from Int to Int {}

View File

@ -0,0 +1,38 @@
/*
* 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 cpp;
extern abstract ConstCharStar(RawConstPointer<Char>) to(RawConstPointer<Char>) {
inline function new(s:String)
this = untyped s.__s;
@:from
static public inline function fromString(s:String):ConstCharStar
return new ConstCharStar(s);
@:to extern public inline function toString():String
return new String(untyped this);
@:to extern public inline function toPointer():RawConstPointer<Char>
return this;
}

View File

@ -0,0 +1,71 @@
/*
* 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 cpp;
@:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer") @:semantics(variable)
extern class ConstPointer<T> {
// ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers
// Use value or ref to get dereferenced value
var ptr:Star<T>;
var value(get, never):T;
// Typecast to non-const
var raw(get, never):RawPointer<T>;
// const version
var constRaw(get, never):RawConstPointer<T>;
function get_value():Reference<T>;
function get_constRaw():RawConstPointer<T>;
function get_raw():RawPointer<T>;
function lt(inOther:ConstPointer<T>):Bool;
function leq(inOther:ConstPointer<T>):Bool;
function gt(inOther:ConstPointer<T>):Bool;
function geq(inOther:ConstPointer<T>):Bool;
function setRaw<O>(ptr:RawPointer<O>):Void;
static function fromRaw<T>(ptr:RawConstPointer<T>):ConstPointer<T>;
@:native("::cpp::Pointer_obj::fromRaw")
static function fromStar<T>(star:Star<T>):ConstPointer<T>;
static function fromPointer<T>(inNativePointer:Dynamic):ConstPointer<T>;
function reinterpret<Other>():Pointer<Other>;
function rawCast<Other>():RawPointer<Other>;
function at(inIndex:Int):Reference<T>;
function inc():ConstPointer<T>;
function dec():ConstPointer<T>;
function incBy(inT:Int):ConstPointer<T>;
function decBy(inT:Int):ConstPointer<T>;
function add(inT:Int):ConstPointer<T>;
function sub(inT:Int):ConstPointer<T>;
function postIncVal():Reference<T>;
}

View File

@ -0,0 +1,29 @@
/*
* 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 cpp;
/**
Allows haxe to type the result correctly, and hxcpp can recognise this uses
the correct type.
**/
typedef ConstStar<T> = Null<T>;

View File

@ -0,0 +1,60 @@
/*
* 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 cpp;
@:native("hx.EnumBase")
extern class EnumBase {
#if (hxcpp_api_level >= 330)
function _hx_getIndex():Int;
function _hx_getTag():String;
function _hx_getParamCount():Int;
function _hx_getParamI(inIndex:Int):Dynamic;
function _hx_getParameters():Array<Dynamic>;
inline function getIndex():Int
return _hx_getIndex();
inline function getTag():String
return _hx_getTag();
inline function getParamCount():Int
return _hx_getParamCount();
inline function getParamI(inIndex:Int):Dynamic
return _hx_getParamI(inIndex);
inline function getParameters():Array<Dynamic>
return _hx_getParameters();
#else
function __EnumParams():Array<Dynamic>;
function __Tag():String;
function __Index():Int;
inline function _hx_getIndex():Int
return untyped __Index();
inline function _hx_getTag():String
return untyped __Tag();
inline function _hx_getParamCount():Int
return untyped __EnumParams() == null ? 0 : __EnumParams().length;
inline function _hx_getParamI(inIndex:Int):Dynamic
return untyped __EnumParams()[inIndex];
inline function _hx_getParameters():Array<Dynamic>
return __EnumParams() == null ? [] : __EnumParams();
#end
}

View File

@ -0,0 +1,40 @@
/*
* 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 cpp;
extern class ErrorConstants {
@:native("HX_INVALID_CAST")
static var invalidCast:Dynamic;
@:native("HX_INDEX_OUT_OF_BOUNDS")
static var indexOutOfBounds:Dynamic;
@:native("HX_INVALID_OBJECT")
static var invalidObject:Dynamic;
@:native("HX_INVALID_ARG_COUNT")
static var invalidArgCount:Dynamic;
@:native("HX_NULL_FUNCTION_POINTER")
static var nullFunctionPointer:Dynamic;
}

View File

@ -0,0 +1,27 @@
/*
* 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 cpp;
@:include("stdio.h")
@:native(" ::cpp::Pointer<FILE>")
extern class FILE {}

View File

@ -0,0 +1,28 @@
/*
* 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 cpp;
extern class FastIterator<T> {
function hasNext():Bool;
function next():T;
}

View File

@ -0,0 +1,36 @@
/*
* 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 cpp;
/**
This is just a helper class. It is not actually required to inherit from this
to use `NativeGc.addFinalizable(this,inPin)`, only a function called
`finalize` is needed.
**/
class Finalizable {
public function new(inPin = false) {
NativeGc.addFinalizable(this, inPin);
}
public function finalize():Void {}
}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Float32 from Float to Float {}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Float64 from Float to Float {}

View File

@ -0,0 +1,60 @@
/*
* 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 cpp;
@:callable
typedef FunctionData<T, ABI> = T;
@:include("cpp/Pointer.h") @:callable
extern abstract Function<T, ABI:cpp.abi.Abi>(FunctionData<T, ABI>) {
inline public function new(inValue:T)
this = inValue;
// Legacy Api
public var call(get, never):FunctionData<T, ABI>;
inline function get_call():FunctionData<T, ABI>
return this;
@:native("::cpp::Function_obj::getProcAddress")
extern static function nativeGetProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):AutoCast;
inline public static function getProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):Function<T, ABI> {
return cast nativeGetProcAddress(inModule, inFunction);
}
@:native("::cpp::Function_obj::fromStaticFunction")
extern static function nativeFromStaticFunction<T>(inStaticFunction:T):AutoCast;
inline public static function fromStaticFunction<T>(inStaticFunction:T):Callable<T> {
return cast nativeFromStaticFunction(inStaticFunction);
}
extern public function lt(inOther:Function<T, ABI>):Bool;
extern public function leq(inOther:Function<T, ABI>):Bool;
extern public function gt(inOther:Function<T, ABI>):Bool;
extern public function geq(inOther:Function<T, ABI>):Bool;
}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Int16 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Int32 from Int to Int {}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Int64 from Int to Int {
@:to
#if !cppia inline #end function toInt64():haxe.Int64 {
return cast this;
}
@:from
static #if !cppia inline #end function ofInt64(x:haxe.Int64):Int64 {
return cast x;
}
}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract Int8 from Int to Int {}

View File

@ -0,0 +1,149 @@
/*
* 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 cpp;
/**
Platform-specific Cpp Library. Provides some platform-specific functions
for the C++ target, such as conversion from Haxe types to native types
and vice-versa.
**/
class Lib {
/**
Load and return a Cpp primitive from a DLL library.
**/
public static function load(lib:String, prim:String, nargs:Int):Dynamic {
#if (iphone || emscripten)
return loadLazy(lib, prim, nargs);
#else
return untyped __global__.__loadprim(lib, prim, nargs);
#end
}
/**
Unloaded all dynamic libraries in reverse order of loading.
Returns the number of libraries unloaded.
**/
public static function unloadAllLibraries():Int {
return untyped __global__.__hxcpp_unload_all_libraries();
}
public static function _loadPrime(lib:String, prim:String, signature:String, quietFail = false):Dynamic {
var factory:Callable<ConstCharStar->Object> = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail);
if (factory != null) {
var func:Dynamic = factory.call(signature);
if (func == null && !quietFail)
throw '$prim does not have signature $signature';
return func;
}
return null;
}
/**
Tries to load, and always returns a valid function, but the function may throw
if called.
**/
public static function loadLazy(lib:String, prim:String, nargs:Int):Dynamic {
try {
return untyped __global__.__loadprim(lib, prim, nargs);
} catch (e:Dynamic) {
return switch (nargs) {
case 0: () -> throw e;
case 2: (_, _) -> throw e;
case 3: (_, _, _) -> throw e;
case 4: (_, _, _, _) -> throw e;
case 5: (_, _, _, _, _) -> throw e;
default: _ -> throw e;
};
}
return null;
}
@:noDebug @:native("HX_STACK_DO_RETHROW")
extern static function do_rethrow(inExp:Dynamic);
@:noDebug #if (!cppia) inline #end
public static function rethrow(inExp:Dynamic) {
do_rethrow(inExp);
}
public static function stringReference(inBytes:haxe.io.Bytes):String {
var result:String = "";
untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, inBytes.length, true);
return result;
}
public static function pushDllSearchPath(inPath:String):Void
untyped __global__.__hxcpp_push_dll_path(inPath);
public static function getDllExtension():String
return untyped __global__.__hxcpp_get_dll_extension();
public static function getBinDirectory():String
return untyped __global__.__hxcpp_get_bin_dir();
/**
Returns bytes referencing the content of a string.
Use with extreme caution - changing constant strings will crash.
Changing one string can cause others to change unexpectedly.
Only really safe if you are using it read-only or if it comes from stringReference above
**/
public inline static function bytesReference(s:String):haxe.io.Bytes {
var bytes = new haxe.io.BytesData();
untyped bytes.__unsafeStringReference(s);
return haxe.io.Bytes.ofData(bytes);
}
/**
Print the specified value on the default output.
**/
public static function print(v:Dynamic):Void {
untyped __global__.__hxcpp_print(v);
}
/**
This function is used to make porting from neko to cpp easy.
It does not need to do anything because the c-code can work with any Dynamic
**/
public static function haxeToNeko(v:Dynamic):Dynamic {
return v;
}
/**
This function is used to make porting from neko to cpp easy.
It does not need to do anything because the c-code can work with any Dynamic
**/
public static function nekoToHaxe(v:Dynamic):Dynamic {
return v;
}
/**
Print the specified value on the default output followed by a newline character.
**/
public static function println(v:Dynamic):Void {
untyped __global__.__hxcpp_println(v);
}
public static function setFloatFormat(inFormat:String):Void {
untyped __global__.__hxcpp_set_float_format(inFormat);
}
}

View File

@ -0,0 +1,103 @@
/*
* 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 cpp;
@:include("stdlib.h")
extern class Native {
@:native("malloc")
static function nativeMalloc(bytes:Int):cpp.Star<cpp.Void>;
@:native("calloc")
static function nativeCalloc(bytes:Int):cpp.Star<cpp.Void>;
@:native("realloc")
static function nativeRealloc(inPtr:cpp.Star<cpp.Void>, bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("free")
static function nativeFree(ptr:cpp.Star<cpp.Void>):Void;
@:native("memcpy")
static function nativeMemcpy(dest:cpp.Star<cpp.Void>, src:cpp.Star<cpp.Void>, bytes:Int):Void;
@:native("::hx::ClassSizeOf") @:templatedCall
static function sizeof<T>(t:T):Int;
#if !cppia
@:native("::hx::Dereference")
static function star<T>(ptr:cpp.Star<T>):cpp.Reference<T>;
@:generic
static inline function set<T>(ptr:cpp.Star<T>, value:T):Void {
var ref:cpp.Reference<T> = star(ptr);
ref = value;
}
@:generic
static inline function get<T>(ptr:cpp.Star<T>):T {
var ref:cpp.Reference<T> = star(ptr);
return ref;
}
@:generic
static inline function memcpy<DEST, SRC>(dest:cpp.Star<DEST>, src:cpp.Star<SRC>, bytes:Int):Void
nativeMemcpy(cast dest, cast src, bytes);
@:generic
static inline function malloc<T>(bytes:Int):cpp.Star<T>
return cast nativeMalloc(bytes);
@:generic
static inline function calloc<T>(bytes:Int):cpp.Star<T>
return cast nativeCalloc(bytes);
@:generic
static inline function realloc<T>(ioPtr:cpp.Star<T>, bytes:Int):cpp.Star<T>
return cast nativeRealloc(cast ioPtr, bytes);
@:generic
static inline function free<T>(ptr:cpp.Star<T>):Void {
if (ptr != null)
nativeFree(cast ptr);
}
@:native("::hx::StarOf")
static function addressOf<T>(inVariable:Reference<T>):Star<T>;
#else
static inline function addressOf<T>(inVariable:Reference<T>):Star<T> {
throw "Native.addressOf not available in cppia";
}
static inline function star<T>(ptr:cpp.Star<T>):cpp.Reference<T> {
throw "Native.star not available in cppia";
}
static inline function set<T>(ptr:cpp.Star<T>, value:T):Void {
throw "Native.set not available in cppia";
}
static inline function get<T>(ptr:cpp.Star<T>):T {
throw "Native.get not available in cppia";
var d:Dynamic = null;
return d;
}
static function memcpy<DEST, SRC>(dest:cpp.Star<DEST>, src:cpp.Star<SRC>, bytes:Int):Void;
static function malloc<T>(bytes:Int):cpp.Star<T>;
static function calloc<T>(bytes:Int):cpp.Star<T>;
static function realloc<T>(ioPtr:cpp.Star<T>, bytes:Int):cpp.Star<T>;
static function free<T>(ptr:cpp.Star<T>):Void;
#end
}

View 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 cpp;
extern class NativeArc {
@:native("(__bridge_transfer id)")
static function _bridgeTransfer<T>(ptr:cpp.RawPointer<cpp.Void>):cpp.RawPointer<T>;
static inline function bridgeTransfer<T>(ptr:cpp.RawPointer<cpp.Void>):T
return cast _bridgeTransfer(ptr);
}

View File

@ -0,0 +1,100 @@
/*
* 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 cpp;
extern class NativeArray {
#if cppia
static inline function create<T>(length:Int):Array<T> {
var result = new Array<T>();
NativeArray.setSize(result, length);
return result;
}
#else
@:native("_hx_create_array_length")
static function create<T>(length:Int):Array<T>;
#end
static inline function blit<T>(ioDestArray:Array<T>, inDestElement:Int, inSourceArray:Array<T>, inSourceElement:Int, inElementCount:Int):Void {
untyped ioDestArray.blit(inDestElement, inSourceArray, inSourceElement, inElementCount);
};
static inline function getBase(inArray:Array<Dynamic>):ArrayBase {
return untyped inArray;
}
@:nativeStaticExtension
static function reserve<T>(inArray:Array<T>, inElements:Int):Void;
@:nativeStaticExtension
static function capacity<T>(inArray:Array<T>):Int;
@:nativeStaticExtension
static function getElementSize<T>(inArray:Array<T>):Int;
static inline function address<T>(inArray:Array<T>, inIndex:Int):Pointer<T> {
return Pointer.arrayElem(inArray, inIndex);
}
@:nativeStaticExtension
static function setData<T>(inArray:Array<T>, inData:Pointer<T>, inElementCount:Int):Void;
@:nativeStaticExtension
static function setUnmanagedData<T>(inArray:Array<T>, inData:ConstPointer<T>, inElementCount:Int):Void;
@:nativeStaticExtension
static function zero<T>(ioDestArray:Array<T>, ?inFirst:Int, ?inElements:Int):Void;
@:nativeStaticExtension
static function removeAt<T>(ioDestArray:Array<T>, inIndex:Int):Void;
@:nativeStaticExtension
static function memcmp<T>(inArrayA:Array<T>, inArrayB:Array<T>):Int;
@:native("_hx_reslove_virtual_array")
static function resolveVirtualArray(inArray:Array<Dynamic>):Dynamic;
#if cppia
static inline function unsafeGet<T>(inDestArray:Array<T>, inIndex:Int):T {
return untyped inDestArray.__unsafe_get(inIndex);
}
static inline function unsafeSet<T>(ioDestArray:Array<T>, inIndex:Int, inValue:T):T {
return untyped ioDestArray.__unsafe_set(inIndex, inValue);
}
static inline function setSize<T>(ioArray:Array<T>, inSize:Int):Array<T> {
return untyped ioArray.__SetSizeExact(inSize);
}
#else
@:native("_hx_array_unsafe_get")
static function unsafeGet<T>(inDestArray:Array<T>, inIndex:Int):T;
@:native("_hx_array_unsafe_set")
static inline function unsafeSet<T>(ioDestArray:Array<T>, inIndex:Int, inValue:T):T {
return untyped ioDestArray.__unsafe_set(inIndex, inValue);
}
@:native("_hx_array_set_size_exact")
static function setSize<T>(ioArray:Array<T>, inSize:Int):Array<T>;
#end
}

View File

@ -0,0 +1,71 @@
/*
* 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 cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeFile {
@:native("_hx_std_file_open")
extern static function file_open(fname:String, r:String):Dynamic;
@:native("_hx_std_file_close")
extern static function file_close(handle:Dynamic):Void;
@:native("_hx_std_file_write")
extern static function file_write(handle:Dynamic, s:haxe.io.BytesData, p:Int, n:Int):Int;
@:native("_hx_std_file_write_char")
extern static function file_write_char(handle:Dynamic, c:Int):Void;
@:native("_hx_std_file_read")
extern static function file_read(handle:Dynamic, s:haxe.io.BytesData, p:Int, n:Int):Int;
@:native("_hx_std_file_read_char")
extern static function file_read_char(handle:Dynamic):Int;
@:native("_hx_std_file_seek")
extern static function file_seek(handle:Dynamic, pos:Int, kind:Int):Void;
@:native("_hx_std_file_tell")
extern static function file_tell(handle:Dynamic):Int;
@:native("_hx_std_file_eof")
extern static function file_eof(handle:Dynamic):Bool;
@:native("_hx_std_file_flush")
extern static function file_flush(handle:Dynamic):Void;
@:native("_hx_std_file_contents_string")
extern static function file_contents_string(name:String):String;
@:native("_hx_std_file_contents_bytes")
extern static function file_contents_bytes(name:String):haxe.io.BytesData;
@:native("_hx_std_file_stdin")
extern static function file_stdin():Dynamic;
@:native("_hx_std_file_stdout")
extern static function file_stdout():Dynamic;
@:native("_hx_std_file_stderr")
extern static function file_stderr():Dynamic;
}

View File

@ -0,0 +1,65 @@
/*
* 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 cpp;
extern class NativeGc {
@:native("__hxcpp_gc_mem_info")
static function memInfo(inWhatInfo:Int):Float;
@:native("_hx_allocate_extended") @:templatedCall
static function allocateExtended<T>(cls:Class<T>, size:Int):T;
@:native("_hx_add_finalizable")
static function addFinalizable(instance:{function finalize():Void;}, inPin:Bool):Void;
@:native("::hx::InternalNew")
static function allocGcBytesRaw(inBytes:Int, isContainer:Bool):RawPointer<cpp.Void>;
inline static function allocGcBytes(inBytes:Int):Pointer<cpp.Void> {
return Pointer.fromRaw(allocGcBytesRaw(inBytes, false));
}
@:native("__hxcpp_enable") extern static function enable(inEnable:Bool):Void;
@:native("__hxcpp_collect") extern static function run(major:Bool):Void;
@:native("__hxcpp_gc_compact") extern static function compact():Void;
@:native("__hxcpp_gc_trace") extern static function nativeTrace(sought:Class<Dynamic>, printInstances:Bool):Int;
@:native("__hxcpp_gc_do_not_kill") extern static function doNotKill(inObject:Dynamic):Void;
@:native("__hxcpp_get_next_zombie") extern static function getNextZombie():Dynamic;
@:native("__hxcpp_gc_safe_point") extern static function safePoint():Void;
@:native("__hxcpp_enter_gc_free_zone") extern static function enterGCFreeZone():Void;
@:native("__hxcpp_exit_gc_free_zone") extern static function exitGCFreeZone():Void;
@:native("__hxcpp_set_minimum_free_space") extern static function setMinimumFreeSpace(inBytes:Int):Void;
@:native("__hxcpp_set_target_free_space_percentage") extern static function setTargetFreeSpacePercentage(inPercentage:Int):Void;
@:native("__hxcpp_set_minimum_working_memory") extern static function setMinimumWorkingMemory(inBytes:Int):Void;
}

View File

@ -0,0 +1,49 @@
/*
* 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 cpp;
@:noPackageRestrict
extern class NativeMath {
#if (cpp && !cppia)
@:native("_hx_idiv")
static function idiv(num:Int, denom:Int):Int;
@:native("_hx_imod")
static function imod(num:Int, denom:Int):Int;
@:native("_hx_cast_int")
static function castInt(f:Float):Int;
@:native("_hx_fast_floor")
static function fastInt(f:Float):Int;
#else
static inline function imod(num:Int, denom:Int):Int
return num % denom;
static inline function idiv(num:Int, denom:Int):Int
return Std.int(num / denom);
static inline function castInt(f:Float):Int
return Std.int(f);
static inline function fastInt(f:Float):Int
return Std.int(f);
#end
}

View File

@ -0,0 +1,56 @@
/*
* 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 cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeProcess {
@:native("_hx_std_process_run")
static function process_run(cmd:String, vargs:Array<String>):Dynamic;
@:native("_hx_std_process_run")
static function process_run_with_show(cmd:String, vargs:Array<String>, inShow:Int):Dynamic;
@:native("_hx_std_process_stdout_read")
static function process_stdout_read(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stderr_read")
static function process_stderr_read(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stdin_write")
static function process_stdin_write(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stdin_close")
static function process_stdin_close(handle:Dynamic):Void;
@:native("_hx_std_process_exit")
static function process_exit(handle:Dynamic):Int;
@:native("_hx_std_process_pid")
static function process_pid(handle:Dynamic):Int;
@:native("_hx_std_process_kill")
static function process_kill(handle:Dynamic):Void;
@:native("_hx_std_process_close")
static function process_close(handle:Dynamic):Void;
}

View File

@ -0,0 +1,38 @@
/*
* 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 cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeRandom {
@:native("_hx_std_random_new")
static function random_new():Dynamic;
@:native("_hx_std_random_set_seed")
static function random_set_seed(handle:Dynamic, v:Int):Void;
@:native("_hx_std_random_int")
static function random_int(handle:Dynamic, max:Int):Int;
@:native("_hx_std_random_float")
static function random_float(handle:Dynamic):Float;
}

View File

@ -0,0 +1,145 @@
/*
* 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 cpp;
import sys.net.Socket;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeSocket {
@:native("_hx_std_socket_init")
static function socket_init():Void;
@:native("_hx_std_socket_new")
static function socket_new(udp:Bool):Dynamic;
@:native("_hx_std_socket_new")
static function socket_new_ip(udp:Bool, ipv6:Bool):Dynamic;
@:native("_hx_std_socket_close")
static function socket_close(handle:Dynamic):Void;
@:native("_hx_std_socket_bind")
static function socket_bind(o:Dynamic, host:Int, port:Int):Void;
@:native("_hx_std_socket_bind_ipv6")
static function socket_bind_ipv6(o:Dynamic, host:haxe.io.BytesData, port:Int):Void;
@:native("_hx_std_socket_send_char")
static function socket_send_char(o:Dynamic, c:Int):Void;
@:native("_hx_std_socket_send")
static function socket_send(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_std_socket_recv")
static function socket_recv(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_std_socket_recv_char")
static function socket_recv_char(o:Dynamic):Int;
@:native("_hx_std_socket_write")
static function socket_write(o:Dynamic, buf:haxe.io.BytesData):Void;
@:native("_hx_std_socket_read")
static function socket_read(o:Dynamic):haxe.io.BytesData;
@:native("_hx_std_host_resolve_ipv6")
static function host_resolve_ipv6(host:String):haxe.io.BytesData;
@:native("_hx_std_host_resolve")
static function host_resolve(host:String):Int;
@:native("_hx_std_host_to_string")
static function host_to_string(ip:Int):String;
@:native("_hx_std_host_to_string_ipv6")
static function host_to_string_ipv6(ipv6:haxe.io.BytesData):String;
@:native("_hx_std_host_reverse")
static function host_reverse(host:Int):String;
@:native("_hx_std_host_reverse_ipv6")
static function host_reverse_ipv6(ipv6:haxe.io.BytesData):String;
@:native("_hx_std_host_local")
static function host_local():String;
inline static function host_local_ipv6():String
return "::1";
@:native("_hx_std_socket_connect")
static function socket_connect(o:Dynamic, host:Int, port:Int):Void;
@:native("_hx_std_socket_connect_ipv6")
static function socket_connect_ipv6(o:Dynamic, host:haxe.io.BytesData, port:Int):Void;
@:native("_hx_std_socket_listen")
static function socket_listen(o:Dynamic, n:Int):Void;
@:native("_hx_std_socket_select")
static function socket_select(rs:Array<Dynamic>, ws:Array<Dynamic>, es:Array<Dynamic>, timeout:Dynamic):Array<Dynamic>;
@:native("_hx_std_socket_fast_select")
static function socket_fast_select(rs:Array<Dynamic>, ws:Array<Dynamic>, es:Array<Dynamic>, timeout:Dynamic):Void;
@:native("_hx_std_socket_accept")
static function socket_accept(o:Dynamic):Dynamic;
@:native("_hx_std_socket_peer")
static function socket_peer(o:Dynamic):Array<Int>;
@:native("_hx_std_socket_host")
static function socket_host(o:Dynamic):Array<Int>;
@:native("_hx_std_socket_set_timeout")
static function socket_set_timeout(o:Dynamic, t:Dynamic):Void;
@:native("_hx_std_socket_shutdown")
static function socket_shutdown(o:Dynamic, r:Bool, w:Bool):Void;
@:native("_hx_std_socket_set_blocking")
static function socket_set_blocking(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_set_fast_send")
static function socket_set_fast_send(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_set_broadcast")
static function socket_set_broadcast(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_poll_alloc")
static function socket_poll_alloc(nsocks:Int):Dynamic;
@:native("_hx_std_socket_poll_prepare")
static function socket_poll_prepare(pdata:Dynamic, rsocks:Array<Socket>, wsocks:Array<Socket>):Array<Array<Int>>;
@:native("_hx_std_socket_poll_events")
static function socket_poll_events(pdata:Dynamic, timeout:Float):Void;
@:native("_hx_std_socket_poll")
static function socket_poll(socks:Array<Socket>, pdata:Dynamic, timeout:Float):Array<Socket>;
@:native("_hx_std_socket_send_to")
static function socket_send_to(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int, inAddr:Dynamic):Int;
@:native("_hx_std_socket_recv_from")
static function socket_recv_from(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int, outAddr:Dynamic):Int;
}

View File

@ -0,0 +1,137 @@
/*
* 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 cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/ssl/Build.xml"/>')
extern class NativeSsl {
@:native("_hx_ssl_debug_set")
static function ssl_debug_set(int:Int):Void;
@:native("_hx_ssl_new")
static function ssl_new(conf:Dynamic):Dynamic;
@:native("_hx_ssl_close")
static function ssl_close(ctx:Dynamic):Void;
@:native("_hx_ssl_handshake")
static function ssl_handshake(ctx:Dynamic):Void;
@:native("_hx_ssl_set_socket")
static function ssl_set_socket(ctx:Dynamic, socket:Dynamic):Void;
@:native("_hx_ssl_set_hostname")
static function ssl_set_hostname(ctx:Dynamic, hostname:String):Void;
@:native("_hx_ssl_get_peer_certificate")
static function ssl_get_peer_certificate(ctx:Dynamic):Dynamic;
@:native("_hx_ssl_get_verify_result")
static function ssl_get_verify_result(ctx:Dynamic):Bool;
@:native("_hx_ssl_send_char")
static function ssl_send_char(ctx:Dynamic, char:Int):Void;
@:native("_hx_ssl_send")
static function ssl_send(ctx:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_ssl_write")
static function ssl_write(ctx:Dynamic, data:haxe.io.BytesData):Void;
@:native("_hx_ssl_recv_char")
static function ssl_recv_char(ctx:Dynamic):Int;
@:native("_hx_ssl_recv")
static function ssl_recv(ctx:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_ssl_read")
static function ssl_read(ctx:Dynamic):haxe.io.BytesData;
@:native("_hx_ssl_conf_new")
static function conf_new(server:Bool):Dynamic;
@:native("_hx_ssl_conf_close")
static function conf_close(conf:Dynamic):Void;
@:native("_hx_ssl_conf_set_ca")
static function conf_set_ca(conf:Dynamic, cert:Dynamic):Void;
@:native("_hx_ssl_conf_set_verify")
static function conf_set_verify(conf:Dynamic, mode:Int):Void;
@:native("_hx_ssl_conf_set_cert")
static function conf_set_cert(conf:Dynamic, cert:Dynamic, pkey:Dynamic):Void;
@:native("_hx_ssl_conf_set_servername_callback")
static function conf_set_servername_callback(conf:Dynamic, cb:Dynamic):Void;
@:native("_hx_ssl_cert_load_defaults")
static function cert_load_defaults():Dynamic;
@:native("_hx_ssl_cert_load_file")
static function cert_load_file(file:String):Dynamic;
@:native("_hx_ssl_cert_load_path")
static function cert_load_path(path:String):Dynamic;
@:native("_hx_ssl_cert_get_subject")
static function cert_get_subject(cert:Dynamic, field:String):String;
@:native("_hx_ssl_cert_get_issuer")
static function cert_get_issuer(cert:Dynamic, field:String):String;
@:native("_hx_ssl_cert_get_altnames")
static function cert_get_altnames(cert:Dynamic):Array<String>;
@:native("_hx_ssl_cert_get_notbefore")
static function cert_get_notbefore(cert:Dynamic):Array<Int>;
@:native("_hx_ssl_cert_get_notafter")
static function cert_get_notafter(cert:Dynamic):Array<Int>;
@:native("_hx_ssl_cert_get_next")
static function cert_get_next(cert:Dynamic):Dynamic;
@:native("_hx_ssl_cert_add_pem")
static function cert_add_pem(cert:Dynamic, data:String):Dynamic;
@:native("_hx_ssl_cert_add_der")
static function cert_add_der(cert:Dynamic, data:haxe.io.BytesData):Dynamic;
@:native("_hx_ssl_key_from_der")
static function key_from_der(data:haxe.io.BytesData, pub:Bool):Dynamic;
@:native("_hx_ssl_key_from_pem")
static function key_from_pem(data:String, pub:Bool, pass:String):Dynamic;
@:native("_hx_ssl_dgst_make")
static function dgst_make(data:haxe.io.BytesData, alg:String):haxe.io.BytesData;
@:native("_hx_ssl_dgst_sign")
static function dgst_sign(data:haxe.io.BytesData, key:Dynamic, alg:String):haxe.io.BytesData;
@:native("_hx_ssl_dgst_verify")
static function dgst_verify(data:haxe.io.BytesData, sign:haxe.io.BytesData, key:Dynamic, alg:String):Bool;
@:native("_hx_ssl_init")
static function init():Void;
}

View File

@ -0,0 +1,73 @@
/*
* 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 cpp;
extern class NativeString {
static inline function raw(inString:String):RawConstPointer<Char> {
return untyped inString.raw_ptr();
}
static inline function c_str(inString:String):ConstPointer<Char> {
return cpp.ConstPointer.fromPointer(untyped inString.c_str());
}
static inline function fromPointer(inPtr:ConstPointer<Char>):String {
return untyped __global__.String(inPtr.ptr);
}
static inline function fromGcPointer(inPtr:ConstPointer<Char>, inLen:Int):String {
return untyped __global__.String(inPtr.ptr, inLen);
}
@:native("__hxcpp_parse_float")
public static function parseFloat(inString:String):Float;
@:native("__hxcpp_parse_substr_float")
public static function parseSubstrFloat(inString:String,start:Int, length:Int):Float;
// Will return 0 for invalid string
@:native("__hxcpp_parse_substr_int")
public static function parseInt(inString:String):Int;
// Will return 0 for invalid string
@:native("__hxcpp_parse_substr_int")
public static function parseSubstrInt(inString:String,start:Int, length:Int):Int;
@:native("_hx_string_compare")
static function compare(inString0:String, inString1:String):Int;
@:native("_hx_utf8_char_code_at")
static function utf8CharCodeAt(inString:String, inIndex:Int):Int;
@:native("_hx_utf8_length")
static function utf8Length(inString:String):Int;
@:native("_hx_utf8_is_valid")
static function utf8IsValid(inString:String):Bool;
@:native("_hx_utf8_sub")
static function utf8Sub(inString:String, charStart:Int, inLen:Int):String;
@:native("_hx_string_create")
static function fromPointerLen(inPtr:ConstPointer<Char>, len:Int):String;
@:native("_hx_utf8_decode_advance")
static function utf8DecodeAdvance(reference:Char):Int;
}

View File

@ -0,0 +1,107 @@
/*
* 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 cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeSys {
@:native("__hxcpp_print")
static function print(v:Dynamic):Void;
@:native("__hxcpp_println")
static function println(v:Dynamic):Void;
@:native("_hx_std_get_env")
extern static function get_env(v:String):String;
@:native("_hx_std_put_env")
extern static function put_env(e:String, v:String):Void;
@:native("_hx_std_sys_sleep")
extern static function sys_sleep(f:Float):Void;
@:native("_hx_std_set_time_locale")
extern static function set_time_locale(l:String):Bool;
@:native("_hx_std_get_cwd")
extern static function get_cwd():String;
@:native("_hx_std_set_cwd")
extern static function set_cwd(d:String):Void;
@:native("_hx_std_sys_string")
extern static function sys_string():String;
@:native("_hx_std_sys_is64")
extern static function sys_is64():Bool;
@:native("_hx_std_sys_command")
extern static function sys_command(cmd:String):Int;
@:native("_hx_std_sys_exit")
extern static function sys_exit(code:Int):Void;
@:native("_hx_std_sys_exists")
extern static function sys_exists(path:String):Bool;
@:native("_hx_std_file_delete")
extern static function file_delete(path:String):Void;
@:native("_hx_std_sys_rename")
extern static function sys_rename(path:String, newname:String):Bool;
@:native("_hx_std_sys_stat")
extern static function sys_stat(path:String):Dynamic;
@:native("_hx_std_sys_file_type")
extern static function sys_file_type(path:String):String;
@:native("_hx_std_sys_create_dir")
extern static function sys_create_dir(path:String, mode:Int):Bool;
@:native("_hx_std_sys_remove_dir")
extern static function sys_remove_dir(path:String):Void;
@:native("_hx_std_sys_time")
extern static function sys_time():Float;
@:native("_hx_std_sys_cpu_time")
extern static function sys_cpu_time():Float;
@:native("_hx_std_sys_read_dir")
extern static function sys_read_dir(p:String):Array<String>;
@:native("_hx_std_file_full_path")
extern static function file_full_path(path:String):String;
@:native("_hx_std_sys_exe_path")
extern static function sys_exe_path():String;
@:native("_hx_std_sys_env")
extern static function sys_env():Array<String>;
@:native("_hx_std_sys_getch")
extern static function sys_getch(b:Bool):Int;
@:native("_hx_std_sys_get_pid")
extern static function sys_get_pid():Int;
}

View File

@ -0,0 +1,473 @@
/*
* 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 cpp;
enum abstract XmlType(Int) {
/**
Represents an XML element type.
**/
var Element = 0;
/**
Represents XML parsed character data type.
**/
var PCData = 1;
/**
Represents XML character data type.
**/
var CData = 2;
/**
Represents an XML comment type.
**/
var Comment = 3;
/**
Represents an XML doctype element type.
**/
var DocType = 4;
/**
Represents an XML processing instruction type.
**/
var ProcessingInstruction = 5;
/**
Represents an XML document type.
**/
var Document = 6;
}
class NativeXmlState {
var cur:Xml;
public function new(x:Xml) {
x._children = new Array<Xml>();
cur = x;
}
@:keep
public function xml(name:String, att:Dynamic<String>) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.Element;
x._nodeName = name;
x._attributes = att;
x._children = new Array<Xml>();
cur.addChild(x);
cur = x;
}
@:keep
public function cdata(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.CData;
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function pcdata(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.PCData;
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function comment(text:String) {
var x = new Xml();
x._parent = cur;
if (text.length > 1 && StringTools.fastCodeAt(text, 0) == 63) {
x.nodeType = Xml.ProcessingInstruction;
text = text.substr(1, text.length - 2);
} else {
x.nodeType = Xml.Comment;
}
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function doctype(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.DocType;
x._nodeValue = text.substr(1);
cur.addChild(x);
}
@:keep
public function done() {
cur = cur._parent;
}
}
private class NativeXmlIterator {
var cur = 0;
var children:Array<Xml>;
public function new(inChildren:Array<Xml>) {
children = inChildren;
cur = 0;
}
public function hasNext():Bool {
var k = cur;
var l = children.length;
while (k < l) {
if (children[k].nodeType == Xml.Element)
break;
k += 1;
}
cur = k;
return k < l;
}
public function next():Xml {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
k += 1;
if (n.nodeType == Xml.Element) {
cur = k;
return n;
}
}
return null;
}
}
private class NativeXmlNamedIterator {
var cur = 0;
var children:Array<Xml>;
var name:String;
public function new(inChildren:Array<Xml>, inName:String) {
children = inChildren;
name = inName;
cur = 0;
}
public function hasNext():Bool {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
if (n.nodeType == Xml.Element && n._nodeName == name)
break;
k++;
}
cur = k;
return k < l;
}
public function next():Xml {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
k++;
if (n.nodeType == Xml.Element && n._nodeName == name) {
cur = k;
return n;
}
}
return null;
}
}
@:cppInclude("./NativeXmlImport.cpp")
@:allow(cpp.NativeXmlState) @:allow(cpp.NativeXmlIterator) @:allow(cpp.NativeXmlNamedIterator)
class Xml {
static inline var Element = XmlType.Element;
static inline var PCData = XmlType.PCData;
static inline var CData = XmlType.CData;
static inline var Comment = XmlType.Comment;
static inline var DocType = XmlType.DocType;
static inline var ProcessingInstruction = XmlType.ProcessingInstruction;
static inline var Document = XmlType.Document;
private var _nodeName:String;
private var _nodeValue:String;
private var _attributes:Dynamic<String>;
private var _children:Array<Xml>;
private var _parent:Xml;
function new():Void {}
@:native("parse_xml")
extern static function parse_xml(str:String, state:NativeXmlState);
public static function parse(str:String):Xml {
var x = new Xml();
var state = new NativeXmlState(x);
parse_xml(str, state);
x.nodeType = Xml.Document;
return x;
}
public static function createElement(name:String):Xml {
var r = new Xml();
r.nodeType = Xml.Element;
r._nodeName = name;
r._attributes = null;
r._children = new Array();
return r;
}
public static function createPCData(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.PCData;
r._nodeValue = data;
return r;
}
public static function createCData(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.CData;
r._nodeValue = data;
return r;
}
public static function createComment(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.Comment;
r._nodeValue = data;
return r;
}
public static function createDocType(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.DocType;
r._nodeValue = data;
return r;
}
public static function createProcessingInstruction(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.ProcessingInstruction;
r._nodeValue = data;
return r;
}
public static function createDocument():Xml {
var r = new Xml();
r.nodeType = Xml.Document;
r._children = new Array();
return r;
}
public var nodeType(default, null):XmlType;
public var nodeName(get, set):String;
public var nodeValue(get, set):String;
private function get_nodeName():String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return _nodeName;
}
private function set_nodeName(n:String):String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return _nodeName = n;
}
private function get_nodeValue():String {
if (nodeType == Xml.Element || nodeType == Xml.Document)
throw "bad nodeType";
return _nodeValue;
}
private function set_nodeValue(v:String):String {
if (nodeType == Xml.Element || nodeType == Xml.Document)
throw "bad nodeType";
return _nodeValue = v;
}
public var parent(get, null):Xml;
private function get_parent():Xml {
return _parent;
}
public function get(att:String):String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.field(_attributes, att);
}
public function set(att:String, value:String):Void {
if (nodeType != Xml.Element)
throw "bad nodeType";
if (_attributes == null)
_attributes = {};
Reflect.setField(_attributes, att, value);
return;
}
public function remove(att:String):Void {
if (nodeType != Xml.Element)
throw "bad nodeType";
Reflect.deleteField(_attributes, att);
return;
}
public function exists(att:String):Bool {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.hasField(_attributes, att);
}
public function attributes():Iterator<String> {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.fields(_attributes).iterator();
}
public function iterator():Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return untyped _children.iterator();
}
public function elements():Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return new NativeXmlIterator(_children);
}
public function elementsNamed(name:String):Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return new NativeXmlNamedIterator(_children, name);
}
public function firstChild():Xml {
if (_children == null)
throw "bad nodetype";
return _children[0];
}
public function firstElement():Xml {
if (_children == null)
throw "bad nodetype";
for (cur in 0..._children.length) {
var n:Xml = _children[cur];
if (n.nodeType == Xml.Element)
return n;
}
return null;
}
public function addChild(x:Xml):Void {
if (_children == null)
throw "bad nodetype";
if (x._parent != null)
x._parent._children.remove(x);
x._parent = this;
_children.push(x);
return;
}
public function removeChild(x:Xml):Bool {
if (_children == null)
throw "bad nodetype";
var b = _children.remove(x);
if (b)
x._parent = null;
return b;
}
public function insertChild(x:Xml, pos:Int):Void {
if (_children == null)
throw "bad nodetype";
if (x._parent != null)
x._parent._children.remove(x);
x._parent = this;
_children.insert(pos, x);
return;
}
public function toString():String {
var s = new StringBuf();
toStringRec(s);
return s.toString();
}
private function toStringRec(s:StringBuf):Void {
switch (nodeType) {
case Xml.Document:
for (x in _children)
x.toStringRec(s);
case Xml.Element:
s.addChar("<".code);
s.add(_nodeName);
for (k in Reflect.fields(_attributes)) {
s.addChar(" ".code);
s.add(k);
s.addChar("=".code);
s.addChar("\"".code);
s.add(Reflect.field(_attributes, k));
s.addChar("\"".code);
}
if (_children.length == 0) {
s.addChar("/".code);
s.addChar(">".code);
return;
}
s.addChar(">".code);
for (x in _children)
x.toStringRec(s);
s.addChar("<".code);
s.addChar("/".code);
s.add(_nodeName);
s.addChar(">".code);
case Xml.PCData:
s.add(StringTools.htmlEscape(_nodeValue));
case Xml.CData:
s.add("<![CDATA[");
s.add(_nodeValue);
s.add("]]>");
case Xml.Comment:
s.add("<!--");
s.add(_nodeValue);
s.add("-->");
case Xml.DocType:
s.add("<!DOCTYPE ");
s.add(_nodeValue);
s.add(">");
case Xml.ProcessingInstruction:
s.add("<?");
s.add(_nodeValue);
s.add("?>");
}
}
}

View File

@ -0,0 +1,386 @@
/*
* 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.
*/
#ifdef EPPC
#include <memory>
#else
#include <memory.h>
#endif
#ifndef HX_WINDOWS
# include <strings.h>
# undef strcmpi
# define strcmpi(a,b) strcasecmp(a,b)
#else
# include <string.h>
#endif
// -------------- parsing --------------------------
enum STATE {
IGNORE_SPACES,
BEGIN,
BEGIN_NODE,
TAG_NAME,
BODY,
ATTRIB_NAME,
EQUALS,
ATTVAL_BEGIN,
ATTRIB_VAL,
CHILDS,
CLOSE,
WAIT_END,
WAIT_END_RET,
PCDATA,
HEADER,
COMMENT,
DOCTYPE,
CDATA,
};
static void xml_error( const char *xml, const char *inWhere, int *line, String msg ) {
String b = HX_CSTRING("Xml parse error : ") + msg + HX_CSTRING(" at line ") + String(*line) + HX_CSTRING(" : ");
String where(inWhere);
int l = where.length;
int nchars = 30;
if( inWhere != xml )
b += HX_CSTRING("...");
if (where.length==0)
b+= HX_CSTRING("<eof>");
else if (where.length<nchars)
b+= where;
else
b+= where.substr(0,nchars) + HX_CSTRING("...");
hx::Throw(b);
}
#define ERRORSTR(msg) xml_error(xml,p,line,msg);
#define ERROR(msg) xml_error(xml,p,line,HX_CSTRING(msg));
static bool is_valid_char( int c ) {
return ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= '0' && c <= '9' ) || c == ':' || c == '.' || c == '_' || c == '-';
}
static void do_parse_xml( const char *xml, const char **lp, int *line, cpp::NativeXmlState callb, String parentname )
{
STATE state = BEGIN;
STATE next = BEGIN;
String aname;
hx::Anon attribs;
String nodename;
const char *start = NULL;
const char *p = *lp;
char c = *p;
int nsubs = 0, nbrackets = 0;
while( c ) {
switch( state ) {
case IGNORE_SPACES:
switch( c ) {
case '\n':
case '\r':
case '\t':
case ' ':
break;
default:
state = next;
continue;
}
break;
case BEGIN:
switch( c ) {
case '<':
state = IGNORE_SPACES;
next = BEGIN_NODE;
break;
default:
start = p;
state = PCDATA;
continue;
}
break;
case PCDATA:
if( c == '<' ) {
callb->pcdata(String(start,p-start).dup());
nsubs++;
state = IGNORE_SPACES;
next = BEGIN_NODE;
}
break;
case CDATA:
if( c == ']' && p[1] == ']' && p[2] == '>' ) {
callb->cdata(String(start,p-start).dup());
nsubs++;
p += 2;
state = BEGIN;
}
break;
case BEGIN_NODE:
switch( c ) {
case '!':
if( p[1] == '[' ) {
p += 2;
if( (p[0] != 'C' && p[0] != 'c') ||
(p[1] != 'D' && p[1] != 'd') ||
(p[2] != 'A' && p[2] != 'a') ||
(p[3] != 'T' && p[3] != 't') ||
(p[4] != 'A' && p[4] != 'a') ||
(p[5] != '[') )
ERROR("Expected <![CDATA[");
p += 5;
state = CDATA;
start = p + 1;
break;
}
if( p[1] == 'D' || p[1] == 'd' ) {
if( (p[2] != 'O' && p[2] != 'o') ||
(p[3] != 'C' && p[3] != 'c') ||
(p[4] != 'T' && p[4] != 't') ||
(p[5] != 'Y' && p[5] != 'y') ||
(p[6] != 'P' && p[6] != 'p') ||
(p[7] != 'E' && p[7] != 'e') )
ERROR("Expected <!DOCTYPE");
p += 7;
state = DOCTYPE;
start = p + 1;
break;
}
if( p[1] != '-' || p[2] != '-' )
ERROR("Expected <!--");
p += 2;
state = COMMENT;
start = p + 1;
break;
case '?':
state = HEADER;
start = p;
break;
case '/':
if( parentname.length==0 )
ERROR("Expected node name");
start = p + 1;
state = IGNORE_SPACES;
next = CLOSE;
break;
default:
state = TAG_NAME;
start = p;
continue;
}
break;
case TAG_NAME:
if( !is_valid_char(c) ) {
if( p == start )
ERROR("Expected node name");
nodename = String(start,p-start).dup();
attribs = hx::Anon_obj::Create();
state = IGNORE_SPACES;
next = BODY;
continue;
}
break;
case BODY:
switch( c ) {
case '/':
state = WAIT_END;
nsubs++;
callb->xml(nodename,attribs);
break;
case '>':
state = CHILDS;
nsubs++;
callb->xml(nodename,attribs);
break;
default:
state = ATTRIB_NAME;
start = p;
continue;
}
break;
case ATTRIB_NAME:
if( !is_valid_char(c) ) {
if( start == p )
ERROR("Expected attribute name");
aname = String(start,p-start).dup();
if( attribs->__Field(aname,hx::paccDynamic) != null() )
ERROR("Duplicate attribute");
state = IGNORE_SPACES;
next = EQUALS;
continue;
}
break;
case EQUALS:
switch( c ) {
case '=':
state = IGNORE_SPACES;
next = ATTVAL_BEGIN;
break;
default:
ERROR("Expected =");
}
break;
case ATTVAL_BEGIN:
switch( c ) {
case '"':
case '\'':
state = ATTRIB_VAL;
start = p;
break;
default:
ERROR("Expected \"");
}
break;
case ATTRIB_VAL:
if( c == *start ) {
attribs->Add( aname, String(start+1,p-start-1).dup() );
state = IGNORE_SPACES;
next = BODY;
}
break;
case CHILDS:
*lp = p;
do_parse_xml(xml,lp,line,callb,nodename);
p = *lp;
start = p;
state = BEGIN;
break;
case WAIT_END:
switch( c ) {
case '>':
callb->done();
state = BEGIN;
break;
default :
ERROR("Expected >");
}
break;
case WAIT_END_RET:
switch( c ) {
case '>':
if( nsubs == 0 )
callb->pcdata(HX_CSTRING(""));
*lp = p;
return;
default :
ERROR("Expected >");
}
break;
case CLOSE:
if( !is_valid_char(c) ) {
if( start == p )
ERROR("Expected node name");
{
String v = String(start,p - start).dup();
if( strcmpi(parentname.__s,v.__s) != 0 ) {
ERRORSTR(HX_CSTRING("Expected </") + parentname + HX_CSTRING(">"));
}
}
state = IGNORE_SPACES;
next = WAIT_END_RET;
continue;
}
break;
case COMMENT:
if( c == '-' && p[1] == '-' && p[2] == '>' ) {
callb->comment(String(start,p-start).dup());
p += 2;
state = BEGIN;
}
break;
case DOCTYPE:
if( c == '[' )
nbrackets++;
else if( c == ']' )
nbrackets--;
else if( c == '>' && nbrackets == 0 ) {
callb->doctype(String(start,p-start).dup());
state = BEGIN;
}
break;
case HEADER:
if( c == '?' && p[1] == '>' ) {
p++;
callb->comment(String(start,p-start).dup());
state = BEGIN;
}
break;
}
c = *++p;
if( c == '\n' )
(*line)++;
}
if( state == BEGIN ) {
start = p;
state = PCDATA;
}
if( parentname.__s == 0 && state == PCDATA ) {
if( p != start || nsubs == 0 )
callb->pcdata(String(start,p-start).dup());
return;
}
ERROR("Unexpected end");
}
// ----------------------------------------------
/**
<doc>
<h1>Xml</h1>
<p>
The standard event-driven XML parser.
</p>
</doc>
**/
/**
parse_xml : xml:string -> events:object -> void
<doc>
The [parse_xml] parse a string and for each parsed element call the
corresponding object method in [events] :
<ul>
<li>[void xml( name : string, attribs : object)] when an XML node is found</li>
<li>[void done()] when an XML node is closed</li>
<li>[void pcdata(string)] when PCData chars found</li>
<li>[void cdata(string)] when a CData session is found</li>
<li>[void comment(string)] when some comment or special header is found</li>
</ul>
You can then implement the events so they build the appropriate XML data
structure needed by your language.
</doc>
**/
static void parse_xml( String str, cpp::NativeXmlState state )
{
int line = 0;
const char *p = str.__s;
// skip BOM
if( p[0] == (char)0xEF && p[1] == (char)0xBB && p[2] == (char)0xBF )
p += 3;
do_parse_xml(p,&p,&line,state,String());
}

View File

@ -0,0 +1,26 @@
/*
* 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 cpp;
@:noPackageRestrict
typedef Object = Dynamic;

View 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 cpp;
extern class ObjectType {
inline static var vtUnknown = -1;
inline static var vtInt = 0xff;
inline static var vtNull = 0;
inline static var vtFloat = 1;
inline static var vtBool = 2;
inline static var vtString = 3;
inline static var vtObject = 4;
inline static var vtArray = 5;
inline static var vtFunction = 6;
inline static var vtEnum = 7;
inline static var vtClass = 8;
inline static var vtInt64 = 9;
inline static var vtAbstractBase = 0x100;
}

View File

@ -0,0 +1,86 @@
/*
* 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 cpp;
import haxe.extern.AsVar;
@:coreType
@:semantics(variable)
extern class Pointer<T> extends ConstPointer<T> implements ArrayAccess<T> {
var ref(get, set):Reference<T>;
function get_ref():Reference<T>;
function set_ref(t:T):Reference<T>;
function setAt(inIndex:Int, value:T):Void;
static function fromRaw<T>(ptr:RawPointer<T>):Pointer<T>;
@:native("::cpp::Pointer_obj::fromRaw")
static function fromStar<T>(star:Star<T>):Pointer<T>;
@:native("::cpp::Pointer_obj::fromHandle")
static function nativeFromHandle<T>(inHandle:Dynamic, ?inKind:String):AutoCast;
inline static function fromHandle<T>(inHandle:Dynamic, ?inKind:String):Pointer<T> {
return cast nativeFromHandle(inHandle, inKind);
}
static function fromPointer<T>(inNativePointer:Dynamic):Pointer<T>;
static function addressOf<T>(inVariable:cpp.Reference<T>):Pointer<T>;
static function endOf<T:{}>(inVariable:T):Pointer<cpp.Void>;
@:native("::cpp::Pointer_obj::arrayElem")
static function nativeArrayElem<T>(array:Array<T>, inElem:Int):AutoCast;
inline static function arrayElem<T>(array:Array<T>, inElem:Int):Pointer<T> {
return cast nativeArrayElem(array, inElem);
}
@:native("::cpp::Pointer_obj::ofArray")
static function nativeOfArray<T>(array:Array<T>):AutoCast;
inline static function ofArray<T>(array:Array<T>):Pointer<T> {
return cast nativeOfArray(array);
}
inline function toUnmanagedArray(elementCount:Int):Array<T> {
var result = new Array<T>();
NativeArray.setUnmanagedData(result, this, elementCount);
return result;
}
inline function toUnmanagedVector(elementCount:Int):haxe.ds.Vector<T>
return cast toUnmanagedArray(elementCount);
override function inc():Pointer<T>;
override function dec():Pointer<T>;
override function incBy(inT:Int):Pointer<T>;
override function decBy(inT:Int):Pointer<T>;
override function add(inT:Int):Pointer<T>;
override function sub(inT:Int):Pointer<T>;
function postIncRef():Reference<T>;
function destroy():Void;
function destroyArray():Void;
}

View File

@ -0,0 +1,117 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
#if macro
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.Expr;
#end
@:noPackageRestrict
class Prime {
#if (!macro && cpp)
public static function _loadPrime(lib:String, prim:String, signature:String, quietFail = false):Dynamic {
var factory:Callable<ConstCharStar->Object> = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail);
if (factory != null) {
var func:Dynamic = factory.call(signature);
if (func == null && !quietFail)
throw '$prim does not have signature $signature';
return func;
}
return null;
}
#end
#if (macro)
static function codeToType(code:String, forCpp:Bool):String {
if (code == "c" && !forCpp)
throw "const char * type only supported in cpp mode";
switch (code) {
case "b":
return "Bool";
case "i":
return "Int";
case "d":
return "Float";
case "s":
return "String";
case "f":
return forCpp ? "cpp.Float32" : "Float";
case "o":
return forCpp ? "cpp.Object" : "Dynamic";
case "v":
return forCpp ? "cpp.Void" : "Dynamic";
case "c":
return "cpp.ConstCharStar";
default:
throw "Unknown signature type :" + code;
}
}
#end
public static function nekoInit(inModuleName:String):Bool {
#if neko
var init = neko.Lib.load(inModuleName, "neko_init", 5);
if (init != null) {
init(function(s) return new String(s), function(len:Int) {
var r = [];
if (len > 0)
r[len - 1] = null;
return r;
}, null, true, false);
return true;
}
#end
return false;
}
public static macro function load(inModule:String, inName:String, inSig:String, inAllowFail:Bool = false) {
var parts = inSig.split("");
if (parts.length < 1)
throw "Invalid function signature " + inSig;
var argCount = parts.length - 1;
var cppiaMode = Context.defined("cppia");
var cppMode = Context.defined("cpp") && !cppiaMode;
var typeString = parts.length == 1 ? "Void" : codeToType(parts.shift(), cppMode);
for (p in parts)
typeString += "->" + codeToType(p, cppMode);
if (cppMode) {
typeString = "cpp.Callable<" + typeString + ">";
var expr = 'new $typeString(cpp.Prime._loadPrime("$inModule","$inName","$inSig",$inAllowFail))';
return Context.parse(expr, Context.currentPos());
} else {
if (argCount > 5)
argCount = -1;
var lazy = inAllowFail ? "loadLazy" : "load";
var lib = cppiaMode ? "cpp" : "neko";
var expr = 'new cpp.Callable<$typeString>($lib.Lib.$lazy("$inModule","$inName",$argCount))';
return Context.parse(expr, Context.currentPos());
}
}
}

View File

@ -0,0 +1,43 @@
/*
* 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 cpp;
class Random {
var r:Dynamic;
public function new() {
r = cpp.NativeRandom.random_new();
}
public function setSeed(s:Int) {
cpp.NativeRandom.random_set_seed(r, s);
}
public function int(max:Int):Int {
return cpp.NativeRandom.random_int(r, max);
}
public function float():Float {
return cpp.NativeRandom.random_float(r);
}
}

View File

@ -0,0 +1,29 @@
/*
* 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 cpp;
@:unreflective
extern class RawConstPointer<T> implements ArrayAccess<T> {
@:native("::hx::AddressOf")
static function addressOf<T>(t:T):RawConstPointer<T>;
}

View File

@ -0,0 +1,29 @@
/*
* 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 cpp;
@:unreflective
extern class RawPointer<T> extends RawConstPointer<T> {
@:native("::hx::AddressOf")
static function addressOf<T>(t:T):RawPointer<T>;
}

View 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 cpp;
/**
Allows haxe to type result correctly, and hxcpp can recognise this and
prevent unwanted casting.
**/
@:semantics(reference)
typedef Reference<T> = T;

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
abstract Rest<T>(Array<T>) {}

View File

@ -0,0 +1,27 @@
/*
* 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 cpp;
@:native("size_t")
@:scalar @:coreType @:notNull
extern abstract SizeT from(Int) to(Int) {}

View File

@ -0,0 +1,29 @@
/*
* 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 cpp;
/**
Allows haxe to type result correctly, and hxcpp can recognise this use the
correct type.
**/
typedef Star<T> = Null<T>;

View File

@ -0,0 +1,49 @@
/*
* 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 cpp;
using cpp.NativeString;
@:native("::hx::StdString")
@:include("hx/StdString.h")
@:stackOnly
@:structAccess
@:unreflective
extern class StdString {
@:native("std::string::npos")
static var npos(default, null):Int;
// function new(inData:StdStringData);
@:native("::hx::StdString")
static function ofString(s:String):StdString;
// function toString():String;
// function find(s:String):Int;
// function substr(pos:Int, len:Int):StdString;
function c_str():ConstPointer<Char>;
function size():Int;
function find(s:String):Int;
function substr(pos:Int, len:Int):StdString;
function toString():String;
function toStdString():StdString;
}

View 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.
*/
package cpp;
using cpp.NativeString;
@:native("::hx::StdString const &")
@:include("hx/StdString.h")
@:structAccess
extern class StdStringRef {
function c_str():ConstPointer<Char>;
function size():Int;
function find(s:String):Int;
function substr(pos:Int, len:Int):StdString;
function toString():String;
function toStdString():StdString;
}

View File

@ -0,0 +1,41 @@
/*
* 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 cpp;
@:include("stdio.h")
extern class Stdio {
@:native("printf")
static function printf(format:ConstCharStar, rest:Rest<VarArg>):Void;
@:native("fopen")
static function fopen(filename:ConstCharStar, mode:ConstCharStar):FILE;
@:native("fwrite")
static function fwrite<T>(data:RawPointer<T>, elemSize:SizeT, elemCount:SizeT, file:FILE):SizeT;
@:native("fclose")
static function fclose(file:FILE):Int;
@:native("fprintf")
static function fprintf(file:FILE, format:ConstCharStar, rest:Rest<VarArg>):Void;
}

View File

@ -0,0 +1,59 @@
/*
* 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 cpp;
@:include("stdlib.h")
extern class Stdlib {
@:native("malloc")
static function nativeMalloc(bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("calloc")
static function nativeCalloc(bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("realloc")
static function nativeRealloc(inPtr:cpp.RawPointer<cpp.Void>, bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("free")
static function nativeFree(ptr:cpp.RawPointer<cpp.Void>):Void;
@:native("memcpy")
static function nativeMemcpy(dest:cpp.RawPointer<cpp.Void>, src:cpp.RawConstPointer<cpp.Void>, bytes:Int):Void;
@:native("::hx::ClassSizeOf") @:templatedCall
static function sizeof<T>(t:T):Int;
inline static function memcpy<DEST, SRC>(dest:cpp.Pointer<DEST>, src:cpp.ConstPointer<SRC>, bytes:Int):Void
nativeMemcpy(cast dest.ptr, cast src.ptr, bytes);
inline static function malloc<T>(bytes:Int):cpp.Pointer<T>
return cast nativeMalloc(bytes);
inline static function calloc<T>(bytes:Int):cpp.Pointer<T>
return cast nativeCalloc(bytes);
inline static function realloc<T>(ioPtr:cpp.Pointer<T>, bytes:Int):Void
ioPtr.setRaw(nativeRealloc(cast ioPtr.ptr, bytes));
inline static function free<T>(ptr:cpp.Pointer<T>):Void {
if (ptr != null) {
nativeFree(cast ptr.ptr);
ptr.ptr = null;
}
}
}

View File

@ -0,0 +1,28 @@
/*
* 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 cpp;
/**
Wraps external types with a class that integrates with Dynamic.
**/
typedef Struct<T> = T;

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract UInt16 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract UInt32 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract UInt64 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* 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 cpp;
@:coreType @:notNull @:runtimeValue abstract UInt8 from Int to Int {}

View File

@ -0,0 +1,29 @@
/*
* 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 cpp;
/**
Allows haxe to type params correctly, and hxcpp can recognise this use the
correct type.
**/
typedef VarArg = Dynamic;

View File

@ -0,0 +1,136 @@
/*
* 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 cpp;
@:native("cpp::VirtualArray")
@:coreType extern class NativeVirtualArray implements ArrayAccess<Dynamic> {
function new():Void;
var length(get, null):Int;
// concat<T>( a:Array<T> ) : Array<T> ?
function concat(a:VirtualArray):VirtualArray;
function join(sep:String):String;
function pop():Dynamic;
function push(x:Dynamic):Int;
function reverse():Void;
function shift():Dynamic;
function slice(pos:Int, ?end:Int):VirtualArray;
function sort(f:Dynamic->Dynamic->Int):Void;
function splice(pos:Int, len:Int):VirtualArray;
function toString():String;
function unshift(x:Dynamic):Void;
function insert(pos:Int, x:Dynamic):Void;
function remove(x:Dynamic):Bool;
function indexOf(x:Dynamic, ?fromIndex:Int):Int;
function lastIndexOf(x:Dynamic, ?fromIndex:Int):Int;
function copy():VirtualArray;
function iterator():Iterator<Dynamic>;
function keyValueIterator():KeyValueIterator<Int, Dynamic>;
function map<S>(f:Dynamic->S):VirtualArray;
function filter(f:Dynamic->Bool):VirtualArray;
function resize(len:Int):Void;
}
abstract VirtualArray(NativeVirtualArray) {
// Add these two functions...
@:from extern inline static public function fromArray<T>(a:Array<T>):VirtualArray
return untyped a;
@:to extern inline public function toArray<T>():Array<T>
return untyped this;
// The rest is just boiler-plate
inline public function new()
this = new NativeVirtualArray();
@:arrayAccess extern inline function get(idx:Int):Dynamic
return untyped this[idx];
@:arrayAccess extern inline function set<T>(pos:Int, value:T):T
return untyped this[idx] = value;
public var length(get, never):Int;
extern inline public function get_length():Int
return this.length;
// concat<T>( a:Array<T> ) : Array<T> ?
extern inline public function concat(a:VirtualArray):VirtualArray
return this.concat(a);
extern inline public function join(sep:String):String
return this.join(sep);
extern inline public function pop():Dynamic
return this.pop();
extern inline public function push(x:Dynamic):Int
return this.push(x);
extern inline public function reverse():Void
this.reverse();
extern inline public function shift():Dynamic
return this.shift();
extern inline public function slice(pos:Int, ?end:Int):VirtualArray
return this.slice(pos, end);
extern inline public function sort(f:Dynamic->Dynamic->Int):Void
this.sort(f);
extern inline public function splice(pos:Int, len:Int):VirtualArray
return this.slice(pos, len);
extern inline public function unshift(x:Dynamic):Void
this.unshift(x);
extern inline public function insert(pos:Int, x:Dynamic):Void
this.insert(pos, x);
extern inline public function remove(x:Dynamic):Bool
return this.remove(x);
extern inline public function indexOf(x:Dynamic, ?fromIndex:Int):Int
return this.indexOf(x, fromIndex);
extern inline public function lastIndexOf(x:Dynamic, ?fromIndex:Int):Int
return this.lastIndexOf(x, fromIndex);
extern inline public function copy():VirtualArray
return this.copy();
extern inline public function iterator():Iterator<Dynamic>
return this.iterator();
extern inline public function keyValueIterator():KeyValueIterator<Int, Dynamic>
return this.keyValueIterator();
extern inline public function map<S>(f:Dynamic->S):VirtualArray
return this.map(f);
extern inline public function filter(f:Dynamic->Bool):VirtualArray
return this.filter(f);
extern inline public function resize(len:Int):Void
return this.resize(len);
}

View File

@ -0,0 +1,26 @@
/*
* 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 cpp;
@:native("void")
extern class Void {}

View File

@ -0,0 +1,128 @@
/*
* 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 class Date {
private var mSeconds:Float;
public function new(year:Int, month:Int, day:Int, hour:Int, min:Int, sec:Int):Void {
mSeconds = untyped __global__.__hxcpp_new_date(year, month, day, hour, min, sec);
}
public function getTime():Float {
return mSeconds * 1000.0;
}
public function getHours():Int {
return untyped __global__.__hxcpp_get_hours(mSeconds);
}
public function getMinutes():Int {
return untyped __global__.__hxcpp_get_minutes(mSeconds);
}
public function getSeconds():Int {
return untyped __global__.__hxcpp_get_seconds(mSeconds);
}
public function getFullYear():Int {
return untyped __global__.__hxcpp_get_year(mSeconds);
}
public function getMonth():Int {
return untyped __global__.__hxcpp_get_month(mSeconds);
}
public function getDate():Int {
return untyped __global__.__hxcpp_get_date(mSeconds);
}
public function getDay():Int {
return untyped __global__.__hxcpp_get_day(mSeconds);
}
public function getUTCHours():Int {
return untyped __global__.__hxcpp_get_utc_hours(mSeconds);
}
public function getUTCMinutes():Int {
return untyped __global__.__hxcpp_get_utc_minutes(mSeconds);
}
public function getUTCSeconds():Int {
return untyped __global__.__hxcpp_get_utc_seconds(mSeconds);
}
public function getUTCFullYear():Int {
return untyped __global__.__hxcpp_get_utc_year(mSeconds);
}
public function getUTCMonth():Int {
return untyped __global__.__hxcpp_get_utc_month(mSeconds);
}
public function getUTCDate():Int {
return untyped __global__.__hxcpp_get_utc_date(mSeconds);
}
public function getUTCDay():Int {
return untyped __global__.__hxcpp_get_utc_day(mSeconds);
}
public function getTimezoneOffset():Int {
return -Std.int((untyped __global__.__hxcpp_timezone_offset(mSeconds)) / 60);
}
public function toString():String {
return untyped __global__.__hxcpp_to_string(mSeconds);
}
public static function now():Date {
return fromTime(untyped __global__.__hxcpp_date_now() * 1000.0);
}
private static function new1(t:Dynamic):Date {
return new Date(2005, 1, 1, 0, 0, 0);
}
public static function fromTime(t:Float):Date {
var result = new Date(0, 0, 0, 0, 0, 0);
result.mSeconds = t * 0.001;
return result;
}
public static function fromString(s:String):Date {
switch (s.length) {
case 8: // hh:mm:ss
var k = s.split(":");
return Date.fromTime(Std.parseInt(k[0]) * 3600000. + Std.parseInt(k[1]) * 60000. + Std.parseInt(k[2]) * 1000.);
case 10: // YYYY-MM-DD
var k = s.split("-");
return new Date(Std.parseInt(k[0]), Std.parseInt(k[1]) - 1, Std.parseInt(k[2]), 0, 0, 0);
case 19: // YYYY-MM-DD hh:mm:ss
var k = s.split(" ");
var y = k[0].split("-");
var t = k[1].split(":");
return new Date(Std.parseInt(y[0]), Std.parseInt(y[1]) - 1, Std.parseInt(y[2]), Std.parseInt(t[0]), Std.parseInt(t[1]), Std.parseInt(t[2]));
default:
throw "Invalid date format : " + s;
}
}
}

View File

@ -0,0 +1,193 @@
/*
* 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.
*/
@:buildXml('<include name="${HXCPP}/src/hx/libs/regexp/Build.xml"/>')
@:coreApi class EReg {
var r:Dynamic;
var last:String;
var global:Bool;
public function new(r:String, opt:String):Void {
var a = opt.split("g");
global = a.length > 1;
if (global)
opt = a.join("");
this.r = _hx_regexp_new_options(r, opt);
}
public function match(s:String):Bool {
var p = _hx_regexp_match(r, s, 0, s.length);
if (p)
last = s;
else
last = null;
return p;
}
public function matched(n:Int):String {
var m = _hx_regexp_matched(r, n);
return m;
}
public function matchedLeft():String {
var p = _hx_regexp_matched_pos(r, 0);
return last.substr(0, p.pos);
}
public function matchedRight():String {
var p = _hx_regexp_matched_pos(r, 0);
var sz = p.pos + p.len;
return last.substr(sz, last.length - sz);
}
public function matchedPos():{pos:Int, len:Int} {
return _hx_regexp_matched_pos(r, 0);
}
public function matchSub(s:String, pos:Int, len:Int = -1):Bool {
var p = _hx_regexp_match(r, s, pos, len < 0 ? s.length - pos : len);
if (p)
last = s;
else
last = null;
return p;
}
public function split(s:String):Array<String> {
var pos = 0;
var len = s.length;
var a = new Array();
var first = true;
do {
if (!_hx_regexp_match(r, s, pos, len))
break;
var p = _hx_regexp_matched_pos(r, 0);
if (p.len == 0 && !first) {
if (p.pos == s.length)
break;
p.pos += 1;
}
a.push(s.substr(pos, p.pos - pos));
var tot = p.pos + p.len - pos;
pos += tot;
len -= tot;
first = false;
} while (global);
a.push(s.substr(pos, len));
return a;
}
public function replace(s:String, by:String):String {
var b = new StringBuf();
var pos = 0;
var len = s.length;
var a = by.split("$");
var first = true;
do {
if (!_hx_regexp_match(r, s, pos, len))
break;
var p = _hx_regexp_matched_pos(r, 0);
if (p.len == 0 && !first) {
if (p.pos == s.length)
break;
p.pos += 1;
}
b.addSub(s, pos, p.pos - pos);
if (a.length > 0)
b.add(a[0]);
var i = 1;
while (i < a.length) {
var k = a[i];
var c = k.charCodeAt(0);
// 1...9
if (c >= 49 && c <= 57) {
var p = try _hx_regexp_matched_pos(r, Std.int(c) - 48) catch (e:String) null;
if (p == null) {
b.add("$");
b.add(k);
} else {
b.addSub(s, p.pos, p.len);
b.addSub(k, 1, k.length - 1);
}
} else if (c == null) {
b.add("$");
i++;
var k2 = a[i];
if (k2 != null && k2.length > 0)
b.add(k2);
} else
b.add("$" + k);
i++;
}
var tot = p.pos + p.len - pos;
pos += tot;
len -= tot;
first = false;
} while (global);
b.addSub(s, pos, len);
return b.toString();
}
public function map(s:String, f:EReg->String):String {
var offset = 0;
var buf = new StringBuf();
do {
if (offset >= s.length)
break;
else if (!matchSub(s, offset)) {
buf.add(s.substr(offset));
break;
}
var p = _hx_regexp_matched_pos(r, 0);
buf.add(s.substr(offset, p.pos - offset));
buf.add(f(this));
if (p.len == 0) {
buf.add(s.substr(p.pos, 1));
offset = p.pos + 1;
} else
offset = p.pos + p.len;
} while (global);
if (!global && offset > 0 && offset < s.length)
buf.add(s.substr(offset));
return buf.toString();
}
public static function escape(s:String):String {
return escapeRegExpRe.map(s, function(r) return "\\" + r.matched(0));
}
static var escapeRegExpRe = ~/[\[\]{}()*+?.\\\^$|]/g;
function toString():String
return 'EReg($r)';
@:native("_hx_regexp_new_options")
extern static function _hx_regexp_new_options(s:String, options:String):Dynamic;
@:native("_hx_regexp_match")
extern static function _hx_regexp_match(handler:Dynamic, string:String, pos:Int, len:Int):Bool;
@:native("_hx_regexp_matched")
extern static function _hx_regexp_matched(handle:Dynamic, pos:Int):String;
@:native("_hx_regexp_matched_pos")
extern static function _hx_regexp_matched_pos(handle:Dynamic, match:Int):{pos:Int, len:Int};
}

View File

@ -0,0 +1,129 @@
/*
* 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 cpp.ObjectType;
@:coreApi
@:analyzer(ignore)
class Reflect {
public static function hasField(o:Dynamic, field:String):Bool
untyped {
return o != null && o.__HasField(field);
}
public static function field(o:Dynamic, field:String):Dynamic
untyped {
return (o == null) ? null : o.__Field(field, untyped __cpp__("::hx::paccNever"));
}
public static function setField(o:Dynamic, field:String, value:Dynamic):Void
untyped {
if (o != null)
o.__SetField(field, value, untyped __cpp__("::hx::paccNever"));
}
public static function getProperty(o:Dynamic, field:String):Dynamic {
return (o == null) ? null : o.__Field(field, untyped __cpp__("::hx::paccAlways"));
}
public static function setProperty(o:Dynamic, field:String, value:Dynamic):Void {
if (o != null)
o.__SetField(field, value, untyped __cpp__("::hx::paccAlways"));
}
public static function callMethod(o:Dynamic, func:haxe.Constraints.Function, args:Array<Dynamic>):Dynamic
untyped {
if (func != null && func.__GetType() == ObjectType.vtString) {
if (o == null)
throw cpp.ErrorConstants.invalidObject;
func = o.__Field(func, untyped __cpp__("::hx::paccDynamic"));
}
if (func == null)
throw cpp.ErrorConstants.nullFunctionPointer;
untyped func.__SetThis(o);
return untyped func.__Run(args);
}
public static function fields(o:Dynamic):Array<String>
untyped {
if (o == null)
return new Array();
var a:Array<String> = [];
o.__GetFields(a);
return a;
}
public static function isFunction(f:Dynamic):Bool
untyped {
return f != null && f.__GetType() == ObjectType.vtFunction;
}
public static function compare<T>(a:T, b:T):Int {
return (a == b) ? 0 : (((a : Dynamic) > (b : Dynamic)) ? 1 : -1);
}
public static function compareMethods(f1:Dynamic, f2:Dynamic):Bool {
if (f1 == f2)
return true;
if (!isFunction(f1) || !isFunction(f2))
return false;
return untyped __global__.__hxcpp_same_closure(f1, f2);
}
public static function isObject(v:Dynamic):Bool
untyped {
if (v == null)
return false;
var t:Int = v.__GetType();
return t == ObjectType.vtObject || t == ObjectType.vtClass || t == ObjectType.vtString || t == ObjectType.vtArray;
}
public static function isEnumValue(v:Dynamic):Bool
untyped {
return v != null && v.__GetType() == ObjectType.vtEnum;
}
public static function deleteField(o:Dynamic, field:String):Bool
untyped {
if (o == null)
return false;
return untyped __global__.__hxcpp_anon_remove(o, field);
}
public static function copy<T>(o:Null<T>):Null<T> {
if (o == null)
return null;
if (untyped o.__GetType() == ObjectType.vtString)
return o;
if (untyped o.__GetType() == ObjectType.vtArray)
return untyped o.__Field("copy", untyped __cpp__("::hx::paccDynamic"))();
var o2:Dynamic = {};
for (f in Reflect.fields(o))
Reflect.setField(o2, f, Reflect.field(o, f));
return o2;
}
@:overload(function(f:Array<Dynamic>->Void):Dynamic {})
public static function makeVarArgs(f:Array<Dynamic>->Dynamic):Dynamic {
return untyped __global__.__hxcpp_create_var_args(f);
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.
*/
@:headerClassCode("\t\tstatic inline String string(String &s) { return s; }")
@:coreApi class Std {
@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
@:keep public static inline function is(v:Dynamic, t:Dynamic):Bool {
return isOfType(v, t);
}
public static function isOfType(v:Dynamic, t:Dynamic):Bool {
return untyped __global__.__instanceof(v, t);
}
@:keep public static function downcast<T:{}, S:T>(value:T, c:Class<S>):S {
return Std.isOfType(value, c) ? cast value : null;
}
@:deprecated('Std.instance() is deprecated. Use Std.downcast() instead.')
@:keep public static function instance<T:{}, S:T>(value:T, c:Class<S>):S {
return inline downcast(value, c);
}
@:keep public static function string(s:Dynamic):String {
return untyped s == null ? "null" : s.toString();
}
@:keep public static function int(x:Float):Int {
return untyped __global__.__int__(x);
}
@:keep public static function parseInt(x:String):Null<Int> {
return untyped __global__.__hxcpp_parse_int(x);
}
@:keep public static function parseFloat(x:String):Float {
return untyped __global__.__hxcpp_parse_float(x);
}
@:keep public static function random(x:Int):Int {
if (x <= 0)
return 0;
return untyped __global__.__hxcpp_irand(x);
}
}

View File

@ -0,0 +1,101 @@
/*
* 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 cpp.NativeString;
using cpp.NativeArray;
@:coreApi
class StringBuf {
private var b:Array<String>;
public var length(get, never):Int;
var charBuf:Array<cpp.Char>;
public function new():Void {}
private function charBufAsString():String {
var len = charBuf.length;
charBuf.push(0);
return NativeString.fromGcPointer(charBuf.address(0), len);
}
private function flush():Void {
if (b == null)
b = [charBufAsString()];
else
b.push(charBufAsString());
charBuf = null;
}
function get_length():Int {
var len = 0;
if (charBuf != null)
len = charBuf.length;
if (b != null)
for (s in b)
len += s == null ? 4 : s.length;
return len;
}
public inline function add<T>(x:T):Void {
if (charBuf != null)
flush();
if (b == null)
b = [Std.string(x)];
else
b.push(Std.string(x));
}
public #if !cppia inline #end function addSub(s:String, pos:Int, ?len:Int):Void {
if (charBuf != null)
flush();
if (b == null)
b = [s.substr(pos, len)];
else
b.push(s.substr(pos, len));
}
public #if !cppia inline #end function addChar(c:Int):Void {
#if hxcpp_smart_strings
if (c >= 127)
add(String.fromCharCode(c));
else
#end
{
if (charBuf == null)
charBuf = new Array<cpp.Char>();
charBuf.push(c);
}
}
public function toString():String {
if (charBuf != null)
flush();
if (b == null || b.length == 0)
return "";
if (b.length == 1)
return b[0];
return b.join("");
}
}

View File

@ -0,0 +1,138 @@
/*
* 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 cpp.NativeSys;
import haxe.SysTools;
@:coreApi class Sys {
public static function print(v:Dynamic):Void {
untyped __global__.__hxcpp_print(v);
}
public static function println(v:Dynamic):Void {
untyped __global__.__hxcpp_println(v);
}
@:access(sys.io.FileInput)
public static function stdin():haxe.io.Input {
return new sys.io.FileInput(cpp.NativeFile.file_stdin());
}
@:access(sys.io.FileOutput)
public static function stdout():haxe.io.Output {
return new sys.io.FileOutput(cpp.NativeFile.file_stdout());
}
@:access(sys.io.FileOutput)
public static function stderr():haxe.io.Output {
return new sys.io.FileOutput(cpp.NativeFile.file_stderr());
}
public static function getChar(echo:Bool):Int {
return NativeSys.sys_getch(echo);
}
public static function args():Array<String>
untyped {
return __global__.__get_args();
}
public static function getEnv(s:String):String {
var v = NativeSys.get_env(s);
if (v == null)
return null;
return v;
}
public static function putEnv(s:String, v:String):Void {
NativeSys.put_env(s, v);
}
public static function sleep(seconds:Float):Void {
NativeSys.sys_sleep(seconds);
}
public static function setTimeLocale(loc:String):Bool {
return NativeSys.set_time_locale(loc);
}
public static function getCwd():String {
return NativeSys.get_cwd();
}
public static function setCwd(s:String):Void {
NativeSys.set_cwd(s);
}
public static function systemName():String {
return NativeSys.sys_string();
}
public static function command(cmd:String, ?args:Array<String>):Int {
if (args == null) {
return NativeSys.sys_command(cmd);
} else {
switch (systemName()) {
case "Windows":
cmd = [
for (a in [StringTools.replace(cmd, "/", "\\")].concat(args))
SysTools.quoteWinArg(a, true)
].join(" ");
return NativeSys.sys_command(cmd);
case _:
cmd = [cmd].concat(args).map(SysTools.quoteUnixArg).join(" ");
return NativeSys.sys_command(cmd);
}
}
}
public static function exit(code:Int):Void {
untyped __global__.__hxcpp_exit(code);
}
public static function time():Float {
return NativeSys.sys_time();
}
public static function cpuTime():Float {
return NativeSys.sys_cpu_time();
}
@:deprecated("Use programPath instead") public static function executablePath():String {
return NativeSys.sys_exe_path();
}
public static function programPath():String {
return NativeSys.sys_exe_path();
}
public static function environment():Map<String, String> {
var vars:Array<String> = NativeSys.sys_env();
var result = new haxe.ds.StringMap<String>();
var i = 0;
while (i < vars.length) {
result.set(vars[i], vars[i + 1]);
i += 2;
}
return result;
}
}

View File

@ -0,0 +1,182 @@
/*
* 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.
*/
enum ValueType {
TNull;
TInt;
TFloat;
TBool;
TObject;
TFunction;
TClass(c:Class<Dynamic>);
TEnum(e:Enum<Dynamic>);
TUnknown;
}
@:coreApi class Type {
public static function getClass<T>(o:T):Class<T>
untyped {
if (o == null || !Reflect.isObject(o))
return null;
var c = o.__GetClass();
switch (c.toString()) {
case "__Anon":
return null;
case "Class":
return null;
}
return c;
}
public static function getEnum(o:EnumValue):Enum<Dynamic>
untyped {
if (o == null)
return null;
return untyped o.__GetClass();
}
public static function getSuperClass(c:Class<Dynamic>):Class<Dynamic>
untyped {
return c.GetSuper();
}
public static function getClassName(c:Class<Dynamic>):String {
if (c == null)
return null;
return untyped c.mName;
}
public static function getEnumName(e:Enum<Dynamic>):String {
return untyped e.__ToString();
}
public static function resolveClass(name:String):Class<Dynamic>
untyped {
var result:Class<Dynamic> = Class.Resolve(name);
if (result != null && result.__IsEnum())
return null;
return result;
}
public static function resolveEnum(name:String):Enum<Dynamic>
untyped {
var result:Class<Dynamic> = Class.Resolve(name);
if (result != null && !result.__IsEnum())
return null;
return result;
}
public static function createInstance<T>(cl:Class<T>, args:Array<Dynamic>):T
untyped {
if (cl != null)
return cl.ConstructArgs(args);
return null;
}
public static function createEmptyInstance<T>(cl:Class<T>):T
untyped {
return cl.ConstructEmpty();
}
public static function createEnum<T>(e:Enum<T>, constr:String, ?params:Array<Dynamic>):T {
return untyped e.ConstructEnum(constr, params);
}
public static function createEnumIndex<T>(e:Enum<T>, index:Int, ?params:Array<Dynamic>):T {
var c = Type.getEnumConstructs(e)[index];
if (c == null)
throw index + " is not a valid enum constructor index";
return createEnum(e, c, params);
}
public static function getInstanceFields(c:Class<Dynamic>):Array<String> {
return untyped c.GetInstanceFields();
}
public static function getClassFields(c:Class<Dynamic>):Array<String> {
return untyped c.GetClassFields();
}
public static function getEnumConstructs(e:Enum<Dynamic>):Array<String>
untyped {
return untyped e.GetClassFields();
}
public static function typeof(v:Dynamic):ValueType
untyped {
if (v == null)
return TNull;
var t:Int = untyped v.__GetType();
switch (t) {
case 2:
return TBool;
case 0xFF:
return TInt;
case 1:
return TFloat;
case 6:
return TFunction;
case 4:
return TObject;
case 7:
return TEnum(v.__GetClass());
default:
return untyped TClass(v.__GetClass());
}
}
@:native("__hxcpp_enum_eq")
extern private static function nativeEnumEq(a:Dynamic, b:Dynamic):Bool;
#if !cppia inline #end
public static function enumEq<T>(a:T, b:T):Bool
return nativeEnumEq(a,b);
public static function enumConstructor(e:EnumValue):String {
var value:cpp.EnumBase = cast e;
return value._hx_getTag();
}
public static function enumParameters(e:EnumValue):Array<Dynamic> {
var value:cpp.EnumBase = cast e;
return value._hx_getParameters();
}
@:native("_hx_getEnumValueIndex")
extern private static function getEnumValueIndex(e:EnumValue):Int;
#if !cppia inline #end public static function enumIndex(e:EnumValue):Int {
return getEnumValueIndex(e);
}
public static function allEnums<T>(e:Enum<T>):Array<T> {
var names:Array<String> = untyped e.GetClassFields();
var enums = new Array<T>();
for (name in names) {
try {
var result:T = untyped e.ConstructEnum(name, null);
if (result != null)
enums.push(result);
} catch (invalidArgCount:String) {}
}
return enums;
}
}

View File

@ -0,0 +1,85 @@
package haxe;
//TODO: extend ::std::exception
@: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:Array<String>;
@: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;
}
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 = NativeStackTrace.toHaxe(__nativeStack, __skipStack);
case s: s;
}
}
}

View File

@ -0,0 +1,418 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe;
import haxe.Int64Helper;
@:notNull
@:include("cpp/Int64.h")
@:native("cpp::Int64Struct")
private extern class ___Int64 {
@:native("_hx_int64_make")
static function make(high:Int32, low:Int32):__Int64;
@:native(" ::cpp::Int64Struct")
static function ofInt(value:Int):__Int64;
@:native(" ::cpp::Int64Struct::is")
static function isInt64(d:Dynamic):Bool;
@:native("_hx_int64_is_neg")
static function isNeg(a:__Int64):Bool;
@:native("_hx_int64_is_zero")
static function isZero(a:__Int64):Bool;
@:native("_hx_int64_compare")
static function compare(a:__Int64, b:__Int64):Int;
@:native("_hx_int64_ucompare")
static function ucompare(a:__Int64, b:__Int64):Int;
@:native("_hx_int64_to_string")
static function toString(a:__Int64):String;
@:native("_hx_int64_neg")
static function neg(a:__Int64):__Int64;
@:native("_hx_int64_pre_increment")
static function preIncrement(a:__Int64):__Int64;
@:native("_hx_int64_post_increment")
static function postIncrement(a:__Int64):__Int64;
@:native("_hx_int64_pre_decrement")
static function preDecrement(a:__Int64):__Int64;
@:native("_hx_int64_post_decrement")
static function postDecrement(a:__Int64):__Int64;
@:native("_hx_int64_add")
static function add(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_add")
static function addInt(a:__Int64, b:Int):__Int64;
@:native("_hx_int64_sub")
static function sub(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_sub")
static function subInt(a:__Int64, b:Int):__Int64;
@:native("_hx_int64_sub")
static function intSub(a:Int, b:__Int64):__Int64;
@:native("_hx_int64_mul")
static function mul(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_div")
static function div(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_mod")
static function mod(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_eq")
static function eq(a:__Int64, b:__Int64):Bool;
@:native("_hx_int64_eq")
static function eqInt(a:__Int64, b:Int):Bool;
@:native("_hx_int64_neq")
static function neq(a:__Int64, b:__Int64):Bool;
@:native("_hx_int64_neq")
static function neqInt(a:__Int64, b:Int):Bool;
@:native("_hx_int64_complement")
static function complement(a:__Int64):__Int64;
@:native("_hx_int64_and")
static function bitAnd(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_or")
static function bitOr(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_xor")
static function bitXor(a:__Int64, b:__Int64):__Int64;
@:native("_hx_int64_shl")
static function shl(a:__Int64, b:Int):__Int64;
@:native("_hx_int64_shr")
static function shr(a:__Int64, b:Int):__Int64;
@:native("_hx_int64_ushr")
static function ushr(a:__Int64, b:Int):__Int64;
@:native("_hx_int64_high")
static function high(a:__Int64):Int32;
@:native("_hx_int64_low")
static function low(a:__Int64):Int32;
}
private typedef __Int64 = ___Int64;
@:coreApi
@:transitive
abstract Int64(__Int64) from __Int64 to __Int64 {
public #if !cppia inline #end function copy():Int64
return this;
public static #if !cppia inline #end function make(high:Int32, low:Int32):Int64 {
return __Int64.make(high, low);
}
@:from
public static #if !cppia inline #end function ofInt(x:Int):Int64 {
return __Int64.ofInt(x);
}
public static #if !cppia inline #end function toInt(x:Int64):Int {
if (x.high != x.low >> 31)
throw "Overflow";
return x.low;
}
@:deprecated('haxe.Int64.is() is deprecated. Use haxe.Int64.isInt64() instead')
inline public static function is(val:Dynamic):Bool {
return isInt64(val);
}
public static #if !cppia inline #end function isInt64(val:Dynamic):Bool
return __Int64.isInt64(val);
@:deprecated("Use high instead")
public static #if !cppia inline #end function getHigh(x:Int64):Int32
return x.high;
@:deprecated("Use low instead")
public static #if !cppia inline #end function getLow(x:Int64):Int32
return x.low;
public static #if !cppia inline #end function isNeg(x:Int64):Bool
return __Int64.isNeg(x);
public static #if !cppia inline #end function isZero(x:Int64):Bool
return __Int64.isZero(x);
public static #if !cppia inline #end function compare(a:Int64, b:Int64):Int
return __Int64.compare(a, b);
public static #if !cppia inline #end function ucompare(a:Int64, b:Int64):Int
return __Int64.ucompare(a, b);
public static #if !cppia inline #end function toStr(x:Int64):String
return x.toString();
private #if !cppia inline #end function toString():String
return __Int64.toString(this);
public static function parseString(sParam:String):Int64 {
return Int64Helper.parseString(sParam);
}
public static function fromFloat(f:Float):Int64 {
return Int64Helper.fromFloat(f);
}
public static function divMod(dividend:Int64, divisor:Int64):{quotient:Int64, modulus:Int64} {
var q = dividend / divisor;
if (isZero(divisor))
throw "divide by zero";
var m = dividend - q * divisor;
return {quotient: q, modulus: m};
}
@:op(-A)
public static #if !cppia inline #end function neg(x:Int64):Int64
return __Int64.neg(x);
@:op(++A) private inline function preIncrement():Int64 {
#if cppia
this = this + make(0, 1);
return this;
#else
return __Int64.preIncrement(this);
#end
}
@:op(A++) private inline function postIncrement():Int64 {
#if cppia
var result = this;
this = this + make(0, 1);
return result;
#else
return __Int64.postIncrement(this);
#end
}
@:op(--A) private inline function preDecrement():Int64 {
#if cppia
untyped this = this - make(0, 1);
return this;
#else
return __Int64.preDecrement(this);
#end
}
@:op(A--) private inline function postDecrement():Int64 {
#if cppia
var result = this;
this = this - make(0, 1);
return result;
#else
return __Int64.postDecrement(this);
#end
}
@:op(A + B)
public static #if !cppia inline #end function add(a:Int64, b:Int64):Int64
return __Int64.add(a, b);
@:op(A + B)
@:commutative
private static #if !cppia inline #end function addInt(a:Int64, b:Int):Int64
return __Int64.addInt(a, b);
@:op(A - B)
public static #if !cppia inline #end function sub(a:Int64, b:Int64):Int64 {
return __Int64.sub(a, b);
}
@:op(A - B)
private static #if !cppia inline #end function subInt(a:Int64, b:Int):Int64
return __Int64.subInt(a, b);
@:op(A - B)
private static #if !cppia inline #end function intSub(a:Int, b:Int64):Int64
return __Int64.intSub(a, b);
@:op(A * B)
public static #if !cppia inline #end function mul(a:Int64, b:Int64):Int64
return __Int64.mul(a, b);
@:op(A * B)
@:commutative
private static #if !cppia inline #end function mulInt(a:Int64, b:Int):Int64
return mul(a, b);
@:op(A / B)
public static #if !cppia inline #end function div(a:Int64, b:Int64):Int64 {
if (__Int64.isZero(b))
throw "divide by zero";
return __Int64.div(a, b);
}
@:op(A / B)
private static #if !cppia inline #end function divInt(a:Int64, b:Int):Int64
return div(a, b);
@:op(A / B)
private static #if !cppia inline #end function intDiv(a:Int, b:Int64):Int64
return toInt(div(a, b));
@:op(A % B)
public static #if !cppia inline #end function mod(a:Int64, b:Int64):Int64 {
if (__Int64.isZero(b))
throw "divide by zero";
return __Int64.mod(a, b);
}
@:op(A % B)
private static #if !cppia inline #end function modInt(a:Int64, b:Int):Int64
return toInt(mod(a, b));
@:op(A % B)
private static #if !cppia inline #end function intMod(a:Int, b:Int64):Int64
return toInt(mod(a, b));
@:op(A == B)
public static #if !cppia inline #end function eq(a:Int64, b:Int64):Bool
return __Int64.eq(a, b);
@:op(A == B)
@:commutative
private static #if !cppia inline #end function eqInt(a:Int64, b:Int):Bool
return __Int64.eqInt(a, b);
@:op(A != B)
public static #if !cppia inline #end function neq(a:Int64, b:Int64):Bool
return __Int64.neq(a, b);
@:op(A != B)
@:commutative
private static #if !cppia inline #end function neqInt(a:Int64, b:Int):Bool
return neq(a, b);
@:op(A < B)
private static #if !cppia inline #end function lt(a:Int64, b:Int64):Bool
return compare(a, b) < 0;
@:op(A < B)
private static #if !cppia inline #end function ltInt(a:Int64, b:Int):Bool
return lt(a, b);
@:op(A < B)
private static #if !cppia inline #end function intLt(a:Int, b:Int64):Bool
return lt(a, b);
@:op(A <= B)
private static #if !cppia inline #end function lte(a:Int64, b:Int64):Bool
return compare(a, b) <= 0;
@:op(A <= B)
private static #if !cppia inline #end function lteInt(a:Int64, b:Int):Bool
return lte(a, b);
@:op(A <= B)
private static #if !cppia inline #end function intLte(a:Int, b:Int64):Bool
return lte(a, b);
@:op(A > B)
private static #if !cppia inline #end function gt(a:Int64, b:Int64):Bool
return compare(a, b) > 0;
@:op(A > B)
private static #if !cppia inline #end function gtInt(a:Int64, b:Int):Bool
return gt(a, b);
@:op(A > B)
private static #if !cppia inline #end function intGt(a:Int, b:Int64):Bool
return gt(a, b);
@:op(A >= B)
private static #if !cppia inline #end function gte(a:Int64, b:Int64):Bool
return compare(a, b) >= 0;
@:op(A >= B)
private static #if !cppia inline #end function gteInt(a:Int64, b:Int):Bool
return gte(a, b);
@:op(A >= B)
private static #if !cppia inline #end function intGte(a:Int, b:Int64):Bool
return gte(a, b);
@:op(~A)
private static #if !cppia inline #end function complement(a:Int64):Int64
return __Int64.complement(a);
@:op(A & B)
public static #if !cppia inline #end function and(a:Int64, b:Int64):Int64
return __Int64.bitAnd(a, b);
@:op(A | B)
public static #if !cppia inline #end function or(a:Int64, b:Int64):Int64
return __Int64.bitOr(a, b);
@:op(A ^ B)
public static #if !cppia inline #end function xor(a:Int64, b:Int64):Int64
return __Int64.bitXor(a, b);
@:op(A << B)
public static #if !cppia inline #end function shl(a:Int64, b:Int):Int64
return __Int64.shl(a, b);
@:op(A >> B)
public static #if !cppia inline #end function shr(a:Int64, b:Int):Int64
return __Int64.shr(a, b);
@:op(A >>> B)
public static #if !cppia inline #end function ushr(a:Int64, b:Int):Int64
return __Int64.ushr(a, b);
public var high(get, never):Int32;
private #if !cppia inline #end function get_high():Int32
return __Int64.high(this);
public var low(get, never):Int32;
private #if !cppia inline #end function get_low():Int32
return __Int64.low(this);
}

View File

@ -0,0 +1,49 @@
/*
* 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 class Log {
@:native("__trace")
extern private static function nativeTrace(message:String, posInfo:Dynamic):Void;
public static dynamic function trace(v:Dynamic, ?infos:PosInfos):Void {
if (infos != null && infos.customParams != null) {
var extra:String = "";
for (v in infos.customParams)
extra += "," + v;
nativeTrace(v + extra, infos);
} else
nativeTrace(v, infos);
}
public static function formatOutput(v:Dynamic, infos:PosInfos):String {
var str = Std.string(v);
if (infos == null)
return str;
var pstr = infos.fileName + ":" + infos.lineNumber;
if (infos != null && infos.customParams != null)
for (v in infos.customParams)
str += ", " + Std.string(v);
return pstr + ": " + str;
}
}

View File

@ -0,0 +1,42 @@
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 {
}
@:noDebug //Do not mess up the exception stack
static public function callStack():Array<String> {
return untyped __global__.__hxcpp_get_call_stack(true);
}
@:noDebug //Do not mess up the exception stack/
static public function exceptionStack():Array<String> {
return untyped __global__.__hxcpp_get_exception_stack();
}
static public function toHaxe(native:Array<String>, skip:Int = 0):Array<StackItem> {
var stack:Array<String> = native;
var m = new Array<StackItem>();
for (i in 0...stack.length) {
if(skip > i) {
continue;
}
var words = stack[i].split("::");
if (words.length == 0)
m.push(CFunction)
else if (words.length == 2)
m.push(Method(words[0], words[1]));
else if (words.length == 4)
m.push(FilePos(Method(words[0], words[1]), words[2], Std.parseInt(words[3])));
}
return m;
}
}

View File

@ -0,0 +1,41 @@
/*
* 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
class Resource {
public static function listNames():Array<String> {
return untyped __global__.__hxcpp_resource_names();
}
public static function getString(name:String):String {
return untyped __global__.__hxcpp_resource_string(name);
}
public static function getBytes(name:String):haxe.io.Bytes {
var array:haxe.io.BytesData = untyped __global__.__hxcpp_resource_bytes(name);
if (array == null)
return null;
return haxe.io.Bytes.ofData(array);
}
}

View File

@ -0,0 +1,85 @@
/*
* 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;
using cpp.NativeString;
@:coreApi
@:deprecated('haxe.Utf8 is deprecated. Use UnicodeString instead.')
class Utf8 {
var __s:Array<Int>;
public function new(?size:Int):Void {
__s = new Array<Int>();
if (size != null && size > 0)
cpp.NativeArray.reserve(__s, size);
}
public function addChar(c:Int):Void {
__s.push(c);
}
public function toString():String {
return untyped __global__.__hxcpp_char_array_to_utf8_string(__s);
}
// Incoming string is array of bytes containing possibly invalid utf8 chars
// Result is the same string with the bytes expanded into utf8 sequences
public static function encode(s:String):String {
return untyped __global__.__hxcpp_char_bytes_to_utf8_string(s);
}
// Incoming string is array of bytes representing valid utf8 chars
// Result is a string containing the compressed bytes
public static function decode(s:String):String {
return untyped __global__.__hxcpp_utf8_string_to_char_bytes(s);
}
public #if !cppia inline #end static function iter(s:String, chars:Int->Void):Void {
var src = s.c_str();
var end = src.add(s.length);
while (src.lt(end))
chars(src.ptr.utf8DecodeAdvance());
}
public static function charCodeAt(s:String, index:Int):Int {
return s.utf8CharCodeAt(index);
}
public static function validate(s:String):Bool {
return s.utf8IsValid();
}
public static function length(s:String):Int {
return s.utf8Length();
}
public static function compare(a:String, b:String):Int {
return a.compare(b);
}
public static function sub(s:String, pos:Int, len:Int):String {
return s.utf8Sub(pos, len);
}
}

View File

@ -0,0 +1,142 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe.ds;
@:headerClassCode("
inline void set(int key, ::null value) { __int_hash_set(HX_MAP_THIS,key,value); }
inline void set(int key, bool value) { __int_hash_set(HX_MAP_THIS,key,value); }
inline void set(int key, char value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, unsigned char value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, signed char value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, short value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, unsigned short value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, int value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, unsigned int value) { __int_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(int key, float value) { __int_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(int key, double value) { __int_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(int key, ::String value) { __int_hash_set_string(HX_MAP_THIS,key,value); }
template<typename V, typename H>
inline void set(int key, const ::cpp::Struct<V,H> &value) {__int_hash_set(HX_MAP_THIS,key,value); }
template<typename F>
inline void set(int key, const ::cpp::Function<F> &value) {__int_hash_set(HX_MAP_THIS,key,value); }
template<typename V>
inline void set(int key, const ::cpp::Pointer<V> &value) {__int_hash_set(HX_MAP_THIS,key,(Dynamic)value ); }
template<typename VALUE>
inline void set(Dynamic &key, const VALUE &value) { set( (int)key, value ); }
inline bool get_bool(int key) { return __int_hash_get_bool(h,key); }
inline int get_int(int key) { return __int_hash_get_int(h,key); }
inline Float get_float(int key) { return __int_hash_get_float(h,key); }
inline String get_string(int key) { return __int_hash_get_string(h,key); }
")
@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
@:ifFeature("haxe.ds.IntMap.*")
private var h:Dynamic;
public function new():Void {}
public function set(key:Int, value:T):Void {
untyped __global__.__int_hash_set(__cpp__("HX_MAP_THIS"), key, value);
}
public function get(key:Int):Null<T> {
return untyped __global__.__int_hash_get(h, key);
}
public function exists(key:Int):Bool {
return untyped __global__.__int_hash_exists(h, key);
}
public function remove(key:Int):Bool {
return untyped __global__.__int_hash_remove(h, key);
}
public function keys():Iterator<Int> {
var a:Array<Int> = untyped __global__.__int_hash_keys(h);
return a.iterator();
}
public function iterator():Iterator<T> {
var a:Array<Dynamic> = untyped __global__.__int_hash_values(h);
return a.iterator();
}
@:runtime public inline function keyValueIterator():KeyValueIterator<Int, T> {
return new haxe.iterators.MapKeyValueIterator(this);
}
public function copy():IntMap<T> {
var copied = new IntMap();
for (key in keys())
copied.set(key, get(key));
return copied;
}
public function toString():String {
return untyped __global__.__int_hash_to_string(h);
}
public function clear():Void {
#if (hxcpp_api_level >= 400)
return untyped __global__.__int_hash_clear(h);
#else
h = null;
#end
}
#if (scriptable)
private function setString(key:Int, val:String):Void {
untyped __int_hash_set_string(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt(key:Int, val:Int):Void {
untyped __int_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setBool(key:Int, val:Bool):Void {
untyped __int_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setFloat(key:Int, val:Float):Void {
untyped __int_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:Int):String {
return untyped __int_hash_get_string(h, key);
}
private function getInt(key:Int):Int {
return untyped __int_hash_get_int(h, key);
}
private function getBool(key:Int):Bool {
return untyped __int_hash_get_bool(h, key);
}
private function getFloat(key:Int):Float {
return untyped __int_hash_get_float(h, key);
}
#end
}

View File

@ -0,0 +1,142 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe.ds;
@:headerClassCode("
inline void set(Dynamic key, ::null value) { __object_hash_set(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, bool value) { __object_hash_set(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, char value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, unsigned char value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, signed char value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, short value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, unsigned short value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, int value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, unsigned int value) { __object_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, float value) { __object_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, double value) { __object_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(Dynamic key, ::String value) { __object_hash_set_string(HX_MAP_THIS,key,value); }
template<typename V, typename H>
inline void set(Dynamic key, const ::cpp::Struct<V,H> &value) {__object_hash_set(HX_MAP_THIS,key,value); }
template<typename V>
inline void set(Dynamic key, const ::cpp::Function<V> &value) {__object_hash_set(HX_MAP_THIS,key,(Dynamic)value ); }
template<typename V>
inline void set(Dynamic key, const ::cpp::Pointer<V> &value) {__object_hash_set(HX_MAP_THIS,key,(Dynamic)value ); }
inline bool get_bool(Dynamic key) { return __object_hash_get_bool(h,key); }
inline int get_int(Dynamic key) { return __object_hash_get_int(h,key); }
inline Float get_float(Dynamic key) { return __object_hash_get_float(h,key); }
inline String get_string(Dynamic key) { return __object_hash_get_string(h,key); }
")
@:coreApi
class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
@:ifFeature("haxe.ds.ObjectMap.*")
private var h:Dynamic;
public function new():Void {}
public function set(key:K, value:V):Void {
untyped __global__.__object_hash_set(__cpp__("HX_MAP_THIS"), key, value);
}
public function get(key:K):Null<V> {
return untyped __global__.__object_hash_get(h, key);
}
public function exists(key:K):Bool {
return untyped __global__.__object_hash_exists(h, key);
}
public function remove(key:K):Bool {
return untyped __global__.__object_hash_remove(h, key);
}
public function keys():Iterator<K> {
var a:Array<K> = untyped __global__.__object_hash_keys(h);
return a.iterator();
}
public function iterator():Iterator<V> {
var a:Array<Dynamic> = untyped __global__.__object_hash_values(h);
return a.iterator();
}
@:runtime public inline function keyValueIterator():KeyValueIterator<K, V> {
return new haxe.iterators.MapKeyValueIterator(this);
}
public function copy():ObjectMap<K, V> {
var copied = new ObjectMap();
for (key in keys())
copied.set(key, get(key));
return copied;
}
public function toString():String {
return untyped __global__.__object_hash_to_string(h);
}
public function clear():Void {
#if (hxcpp_api_level >= 400)
return untyped __global__.__object_hash_clear(h);
#else
h = null;
#end
}
#if (scriptable)
private function setString(key:Dynamic, val:String):Void {
untyped __object_hash_set_string(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt(key:Dynamic, val:Int):Void {
untyped __object_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setBool(key:Dynamic, val:Bool):Void {
untyped __object_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setFloat(key:Dynamic, val:Float):Void {
untyped __object_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:Dynamic):String {
return untyped __object_hash_get_string(h, key);
}
private function getInt(key:Dynamic):Int {
return untyped __object_hash_get_int(h, key);
}
private function getBool(key:Dynamic):Bool {
return untyped __object_hash_get_bool(h, key);
}
private function getFloat(key:Dynamic):Float {
return untyped __object_hash_get_float(h, key);
}
#end
}

View File

@ -0,0 +1,142 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe.ds;
@:headerClassCode("
inline void set(String key, ::null value) { __string_hash_set(HX_MAP_THIS,key,value); }
inline void set(String key, bool value) { __string_hash_set(HX_MAP_THIS,key,value); }
inline void set(String key, char value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, unsigned char value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, signed char value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, short value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, unsigned short value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, int value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, unsigned int value) { __string_hash_set_int(HX_MAP_THIS,key,value); }
inline void set(String key, float value) { __string_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(String key, double value) { __string_hash_set_float(HX_MAP_THIS,key,value); }
inline void set(String key, ::String value) { __string_hash_set_string(HX_MAP_THIS,key,value); }
template<typename V, typename H>
inline void set(String key, const ::cpp::Struct<V,H> &value) {__string_hash_set(HX_MAP_THIS,key,value); }
template<typename V>
inline void set(String key, const ::cpp::Function<V> &value) {__string_hash_set(HX_MAP_THIS,key,(Dynamic)value ); }
template<typename V>
inline void set(String key, const ::cpp::Pointer<V> &value) {__string_hash_set(HX_MAP_THIS,key,(Dynamic)value ); }
template<typename VALUE>
inline void set(Dynamic &key, const VALUE &value) { set( (String)key, value ); }
inline bool get_bool(String key) { return __string_hash_get_bool(h,key); }
inline int get_int(String key) { return __string_hash_get_int(h,key); }
inline Float get_float(String key) { return __string_hash_get_float(h,key); }
inline String get_string(String key) { return __string_hash_get_string(h,key); }
")
@:coreApi class StringMap<T> implements haxe.Constraints.IMap<String, T> {
@:ifFeature("haxe.ds.StringMap.*")
private var h:Dynamic;
public function new():Void {}
public function set(key:String, value:T):Void {
untyped __global__.__string_hash_set(__cpp__("HX_MAP_THIS"), key, value);
}
public function get(key:String):Null<T> {
return untyped __global__.__string_hash_get(h, key);
}
public function exists(key:String):Bool {
return untyped __global__.__string_hash_exists(h, key);
}
public function remove(key:String):Bool {
return untyped __global__.__string_hash_remove(h, key);
}
public function keys():Iterator<String> {
var a:Array<String> = untyped __global__.__string_hash_keys(h);
return a.iterator();
}
public function iterator():Iterator<T> {
var a:Array<Dynamic> = untyped __global__.__string_hash_values(h);
return a.iterator();
}
@:runtime public inline function keyValueIterator():KeyValueIterator<String, T> {
return new haxe.iterators.MapKeyValueIterator(this);
}
public function copy():StringMap<T> {
var copied = new StringMap();
for (key in keys())
copied.set(key, get(key));
return copied;
}
public function toString():String {
return untyped __global__.__string_hash_to_string(h);
}
public function clear():Void {
#if (hxcpp_api_level >= 400)
return untyped __global__.__string_hash_clear(h);
#else
h = null;
#end
}
#if (scriptable)
private function setString(key:String, val:String):Void {
untyped __string_hash_set_string(__cpp__("HX_MAP_THIS"), key, val);
}
private function setInt(key:String, val:Int):Void {
untyped __string_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setBool(key:String, val:Bool):Void {
untyped __string_hash_set_int(__cpp__("HX_MAP_THIS"), key, val);
}
private function setFloat(key:String, val:Float):Void {
untyped __string_hash_set_float(__cpp__("HX_MAP_THIS"), key, val);
}
private function getString(key:String):String {
return untyped __string_hash_get_string(h, key);
}
private function getInt(key:String):Int {
return untyped __string_hash_get_int(h, key);
}
private function getBool(key:String):Bool {
return untyped __string_hash_get_bool(h, key);
}
private function getFloat(key:String):Float {
return untyped __string_hash_get_float(h, key);
}
#end
}

View File

@ -0,0 +1,101 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe.ds;
@:headerClassCode("
inline void set(Dynamic key, ::null value) { __object_hash_set(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, bool value) { __object_hash_set(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, char value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, unsigned char value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, signed char value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, short value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, unsigned short value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, int value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, unsigned int value) { __object_hash_set_int(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, float value) { __object_hash_set_float(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, double value) { __object_hash_set_float(HX_MAP_THIS,key,value,true); }
inline void set(Dynamic key, ::String value) { __object_hash_set_string(HX_MAP_THIS,key,value,true); }
template<typename V, typename H>
inline void set(Dynamic key, const ::cpp::Struct<V,H> &value) {__object_hash_set(HX_MAP_THIS,key,value,true); }
template<typename V>
inline void set(Dynamic key, const ::cpp::Pointer<V> &value) {__object_hash_set(HX_MAP_THIS,key,(Dynamic)value,true ); }
template<typename V>
inline void set(Dynamic key, const ::cpp::Function<V> &value) {__object_hash_set(HX_MAP_THIS,key,(Dynamic)value,true ); }
")
@:coreApi
class WeakMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
@:ifFeature("haxe.ds.WeakMap.*")
private var h:Dynamic;
public function new():Void {}
public function set(key:K, value:V):Void {
untyped __global__.__object_hash_set(__cpp__("HX_MAP_THIS"), key, value, true);
}
public function get(key:K):Null<V> {
return untyped __global__.__object_hash_get(h, key);
}
public function exists(key:K):Bool {
return untyped __global__.__object_hash_exists(h, key);
}
public function remove(key:K):Bool {
return untyped __global__.__object_hash_remove(h, key);
}
public function keys():Iterator<K> {
var a:Array<K> = untyped __global__.__object_hash_keys(h);
return a.iterator();
}
public function iterator():Iterator<V> {
var a:Array<Dynamic> = untyped __global__.__object_hash_values(h);
return a.iterator();
}
public inline function keyValueIterator():KeyValueIterator<K, V> {
return new haxe.iterators.MapKeyValueIterator(this);
}
public function copy():WeakMap<K, V> {
var copied = new WeakMap();
for (key in keys())
copied.set(key, get(key));
return copied;
}
public function toString():String {
return untyped __global__.__object_hash_to_string(h);
}
public function clear():Void {
#if (hxcpp_api_level >= 400)
return untyped __global__.__object_hash_clear(h);
#else
h = null;
#end
}
}

View File

@ -0,0 +1,71 @@
/*
* 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;
@:coreApi @:buildXml('<include name="${HXCPP}/src/hx/libs/zlib/Build.xml" />')
class Compress {
var s:Dynamic;
public function new(level:Int):Void {
s = _deflate_init(level);
}
public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
return _deflate_buffer(s, src.getData(), srcPos, dst.getData(), dstPos);
}
public function setFlushMode(f:FlushMode):Void {
_set_flush_mode(s, Std.string(f));
}
public function close():Void {
_deflate_end(s);
}
public static function run(s:haxe.io.Bytes, level:Int):haxe.io.Bytes {
var c = new Compress(level);
c.setFlushMode(FlushMode.FINISH);
var out = haxe.io.Bytes.alloc(_deflate_bound(c.s, s.length));
var r = c.execute(s, 0, out, 0);
c.close();
if (!r.done || r.read != s.length)
throw "Compression failed";
return out.sub(0, r.write);
}
@:native("_hx_deflate_init")
extern static function _deflate_init(level:Int):Dynamic;
@:native("_hx_deflate_bound")
extern static function _deflate_bound(handle:Dynamic, length:Int):Int;
@:native("_hx_deflate_buffer")
extern static function _deflate_buffer(handle:Dynamic, src:haxe.io.BytesData, srcPos:Int, dest:haxe.io.BytesData,
destPos:Int):{done:Bool, read:Int, write:Int};
@:native("_hx_deflate_end")
extern static function _deflate_end(handle:Dynamic):Void;
@:native("_hx_zip_set_flush_mode")
extern static function _set_flush_mode(handle:Dynamic, flushMode:String):Void;
}

View File

@ -0,0 +1,76 @@
/*
* 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;
@:coreApi @:buildXml('<include name="${HXCPP}/src/hx/libs/zlib/Build.xml"/>')
class Uncompress {
var s:Dynamic;
public function new(?windowBits:Int):Void {
s = _inflate_init(windowBits);
}
public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
return _inflate_buffer(s, src.getData(), srcPos, dst.getData(), dstPos);
}
public function setFlushMode(f:FlushMode):Void {
_set_flush_mode(s, untyped f.__Tag());
}
public function close():Void {
_inflate_end(s);
}
public static function run(src:haxe.io.Bytes, ?bufsize:Int):haxe.io.Bytes {
var u = new Uncompress(null);
if (bufsize == null)
bufsize = 1 << 16; // 64K
var tmp = haxe.io.Bytes.alloc(bufsize);
var b = new haxe.io.BytesBuffer();
var pos = 0;
u.setFlushMode(FlushMode.SYNC);
while (true) {
var r = u.execute(src, pos, tmp, 0);
b.addBytes(tmp, 0, r.write);
pos += r.read;
if (r.done)
break;
}
u.close();
return b.getBytes();
}
@:native("_hx_inflate_init")
extern static function _inflate_init(windowBits:Dynamic):Dynamic;
@:native("_hx_inflate_buffer")
extern static function _inflate_buffer(handle:Dynamic, src:haxe.io.BytesData, srcPos:Int, dest:haxe.io.BytesData,
destPos:Int):{done:Bool, read:Int, write:Int};
@:native("_hx_inflate_end")
extern static function _inflate_end(handle:Dynamic):Void;
@:native("_hx_zip_set_flush_mode")
extern static function _set_flush_mode(handle:Dynamic, flushMode:String):Void;
}

View File

@ -0,0 +1,113 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys;
import cpp.NativeSys;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
@:coreApi
class FileSystem {
public static function exists(path:String):Bool {
return NativeSys.sys_exists(makeCompatiblePath(path));
}
public static function rename(path:String, newPath:String):Void {
NativeSys.sys_rename(path, newPath);
}
public static function stat(path:String):FileStat {
var s:FileStat = NativeSys.sys_stat(makeCompatiblePath(path));
if (s == null)
return {
gid: 0,
uid: 0,
atime: Date.fromTime(0),
mtime: Date.fromTime(0),
ctime: Date.fromTime(0),
dev: 0,
ino: 0,
nlink: 0,
rdev: 0,
size: 0,
mode: 0
};
s.atime = Date.fromTime(1000.0 * (untyped s.atime));
s.mtime = Date.fromTime(1000.0 * (untyped s.mtime));
s.ctime = Date.fromTime(1000.0 * (untyped s.ctime));
return s;
}
public static function fullPath(relPath:String):String {
return NativeSys.file_full_path(relPath);
}
public static function absolutePath(relPath:String):String {
if (haxe.io.Path.isAbsolute(relPath))
return relPath;
return haxe.io.Path.join([Sys.getCwd(), relPath]);
}
inline static function kind(path:String):String {
return NativeSys.sys_file_type(makeCompatiblePath(path));
}
public static function isDirectory(path:String):Bool {
return kind(path) == "dir";
}
public static function createDirectory(path:String):Void {
var path = haxe.io.Path.addTrailingSlash(path);
var _p = null;
var parts = [];
while (path != (_p = haxe.io.Path.directory(path))) {
parts.unshift(path);
path = _p;
}
for (part in parts) {
if (part.charCodeAt(part.length - 1) != ":".code && !exists(part) && !NativeSys.sys_create_dir(part, 493))
throw "Could not create directory:" + part;
}
}
public static function deleteFile(path:String):Void {
NativeSys.file_delete(path);
}
public static function deleteDirectory(path:String):Void {
NativeSys.sys_remove_dir(path);
}
public static function readDirectory(path:String):Array<String> {
return NativeSys.sys_read_dir(path);
}
private static inline function makeCompatiblePath(path:String):String {
return if (path.charCodeAt(1) == ":".code && path.length <= 3) {
haxe.io.Path.addTrailingSlash(path);
} else if (path == "/") {
"/";
} else {
haxe.io.Path.removeTrailingSlashes(path);
}
}
}

View File

@ -0,0 +1,228 @@
/*
* 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.db;
@:keep
private class D {
@:native("_hx_mysql_connect")
extern public static function connect(params:Dynamic):Dynamic;
@:native("_hx_mysql_select_db")
extern public static function select_db(handle:Dynamic, db:String):Void;
@:native("_hx_mysql_request")
extern public static function request(handle:Dynamic, req:String):Dynamic;
@:native("_hx_mysql_close")
extern public static function close(handle:Dynamic):Dynamic;
@:native("_hx_mysql_escape")
extern public static function escape(handle:Dynamic, str:String):String;
@:native("_hx_mysql_result_get_length")
extern public static function result_get_length(handle:Dynamic):Int;
@:native("_hx_mysql_result_get_nfields")
extern public static function result_get_nfields(handle:Dynamic):Int;
@:native("_hx_mysql_result_next")
extern public static function result_next(handle:Dynamic):Dynamic;
@:native("_hx_mysql_result_get")
extern public static function result_get(handle:Dynamic, i:Int):String;
@:native("_hx_mysql_result_get_int")
extern public static function result_get_int(handle:Dynamic, i:Int):Int;
@:native("_hx_mysql_result_get_float")
extern public static function result_get_float(handle:Dynamic, i:Int):Float;
@:native("_hx_mysql_result_get_fields_names")
extern public static function result_fields_names(handle:Dynamic):Array<String>;
@:native("_hx_mysql_set_conversion")
extern public static function set_conv_funs(charsToBytes:cpp.Callable<Dynamic->Dynamic>, intToDate:cpp.Callable<Float->Dynamic>):Void;
public static function charsToBytes(data:Dynamic):Dynamic
return haxe.io.Bytes.ofData(data);
public static function secondsToDate(seconds:Float):Dynamic
return Date.fromTime(seconds * 1000);
}
private class MysqlResultSet implements sys.db.ResultSet {
public var length(get, null):Int;
public var nfields(get, null):Int;
private var __r:Dynamic;
private var cache:Dynamic;
public function new(r:Dynamic) {
__r = r;
}
private function get_length() {
return D.result_get_length(__r);
}
private function get_nfields() {
return D.result_get_nfields(__r);
}
public function hasNext() {
if (cache == null)
cache = next();
return (cache != null);
}
public function next():Dynamic {
var c = cache;
if (c != null) {
cache = null;
return c;
}
c = D.result_next(__r);
return c;
}
public function results():List<Dynamic> {
var l = new List();
while (hasNext())
l.add(next());
return l;
}
public function getResult(n:Int) {
return D.result_get(__r, n);
}
public function getIntResult(n:Int):Int {
return D.result_get_int(__r, n);
}
public function getFloatResult(n:Int):Float {
return D.result_get_float(__r, n);
}
public function getFieldsNames():Array<String> {
var a = D.result_fields_names(__r);
return a;
}
}
private class MysqlConnection implements sys.db.Connection {
private var __c:Dynamic;
public function new(c:Dynamic) {
__c = c;
D.set_conv_funs(cpp.Function.fromStaticFunction(D.charsToBytes), cpp.Function.fromStaticFunction(D.secondsToDate));
}
public function request(s:String):sys.db.ResultSet {
var r = D.request(this.__c, s);
return new MysqlResultSet(r);
}
public function close() {
D.close(__c);
}
public function escape(s:String) {
return D.escape(__c, s);
}
public function quote(s:String) {
return "'" + escape(s) + "'";
}
public function addValue(s:StringBuf, v:Dynamic) {
if (v == null) {
s.add(v);
} else if (Std.isOfType(v, Bool)) {
s.add(v ? 1 : 0);
} else {
var t:Int = untyped v.__GetType();
if (t == 0xff)
s.add(v);
else if (t == 2)
s.add(untyped v.__GetInt() ? "1".code : "0".code);
else {
s.addChar("'".code);
s.add(escape(Std.string(v)));
s.addChar("'".code);
}
}
}
public function lastInsertId() {
return request("SELECT LAST_INSERT_ID()").getIntResult(0);
}
public function dbName() {
return "MySQL";
}
public function startTransaction() {
request("START TRANSACTION");
}
public function commit() {
request("COMMIT");
}
public function rollback() {
request("ROLLBACK");
}
private static var __use_date = Date;
}
@:buildXml('<include name="${HXCPP}/src/hx/libs/mysql/Build.xml"/>')
@:coreApi class Mysql {
public static function connect(params:{
host:String,
?port:Int,
user:String,
pass:String,
?socket:String,
?database:String
}):sys.db.Connection {
var o = {
host: params.host,
port: if (params.port == null) 3306 else params.port,
user: params.user,
pass: params.pass,
socket: if (params.socket == null) null else params.socket
};
var c = D.connect(o);
if (params.database != null) {
try {
D.select_db(c, params.database);
} catch (e:Dynamic) {
D.close(c);
cpp.Lib.rethrow(e);
}
}
return new MysqlConnection(c);
}
}

View File

@ -0,0 +1,203 @@
/*
* 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.db;
private class SqliteConnection implements Connection {
var c:Dynamic;
public function new(file:String) {
c = _connect(file);
}
public function close() {
_close(c);
}
public function request(s:String):ResultSet {
try {
return new SqliteResultSet(_request(c, s));
} catch (e:String) {
throw "Error while executing " + s + " (" + e + ")";
}
}
public function escape(s:String) {
return s.split("'").join("''");
}
public function quote(s:String) {
if (s.indexOf("\000") >= 0) {
var hexChars = new Array<String>();
for (i in 0...s.length)
hexChars.push(StringTools.hex(StringTools.fastCodeAt(s, i), 2));
return "x'" + hexChars.join("") + "'";
}
return "'" + s.split("'").join("''") + "'";
}
public function addValue(s:StringBuf, v:Dynamic) {
if (v == null) {
s.add(v);
} else if (Std.isOfType(v, Bool)) {
s.add(v ? 1 : 0);
} else {
var t:Int = untyped v.__GetType();
if (t == 0xff)
s.add(v);
else if (t == 2)
s.add(untyped v.__GetInt());
else
s.add(quote(Std.string(v)));
}
}
public function lastInsertId():Int {
return _last_id(c);
}
public function dbName() {
return "SQLite";
}
public function startTransaction() {
request("BEGIN TRANSACTION");
}
public function commit() {
request("COMMIT");
}
public function rollback() {
request("ROLLBACK");
}
@:native("_hx_sqlite_connect")
extern public static function _connect(filename:String):Dynamic;
@:native("_hx_sqlite_request")
extern public static function _request(handle:Dynamic, req:String):Dynamic;
@:native("_hx_sqlite_close")
extern public static function _close(handle:Dynamic):Void;
@:native("_hx_sqlite_last_insert_id")
extern public static function _last_id(handle:Dynamic):Int;
}
private class SqliteResultSet implements ResultSet {
public var length(get, null):Int;
public var nfields(get, null):Int;
var r:Dynamic;
var cache:List<Dynamic>;
public function new(r:Dynamic) {
cache = new List();
this.r = r;
hasNext(); // execute the request
}
function get_length() {
if (nfields != 0) {
while (true) {
var c = result_next(r);
if (c == null)
break;
cache.add(c);
}
return cache.length;
}
return result_get_length(r);
}
function get_nfields() {
return result_get_nfields(r);
}
public function hasNext() {
var c = next();
if (c == null)
return false;
cache.push(c);
return true;
}
public function next():Dynamic {
var c = cache.pop();
if (c != null)
return c;
return result_next(r);
}
public function results():List<Dynamic> {
var l = new List();
while (true) {
var c = next();
if (c == null)
break;
l.add(c);
}
return l;
}
public function getResult(n:Int) {
return new String(result_get(r, n));
}
public function getIntResult(n:Int):Int {
return result_get_int(r, n);
}
public function getFloatResult(n:Int):Float {
return result_get_float(r, n);
}
public function getFieldsNames():Array<String> {
throw new haxe.exceptions.NotImplementedException();
}
@:native("_hx_sqlite_result_next")
extern public static function result_next(handle:Dynamic):Dynamic;
@:native("_hx_sqlite_result_get_length")
extern public static function result_get_length(handle:Dynamic):Int;
@:native("_hx_sqlite_result_get_nfields")
extern public static function result_get_nfields(handle:Dynamic):Int;
@:native("_hx_sqlite_result_get")
extern public static function result_get(handle:Dynamic, i:Int):String;
@:native("_hx_sqlite_result_get_int")
extern public static function result_get_int(handle:Dynamic, i:Int):Int;
@:native("_hx_sqlite_result_get_float")
extern public static function result_get_float(handle:Dynamic, i:Int):Float;
}
@:buildXml('<include name="${HXCPP}/src/hx/libs/sqlite/Build.xml"/>')
@:coreApi class Sqlite {
public static function open(file:String):Connection {
return new SqliteConnection(file);
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
import cpp.NativeFile;
@:coreApi
class File {
public static function getContent(path:String):String {
return NativeFile.file_contents_string(path);
}
public static function getBytes(path:String):haxe.io.Bytes {
var data = NativeFile.file_contents_bytes(path);
return haxe.io.Bytes.ofData(data);
}
public static function saveContent(path:String, content:String):Void {
var f = write(path);
f.writeString(content);
f.close();
}
public static function saveBytes(path:String, bytes:haxe.io.Bytes):Void {
var f = write(path);
f.write(bytes);
f.close();
}
public static function read(path:String, binary:Bool = true):FileInput {
return untyped new FileInput(NativeFile.file_open(path, (if (binary) "rb" else "r")));
}
public static function write(path:String, binary:Bool = true):FileOutput {
return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "wb" else "w")));
}
public static function append(path:String, binary:Bool = true):FileOutput {
return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "ab" else "a")));
}
public static function update(path:String, binary:Bool = true):FileOutput {
if (!FileSystem.exists(path)) {
write(path).close();
}
return untyped new FileOutput(NativeFile.file_open(path, (if (binary) "rb+" else "r+")));
}
public static function copy(srcPath:String, dstPath:String):Void {
var s = read(srcPath, true);
var d = write(dstPath, true);
d.writeInput(s);
s.close();
d.close();
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
import sys.io.FileSeek;
import cpp.NativeFile;
@:coreApi
class FileInput extends haxe.io.Input {
private var __f:Dynamic;
function new(f:Dynamic):Void {
__f = f;
}
public override function readByte():Int {
return try {
NativeFile.file_read_char(__f);
} catch (e:Dynamic) {
if (untyped e.__IsArray())
throw new haxe.io.Eof();
else
throw haxe.io.Error.Custom(e);
}
}
public override function readBytes(s:haxe.io.Bytes, p:Int, l:Int):Int {
return try {
NativeFile.file_read(__f, s.getData(), p, l);
} catch (e:Dynamic) {
if (untyped e.__IsArray())
throw new haxe.io.Eof();
else
throw haxe.io.Error.Custom(e);
}
}
public override function close():Void {
super.close();
NativeFile.file_close(__f);
}
public function seek(p:Int, pos:FileSeek):Void {
NativeFile.file_seek(__f, p, pos == SeekBegin ? 0 : pos == SeekCur ? 1 : 2);
}
public function tell():Int {
return NativeFile.file_tell(__f);
}
public function eof():Bool {
return NativeFile.file_eof(__f);
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
import sys.io.FileSeek;
import cpp.NativeFile;
@:coreApi
class FileOutput extends haxe.io.Output {
private var __f:Dynamic;
function new(f:Dynamic):Void {
__f = f;
}
public override function writeByte(c:Int):Void {
try
NativeFile.file_write_char(__f, c)
catch (e:Dynamic)
throw haxe.io.Error.Custom(e);
}
public override function writeBytes(s:haxe.io.Bytes, p:Int, l:Int):Int {
return try NativeFile.file_write(__f, s.getData(), p, l) catch (e:Dynamic) throw haxe.io.Error.Custom(e);
}
public override function flush():Void {
NativeFile.file_flush(__f);
}
public override function close():Void {
super.close();
NativeFile.file_close(__f);
}
public function seek(p:Int, pos:FileSeek):Void {
NativeFile.file_seek(__f, p, pos == SeekBegin ? 0 : pos == SeekCur ? 1 : 2);
}
public function tell():Int {
return NativeFile.file_tell(__f);
}
}

View File

@ -0,0 +1,120 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
import cpp.NativeProcess;
private class Stdin extends haxe.io.Output {
var p:Dynamic;
var buf:haxe.io.Bytes;
public function new(p:Dynamic) {
this.p = p;
buf = haxe.io.Bytes.alloc(1);
}
public override function close() {
super.close();
NativeProcess.process_stdin_close(p);
}
public override function writeByte(c) {
buf.set(0, c);
writeBytes(buf, 0, 1);
}
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
try {
return NativeProcess.process_stdin_write(p, buf.getData(), pos, len);
} catch (e:Dynamic) {
throw new haxe.io.Eof();
}
return 0;
}
}
private class Stdout extends haxe.io.Input {
var p:Dynamic;
var out:Bool;
var buf:haxe.io.Bytes;
public function new(p:Dynamic, out) {
this.p = p;
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(str:haxe.io.Bytes, pos:Int, len:Int):Int {
var result:Int;
try {
result = out ? NativeProcess.process_stdout_read(p, str.getData(), pos, len) : NativeProcess.process_stderr_read(p, str.getData(), pos, len);
} catch (e:Dynamic) {
throw new haxe.io.Eof();
}
if (result == 0)
throw new haxe.io.Eof();
return result;
}
}
@:coreApi
class Process {
var p:Dynamic;
public var stdout(default, null):haxe.io.Input;
public var stderr(default, null):haxe.io.Input;
public var stdin(default, null):haxe.io.Output;
public function new(cmd:String, ?args:Array<String>, ?detached:Bool):Void {
if (detached)
throw "Detached process is not supported on this platform";
p = try NativeProcess.process_run(cmd, args) catch (e:Dynamic) throw "Process creation failure : " + cmd;
stdin = new Stdin(p);
stdout = new Stdout(p, true);
stderr = new Stdout(p, false);
}
public function getPid():Int {
return NativeProcess.process_pid(p);
}
public function exitCode(block:Bool = true):Null<Int> {
if (block == false)
throw "Non blocking exitCode() not supported on this platform";
return NativeProcess.process_exit(p);
}
public function close():Void {
NativeProcess.process_close(p);
}
public function kill():Void {
NativeProcess.process_kill(p);
}
}

View File

@ -0,0 +1,59 @@
/*
* 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 cpp.NativeSocket;
@:coreApi
class Host {
public var host(default, null):String;
public var ip(default, null):Int;
private var ipv6(default, null):haxe.io.BytesData;
public function new(name:String):Void {
host = name;
try {
ip = NativeSocket.host_resolve(name);
} catch (e:Dynamic) {
ipv6 = NativeSocket.host_resolve_ipv6(name);
}
}
public function toString():String {
return ipv6 == null ? NativeSocket.host_to_string(ip) : NativeSocket.host_to_string_ipv6(ipv6);
}
public function reverse():String {
return ipv6 == null ? NativeSocket.host_reverse(ip) : NativeSocket.host_reverse_ipv6(ipv6);
}
public static function localhost():String {
return NativeSocket.host_local();
}
static function __init__():Void {
NativeSocket.socket_init();
}
}

View File

@ -0,0 +1,273 @@
/*
* 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 cpp.NativeSocket;
import cpp.NativeString;
import cpp.Pointer;
private class SocketInput extends haxe.io.Input {
var __s:Dynamic;
public function new(s:Dynamic) {
__s = s;
}
public override function readByte() {
return try {
NativeSocket.socket_recv_char(__s);
} catch (e:Dynamic) {
if (e == "Blocking")
throw Blocked;
else if (__s == null)
throw Custom(e);
else
throw new haxe.io.Eof();
}
}
public override function readBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
var r;
if (__s == null)
throw "Invalid handle";
try {
r = NativeSocket.socket_recv(__s, buf.getData(), 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();
if (__s != null)
NativeSocket.socket_close(__s);
}
}
private class SocketOutput extends haxe.io.Output {
var __s:Dynamic;
public function new(s:Dynamic) {
__s = s;
}
public override function writeByte(c:Int) {
if (__s == null)
throw "Invalid handle";
try {
NativeSocket.socket_send_char(__s, c);
} catch (e:Dynamic) {
if (e == "Blocking")
throw Blocked;
else
throw Custom(e);
}
}
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
return try {
NativeSocket.socket_send(__s, buf.getData(), pos, len);
} catch (e:Dynamic) {
if (e == "Blocking")
throw Blocked;
else if (e == "EOF")
throw new haxe.io.Eof();
else
throw Custom(e);
}
}
public override function close() {
super.close();
if (__s != null)
NativeSocket.socket_close(__s);
}
}
@:coreApi
class Socket {
private var __s:Dynamic;
// We need to keep these values so that we can restore
// them if we re-create the socket for ipv6 as in
// connect() and bind() below.
private var __timeout:Float = 0.0;
private var __blocking:Bool = true;
private var __fastSend:Bool = false;
public var input(default, null):haxe.io.Input;
public var output(default, null):haxe.io.Output;
public var custom:Dynamic;
public function new():Void {
init();
}
private function init():Void {
if (__s == null)
__s = NativeSocket.socket_new(false);
// Restore these values if they changed. This can happen
// in connect() and bind() if using an ipv6 address.
setTimeout(__timeout);
setBlocking(__blocking);
setFastSend(__fastSend);
input = new SocketInput(__s);
output = new SocketOutput(__s);
}
public function close():Void {
NativeSocket.socket_close(__s);
untyped {
var input:SocketInput = cast input;
var output:SocketOutput = cast output;
input.__s = null;
output.__s = null;
}
input.close();
output.close();
}
public function read():String {
var bytes:haxe.io.BytesData = NativeSocket.socket_read(__s);
if (bytes == null)
return "";
var arr:Array<cpp.Char> = cast bytes;
return NativeString.fromPointer(Pointer.ofArray(arr));
}
public function write(content:String):Void {
NativeSocket.socket_write(__s, haxe.io.Bytes.ofString(content).getData());
}
public function connect(host:Host, port:Int):Void {
try {
if (host.ip == 0 && host.host != "0.0.0.0") {
// hack, hack, hack
var ipv6:haxe.io.BytesData = Reflect.field(host, "ipv6");
if (ipv6 != null) {
close();
__s = NativeSocket.socket_new_ip(false, true);
init();
NativeSocket.socket_connect_ipv6(__s, ipv6, port);
} else
throw "Unresolved host";
} else
NativeSocket.socket_connect(__s, host.ip, port);
} catch (s:String) {
if (s == "Invalid socket handle")
throw "Failed to connect on " + host.toString() + ":" + port;
else if (s == "Blocking") {
// Do nothing, this is not a real error, it simply indicates
// that a non-blocking connect is in progress
} else
cpp.Lib.rethrow(s);
}
}
public function listen(connections:Int):Void {
NativeSocket.socket_listen(__s, connections);
}
public function shutdown(read:Bool, write:Bool):Void {
NativeSocket.socket_shutdown(__s, read, write);
}
public function bind(host:Host, port:Int):Void {
if (host.ip == 0 && host.host != "0.0.0.0") {
var ipv6:haxe.io.BytesData = Reflect.field(host, "ipv6");
if (ipv6 != null) {
close();
__s = NativeSocket.socket_new_ip(false, true);
init();
NativeSocket.socket_bind_ipv6(__s, ipv6, port);
} else
throw "Unresolved host";
} else
NativeSocket.socket_bind(__s, host.ip, port);
}
public function accept():Socket {
var c = NativeSocket.socket_accept(__s);
var s = Type.createEmptyInstance(Socket);
s.__s = c;
s.input = new SocketInput(c);
s.output = new SocketOutput(c);
return s;
}
public function peer():{host:Host, port:Int} {
var a:Dynamic = NativeSocket.socket_peer(__s);
if (a == null) {
return null;
}
var h = new Host("127.0.0.1");
untyped h.ip = a[0];
return {host: h, port: a[1]};
}
public function host():{host:Host, port:Int} {
var a:Dynamic = NativeSocket.socket_host(__s);
if (a == null) {
return null;
}
var h = new Host("127.0.0.1");
untyped h.ip = a[0];
return {host: h, port: a[1]};
}
public function setTimeout(timeout:Float):Void {
__timeout = timeout;
NativeSocket.socket_set_timeout(__s, timeout);
}
public function waitForRead():Void {
select([this], null, null, null);
}
public function setBlocking(b:Bool):Void {
__blocking = b;
NativeSocket.socket_set_blocking(__s, b);
}
public function setFastSend(b:Bool):Void {
__fastSend = b;
NativeSocket.socket_set_fast_send(__s, 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>} {
var neko_array = NativeSocket.socket_select(read, write, others, timeout);
if (neko_array == null)
throw "Select error";
return @:fixed {
read:neko_array[0], write:neko_array[1], others:neko_array[2]
};
}
}

View 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 sys.net;
import haxe.io.Error;
import cpp.NativeSocket;
@:coreApi
class UdpSocket extends Socket {
private override function init():Void {
__s = NativeSocket.socket_new(true);
super.init();
}
public function sendTo(buf:haxe.io.Bytes, pos:Int, len:Int, addr:Address):Int {
return try {
NativeSocket.socket_send_to(__s, buf.getData(), pos, len, addr);
} catch (e:Dynamic) {
if (e == "Blocking")
throw Blocked;
else
throw Custom(e);
}
}
public function readFrom(buf:haxe.io.Bytes, pos:Int, len:Int, addr:Address):Int {
var r;
try {
r = NativeSocket.socket_recv_from(__s, buf.getData(), pos, len, addr);
} catch (e:Dynamic) {
if (e == "Blocking")
throw Blocked;
else
throw Custom(e);
}
if (r == 0)
throw new haxe.io.Eof();
return r;
}
public function setBroadcast(b:Bool):Void {
NativeSocket.socket_set_broadcast(__s, b);
}
}

View File

@ -0,0 +1,136 @@
/*
* 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 cpp.NativeSsl;
@:coreApi
class Certificate {
var __h:Null<Certificate>;
var __x:Dynamic;
@:allow(sys.ssl.Socket)
function new(x:Dynamic, ?h:Certificate) {
__x = x;
__h = h;
}
public static function loadFile(file:String):Certificate {
return new Certificate(NativeSsl.cert_load_file(file));
}
public static function loadPath(path:String):Certificate {
return new Certificate(NativeSsl.cert_load_path(path));
}
public static function fromString(str:String):Certificate {
return new Certificate(NativeSsl.cert_add_pem(null, str));
}
public static function loadDefaults():Certificate {
var x = NativeSsl.cert_load_defaults();
if (x != null)
return new Certificate(x);
var defPaths = null;
switch (Sys.systemName()) {
case "Linux":
defPaths = [
"/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":
defPaths = [
"/usr/local/share/certs/ca-root-nss.crt", // FreeBSD/DragonFly
"/etc/ssl/cert.pem", // OpenBSD
"/etc/openssl/certs/ca-certificates.crt", // NetBSD
];
case "Android":
defPaths = ["/system/etc/security/cacerts"];
default:
}
if (defPaths != null) {
for (path in defPaths) {
if (sys.FileSystem.exists(path)) {
if (sys.FileSystem.isDirectory(path))
return loadPath(path);
else
return loadFile(path);
}
}
}
return null;
}
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;
function get_commonName():Null<String> {
return subject("CN");
}
function get_altNames():Array<String> {
return NativeSsl.cert_get_altnames(__x);
}
public function subject(field:String):Null<String> {
return NativeSsl.cert_get_subject(__x, field);
}
public function issuer(field:String):Null<String> {
return NativeSsl.cert_get_issuer(__x, field);
}
function get_notBefore():Date {
var a = NativeSsl.cert_get_notbefore(__x);
return new Date(a[0], a[1] - 1, a[2], a[3], a[4], a[5]);
}
function get_notAfter():Date {
var a = NativeSsl.cert_get_notafter(__x);
return new Date(a[0], a[1] - 1, a[2], a[3], a[4], a[5]);
}
public function next():Null<Certificate> {
var n = NativeSsl.cert_get_next(__x);
return n == null ? null : new Certificate(n, __h == null ? this : __h);
}
public function add(pem:String):Void {
NativeSsl.cert_add_pem(__x, pem);
}
public function addDER(der:haxe.io.Bytes):Void {
NativeSsl.cert_add_der(__x, der.getData());
}
static function __init__():Void {
NativeSsl.init();
}
}

View File

@ -0,0 +1,40 @@
/*
* 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 cpp.NativeSsl;
@:coreApi
class Digest {
public static function make(data:haxe.io.Bytes, alg:DigestAlgorithm):haxe.io.Bytes {
return haxe.io.Bytes.ofData(NativeSsl.dgst_make(data.getData(), alg));
}
public static function sign(data:haxe.io.Bytes, privKey:Key, alg:DigestAlgorithm):haxe.io.Bytes {
return haxe.io.Bytes.ofData(NativeSsl.dgst_sign(data.getData(), @:privateAccess privKey.__k, alg));
}
public static function verify(data:haxe.io.Bytes, signature:haxe.io.Bytes, pubKey:Key, alg:DigestAlgorithm):Bool {
return NativeSsl.dgst_verify(data.getData(), signature.getData(), @:privateAccess pubKey.__k, alg);
}
}

View File

@ -0,0 +1,57 @@
/*
* 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 cpp.NativeSsl;
private typedef PKEY = Dynamic;
@:coreApi
class Key {
private var __k:PKEY;
private function new(k:PKEY) {
__k = k;
}
public static function loadFile(file:String, ?isPublic:Bool, ?pass:String):Key {
var data = sys.io.File.getBytes(file);
var str = cpp.Lib.stringReference(data);
if (str.indexOf("-----BEGIN ") >= 0)
return readPEM(str, isPublic == true, pass);
else
return readDER(data, isPublic == true);
}
public static function readPEM(data:String, isPublic:Bool, ?pass:String):Key {
return new Key(NativeSsl.key_from_pem(data, isPublic, pass));
}
public static function readDER(data:haxe.io.Bytes, isPublic:Bool):Key {
return new Key(NativeSsl.key_from_der(data.getData(), isPublic));
}
static function __init__():Void {
NativeSsl.init();
}
}

View File

@ -0,0 +1,297 @@
/*
* 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 cpp.NativeSocket;
import cpp.NativeSsl;
private typedef SocketHandle = Dynamic;
private typedef CONF = Dynamic;
private typedef SSL = Dynamic;
private class SocketInput extends haxe.io.Input {
@:allow(sys.ssl.Socket) private var __s:Socket;
public function new(s:Socket) {
this.__s = s;
}
public override function readByte() {
return try {
__s.handshake();
NativeSsl.ssl_recv_char(@:privateAccess __s.ssl);
} catch (e:Dynamic) {
if (e == "Blocking")
throw haxe.io.Error.Blocked;
else if (__s == null)
throw haxe.io.Error.Custom(e);
else
throw new haxe.io.Eof();
}
}
public override function readBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
var r:Int;
if (__s == null)
throw "Invalid handle";
try {
__s.handshake();
r = NativeSsl.ssl_recv(@:privateAccess __s.ssl, buf.getData(), pos, len);
} catch (e:Dynamic) {
if (e == "Blocking")
throw haxe.io.Error.Blocked;
else
throw haxe.io.Error.Custom(e);
}
if (r == 0)
throw new haxe.io.Eof();
return r;
}
public override function close() {
super.close();
if (__s != null)
__s.close();
}
}
private class SocketOutput extends haxe.io.Output {
@:allow(sys.ssl.Socket) private var __s:Socket;
public function new(s:Socket) {
this.__s = s;
}
public override function writeByte(c:Int) {
if (__s == null)
throw "Invalid handle";
try {
__s.handshake();
NativeSsl.ssl_send_char(@:privateAccess __s.ssl, c);
} catch (e:Dynamic) {
if (e == "Blocking")
throw haxe.io.Error.Blocked;
else
throw haxe.io.Error.Custom(e);
}
}
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
return try {
__s.handshake();
NativeSsl.ssl_send(@:privateAccess __s.ssl, buf.getData(), pos, len);
} catch (e:Dynamic) {
if (e == "Blocking")
throw haxe.io.Error.Blocked;
else
throw haxe.io.Error.Custom(e);
}
}
public override function close() {
super.close();
if (__s != null)
__s.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:CONF;
private var ssl:SSL;
public var verifyCert:Null<Bool>;
private var caCert:Null<Certificate>;
private var hostname:String;
private var ownCert:Null<Certificate>;
private var ownKey:Null<Key>;
private var altSNIContexts:Null<Array<{match:String->Bool, key:Key, cert:Certificate}>>;
private var sniCallback:Dynamic;
private var handshakeDone:Bool;
private override function init():Void {
__s = NativeSocket.socket_new(false);
input = new SocketInput(this);
output = new SocketOutput(this);
if (DEFAULT_VERIFY_CERT && DEFAULT_CA == null) {
try {
DEFAULT_CA = Certificate.loadDefaults();
} catch (e:Dynamic) {}
}
caCert = DEFAULT_CA;
verifyCert = DEFAULT_VERIFY_CERT;
}
public override function connect(host:sys.net.Host, port:Int):Void {
try {
conf = buildSSLConfig(false);
ssl = NativeSsl.ssl_new(conf);
handshakeDone = false;
NativeSsl.ssl_set_socket(ssl, __s);
if (hostname == null)
hostname = host.host;
if (hostname != null)
NativeSsl.ssl_set_hostname(ssl, hostname);
NativeSocket.socket_connect(__s, host.ip, port);
handshake();
} catch (s:String) {
if (s == "Invalid socket handle")
throw "Failed to connect on " + host.host + ":" + port;
else
cpp.Lib.rethrow(s);
} catch (e:Dynamic) {
cpp.Lib.rethrow(e);
}
}
public function handshake():Void {
if (!handshakeDone) {
try {
NativeSsl.ssl_handshake(ssl);
handshakeDone = true;
} catch (e:Dynamic) {
if (e == "Blocking")
throw haxe.io.Error.Blocked;
else
cpp.Lib.rethrow(e);
}
}
}
public function setCA(cert:Certificate):Void {
caCert = cert;
}
public function setHostname(name:String):Void {
hostname = name;
}
public function setCertificate(cert:Certificate, key:Key):Void {
ownCert = cert;
ownKey = key;
}
public override function read():String {
handshake();
var b = NativeSsl.ssl_read(ssl);
if (b == null)
return "";
return haxe.io.Bytes.ofData(b).toString();
}
public override function write(content:String):Void {
handshake();
NativeSsl.ssl_write(ssl, haxe.io.Bytes.ofString(content).getData());
}
public override function close():Void {
if (ssl != null)
NativeSsl.ssl_close(ssl);
if (conf != null)
NativeSsl.conf_close(conf);
if (altSNIContexts != null)
sniCallback = null;
NativeSocket.socket_close(__s);
var input:SocketInput = cast input;
var output:SocketOutput = cast output;
@:privateAccess input.__s = output.__s = null;
input.close();
output.close();
}
public function addSNICertificate(cbServernameMatch:String->Bool, cert:Certificate, key:Key):Void {
if (altSNIContexts == null)
altSNIContexts = [];
altSNIContexts.push({match: cbServernameMatch, cert: cert, key: key});
}
public override function bind(host:sys.net.Host, port:Int):Void {
conf = buildSSLConfig(true);
NativeSocket.socket_bind(__s, host.ip, port);
}
public override function accept():Socket {
var c = NativeSocket.socket_accept(__s);
var ssl = NativeSsl.ssl_new(conf);
NativeSsl.ssl_set_socket(ssl, c);
var s = Type.createEmptyInstance(sys.ssl.Socket);
s.__s = c;
s.ssl = ssl;
s.input = new SocketInput(s);
s.output = new SocketOutput(s);
s.handshakeDone = false;
return s;
}
public function peerCertificate():sys.ssl.Certificate {
var x = NativeSsl.ssl_get_peer_certificate(ssl);
return x == null ? null : new sys.ssl.Certificate(x);
}
private function buildSSLConfig(server:Bool):CONF {
var conf:CONF = NativeSsl.conf_new(server);
if (ownCert != null && ownKey != null)
NativeSsl.conf_set_cert(conf, @:privateAccess ownCert.__x, @:privateAccess ownKey.__k);
if (altSNIContexts != null) {
sniCallback = function(servername) {
var servername = new String(cast servername);
for (c in altSNIContexts) {
if (c.match(servername))
return @:privateAccess {
key:c.key.__k, cert:c.cert.__x
};
}
if (ownKey != null && ownCert != null)
return @:privateAccess {
key:ownKey.__k, cert:ownCert.__x
};
return null;
}
NativeSsl.conf_set_servername_callback(conf, sniCallback);
}
if (caCert != null)
NativeSsl.conf_set_ca(conf, caCert == null ? null : @:privateAccess caCert.__x);
if (verifyCert == null)
NativeSsl.conf_set_verify(conf, 2);
else
NativeSsl.conf_set_verify(conf, verifyCert ? 1 : 0);
return conf;
}
static function __init__():Void {
NativeSsl.init();
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.thread;
@:coreApi
class Deque<T> {
var q:Dynamic;
public function new() {
q = untyped __global__.__hxcpp_deque_create();
}
public function add(i:T):Void {
untyped __global__.__hxcpp_deque_add(q, i);
}
public function push(i:T):Void {
untyped __global__.__hxcpp_deque_push(q, i);
}
public function pop(block:Bool):Null<T> {
return untyped __global__.__hxcpp_deque_pop(q, block);
}
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.thread;
@:coreApi
class Lock {
var l:Dynamic;
public function new() {
l = untyped __global__.__hxcpp_lock_create();
}
public function wait(?timeout:Float = -1):Bool {
return untyped __global__.__hxcpp_lock_wait(l, timeout);
}
public function release():Void {
untyped __global__.__hxcpp_lock_release(l);
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.thread;
@:coreApi
class Mutex {
var m:Dynamic;
public function new() {
m = untyped __global__.__hxcpp_mutex_create();
}
public function acquire():Void {
untyped __global__.__hxcpp_mutex_acquire(m);
}
public function tryAcquire():Bool {
return untyped __global__.__hxcpp_mutex_try(m);
}
public function release():Void {
untyped __global__.__hxcpp_mutex_release(m);
}
}

View File

@ -0,0 +1,189 @@
/*
* 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;
private typedef ThreadImpl = HaxeThread;
abstract Thread(ThreadImpl) from ThreadImpl {
public var events(get,never):EventLoop;
public inline function sendMessage(msg:Dynamic):Void {
this.sendMessage(msg);
}
public static inline function current():Thread {
return HaxeThread.current();
}
public static inline function create(job:()->Void):Thread {
return HaxeThread.create(job, false);
}
public static inline function runWithEventLoop(job:()->Void):Void {
HaxeThread.runWithEventLoop(job);
}
public static inline function createWithEventLoop(job:()->Void):Thread {
return HaxeThread.create(job, true);
}
public static function readMessage(block:Bool):Dynamic {
return HaxeThread.readMessage(block);
}
function get_events():EventLoop {
if(this.events == null)
throw new NoEventLoopException();
return this.events;
}
@:keep
static public function processEvents() {
HaxeThread.current().events.loop();
}
}
@:callable
@:coreType
private abstract NativeThreadHandle {}
private typedef ThreadHandle = NativeThreadHandle;
private class HaxeThread {
static var threads:Array<{thread:HaxeThread, handle:ThreadHandle}>;
static var threadsMutex:Mutex;
static var mainThreadHandle:ThreadHandle;
static var mainThread:HaxeThread;
static function __init__() {
threads = [];
threadsMutex = new Mutex();
mainThreadHandle = currentHandle();
mainThread = new HaxeThread(currentHandle());
mainThread.events = new EventLoop();
}
public var events(default,null):Null<EventLoop>;
public var handle:ThreadHandle;
final messages = new Deque<Dynamic>();
static public function current():HaxeThread {
var handle = currentHandle();
if(handle == mainThreadHandle) {
return mainThread;
}
threadsMutex.acquire();
var thread = null;
for(item in threads) {
if(item.handle == handle) {
thread = item.thread;
break;
}
}
if(thread == null) {
thread = new HaxeThread(handle);
threads.push({thread:thread, handle:handle});
}
threadsMutex.release();
return thread;
}
public static function create(job:()->Void, withEventLoop:Bool):Thread {
var item = {handle:null, thread:new HaxeThread(null)};
threadsMutex.acquire();
var index = threads.push(item);
threadsMutex.release();
if(withEventLoop)
item.thread.events = new EventLoop();
item.handle = createHandle(() -> {
if(item.thread.handle == null) {
item.handle = currentHandle();
item.thread.handle = item.handle;
}
try {
job();
if(withEventLoop)
item.thread.events.loop();
} catch(e) {
dropThread(item, index);
throw e;
}
dropThread(item, index);
});
item.thread.handle = item.handle;
return item.thread;
}
public static function runWithEventLoop(job:()->Void):Void {
var thread = current();
if(thread.events == null) {
thread.events = new EventLoop();
try {
job();
thread.events.loop();
thread.events = null;
} catch(e) {
thread.events = null;
throw e;
}
} else {
job();
}
}
static function dropThread(item, probableIndex:Int) {
threadsMutex.acquire();
if(threads[probableIndex] == item) {
threads.splice(probableIndex, 1);
} else {
for(i => item2 in threads) {
if(item2 == item) {
threads.splice(i, 1);
break;
}
}
}
threadsMutex.release();
}
function new(h:ThreadHandle):Void {
handle = h;
}
public inline function sendMessage(msg:Dynamic):Void {
messages.add(msg);
}
static #if !scriptable inline #end function currentHandle():ThreadHandle {
return untyped __global__.__hxcpp_thread_current();
}
static #if !scriptable inline #end function createHandle(callb:Void->Void):ThreadHandle {
return untyped __global__.__hxcpp_thread_create(callb);
}
public static #if !scriptable inline #end function readMessage(block:Bool):Dynamic {
return current().messages.pop(block);
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.thread;
@:coreApi
class Tls<T> {
static var sFreeSlot = 0;
var mTLSID:Int;
public var value(get, set):T;
public function new() {
mTLSID = sFreeSlot++;
}
function get_value():T {
return untyped __global__.__hxcpp_tls_get(mTLSID);
}
function set_value(v:T):T {
untyped __global__.__hxcpp_tls_set(mTLSID, v);
return v;
}
}

View File

@ -0,0 +1,26 @@
/*
* 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 cpp.abi;
// Base case, for calling conventions - means "use default"
extern class Abi {}

View File

@ -0,0 +1,26 @@
/*
* 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 cpp.abi;
@:abi("__cdecl")
extern class CDecl extends Abi {}

View File

@ -0,0 +1,26 @@
/*
* 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 cpp.abi;
@:abi("__fastcall")
extern class FastCall extends Abi {}

Some files were not shown because too many files have changed in this diff Show More