haxe/src/haxe/io/Bytes.cs
// Generated by Haxe 4.3.7
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe.io {
public class Bytes : global::haxe.lang.HxObject {
public Bytes(global::haxe.lang.EmptyObject empty) {
}
public Bytes(int length, byte[] b) {
global::haxe.io.Bytes.__hx_ctor_haxe_io_Bytes(this, length, b);
}
protected static void __hx_ctor_haxe_io_Bytes(global::haxe.io.Bytes __hx_this, int length, byte[] b) {
__hx_this.length = length;
__hx_this.b = b;
}
public static global::haxe.io.Bytes alloc(int length) {
return new global::haxe.io.Bytes(((int) (length) ), ((byte[]) (new byte[length]) ));
}
public static global::haxe.io.Bytes ofString(string s, global::haxe.io.Encoding encoding) {
unchecked {
byte[] b = null;
if (( encoding == null )) {
b = global::System.Text.Encoding.UTF8.GetBytes(((string) (s) ));
}
else {
switch (encoding._hx_index) {
case 0:
{
b = global::System.Text.Encoding.UTF8.GetBytes(((string) (s) ));
break;
}
case 1:
{
b = global::System.Text.Encoding.Unicode.GetBytes(((string) (s) ));
break;
}
}
}
return new global::haxe.io.Bytes(((int) (( b as global::System.Array ).Length) ), ((byte[]) (b) ));
}
}
public static global::haxe.io.Bytes ofData(byte[] b) {
return new global::haxe.io.Bytes(((int) (( b as global::System.Array ).Length) ), ((byte[]) (b) ));
}
public static global::haxe.io.Bytes ofHex(string s) {
unchecked {
int len = s.Length;
if (( (( len & 1 )) != 0 )) {
throw ((global::System.Exception) (global::haxe.Exception.thrown("Not a hex string (odd number of digits)")) );
}
global::haxe.io.Bytes ret = global::haxe.io.Bytes.alloc(( len >> 1 ));
{
int _g = 0;
int _g1 = ret.length;
while (( _g < _g1 )) {
int i = _g++;
int high = global::StringTools.fastCodeAt(s, ( i * 2 ));
int low = global::StringTools.fastCodeAt(s, ( ( i * 2 ) + 1 ));
high = ( (( high & 15 )) + ( (( (( high & 64 )) >> 6 )) * 9 ) );
low = ( (( low & 15 )) + ( (( (( low & 64 )) >> 6 )) * 9 ) );
ret.@set(i, ( (( ( high << 4 ) | low )) & 255 ));
}
}
return ret;
}
}
public static int fastGet(byte[] b, int pos) {
return ((int) (b[pos]) );
}
public int length;
public byte[] b;
public int @get(int pos) {
return ((int) (this.b[pos]) );
}
public void @set(int pos, int v) {
this.b[pos] = ((byte) (v) );
}
public virtual void blit(int pos, global::haxe.io.Bytes src, int srcpos, int len) {
if (( ( ( ( ( pos < 0 ) || ( srcpos < 0 ) ) || ( len < 0 ) ) || ( ( pos + len ) > this.length ) ) || ( ( srcpos + len ) > src.length ) )) {
throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.OutsideBounds)) );
}
global::System.Array.Copy(((global::System.Array) (src.b) ), ((int) (srcpos) ), ((global::System.Array) (this.b) ), ((int) (pos) ), ((int) (len) ));
}
public virtual void fill(int pos, int len, int @value) {
int _g = 0;
int _g1 = len;
while (( _g < _g1 )) {
int i = _g++;
this.@set(pos++, @value);
}
}
public virtual global::haxe.io.Bytes sub(int pos, int len) {
if (( ( ( pos < 0 ) || ( len < 0 ) ) || ( ( pos + len ) > this.length ) )) {
throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.OutsideBounds)) );
}
byte[] newarr = new byte[len];
global::System.Array.Copy(((global::System.Array) (this.b) ), ((int) (pos) ), ((global::System.Array) (newarr) ), ((int) (0) ), ((int) (len) ));
return new global::haxe.io.Bytes(((int) (len) ), ((byte[]) (newarr) ));
}
public virtual int compare(global::haxe.io.Bytes other) {
byte[] b1 = this.b;
byte[] b2 = other.b;
int len = ( (( this.length < other.length )) ? (this.length) : (other.length) );
{
int _g = 0;
int _g1 = len;
while (( _g < _g1 )) {
int i = _g++;
if (( b1[i] != b2[i] )) {
return ( b1[i] - b2[i] );
}
}
}
return ( this.length - other.length );
}
public virtual double getDouble(int pos) {
unchecked {
return global::haxe.io.FPHelper.i64ToDouble(this.getInt32(pos), this.getInt32(( pos + 4 )));
}
}
public virtual double getFloat(int pos) {
return global::haxe.io.FPHelper.i32ToFloat(this.getInt32(pos));
}
public virtual void setDouble(int pos, double v) {
unchecked {
long i = global::haxe.io.FPHelper.doubleToI64(v);
this.setInt32(pos, ((int) (((long) (i) )) ));
this.setInt32(( pos + 4 ), ((int) (( ((long) (i) ) >> 32 )) ));
}
}
public virtual void setFloat(int pos, double v) {
this.setInt32(pos, global::haxe.io.FPHelper.floatToI32(v));
}
public int getUInt16(int pos) {
unchecked {
return ( this.@get(pos) | ( this.@get(( pos + 1 )) << 8 ) );
}
}
public void setUInt16(int pos, int v) {
unchecked {
this.@set(pos, v);
this.@set(( pos + 1 ), ( v >> 8 ));
}
}
public int getInt32(int pos) {
unchecked {
return ( ( ( this.@get(pos) | ( this.@get(( pos + 1 )) << 8 ) ) | ( this.@get(( pos + 2 )) << 16 ) ) | ( this.@get(( pos + 3 )) << 24 ) );
}
}
public long getInt64(int pos) {
unchecked {
return ((long) (( ( ((long) (((int) (this.getInt32(( pos + 4 ))) )) ) << 32 ) | ( ((long) (((int) (this.getInt32(pos)) )) ) & 0xffffffffL ) )) );
}
}
public void setInt32(int pos, int v) {
unchecked {
this.@set(pos, v);
this.@set(( pos + 1 ), ( v >> 8 ));
this.@set(( pos + 2 ), ( v >> 16 ));
this.@set(( pos + 3 ), ((int) (( ((uint) (v) ) >> 24 )) ));
}
}
public void setInt64(int pos, long v) {
unchecked {
this.setInt32(pos, ((int) (((long) (v) )) ));
this.setInt32(( pos + 4 ), ((int) (( ((long) (v) ) >> 32 )) ));
}
}
public virtual string getString(int pos, int len, global::haxe.io.Encoding encoding) {
unchecked {
bool tmp = ( encoding == null );
if (( ( ( pos < 0 ) || ( len < 0 ) ) || ( ( pos + len ) > this.length ) )) {
throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.OutsideBounds)) );
}
if (( encoding == null )) {
return global::System.Text.Encoding.UTF8.GetString(((byte[]) (this.b) ), ((int) (pos) ), ((int) (len) ));
}
else {
switch (encoding._hx_index) {
case 0:
{
return global::System.Text.Encoding.UTF8.GetString(((byte[]) (this.b) ), ((int) (pos) ), ((int) (len) ));
}
case 1:
{
return global::System.Text.Encoding.Unicode.GetString(((byte[]) (this.b) ), ((int) (pos) ), ((int) (len) ));
}
}
}
return null;
}
}
public string readString(int pos, int len) {
return this.getString(pos, len, null);
}
public virtual string toString() {
return global::System.Text.Encoding.UTF8.GetString(((byte[]) (this.b) ), ((int) (0) ), ((int) (this.length) ));
}
public virtual string toHex() {
unchecked {
global::StringBuf s = new global::StringBuf();
global::Array<object> chars = new global::Array<object>(new object[]{});
string str = "0123456789abcdef";
{
int _g = 0;
int _g1 = str.Length;
while (( _g < _g1 )) {
int i = _g++;
chars.push((global::haxe.lang.StringExt.charCodeAt(str, i)).toDynamic());
}
}
{
int _g2 = 0;
int _g3 = this.length;
while (( _g2 < _g3 )) {
int i1 = _g2++;
int c = this.@get(i1);
s.addChar(((int) (global::haxe.lang.Runtime.toInt(chars[( c >> 4 )])) ));
s.addChar(((int) (global::haxe.lang.Runtime.toInt(chars[( c & 15 )])) ));
}
}
return s.toString();
}
}
public byte[] getData() {
return this.b;
}
public override double __hx_setField_f(string field, int hash, double @value, bool handleProperties) {
unchecked {
switch (hash) {
case 520590566:
{
this.length = ((int) (@value) );
return @value;
}
default:
{
return base.__hx_setField_f(field, hash, @value, handleProperties);
}
}
}
}
public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
unchecked {
switch (hash) {
case 98:
{
this.b = ((byte[]) (@value) );
return @value;
}
case 520590566:
{
this.length = ((int) (global::haxe.lang.Runtime.toInt(@value)) );
return @value;
}
default:
{
return base.__hx_setField(field, hash, @value, handleProperties);
}
}
}
}
public override object __hx_getField(string field, int hash, bool throwErrors, bool isCheck, bool handleProperties) {
unchecked {
switch (hash) {
case 350619104:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getData", 350619104)) );
}
case 336655392:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "toHex", 336655392)) );
}
case 946786476:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "toString", 946786476)) );
}
case 179047623:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readString", 179047623)) );
}
case 226931207:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getString", 226931207)) );
}
case 1280638699:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "setInt64", 1280638699)) );
}
case 1280638028:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "setInt32", 1280638028)) );
}
case 502769015:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getInt64", 502769015)) );
}
case 502768344:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getInt32", 502768344)) );
}
case 2025238049:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "setUInt16", 2025238049)) );
}
case 358990357:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUInt16", 358990357)) );
}
case 281751194:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "setFloat", 281751194)) );
}
case 309502035:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "setDouble", 309502035)) );
}
case 1651365158:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getFloat", 1651365158)) );
}
case 790737991:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getDouble", 790737991)) );
}
case 57219237:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "compare", 57219237)) );
}
case 5745024:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "sub", 5745024)) );
}
case 1136381571:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "fill", 1136381571)) );
}
case 1092171829:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "blit", 1092171829)) );
}
case 5741474:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "set", 5741474)) );
}
case 5144726:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "get", 5144726)) );
}
case 98:
{
return this.b;
}
case 520590566:
{
return this.length;
}
default:
{
return base.__hx_getField(field, hash, throwErrors, isCheck, handleProperties);
}
}
}
}
public override double __hx_getField_f(string field, int hash, bool throwErrors, bool handleProperties) {
unchecked {
switch (hash) {
case 520590566:
{
return ((double) (this.length) );
}
default:
{
return base.__hx_getField_f(field, hash, throwErrors, handleProperties);
}
}
}
}
public override object __hx_invokeField(string field, int hash, object[] dynargs) {
unchecked {
switch (hash) {
case 350619104:
{
return this.getData();
}
case 336655392:
{
return this.toHex();
}
case 946786476:
{
return this.toString();
}
case 179047623:
{
return this.readString(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ));
}
case 226931207:
{
return this.getString(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ), ((global::haxe.io.Encoding) (( (( dynargs.Length > 2 )) ? (dynargs[2]) : (null) )) ));
}
case 1280638699:
{
this.setInt64(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((long) (dynargs[1]) ));
break;
}
case 1280638028:
{
this.setInt32(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ));
break;
}
case 502769015:
{
return this.getInt64(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
case 502768344:
{
return this.getInt32(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
case 2025238049:
{
this.setUInt16(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ));
break;
}
case 358990357:
{
return this.getUInt16(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
case 281751194:
{
this.setFloat(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((double) (global::haxe.lang.Runtime.toDouble(dynargs[1])) ));
break;
}
case 309502035:
{
this.setDouble(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((double) (global::haxe.lang.Runtime.toDouble(dynargs[1])) ));
break;
}
case 1651365158:
{
return this.getFloat(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
case 790737991:
{
return this.getDouble(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
case 57219237:
{
return this.compare(((global::haxe.io.Bytes) (dynargs[0]) ));
}
case 5745024:
{
return this.sub(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ));
}
case 1136381571:
{
this.fill(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[2])) ));
break;
}
case 1092171829:
{
this.blit(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((global::haxe.io.Bytes) (dynargs[1]) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[2])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[3])) ));
break;
}
case 5741474:
{
this.@set(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ));
break;
}
case 5144726:
{
return this.@get(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
}
default:
{
return base.__hx_invokeField(field, hash, dynargs);
}
}
return null;
}
}
public override void __hx_getFields(global::Array<string> baseArr) {
baseArr.push("b");
baseArr.push("length");
base.__hx_getFields(baseArr);
}
public override string ToString(){
return this.toString();
}
}
}