Revert "ALC bindings for HL"

This reverts commit 8d1ff873d8.

Revert "Binding fix"

This reverts commit c606ec5139.

Revert "Add support for HL libraries"

This reverts commit 6b49f4d240.

Revert "Minor fixes"

This reverts commit dcacb9f04a.

Revert "Compile fixes"

This reverts commit 3b9e572f8b.

Revert "Sync with Haxe std library (remove some overrides)"

This reverts commit c05061c970.

Revert "Initial support for HL target in tools (for testing)"

This reverts commit 1dadbb725c.
This commit is contained in:
Joshua Granick
2018-04-27 06:27:32 -07:00
parent 8d1ff873d8
commit e496d09527
27 changed files with 1135 additions and 2138 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2005-2018 Haxe Foundation
* Copyright (C)2005-2016 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -19,7 +19,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package haxe.io; #if (!hl && !js)
package haxe.io; #if !js
#if cpp
@@ -53,6 +53,8 @@ class Bytes {
return untyped $sget(b,pos);
#elseif flash
return b[pos];
#elseif php
return b.get(pos);
#elseif cpp
return untyped b[pos];
#elseif java
@@ -69,6 +71,8 @@ class Bytes {
untyped $sset(b,pos,v);
#elseif flash
b[pos] = v;
#elseif php
b.set(pos, v);
#elseif cpp
untyped b[pos] = v;
#elseif java
@@ -88,6 +92,8 @@ class Bytes {
#end
#if neko
try untyped $sblit(b,pos,src.b,srcpos,len) catch( e : Dynamic ) throw Error.OutsideBounds;
#elseif php
b.blit(pos, src.b, srcpos, len);
#elseif flash
b.position = pos;
if( len > 0 ) b.writeBytes(src.b,srcpos,len);
@@ -96,7 +102,7 @@ class Bytes {
#elseif cs
cs.system.Array.Copy(src.b, srcpos, b, pos, len);
#elseif python
python.Syntax.code("self.b[{0}:{0}+{1}] = src.b[srcpos:srcpos+{1}]", pos, len);
python.Syntax.pythonCode("self.b[{0}:{0}+{1}] = src.b[srcpos:srcpos+{1}]", pos, len);
#elseif cpp
b.blit(pos, src.b, srcpos, len);
#else
@@ -145,6 +151,8 @@ class Bytes {
var b2 = new flash.utils.ByteArray();
b.readBytes(b2,0,len);
return new Bytes(len,b2);
#elseif php
return new Bytes(len, b.sub(pos, len));
#elseif java
var newarr = new java.NativeArray(len);
java.lang.System.arraycopy(b, pos, newarr, 0, len);
@@ -189,6 +197,8 @@ class Bytes {
b1.endian = flash.utils.Endian.LITTLE_ENDIAN;
b2.endian = flash.utils.Endian.LITTLE_ENDIAN;
return length - other.length;
#elseif php
return b.compare(other.b);
//#elseif cs
//TODO: memcmp if unsafe flag is on
#elseif cpp
@@ -316,7 +326,7 @@ class Bytes {
public inline function getInt32( pos : Int ) : Int {
#if neko_v21
return untyped $sget32(b, pos, false);
#elseif python
#elseif (php || python)
var v = get(pos) | (get(pos + 1) << 8) | (get(pos + 2) << 16) | (get(pos+3) << 24);
return if( v & 0x80000000 != 0 ) v | 0x80000000 else v;
#elseif lua
@@ -365,6 +375,8 @@ class Bytes {
#elseif flash
b.position = pos;
return b.readUTFBytes(len);
#elseif php
return b.getString(pos, len);
#elseif cpp
var result:String="";
untyped __global__.__hxcpp_string_of_bytes(b,result,pos,len);
@@ -376,7 +388,7 @@ class Bytes {
return new String(b, pos, len, "UTF-8")
catch (e:Dynamic) throw e;
#elseif python
return python.Syntax.code("self.b[{0}:{0}+{1}].decode('UTF-8','replace')", pos, len);
return python.Syntax.pythonCode("self.b[{0}:{0}+{1}].decode('UTF-8','replace')", pos, len);
#elseif lua
var begin = cast(Math.min(pos,b.length),Int);
var end = cast(Math.min(pos+len,b.length),Int);
@@ -423,6 +435,8 @@ class Bytes {
#elseif flash
b.position = 0;
return b.toString();
#elseif php
return b.toString();
#elseif cs
return cs.system.text.Encoding.UTF8.GetString(b, 0, length);
#elseif java
@@ -461,6 +475,8 @@ class Bytes {
var b = new flash.utils.ByteArray();
b.length = length;
return new Bytes(length,b);
#elseif php
return new Bytes(length, BytesData.alloc(length));
#elseif cpp
var a = new BytesData();
if (length>0) cpp.NativeArray.setSize(a, length);
@@ -487,6 +503,9 @@ class Bytes {
var b = new flash.utils.ByteArray();
b.writeUTFBytes(s);
return new Bytes(b.length,b);
#elseif php
var x = BytesData.ofString(s);
return new Bytes(x.length, x);
#elseif cpp
var a = new BytesData();
untyped __global__.__hxcpp_bytes_of_string(a,s);
@@ -543,6 +562,8 @@ class Bytes {
return new Bytes(b.length,b);
#elseif neko
return new Bytes(untyped __dollar__ssize(b),b);
#elseif php
return new Bytes(b.length, b);
#elseif cs
return new Bytes(b.Length,b);
#else
@@ -559,6 +580,8 @@ class Bytes {
return untyped __dollar__sget(b,pos);
#elseif flash
return b[pos];
#elseif php
return b.get(pos);
#elseif cpp
return untyped b.unsafeGet(pos);
#elseif java
@@ -571,7 +594,7 @@ class Bytes {
}
#elseif js
#else
#if !nodejs
@@ -807,165 +830,4 @@ class Bytes {
}
#elseif hl
@:coreApi
class Bytes {
public var length(default,null) : Int;
var b : hl.Bytes;
function new(b:hl.Bytes,length:Int) : Void {
this.b = b;
this.length = length;
}
inline function out(pos:Int) : Bool {
return (pos:UInt) >= (length : UInt);
}
inline function outRange(pos:Int,len:Int) : Bool {
return pos < 0 || len < 0 || ((pos+len):UInt) > (length : UInt);
}
public function get( pos : Int ) : Int {
return if( out(pos) ) 0 else b[pos];
}
public function set( pos : Int, v : Int ) : Void {
if( out(pos) ) throw Error.OutsideBounds;
b[pos] = v;
}
public function blit( pos : Int, src : Bytes, srcpos : Int, len : Int ) : Void {
if( outRange(pos, len) || src.outRange(srcpos,len) ) throw Error.OutsideBounds;
b.blit(pos, src.b, srcpos, len);
}
public function fill( pos : Int, len : Int, value : Int ) : Void {
if( outRange(pos,len) ) throw Error.OutsideBounds;
b.fill(pos, len, value);
}
public function sub( pos : Int, len : Int ) : Bytes {
if( outRange(pos,len) ) throw Error.OutsideBounds;
return new Bytes(b.sub(pos, len), len);
}
public function compare( other : Bytes ) : Int {
var len = length < other.length ? length : other.length;
var r = b.compare(0, other.b, 0, len);
if( r == 0 )
r = length - other.length;
return r;
}
public function getDouble( pos : Int ) : Float {
return if( out(pos + 7) ) 0. else b.getF64(pos);
}
public function getFloat( pos : Int ) : Float {
return if( out(pos + 3) ) 0. else b.getF32(pos);
}
public function setDouble( pos : Int, v : Float ) : Void {
if( out(pos + 7) ) throw Error.OutsideBounds;
b.setF64(pos, v);
}
public function setFloat( pos : Int, v : Float ) : Void {
if( out(pos + 3) ) throw Error.OutsideBounds;
b.setF32(pos, v);
}
public inline function getUInt16( pos : Int ) : Int {
return if( out(pos + 1) ) 0 else b.getUI16(pos);
}
public inline function setUInt16( pos : Int, v : Int ) : Void {
if( out(pos + 1) ) throw Error.OutsideBounds;
b.setUI16(pos, v);
}
public function getInt32( pos : Int ) : Int {
return if( out(pos + 3) ) 0 else b.getI32(pos);
}
public function getInt64( pos : Int ) : haxe.Int64 {
if( out(pos + 7) )
return haxe.Int64.ofInt(0);
return haxe.Int64.make(b.getI32(pos+4), b.getI32(pos));
}
public function setInt32( pos : Int, v : Int ) : Void {
if( out(pos + 3) ) throw Error.OutsideBounds;
b.setI32(pos, v);
}
public inline function setInt64( pos : Int, v : haxe.Int64 ) : Void {
setInt32(pos + 4, v.high);
setInt32(pos, v.low);
}
public function getString( pos : Int, len : Int ) : String {
if( outRange(pos,len) ) throw Error.OutsideBounds;
var b = new hl.Bytes(len + 1);
b.blit(0, this.b, pos, len);
b[len] = 0;
return @:privateAccess String.fromUTF8(b);
}
@:deprecated("readString is deprecated, use getString instead")
@:noCompletion
public inline function readString(pos:Int, len:Int):String {
return getString(pos, len);
}
public function toString() : String {
return getString(0,length);
}
public function toHex() : String {
var s = new StringBuf();
var chars = [];
var str = "0123456789abcdef";
for( i in 0...str.length )
chars.push(str.charCodeAt(i));
for( i in 0...length ) {
var c = get(i);
s.addChar(chars[c >> 4]);
s.addChar(chars[c & 15]);
}
return s.toString();
}
public inline function getData() : BytesData {
return new haxe.io.BytesData(b,length);
}
public static function alloc( length : Int ) : Bytes {
var b = new hl.Bytes(length);
b.fill(0, length, 0);
return new Bytes(b,length);
}
public static function ofString( s : String ) : Bytes @:privateAccess {
var size = 0;
var b = s.bytes.utf16ToUtf8(0, size);
return new Bytes(b,size);
}
public static function ofData( b : BytesData ) : Bytes {
return new Bytes(b.bytes,b.length);
}
public inline static function fastGet( b : BytesData, pos : Int ) : Int {
return b[pos];
}
}
#end