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

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe.io {
	public class Input : global::haxe.lang.HxObject {
		
		public Input(global::haxe.lang.EmptyObject empty) {
		}
		
		
		public Input() {
			global::haxe.io.Input.__hx_ctor_haxe_io_Input(this);
		}
		
		
		protected static void __hx_ctor_haxe_io_Input(global::haxe.io.Input __hx_this) {
		}
		
		
		public bool bigEndian;
		
		public byte[] helper;
		
		public virtual int readByte() {
			unchecked {
				throw new global::haxe.exceptions.NotImplementedException(default(string), default(global::haxe.Exception), ((object) (new global::haxe.lang.DynamicObject(new int[]{302979532, 1547539107, 1648581351}, new object[]{"readByte", "haxe.io.Input", "haxe/io/Input.hx"}, new int[]{1981972957}, new double[]{((double) (53) )})) ));
			}
		}
		
		
		public virtual int readBytes(global::haxe.io.Bytes s, int pos, int len) {
			int k = len;
			byte[] b = s.getData();
			if (( ( ( pos < 0 ) || ( len < 0 ) ) || ( ( pos + len ) > s.length ) )) {
				throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.OutsideBounds)) );
			}
			
			try {
				while (( k > 0 )) {
					b[pos] = ((byte) (this.readByte()) );
					 ++ pos;
					 -- k;
				}
				
			}
			catch (global::System.Exception _g){
				global::haxe.NativeStackTrace.saveStack(_g);
				if (( ((object) (global::haxe.Exception.caught(_g).unwrap()) ) is global::haxe.io.Eof )) {
				}
				else {
					throw;
				}
				
			}
			
			
			return ( len - k );
		}
		
		
		public virtual void close() {
		}
		
		
		public virtual bool set_bigEndian(bool b) {
			this.bigEndian = b;
			return b;
		}
		
		
		public virtual global::haxe.io.Bytes readAll(global::haxe.lang.Null<int> bufsize) {
			unchecked {
				if ( ! (bufsize.hasValue) ) {
					bufsize = new global::haxe.lang.Null<int>(16384, true);
				}
				
				global::haxe.io.Bytes buf = global::haxe.io.Bytes.alloc((bufsize).@value);
				global::haxe.io.BytesBuffer total = new global::haxe.io.BytesBuffer();
				try {
					while (true) {
						int len = this.readBytes(buf, 0, (bufsize).@value);
						if (( len == 0 )) {
							throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.Blocked)) );
						}
						
						total.addBytes(buf, 0, len);
					}
					
				}
				catch (global::System.Exception _g){
					global::haxe.NativeStackTrace.saveStack(_g);
					if (( ((object) (global::haxe.Exception.caught(_g).unwrap()) ) is global::haxe.io.Eof )) {
					}
					else {
						throw;
					}
					
				}
				
				
				return total.getBytes();
			}
		}
		
		
		public virtual void readFullBytes(global::haxe.io.Bytes s, int pos, int len) {
			while (( len > 0 )) {
				int k = this.readBytes(s, pos, len);
				if (( k == 0 )) {
					throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.Blocked)) );
				}
				
				pos += k;
				len -= k;
			}
			
		}
		
		
		public virtual global::haxe.io.Bytes read(int nbytes) {
			global::haxe.io.Bytes s = global::haxe.io.Bytes.alloc(nbytes);
			int p = 0;
			while (( nbytes > 0 )) {
				int k = this.readBytes(s, p, nbytes);
				if (( k == 0 )) {
					throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.io.Error.Blocked)) );
				}
				
				p += k;
				nbytes -= k;
			}
			
			return s;
		}
		
		
		public virtual string readUntil(int end) {
			global::haxe.io.BytesBuffer buf = new global::haxe.io.BytesBuffer();
			int last = default(int);
			while (true) {
				last = this.readByte();
				if (( last == end )) {
					break;
				}
				
				buf.addByte(last);
			}
			
			return buf.getBytes().toString();
		}
		
		
		public virtual string readLine() {
			unchecked {
				global::haxe.io.BytesBuffer buf = new global::haxe.io.BytesBuffer();
				int last = default(int);
				string s = null;
				try {
					while (true) {
						last = this.readByte();
						if (( last == 10 )) {
							break;
						}
						
						buf.addByte(last);
					}
					
					s = buf.getBytes().toString();
					if (global::haxe.lang.Runtime.eq((global::haxe.lang.StringExt.charCodeAt(s, ( s.Length - 1 ))).toDynamic(), 13)) {
						s = global::haxe.lang.StringExt.substr(s, 0, new global::haxe.lang.Null<int>(-1, true));
					}
					
				}
				catch (global::System.Exception _g){
					global::haxe.NativeStackTrace.saveStack(_g);
					object _g1 = global::haxe.Exception.caught(_g).unwrap();
					if (( _g1 is global::haxe.io.Eof )) {
						global::haxe.io.Eof e = ((global::haxe.io.Eof) (_g1) );
						{
							s = buf.getBytes().toString();
							if (( s.Length == 0 )) {
								throw ((global::System.Exception) (global::haxe.Exception.thrown(e)) );
							}
							
						}
						
					}
					else {
						throw;
					}
					
				}
				
				
				return s;
			}
		}
		
		
		public virtual double readFloat() {
			return global::haxe.io.FPHelper.i32ToFloat(this.readInt32());
		}
		
		
		public virtual double readDouble() {
			int i1 = this.readInt32();
			int i2 = this.readInt32();
			if (this.bigEndian) {
				return global::haxe.io.FPHelper.i64ToDouble(i2, i1);
			}
			else {
				return global::haxe.io.FPHelper.i64ToDouble(i1, i2);
			}
			
		}
		
		
		public virtual int readInt8() {
			unchecked {
				int n = this.readByte();
				if (( n >= 128 )) {
					return ( n - 256 );
				}
				
				return n;
			}
		}
		
		
		public virtual int readInt16() {
			unchecked {
				int ch1 = this.readByte();
				int ch2 = this.readByte();
				int n = ( (this.bigEndian) ? (( ch2 | ( ch1 << 8 ) )) : (( ch1 | ( ch2 << 8 ) )) );
				if (( (( n & 32768 )) != 0 )) {
					return ( n - 65536 );
				}
				
				return n;
			}
		}
		
		
		public virtual int readUInt16() {
			unchecked {
				int ch1 = this.readByte();
				int ch2 = this.readByte();
				if (this.bigEndian) {
					return ( ch2 | ( ch1 << 8 ) );
				}
				else {
					return ( ch1 | ( ch2 << 8 ) );
				}
				
			}
		}
		
		
		public virtual int readInt24() {
			unchecked {
				int ch1 = this.readByte();
				int ch2 = this.readByte();
				int ch3 = this.readByte();
				int n = ( (this.bigEndian) ? (( ( ch3 | ( ch2 << 8 ) ) | ( ch1 << 16 ) )) : (( ( ch1 | ( ch2 << 8 ) ) | ( ch3 << 16 ) )) );
				if (( (( n & 8388608 )) != 0 )) {
					return ( n - 16777216 );
				}
				
				return n;
			}
		}
		
		
		public virtual int readUInt24() {
			unchecked {
				int ch1 = this.readByte();
				int ch2 = this.readByte();
				int ch3 = this.readByte();
				if (this.bigEndian) {
					return ( ( ch3 | ( ch2 << 8 ) ) | ( ch1 << 16 ) );
				}
				else {
					return ( ( ch1 | ( ch2 << 8 ) ) | ( ch3 << 16 ) );
				}
				
			}
		}
		
		
		public virtual int readInt32() {
			unchecked {
				int ch1 = this.readByte();
				int ch2 = this.readByte();
				int ch3 = this.readByte();
				int ch4 = this.readByte();
				if (this.bigEndian) {
					return ( ( ( ch4 | ( ch3 << 8 ) ) | ( ch2 << 16 ) ) | ( ch1 << 24 ) );
				}
				else {
					return ( ( ( ch1 | ( ch2 << 8 ) ) | ( ch3 << 16 ) ) | ( ch4 << 24 ) );
				}
				
			}
		}
		
		
		public virtual string readString(int len, global::haxe.io.Encoding encoding) {
			global::haxe.io.Bytes b = global::haxe.io.Bytes.alloc(len);
			this.readFullBytes(b, 0, len);
			return b.getString(0, len, encoding);
		}
		
		
		public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
			unchecked {
				switch (hash) {
					case 72252782:
					{
						this.helper = ((byte[]) (@value) );
						return @value;
					}
					
					
					case 542823803:
					{
						if (handleProperties) {
							this.set_bigEndian(global::haxe.lang.Runtime.toBool(@value));
							return @value;
						}
						else {
							this.bigEndian = global::haxe.lang.Runtime.toBool(@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 179047623:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readString", 179047623)) );
					}
					
					
					case 252174360:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readInt32", 252174360)) );
					}
					
					
					case 311106994:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readUInt24", 311106994)) );
					}
					
					
					case 252174139:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readInt24", 252174139)) );
					}
					
					
					case 311106773:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readUInt16", 311106773)) );
					}
					
					
					case 252173918:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readInt16", 252173918)) );
					}
					
					
					case 1840455391:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readInt8", 1840455391)) );
					}
					
					
					case 742854407:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readDouble", 742854407)) );
					}
					
					
					case 1400771174:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readFloat", 1400771174)) );
					}
					
					
					case 1873474154:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readLine", 1873474154)) );
					}
					
					
					case 2010580328:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readUntil", 2010580328)) );
					}
					
					
					case 1269254998:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "read", 1269254998)) );
					}
					
					
					case 1309344294:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readFullBytes", 1309344294)) );
					}
					
					
					case 46374763:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readAll", 46374763)) );
					}
					
					
					case 650414942:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "set_bigEndian", 650414942)) );
					}
					
					
					case 1214453688:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "close", 1214453688)) );
					}
					
					
					case 243225909:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readBytes", 243225909)) );
					}
					
					
					case 1763375486:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "readByte", 1763375486)) );
					}
					
					
					case 72252782:
					{
						return this.helper;
					}
					
					
					case 542823803:
					{
						return this.bigEndian;
					}
					
					
					default:
					{
						return base.__hx_getField(field, hash, throwErrors, isCheck, handleProperties);
					}
					
				}
				
			}
		}
		
		
		public override object __hx_invokeField(string field, int hash, object[] dynargs) {
			unchecked {
				switch (hash) {
					case 179047623:
					{
						return this.readString(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ), ((global::haxe.io.Encoding) (( (( dynargs.Length > 1 )) ? (dynargs[1]) : (null) )) ));
					}
					
					
					case 252174360:
					{
						return this.readInt32();
					}
					
					
					case 311106994:
					{
						return this.readUInt24();
					}
					
					
					case 252174139:
					{
						return this.readInt24();
					}
					
					
					case 311106773:
					{
						return this.readUInt16();
					}
					
					
					case 252173918:
					{
						return this.readInt16();
					}
					
					
					case 1840455391:
					{
						return this.readInt8();
					}
					
					
					case 742854407:
					{
						return this.readDouble();
					}
					
					
					case 1400771174:
					{
						return this.readFloat();
					}
					
					
					case 1873474154:
					{
						return this.readLine();
					}
					
					
					case 2010580328:
					{
						return this.readUntil(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
					}
					
					
					case 1269254998:
					{
						return this.read(((int) (global::haxe.lang.Runtime.toInt(dynargs[0])) ));
					}
					
					
					case 1309344294:
					{
						this.readFullBytes(((global::haxe.io.Bytes) (dynargs[0]) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[2])) ));
						break;
					}
					
					
					case 46374763:
					{
						return this.readAll(global::haxe.lang.Null<object>.ofDynamic<int>(( (( dynargs.Length > 0 )) ? (dynargs[0]) : (null) )));
					}
					
					
					case 650414942:
					{
						return this.set_bigEndian(global::haxe.lang.Runtime.toBool(dynargs[0]));
					}
					
					
					case 1214453688:
					{
						this.close();
						break;
					}
					
					
					case 243225909:
					{
						return this.readBytes(((global::haxe.io.Bytes) (dynargs[0]) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[1])) ), ((int) (global::haxe.lang.Runtime.toInt(dynargs[2])) ));
					}
					
					
					case 1763375486:
					{
						return this.readByte();
					}
					
					
					default:
					{
						return base.__hx_invokeField(field, hash, dynargs);
					}
					
				}
				
				return null;
			}
		}
		
		
		public override void __hx_getFields(global::Array<string> baseArr) {
			baseArr.push("helper");
			baseArr.push("bigEndian");
			base.__hx_getFields(baseArr);
		}
		
		
	}
}