haxe/src/sys/io/Process.cs
// Generated by Haxe 4.3.7 (patched: no System.Diagnostics.Process)

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace sys.io {
	public class Process : global::haxe.lang.HxObject {
		
		public Process(global::haxe.lang.EmptyObject empty) {
		}
		
		
		public Process(string cmd, global::Array<string> args, global::haxe.lang.Null<bool> detached) {
			global::sys.io.Process.__hx_ctor_sys_io_Process(this, cmd, args, detached);
		}
		
		
		protected static void __hx_ctor_sys_io_Process(global::sys.io.Process __hx_this, string cmd, global::Array<string> args, global::haxe.lang.Null<bool> detached) {
			if (((detached)).@value) {
				throw ((global::System.Exception) (global::haxe.Exception.thrown("Detached process is not supported on this platform")) );
			}
			
			__hx_this.stdout = new global::cs.io.NativeInput(((global::System.IO.Stream) (new global::System.IO.MemoryStream()) ));
			__hx_this.stderr = new global::cs.io.NativeInput(((global::System.IO.Stream) (new global::System.IO.MemoryStream()) ));
			__hx_this.stdin = new global::cs.io.NativeOutput(((global::System.IO.Stream) (new global::System.IO.MemoryStream()) ));
			__hx_this._exitCode = 0;
			__hx_this._hasExited = true;
		}
		
		
		public static object createNativeProcess(string cmd, global::Array<string> args) {
			throw new global::System.NotSupportedException("Process creation is not supported in whitelist mode.");
		}
		
		
		public static string buildArgumentsString(global::Array<string> args) {
			unchecked {
				if (( global::Sys.systemName() == "Windows" )) {
					global::Array<string> _g = new global::Array<string>(new string[]{});
					{
						int _g1 = 0;
						while (( _g1 < args.length )) {
							string a = args[_g1];
							 ++ _g1;
							_g.push(global::haxe.SysTools.quoteWinArg(a, false));
						}
						
					}
					
					return _g.@join(" ");
				}
				else {
					global::Array<string> _g2 = new global::Array<string>(new string[]{});
					{
						int _g3 = 0;
						while (( _g3 < args.length )) {
							string arg = args[_g3];
							 ++ _g3;
							global::StringBuf b = new global::StringBuf();
							b.@add<string>(((string) ("\"") ));
							{
								int _g4 = 0;
								int _g5 = arg.Length;
								while (( _g4 < _g5 )) {
									int i = _g4++;
									global::haxe.lang.Null<int> c = global::haxe.lang.StringExt.charCodeAt(arg, i);
									if ( ! (c.hasValue) ) {
									}
									else {
										switch (((c)).@value) {
											case 34:
											case 92:
											{
												b.addChar(92);
												break;
											}
											
											
											default:
											{
												break;
											}
											
										}
										
									}
									
									b.addChar((c).@value);
								}
								
							}
							
							b.@add<string>(((string) ("\"") ));
							_g2.push(b.toString());
						}
						
					}
					
					return _g2.@join(" ");
				}
				
			}
		}
		
		
		public global::haxe.io.Input stdout;
		
		public global::haxe.io.Input stderr;
		
		public global::haxe.io.Output stdin;
		
		private int _exitCode;
		
		private bool _hasExited;
		
		public virtual int getPid() {
			return -1;
		}
		
		
		public virtual global::haxe.lang.Null<int> exitCode(global::haxe.lang.Null<bool> block) {
			bool block1 = ( ( ! (block.hasValue) ) ? (true) : ((block).@value) );
			if (( ( block1 == false ) &&  ! (this._hasExited)  )) {
				return default(global::haxe.lang.Null<int>);
			}
			
			return new global::haxe.lang.Null<int>(this._exitCode, true);
		}
		
		
		public virtual void close() {
		}
		
		
		public virtual void kill() {
			this._exitCode = -1;
			this._hasExited = true;
		}
		
		
		public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
			unchecked {
				switch (hash) {
					case 68006728:
					{
						this.stdin = ((global::haxe.io.Output) (@value) );
						return @value;
					}
					
					
					case 132916898:
					{
						this.stderr = ((global::haxe.io.Input) (@value) );
						return @value;
					}
					
					
					case 133414859:
					{
						this.stdout = ((global::haxe.io.Input) (@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 1191829406:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "kill", 1191829406)) );
					}
					
					
					case 1214453688:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "close", 1214453688)) );
					}
					
					
					case 25738091:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "exitCode", 25738091)) );
					}
					
					
					case 589599061:
					{
						return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getPid", 589599061)) );
					}
					
					
					case 68006728:
					{
						return this.stdin;
					}
					
					
					case 132916898:
					{
						return this.stderr;
					}
					
					
					case 133414859:
					{
						return this.stdout;
					}
					
					
					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 1191829406:
					{
						this.kill();
						break;
					}
					
					
					case 1214453688:
					{
						this.close();
						break;
					}
					
					
					case 25738091:
					{
						return (this.exitCode(global::haxe.lang.Null<object>.ofDynamic<bool>(( (( dynargs.Length > 0 )) ? (dynargs[0]) : (null) )))).toDynamic();
					}
					
					
					case 589599061:
					{
						return this.getPid();
					}
					
					
					default:
					{
						return base.__hx_invokeField(field, hash, dynargs);
					}
					
				}
				
				return null;
			}
		}
		
		
		public override void __hx_getFields(global::Array<string> baseArr) {
			baseArr.push("stdin");
			baseArr.push("stderr");
			baseArr.push("stdout");
			base.__hx_getFields(baseArr);
		}
		
		
	}
}