haxe/src/haxe/io/BytesBuffer.cs
// Generated by Haxe 4.3.7

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe.io {
	public class BytesBuffer : global::haxe.lang.HxObject {
		
		public BytesBuffer(global::haxe.lang.EmptyObject empty) {
		}
		
		
		public BytesBuffer() {
			global::haxe.io.BytesBuffer.__hx_ctor_haxe_io_BytesBuffer(this);
		}
		
		
		protected static void __hx_ctor_haxe_io_BytesBuffer(global::haxe.io.BytesBuffer __hx_this) {
			__hx_this.b = new global::System.IO.MemoryStream();
		}
		
		
		public global::System.IO.MemoryStream b;
		
		
		
		public int get_length() {
			unchecked {
				long x = ( this.b as global::System.IO.Stream ).Length;
				if (( ( ((long) (x) ) < -2147483648 ) || ( ((long) (x) ) > 2147483647 ) )) {
					throw ((global::System.Exception) (global::haxe.Exception.thrown("Overflow")) );
				}
				
				return ((int) (((long) (x) )) );
			}
		}
		
		
		public void addByte(int @byte) {
			( this.b as global::System.IO.Stream ).WriteByte(((byte) (@byte) ));
		}
		
		
		public void @add(global::haxe.io.Bytes src) {
			( this.b as global::System.IO.Stream ).Write(((byte[]) (src.getData()) ), ((int) (0) ), ((int) (src.length) ));
		}
		
		
		public void addString(string v, global::haxe.io.Encoding encoding) {
			this.@add(global::haxe.io.Bytes.ofString(v, encoding));
		}
		
		
		public virtual void addInt32(int v) {
			unchecked {
				this.addByte(( v & 255 ));
				this.addByte(( ( v >> 8 ) & 255 ));
				this.addByte(( ( v >> 16 ) & 255 ));
				this.addByte(((int) (( ((uint) (v) ) >> 24 )) ));
			}
		}
		
		
		public virtual void addInt64(long v) {
			unchecked {
				this.addInt32(((int) (((long) (v) )) ));
				this.addInt32(((int) (( ((long) (v) ) >> 32 )) ));
			}
		}
		
		
		public void addFloat(double v) {
			this.addInt32(global::haxe.io.FPHelper.floatToI32(v));
		}
		
		
		public void addDouble(double v) {
			this.addInt64(global::haxe.io.FPHelper.doubleToI64(v));
		}
		
		
		public void addBytes(global::haxe.io.Bytes src, int pos, int len) {
			if (( ( ( pos < 0 ) || ( len < 0 ) ) || ( ( pos + len ) > src.length ) )) {
				throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.OutsideBounds)) );
			}
			
			( this.b as global::System.IO.Stream ).Write(((byte[]) (src.getData()) ), ((int) (pos) ), ((int) (len) ));
		}
		
		
		public virtual global::haxe.io.Bytes getBytes() {
			byte[] buf = this.b.GetBuffer();
			global::haxe.io.Bytes bytes = new global::haxe.io.Bytes(((int) (( this.b as global::System.IO.Stream ).Length) ), ((byte[]) (buf) ));
			this.b = null;
			return bytes;
		}
		
		
		public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
			unchecked {
				switch (hash) {
					case 98:
					{
						this.b = ((global::System.IO.MemoryStream) (@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 493819893:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getBytes", 493819893)) );
					}
					
					
					case 922037898:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addBytes", 922037898)) );
					}
					
					
					case 1794072594:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addDouble", 1794072594)) );
					}
					
					
					case 2079583163:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addFloat", 2079583163)) );
					}
					
					
					case 930987020:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addInt64", 930987020)) );
					}
					
					
					case 930986349:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addInt32", 930986349)) );
					}
					
					
					case 1230265810:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addString", 1230265810)) );
					}
					
					
					case 4846113:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "add", 4846113)) );
					}
					
					
					case 2103468489:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "addByte", 2103468489)) );
					}
					
					
					case 261031087:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "get_length", 261031087)) );
					}
					
					
					case 520590566:
					{
						return this.get_length();
					}
					
					
					case 98:
					{
						return this.b;
					}
					
					
					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.get_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 493819893:
					{
						return this.getBytes();
					}
					
					
					case 922037898:
					{
						this.addBytes(((global::haxe.io.Bytes) (dynargs[0]) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[2])) ));
						break;
					}
					
					
					case 1794072594:
					{
						this.addDouble(((double) (global::haxe.lang.Runtime.toDouble(dynargs[0])) ));
						break;
					}
					
					
					case 2079583163:
					{
						this.addFloat(((double) (global::haxe.lang.Runtime.toDouble(dynargs[0])) ));
						break;
					}
					
					
					case 930987020:
					{
						this.addInt64(((long) (dynargs[0]) ));
						break;
					}
					
					
					case 930986349:
					{
						this.addInt32(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
						break;
					}
					
					
					case 1230265810:
					{
						this.addString(global::haxe.lang.Runtime.toString(dynargs[0]), ((global::haxe.io.Encoding) (( (( dynargs.Length > 1 )) ? (dynargs[1]) : (null) )) ));
						break;
					}
					
					
					case 4846113:
					{
						this.@add(((global::haxe.io.Bytes) (dynargs[0]) ));
						break;
					}
					
					
					case 2103468489:
					{
						this.addByte(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
						break;
					}
					
					
					case 261031087:
					{
						return this.get_length();
					}
					
					
					default:
					{
						return base.__hx_invokeField(field, hash, dynargs);
					}
					
				}
				
				return null;
			}
		}
		
		
		public override void __hx_getFields(global::Array<string> baseArr) {
			baseArr.push("length");
			baseArr.push("b");
			base.__hx_getFields(baseArr);
		}
		
		
	}
}