1 module libwasm.bindings.XMLHttpRequest; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.Document; 7 import libwasm.bindings.EventHandler; 8 import libwasm.bindings.Fetch; 9 import libwasm.bindings.LegacyQueryInterface; 10 import libwasm.bindings.XMLHttpRequestEventTarget; 11 import libwasm.bindings.XMLHttpRequestUpload; 12 13 @safe: 14 nothrow: 15 16 struct MozXMLHttpRequestParameters { 17 nothrow: 18 JsHandle handle; 19 alias handle this; 20 this(Handle h) { 21 this.handle = JsHandle(h); 22 } 23 static auto create() { 24 return MozXMLHttpRequestParameters(libwasm_add__object()); 25 } 26 void mozAnon()(bool mozAnon) { 27 Object_Call_bool__void(this.handle, "mozAnon", mozAnon); 28 } 29 bool mozAnon()() { 30 return Object_Getter__bool(this.handle, "mozAnon"); 31 } 32 void mozSystem()(bool mozSystem) { 33 Object_Call_bool__void(this.handle, "mozSystem", mozSystem); 34 } 35 bool mozSystem()() { 36 return Object_Getter__bool(this.handle, "mozSystem"); 37 } 38 } 39 struct XMLHttpRequest { 40 nothrow: 41 libwasm.bindings.XMLHttpRequestEventTarget.XMLHttpRequestEventTarget _parent; 42 alias _parent this; 43 this(Handle h) { 44 _parent = .XMLHttpRequestEventTarget(h); 45 } 46 void onreadystatechange(T0)(scope auto ref Optional!(T0) onreadystatechange) if (isTOrPointer!(T0, EventHandlerNonNull)) { 47 Object_Call_EventHandler__void(this._parent, "onreadystatechange", !onreadystatechange.empty, onreadystatechange.front); 48 } 49 EventHandler onreadystatechange()() { 50 return Object_Getter__EventHandler(this._parent, "onreadystatechange"); 51 } 52 enum ushort UNSENT = 0; 53 enum ushort OPENED = 1; 54 enum ushort HEADERS_RECEIVED = 2; 55 enum ushort LOADING = 3; 56 enum ushort DONE = 4; 57 ushort readyState()() { 58 return Object_Getter__ushort(this._parent, "readyState"); 59 } 60 void open()(string method, string url) { 61 Object_Call_string_string__void(this._parent, "open", method, url); 62 } 63 void open(T3, T4)(string method, string url, bool async, scope auto ref Optional!(T3) user /* = no!(string) */, scope auto ref Optional!(T4) password /* = no!(string) */) if (isTOrPointer!(T3, string) && isTOrPointer!(T4, string)) { 64 Serialize_Object_VarArgCall!void(this._parent, "open", "string;string;bool;Optional!(string);Optional!(string)", tuple(method, url, async, !user.empty, user.front, !password.empty, password.front)); 65 } 66 void open(T3)(string method, string url, bool async, scope auto ref Optional!(T3) user /* = no!(string) */) if (isTOrPointer!(T3, string)) { 67 Serialize_Object_VarArgCall!void(this._parent, "open", "string;string;bool;Optional!(string)", tuple(method, url, async, !user.empty, user.front)); 68 } 69 void open()(string method, string url, bool async) { 70 Serialize_Object_VarArgCall!void(this._parent, "open", "string;string;bool", tuple(method, url, async)); 71 } 72 void setRequestHeader()(string header, string value) { 73 Object_Call_string_string__void(this._parent, "setRequestHeader", header, value); 74 } 75 void timeout()(uint timeout) { 76 Object_Call_uint__void(this._parent, "timeout", timeout); 77 } 78 uint timeout()() { 79 return Object_Getter__uint(this._parent, "timeout"); 80 } 81 void withCredentials()(bool withCredentials) { 82 Object_Call_bool__void(this._parent, "withCredentials", withCredentials); 83 } 84 bool withCredentials()() { 85 return Object_Getter__bool(this._parent, "withCredentials"); 86 } 87 auto upload()() { 88 return XMLHttpRequestUpload(Object_Getter__Handle(this._parent, "upload")); 89 } 90 void send(T0)(scope auto ref Optional!(T0) body_ /* = no!(SumType!(Document, BodyInit)) */) if (isTOrPointer!(T0, SumType!(Document, BodyInit))) { 91 Serialize_Object_VarArgCall!void(this._parent, "send", "Optional!SumType!(Handle,Handle,Handle,Handle,Handle,string)", tuple(!body_.empty, libwasm.sumtype.match!(((ref body_.Types[0] v) => 0),((ref body_.Types[1] v) => 1),((ref body_.Types[2] v) => 2),((ref body_.Types[3] v) => 3),((ref body_.Types[4] v) => 4),((string v) => 5))(body_),tuple(libwasm.sumtype.match!(((ref body_.Types[0] v) => cast(Handle)v.handle),((ref body_.Types[1] v) => Handle.init),((ref body_.Types[2] v) => Handle.init),((ref body_.Types[3] v) => Handle.init),((ref body_.Types[4] v) => Handle.init),((string v) => Handle.init))(body_),libwasm.sumtype.match!(((ref body_.Types[0] v) => Handle.init),((ref body_.Types[1] v) => cast(Handle)v.handle),((ref body_.Types[2] v) => Handle.init),((ref body_.Types[3] v) => Handle.init),((ref body_.Types[4] v) => Handle.init),((string v) => Handle.init))(body_),libwasm.sumtype.match!(((ref body_.Types[0] v) => Handle.init),((ref body_.Types[1] v) => Handle.init),((ref body_.Types[2] v) => cast(Handle)v.handle),((ref body_.Types[3] v) => Handle.init),((ref body_.Types[4] v) => Handle.init),((string v) => Handle.init))(body_),libwasm.sumtype.match!(((ref body_.Types[0] v) => Handle.init),((ref body_.Types[1] v) => Handle.init),((ref body_.Types[2] v) => Handle.init),((ref body_.Types[3] v) => cast(Handle)v.handle),((ref body_.Types[4] v) => Handle.init),((string v) => Handle.init))(body_),libwasm.sumtype.match!(((ref body_.Types[0] v) => Handle.init),((ref body_.Types[1] v) => Handle.init),((ref body_.Types[2] v) => Handle.init),((ref body_.Types[3] v) => Handle.init),((ref body_.Types[4] v) => cast(Handle)v.handle),((string v) => Handle.init))(body_),libwasm.sumtype.match!(((ref body_.Types[0] v) => string.init),((ref body_.Types[1] v) => string.init),((ref body_.Types[2] v) => string.init),((ref body_.Types[3] v) => string.init),((ref body_.Types[4] v) => string.init),((string v) => v))(body_)))); 92 } 93 void send()() { 94 Object_Call__void(this._parent, "send"); 95 } 96 void abort()() { 97 Object_Call__void(this._parent, "abort"); 98 } 99 string responseURL()() { 100 return Object_Getter__string(this._parent, "responseURL"); 101 } 102 ushort status()() { 103 return Object_Getter__ushort(this._parent, "status"); 104 } 105 string statusText()() { 106 return Object_Getter__string(this._parent, "statusText"); 107 } 108 Optional!(string) getResponseHeader()(string header) { 109 return Object_Call_string__OptionalString(this._parent, "getResponseHeader", header); 110 } 111 string getAllResponseHeaders()() { 112 return Object_Getter__string(this._parent, "getAllResponseHeaders"); 113 } 114 void overrideMimeType()(string mime) { 115 Object_Call_string__void(this._parent, "overrideMimeType", mime); 116 } 117 void responseType()(XMLHttpRequestResponseType responseType) { 118 Object_Call_int__void(this._parent, "responseType", responseType); 119 } 120 XMLHttpRequestResponseType responseType()() { 121 return Object_Getter__int(this._parent, "responseType"); 122 } 123 auto response()() { 124 return Any(Object_Getter__Handle(this._parent, "response")); 125 } 126 Optional!(string) responseText()() { 127 return Object_Getter__OptionalString(this._parent, "responseText"); 128 } 129 auto responseXML()() { 130 return recastOpt!(Document)(Object_Getter__OptionalHandle(this._parent, "responseXML")); 131 } 132 void mozBackgroundRequest()(bool mozBackgroundRequest) { 133 Object_Call_bool__void(this._parent, "mozBackgroundRequest", mozBackgroundRequest); 134 } 135 bool mozBackgroundRequest()() { 136 return Object_Getter__bool(this._parent, "mozBackgroundRequest"); 137 } 138 auto channel()() { 139 return recastOpt!(MozChannel)(Object_Getter__OptionalHandle(this._parent, "channel")); 140 } 141 auto getInterface(T0)(scope auto ref T0 iid) { 142 // Any 143 Handle _handle_iid = getOrCreateHandle(iid); 144 auto result = Any(Object_Call_Handle__Handle(this._parent, "getInterface", _handle_iid)); 145 dropHandle!(T0)(_handle_iid); 146 return result; 147 } 148 void setOriginAttributes()(scope ref OriginAttributesDictionary originAttributes) { 149 Object_Call_Handle__void(this._parent, "setOriginAttributes", originAttributes.handle); 150 } 151 void setOriginAttributes()() { 152 Object_Call__void(this._parent, "setOriginAttributes"); 153 } 154 void sendInputStream()(scope ref InputStream body_) { 155 Object_Call_Handle__void(this._parent, "sendInputStream", body_.handle); 156 } 157 ushort errorCode()() { 158 return Object_Getter__ushort(this._parent, "errorCode"); 159 } 160 bool mozAnon()() { 161 return Object_Getter__bool(this._parent, "mozAnon"); 162 } 163 bool mozSystem()() { 164 return Object_Getter__bool(this._parent, "mozSystem"); 165 } 166 auto QueryInterface(T0)(scope auto ref T0 iid) { 167 // Any 168 Handle _handle_iid = getOrCreateHandle(iid); 169 auto result = nsISupports(Object_Call_Handle__Handle(this._parent, "QueryInterface", _handle_iid)); 170 dropHandle!(T0)(_handle_iid); 171 return result; 172 } 173 } 174 enum XMLHttpRequestResponseType { 175 none, 176 arraybuffer, 177 blob, 178 document, 179 json, 180 text, 181 moz_chunked_arraybuffer 182 } 183 184