1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
6use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
7use crate::import::base::*;
8use crate::record::Record;
9
10pub use self::GenericUnionTypes::ByteStringSequenceSequenceOrByteStringByteStringRecord as HeadersInit;
11
12pub use self::Headers_Binding::{Wrap as HeadersWrap, HeadersMethods, GetProtoObject as HeadersGetProtoObject, DefineDOMInterface as HeadersDefineDOMInterface};
13pub mod Headers_Binding {
14use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
15use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
16use crate::import::module::*;
17use crate::record::Record;
18
19unsafe extern "C" fn append<D: DomTypes>
20(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
21 let mut result = false;
22 wrap_panic(&mut || result = (|| {
23 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
24 let this = &*(this as *const D::Headers);
25 let args = &*args;
26 let argc = args.argc_;
27
28 if argc < 2 {
29 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.append\".");
30 return false;
31 }
32 let arg0: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
33 Ok(ConversionResult::Success(value)) => value,
34 Ok(ConversionResult::Failure(error)) => {
35 throw_type_error(cx.raw_cx(), &error);
36 return false;
37
38 }
39 _ => {
40 return false;
41
42 },
43 }
44 ;
45 let arg1: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
46 Ok(ConversionResult::Success(value)) => value,
47 Ok(ConversionResult::Failure(error)) => {
48 throw_type_error(cx.raw_cx(), &error);
49 return false;
50
51 }
52 _ => {
53 return false;
54
55 },
56 }
57 ;
58 let result: Result<(), Error> = this.Append(arg0, arg1);
59 let result = match result {
60 Ok(result) => result,
61 Err(e) => {
62 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
63 return false;
64 },
65 };
66
67 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
68 return true;
69 })());
70 result
71}
72
73
74static append_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
75
76pub(crate) fn init_append_methodinfo<D: DomTypes>() {
77 append_methodinfo.set(JSJitInfo {
78 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
79 method: Some(append::<D>)
80 },
81 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
82 protoID: PrototypeList::ID::Headers as u16,
83 },
84 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
85 _bitfield_align_1: [],
86 _bitfield_1: __BindgenBitfieldUnit::new(
87 new_jsjitinfo_bitfield_1!(
88 JSJitInfo_OpType::Method as u8,
89 JSJitInfo_AliasSet::AliasEverything as u8,
90 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
91 false,
92 false,
93 false,
94 false,
95 false,
96 false,
97 0,
98 ).to_ne_bytes()
99 ),
100});
101}
102unsafe extern "C" fn delete<D: DomTypes>
103(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
104 let mut result = false;
105 wrap_panic(&mut || result = (|| {
106 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
107 let this = &*(this as *const D::Headers);
108 let args = &*args;
109 let argc = args.argc_;
110
111 if argc < 1 {
112 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.delete\".");
113 return false;
114 }
115 let arg0: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
116 Ok(ConversionResult::Success(value)) => value,
117 Ok(ConversionResult::Failure(error)) => {
118 throw_type_error(cx.raw_cx(), &error);
119 return false;
120
121 }
122 _ => {
123 return false;
124
125 },
126 }
127 ;
128 let result: Result<(), Error> = this.Delete(arg0);
129 let result = match result {
130 Ok(result) => result,
131 Err(e) => {
132 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
133 return false;
134 },
135 };
136
137 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
138 return true;
139 })());
140 result
141}
142
143
144static delete_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
145
146pub(crate) fn init_delete_methodinfo<D: DomTypes>() {
147 delete_methodinfo.set(JSJitInfo {
148 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
149 method: Some(delete::<D>)
150 },
151 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
152 protoID: PrototypeList::ID::Headers as u16,
153 },
154 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
155 _bitfield_align_1: [],
156 _bitfield_1: __BindgenBitfieldUnit::new(
157 new_jsjitinfo_bitfield_1!(
158 JSJitInfo_OpType::Method as u8,
159 JSJitInfo_AliasSet::AliasEverything as u8,
160 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
161 false,
162 false,
163 false,
164 false,
165 false,
166 false,
167 0,
168 ).to_ne_bytes()
169 ),
170});
171}
172unsafe extern "C" fn get<D: DomTypes>
173(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
174 let mut result = false;
175 wrap_panic(&mut || result = (|| {
176 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
177 let this = &*(this as *const D::Headers);
178 let args = &*args;
179 let argc = args.argc_;
180
181 if argc < 1 {
182 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.get\".");
183 return false;
184 }
185 let arg0: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
186 Ok(ConversionResult::Success(value)) => value,
187 Ok(ConversionResult::Failure(error)) => {
188 throw_type_error(cx.raw_cx(), &error);
189 return false;
190
191 }
192 _ => {
193 return false;
194
195 },
196 }
197 ;
198 let result: Result<Option<ByteString>, Error> = this.Get(arg0);
199 let result = match result {
200 Ok(result) => result,
201 Err(e) => {
202 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
203 return false;
204 },
205 };
206
207 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
208 return true;
209 })());
210 result
211}
212
213
214static get_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
215
216pub(crate) fn init_get_methodinfo<D: DomTypes>() {
217 get_methodinfo.set(JSJitInfo {
218 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
219 method: Some(get::<D>)
220 },
221 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
222 protoID: PrototypeList::ID::Headers as u16,
223 },
224 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
225 _bitfield_align_1: [],
226 _bitfield_1: __BindgenBitfieldUnit::new(
227 new_jsjitinfo_bitfield_1!(
228 JSJitInfo_OpType::Method as u8,
229 JSJitInfo_AliasSet::AliasEverything as u8,
230 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
231 false,
232 false,
233 false,
234 false,
235 false,
236 false,
237 0,
238 ).to_ne_bytes()
239 ),
240});
241}
242unsafe extern "C" fn getSetCookie<D: DomTypes>
243(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
244 let mut result = false;
245 wrap_panic(&mut || result = (|| {
246 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
247 let this = &*(this as *const D::Headers);
248 let args = &*args;
249 let argc = args.argc_;
250 let result: Vec<ByteString> = this.GetSetCookie();
251
252 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
253 return true;
254 })());
255 result
256}
257
258
259static getSetCookie_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
260
261pub(crate) fn init_getSetCookie_methodinfo<D: DomTypes>() {
262 getSetCookie_methodinfo.set(JSJitInfo {
263 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
264 method: Some(getSetCookie::<D>)
265 },
266 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
267 protoID: PrototypeList::ID::Headers as u16,
268 },
269 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
270 _bitfield_align_1: [],
271 _bitfield_1: __BindgenBitfieldUnit::new(
272 new_jsjitinfo_bitfield_1!(
273 JSJitInfo_OpType::Method as u8,
274 JSJitInfo_AliasSet::AliasEverything as u8,
275 JSValueType::JSVAL_TYPE_OBJECT as u8,
276 true,
277 false,
278 false,
279 false,
280 false,
281 false,
282 0,
283 ).to_ne_bytes()
284 ),
285});
286}
287unsafe extern "C" fn has<D: DomTypes>
288(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
289 let mut result = false;
290 wrap_panic(&mut || result = (|| {
291 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
292 let this = &*(this as *const D::Headers);
293 let args = &*args;
294 let argc = args.argc_;
295
296 if argc < 1 {
297 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.has\".");
298 return false;
299 }
300 let arg0: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
301 Ok(ConversionResult::Success(value)) => value,
302 Ok(ConversionResult::Failure(error)) => {
303 throw_type_error(cx.raw_cx(), &error);
304 return false;
305
306 }
307 _ => {
308 return false;
309
310 },
311 }
312 ;
313 let result: Result<bool, Error> = this.Has(arg0);
314 let result = match result {
315 Ok(result) => result,
316 Err(e) => {
317 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
318 return false;
319 },
320 };
321
322 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
323 return true;
324 })());
325 result
326}
327
328
329static has_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
330
331pub(crate) fn init_has_methodinfo<D: DomTypes>() {
332 has_methodinfo.set(JSJitInfo {
333 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
334 method: Some(has::<D>)
335 },
336 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
337 protoID: PrototypeList::ID::Headers as u16,
338 },
339 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
340 _bitfield_align_1: [],
341 _bitfield_1: __BindgenBitfieldUnit::new(
342 new_jsjitinfo_bitfield_1!(
343 JSJitInfo_OpType::Method as u8,
344 JSJitInfo_AliasSet::AliasEverything as u8,
345 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
346 false,
347 false,
348 false,
349 false,
350 false,
351 false,
352 0,
353 ).to_ne_bytes()
354 ),
355});
356}
357unsafe extern "C" fn set<D: DomTypes>
358(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
359 let mut result = false;
360 wrap_panic(&mut || result = (|| {
361 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
362 let this = &*(this as *const D::Headers);
363 let args = &*args;
364 let argc = args.argc_;
365
366 if argc < 2 {
367 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.set\".");
368 return false;
369 }
370 let arg0: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
371 Ok(ConversionResult::Success(value)) => value,
372 Ok(ConversionResult::Failure(error)) => {
373 throw_type_error(cx.raw_cx(), &error);
374 return false;
375
376 }
377 _ => {
378 return false;
379
380 },
381 }
382 ;
383 let arg1: ByteString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
384 Ok(ConversionResult::Success(value)) => value,
385 Ok(ConversionResult::Failure(error)) => {
386 throw_type_error(cx.raw_cx(), &error);
387 return false;
388
389 }
390 _ => {
391 return false;
392
393 },
394 }
395 ;
396 let result: Result<(), Error> = this.Set(arg0, arg1);
397 let result = match result {
398 Ok(result) => result,
399 Err(e) => {
400 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
401 return false;
402 },
403 };
404
405 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
406 return true;
407 })());
408 result
409}
410
411
412static set_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
413
414pub(crate) fn init_set_methodinfo<D: DomTypes>() {
415 set_methodinfo.set(JSJitInfo {
416 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
417 method: Some(set::<D>)
418 },
419 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
420 protoID: PrototypeList::ID::Headers as u16,
421 },
422 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
423 _bitfield_align_1: [],
424 _bitfield_1: __BindgenBitfieldUnit::new(
425 new_jsjitinfo_bitfield_1!(
426 JSJitInfo_OpType::Method as u8,
427 JSJitInfo_AliasSet::AliasEverything as u8,
428 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
429 false,
430 false,
431 false,
432 false,
433 false,
434 false,
435 0,
436 ).to_ne_bytes()
437 ),
438});
439}
440unsafe extern "C" fn entries<D: DomTypes>
441(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
442 let mut result = false;
443 wrap_panic(&mut || result = (|| {
444 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
445 let this = &*(this as *const D::Headers);
446 let args = &*args;
447 let argc = args.argc_;
448 let realm = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()));
449 let result = IterableIterator::new(this, IteratorType::Entries, InRealm::already(&realm));
450
451
452 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
453 return true;
454 })());
455 result
456}
457
458const entries_methodinfo_argTypes: [i32; 1] = [ JSJitInfo_ArgType::ArgTypeListEnd as i32 ];
459static entries_methodinfo: ThreadUnsafeOnceLock<JSTypedMethodJitInfo> = ThreadUnsafeOnceLock::new();
460
461pub(crate) fn init_entries_methodinfo<D: DomTypes>() {
462 entries_methodinfo.set(JSTypedMethodJitInfo {
463 base: JSJitInfo {
464 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
465 method: Some(entries::<D>)
466 },
467 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
468 protoID: PrototypeList::ID::Headers as u16,
469 },
470 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
471 _bitfield_align_1: [],
472 _bitfield_1: __BindgenBitfieldUnit::new(
473 new_jsjitinfo_bitfield_1!(
474 JSJitInfo_OpType::Method as u8,
475 JSJitInfo_AliasSet::AliasEverything as u8,
476 JSValueType::JSVAL_TYPE_OBJECT as u8,
477 false,
478 false,
479 false,
480 false,
481 false,
482 true,
483 0,
484 ).to_ne_bytes()
485 ),
486 },
487 argTypes: &entries_methodinfo_argTypes as *const _ as *const JSJitInfo_ArgType,
488 });
489}
490
491unsafe extern "C" fn keys<D: DomTypes>
492(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
493 let mut result = false;
494 wrap_panic(&mut || result = (|| {
495 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
496 let this = &*(this as *const D::Headers);
497 let args = &*args;
498 let argc = args.argc_;
499 let realm = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()));
500 let result = IterableIterator::new(this, IteratorType::Keys, InRealm::already(&realm));
501
502
503 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
504 return true;
505 })());
506 result
507}
508
509const keys_methodinfo_argTypes: [i32; 1] = [ JSJitInfo_ArgType::ArgTypeListEnd as i32 ];
510static keys_methodinfo: ThreadUnsafeOnceLock<JSTypedMethodJitInfo> = ThreadUnsafeOnceLock::new();
511
512pub(crate) fn init_keys_methodinfo<D: DomTypes>() {
513 keys_methodinfo.set(JSTypedMethodJitInfo {
514 base: JSJitInfo {
515 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
516 method: Some(keys::<D>)
517 },
518 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
519 protoID: PrototypeList::ID::Headers as u16,
520 },
521 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
522 _bitfield_align_1: [],
523 _bitfield_1: __BindgenBitfieldUnit::new(
524 new_jsjitinfo_bitfield_1!(
525 JSJitInfo_OpType::Method as u8,
526 JSJitInfo_AliasSet::AliasEverything as u8,
527 JSValueType::JSVAL_TYPE_OBJECT as u8,
528 false,
529 false,
530 false,
531 false,
532 false,
533 true,
534 0,
535 ).to_ne_bytes()
536 ),
537 },
538 argTypes: &keys_methodinfo_argTypes as *const _ as *const JSJitInfo_ArgType,
539 });
540}
541
542unsafe extern "C" fn values<D: DomTypes>
543(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
544 let mut result = false;
545 wrap_panic(&mut || result = (|| {
546 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
547 let this = &*(this as *const D::Headers);
548 let args = &*args;
549 let argc = args.argc_;
550 let realm = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()));
551 let result = IterableIterator::new(this, IteratorType::Values, InRealm::already(&realm));
552
553
554 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
555 return true;
556 })());
557 result
558}
559
560const values_methodinfo_argTypes: [i32; 1] = [ JSJitInfo_ArgType::ArgTypeListEnd as i32 ];
561static values_methodinfo: ThreadUnsafeOnceLock<JSTypedMethodJitInfo> = ThreadUnsafeOnceLock::new();
562
563pub(crate) fn init_values_methodinfo<D: DomTypes>() {
564 values_methodinfo.set(JSTypedMethodJitInfo {
565 base: JSJitInfo {
566 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
567 method: Some(values::<D>)
568 },
569 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
570 protoID: PrototypeList::ID::Headers as u16,
571 },
572 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
573 _bitfield_align_1: [],
574 _bitfield_1: __BindgenBitfieldUnit::new(
575 new_jsjitinfo_bitfield_1!(
576 JSJitInfo_OpType::Method as u8,
577 JSJitInfo_AliasSet::AliasEverything as u8,
578 JSValueType::JSVAL_TYPE_OBJECT as u8,
579 false,
580 false,
581 false,
582 false,
583 false,
584 true,
585 0,
586 ).to_ne_bytes()
587 ),
588 },
589 argTypes: &values_methodinfo_argTypes as *const _ as *const JSJitInfo_ArgType,
590 });
591}
592
593unsafe extern "C" fn forEach<D: DomTypes>
594(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
595 let mut result = false;
596 wrap_panic(&mut || result = (|| {
597 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
598 let this = &*(this as *const D::Headers);
599 let args = &*args;
600 let argc = args.argc_;
601
602 if argc < 1 {
603 throw_type_error(cx.raw_cx(), "Not enough arguments to \"Headers.forEach\".");
604 return false;
605 }
606 let arg0: *mut JSObject = if HandleValue::from_raw(args.get(0)).get().is_object() {
607 HandleValue::from_raw(args.get(0)).get().to_object()
608 } else {
609 throw_type_error(cx.raw_cx(), "Value is not an object.");
610 return false;
611
612 };
613 let arg1: HandleValue = if args.get(1).is_undefined() {
614 HandleValue::undefined()
615 } else {
616 HandleValue::from_raw(args.get(1))
617 };
618 if !IsCallable(arg0) {
619 throw_type_error(cx.raw_cx(), "Argument 1 of Headers.forEach is not callable.");
620 return false;
621 }
622 rooted!(&in(cx) let arg0 = ObjectValue(arg0));
623 rooted!(&in(cx) let mut call_arg1 = UndefinedValue());
624 rooted!(&in(cx) let mut call_arg2 = UndefinedValue());
625 rooted_vec!(let mut call_args);
626 call_args.push(UndefinedValue());
627 call_args.push(UndefinedValue());
628 call_args.push(ObjectValue(*_obj));
629 rooted!(&in(cx) let mut ignoredReturnVal = UndefinedValue());
630
631 let mut i = 0;
639 while i < (*this).get_iterable_length() {
640 (*this).get_value_at_index(i).to_jsval(cx.raw_cx(), call_arg1.handle_mut());
641 (*this).get_key_at_index(i).to_jsval(cx.raw_cx(), call_arg2.handle_mut());
642 call_args[0] = call_arg1.handle().get();
643 call_args[1] = call_arg2.handle().get();
644 let call_args_handle = HandleValueArray::from(&call_args);
645 if !Call(cx.raw_cx(), arg1, arg0.handle(), &call_args_handle,
646 ignoredReturnVal.handle_mut()) {
647 return false;
648 }
649
650 i += 1;
651 }
652
653 let result = ();
654
655
656 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
657 return true;
658 })());
659 result
660}
661
662
663static forEach_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
664
665pub(crate) fn init_forEach_methodinfo<D: DomTypes>() {
666 forEach_methodinfo.set(JSJitInfo {
667 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
668 method: Some(forEach::<D>)
669 },
670 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
671 protoID: PrototypeList::ID::Headers as u16,
672 },
673 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
674 _bitfield_align_1: [],
675 _bitfield_1: __BindgenBitfieldUnit::new(
676 new_jsjitinfo_bitfield_1!(
677 JSJitInfo_OpType::Method as u8,
678 JSJitInfo_AliasSet::AliasEverything as u8,
679 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
680 false,
681 false,
682 false,
683 false,
684 false,
685 false,
686 0,
687 ).to_ne_bytes()
688 ),
689});
690}
691unsafe extern "C" fn _finalize<D: DomTypes>
692(_cx: *mut GCContext, obj: *mut JSObject){
693 wrap_panic(&mut || {
694
695 let this = native_from_object_static::<D::Headers>(obj).unwrap();
696 finalize_common(this);
697 })
698}
699
700unsafe extern "C" fn _trace<D: DomTypes>
701(trc: *mut JSTracer, obj: *mut JSObject){
702 wrap_panic(&mut || {
703
704 let this = native_from_object_static::<D::Headers>(obj).unwrap();
705 if this.is_null() { return; } (*this).trace(trc);
707 })
708}
709
710
711static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
712
713pub(crate) fn init_class_ops<D: DomTypes>() {
714 CLASS_OPS.set(JSClassOps {
715 addProperty: None,
716 delProperty: None,
717 enumerate: None,
718 newEnumerate: None,
719 resolve: None,
720 mayResolve: None,
721 finalize: Some(_finalize::<D>),
722 call: None,
723 construct: None,
724 trace: Some(_trace::<D>),
725 });
726}
727
728pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
729
730pub(crate) fn init_domjs_class<D: DomTypes>() {
731 init_class_ops::<D>();
732 Class.set(DOMJSClass {
733 base: JSClass {
734 name: c"Headers".as_ptr(),
735 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
736 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
737 ,
738 cOps: unsafe { CLASS_OPS.get() },
739 spec: ptr::null(),
740 ext: ptr::null(),
741 oOps: ptr::null(),
742 },
743 dom_class:
744DOMClass {
745 interface_chain: [ PrototypeList::ID::Headers, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
746 depth: 0,
747 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
748 malloc_size_of: malloc_size_of_including_raw_self::<D::Headers> as unsafe fn(&mut _, _) -> _,
749 global: Globals::EMPTY,
750},
751 });
752}
753
754#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
755(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::Headers>, _can_gc: CanGc) -> DomRoot<D::Headers>{
756
757 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
758
759 let scope = scope.reflector().get_jsobject();
760 assert!(!scope.get().is_null());
761 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
762 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
763
764 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
765 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
766 assert!(!canonical_proto.is_null());
767
768
769 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
770 if let Some(given) = given_proto {
771 proto.set(*given);
772 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
773 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
774 }
775 } else {
776 proto.set(*canonical_proto);
777 }
778 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
779 cx.raw_cx(),
780 &Class.get().base,
781 proto.handle(),
782 ));
783 assert!(!obj.is_null());
784 JS_SetReservedSlot(
785 obj.get(),
786 DOM_OBJECT_SLOT,
787 &PrivateValue(raw.as_ptr() as *const libc::c_void),
788 );
789
790 let root = raw.reflect_with(obj.get());
791
792
793
794 DomRoot::from_ref(&*root)
795}
796
797pub trait HeadersMethods<D: DomTypes> {
798 fn Append(&self, r#name: ByteString, r#value: ByteString) -> Fallible<()>;
799 fn Delete(&self, r#name: ByteString) -> Fallible<()>;
800 fn Get(&self, r#name: ByteString) -> Fallible<Option<ByteString>>;
801 fn GetSetCookie(&self, ) -> Vec<ByteString>;
802 fn Has(&self, r#name: ByteString) -> Fallible<bool>;
803 fn Set(&self, r#name: ByteString, r#value: ByteString) -> Fallible<()>;
804 fn Constructor(r#global: &D::GlobalScope, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#init: Option<GenericUnionTypes::ByteStringSequenceSequenceOrByteStringByteStringRecord>) -> Fallible<DomRoot<D::Headers>>;
805}
806static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
807
808pub(crate) fn init_sMethods_specs<D: DomTypes>() {
809 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
810 JSFunctionSpec {
811 name: JSPropertySpec_Name { string_: c"append".as_ptr() },
812 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { append_methodinfo.get() } as *const _ as *const JSJitInfo },
813 nargs: 2,
814 flags: (JSPROP_ENUMERATE) as u16,
815 selfHostedName: ptr::null()
816 },
817 JSFunctionSpec {
818 name: JSPropertySpec_Name { string_: c"delete".as_ptr() },
819 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { delete_methodinfo.get() } as *const _ as *const JSJitInfo },
820 nargs: 1,
821 flags: (JSPROP_ENUMERATE) as u16,
822 selfHostedName: ptr::null()
823 },
824 JSFunctionSpec {
825 name: JSPropertySpec_Name { string_: c"get".as_ptr() },
826 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { get_methodinfo.get() } as *const _ as *const JSJitInfo },
827 nargs: 1,
828 flags: (JSPROP_ENUMERATE) as u16,
829 selfHostedName: ptr::null()
830 },
831 JSFunctionSpec {
832 name: JSPropertySpec_Name { string_: c"getSetCookie".as_ptr() },
833 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getSetCookie_methodinfo.get() } as *const _ as *const JSJitInfo },
834 nargs: 0,
835 flags: (JSPROP_ENUMERATE) as u16,
836 selfHostedName: ptr::null()
837 },
838 JSFunctionSpec {
839 name: JSPropertySpec_Name { string_: c"has".as_ptr() },
840 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { has_methodinfo.get() } as *const _ as *const JSJitInfo },
841 nargs: 1,
842 flags: (JSPROP_ENUMERATE) as u16,
843 selfHostedName: ptr::null()
844 },
845 JSFunctionSpec {
846 name: JSPropertySpec_Name { string_: c"set".as_ptr() },
847 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { set_methodinfo.get() } as *const _ as *const JSJitInfo },
848 nargs: 2,
849 flags: (JSPROP_ENUMERATE) as u16,
850 selfHostedName: ptr::null()
851 },
852 JSFunctionSpec {
853 name: JSPropertySpec_Name { string_: c"entries".as_ptr() },
854 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { entries_methodinfo.get() } as *const _ as *const JSJitInfo },
855 nargs: 0,
856 flags: (JSPROP_ENUMERATE) as u16,
857 selfHostedName: ptr::null()
858 },
859 JSFunctionSpec {
860 name: JSPropertySpec_Name { string_: c"keys".as_ptr() },
861 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { keys_methodinfo.get() } as *const _ as *const JSJitInfo },
862 nargs: 0,
863 flags: (JSPROP_ENUMERATE) as u16,
864 selfHostedName: ptr::null()
865 },
866 JSFunctionSpec {
867 name: JSPropertySpec_Name { string_: c"values".as_ptr() },
868 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { values_methodinfo.get() } as *const _ as *const JSJitInfo },
869 nargs: 0,
870 flags: (JSPROP_ENUMERATE) as u16,
871 selfHostedName: ptr::null()
872 },
873 JSFunctionSpec {
874 name: JSPropertySpec_Name { string_: c"forEach".as_ptr() },
875 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { forEach_methodinfo.get() } as *const _ as *const JSJitInfo },
876 nargs: 1,
877 flags: (JSPROP_ENUMERATE) as u16,
878 selfHostedName: ptr::null()
879 },
880 JSFunctionSpec {
881 name: JSPropertySpec_Name { string_: ptr::null() },
882 call: JSNativeWrapper { op: None, info: ptr::null() },
883 nargs: 0,
884 flags: 0,
885 selfHostedName: ptr::null()
886 }]))[..]
887])));
888}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
889
890pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
891 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sMethods_specs.get() })[0])])));
892}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
893
894pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
895 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
896 JSPropertySpec {
897 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
898 attributes_: (JSPROP_READONLY),
899 kind_: (JSPropertySpec_Kind::Value),
900 u: JSPropertySpec_AccessorsOrValue {
901 value: JSPropertySpec_ValueWrapper {
902 type_: JSPropertySpec_ValueWrapper_Type::String,
903 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
904 string: c"Headers".as_ptr(),
905 }
906 }
907 }
908 }
909,
910 JSPropertySpec::ZERO]))[..]
911])));
912}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
913
914pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
915 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
916}
917pub fn GetProtoObject<D: DomTypes>
918(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
919 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::Headers), CreateInterfaceObjects::<D>, rval)
921}
922
923
924static PrototypeClass: JSClass = JSClass {
925 name: c"HeadersPrototype".as_ptr(),
926 flags:
927 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
929 cOps: ptr::null(),
930 spec: ptr::null(),
931 ext: ptr::null(),
932 oOps: ptr::null(),
933};
934
935unsafe extern "C" fn _constructor<D: DomTypes>
936(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
937 let mut result = false;
938 wrap_panic(&mut || result = {
939 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
940 let args = CallArgs::from_vp(vp, argc);
941 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
942
943 call_default_constructor::<D>(
944 SafeJSContext::from_ptr(cx.raw_cx()),
945 &args,
946 &global,
947 PrototypeList::ID::Headers,
948 "Headers",
949 CreateInterfaceObjects::<D>,
950 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
951 let arg0: Option<GenericUnionTypes::ByteStringSequenceSequenceOrByteStringByteStringRecord> = if args.get(0).is_undefined() {
952 None
953 } else {
954 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
955 Ok(ConversionResult::Success(value)) => value,
956 Ok(ConversionResult::Failure(error)) => {
957 throw_type_error(cx.raw_cx(), &error);
958 return false;
959
960 }
961 _ => {
962 return false;
963
964 },
965 }
966 )
967 };
968 let result: Result<DomRoot<D::Headers>, Error> = <D::Headers>::Constructor(global, Some(desired_proto), CanGc::note(), arg0);
969 let result = match result {
970 Ok(result) => result,
971 Err(e) => {
972 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), global.upcast::<D::GlobalScope>(), e, CanGc::note());
973 return false;
974 },
975 };
976
977 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
978 return true;
979 }
980 )
981
982 });
983 result
984}
985
986
987static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
988
989pub(crate) fn init_interface_object<D: DomTypes>() {
990 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
991 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
992 b"function Headers() {\n [native code]\n}",
993 PrototypeList::ID::Headers,
994 0,
995 ));
996}
997
998pub fn DefineDOMInterface<D: DomTypes>
999(cx: SafeJSContext, global: HandleObject){
1000 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::Headers),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
1001}
1002
1003pub fn ConstructorEnabled<D: DomTypes>
1004(aCx: SafeJSContext, aObj: HandleObject) -> bool{
1005 is_exposed_in(aObj, Globals::DEDICATED_WORKER_GLOBAL_SCOPE | Globals::SERVICE_WORKER_GLOBAL_SCOPE | Globals::WINDOW)
1006}
1007
1008unsafe fn CreateInterfaceObjects<D: DomTypes>
1009(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
1010
1011 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
1012 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
1013 assert!(!prototype_proto.is_null());
1014
1015 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
1016 create_interface_prototype_object::<D>(cx,
1017 global,
1018 prototype_proto.handle(),
1019 &PrototypeClass,
1020 sMethods.get(),
1021 sAttributes.get(),
1022 &[],
1023 &[],
1024 prototype.handle_mut());
1025 assert!(!prototype.is_null());
1026 assert!((*cache)[PrototypeList::ID::Headers as usize].is_null());
1027 (*cache)[PrototypeList::ID::Headers as usize] = prototype.get();
1028 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::Headers as isize),
1029 ptr::null_mut(),
1030 prototype.get());
1031
1032 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
1033 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
1034
1035 assert!(!interface_proto.is_null());
1036
1037 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
1038 create_noncallback_interface_object::<D>(cx,
1039 global,
1040 interface_proto.handle(),
1041 INTERFACE_OBJECT_CLASS.get(),
1042 &[],
1043 &[],
1044 &[],
1045 prototype.handle(),
1046 c"Headers",
1047 0,
1048 &[],
1049 interface.handle_mut());
1050 assert!(!interface.is_null());
1051 rooted!(&in(cx) let mut aliasedVal = UndefinedValue());
1054
1055 assert!(JS_GetProperty(cx.raw_cx(), prototype.handle(),
1056 c"entries".as_ptr() as *const u8 as *const _,
1057 aliasedVal.handle_mut()));
1058 rooted!(&in(cx) let mut iteratorId: jsid);
1059 RUST_SYMBOL_TO_JSID(GetWellKnownSymbol(cx.raw_cx(), SymbolCode::iterator), iteratorId.handle_mut());
1060
1061 assert!(JS_DefinePropertyById2(cx.raw_cx(), prototype.handle(), iteratorId.handle(), aliasedVal.handle(), 0));
1062
1063}
1064
1065
1066 pub(crate) fn init_statics<D: DomTypes>() {
1067 init_interface_object::<D>();
1068 init_domjs_class::<D>();
1069 crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_append_methodinfo::<D>();
1070crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_delete_methodinfo::<D>();
1071crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_get_methodinfo::<D>();
1072crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_getSetCookie_methodinfo::<D>();
1073crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_has_methodinfo::<D>();
1074crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_set_methodinfo::<D>();
1075crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_entries_methodinfo::<D>();
1076crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_keys_methodinfo::<D>();
1077crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_values_methodinfo::<D>();
1078crate::codegen::GenericBindings::HeadersBinding::Headers_Binding::init_forEach_methodinfo::<D>();
1079
1080
1081
1082 init_sMethods_specs::<D>();
1083init_sMethods_prefs::<D>();
1084init_sAttributes_specs::<D>();
1085init_sAttributes_prefs::<D>();
1086 }
1087 } pub use self::HeadersIterator_Binding::{Wrap as HeadersIteratorWrap, HeadersIteratorMethods, GetProtoObject as HeadersIteratorGetProtoObject};
1091pub mod HeadersIterator_Binding {
1092use crate::import::module::*;
1093
1094unsafe extern "C" fn next<D: DomTypes>
1095(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1096 let mut result = false;
1097 wrap_panic(&mut || result = (|| {
1098 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1099 let this = &*(this as *const IterableIterator<D, D::Headers>);
1100 let args = &*args;
1101 let argc = args.argc_;
1102 let result: Result<NonNull<JSObject>, Error> = this.Next(SafeJSContext::from_ptr(cx.raw_cx()));
1103 let result = match result {
1104 Ok(result) => result,
1105 Err(e) => {
1106 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1107 return false;
1108 },
1109 };
1110
1111 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1112 return true;
1113 })());
1114 result
1115}
1116
1117
1118static next_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1119
1120pub(crate) fn init_next_methodinfo<D: DomTypes>() {
1121 next_methodinfo.set(JSJitInfo {
1122 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1123 method: Some(next::<D>)
1124 },
1125 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1126 protoID: PrototypeList::ID::HeadersIterator as u16,
1127 },
1128 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1129 _bitfield_align_1: [],
1130 _bitfield_1: __BindgenBitfieldUnit::new(
1131 new_jsjitinfo_bitfield_1!(
1132 JSJitInfo_OpType::Method as u8,
1133 JSJitInfo_AliasSet::AliasEverything as u8,
1134 JSValueType::JSVAL_TYPE_OBJECT as u8,
1135 false,
1136 false,
1137 false,
1138 false,
1139 false,
1140 false,
1141 0,
1142 ).to_ne_bytes()
1143 ),
1144});
1145}
1146unsafe extern "C" fn _finalize<D: DomTypes>
1147(_cx: *mut GCContext, obj: *mut JSObject){
1148 wrap_panic(&mut || {
1149
1150 let this = native_from_object_static::<IterableIterator<D, D::Headers>>(obj).unwrap();
1151 finalize_common(this);
1152 })
1153}
1154
1155unsafe extern "C" fn _trace<D: DomTypes>
1156(trc: *mut JSTracer, obj: *mut JSObject){
1157 wrap_panic(&mut || {
1158
1159 let this = native_from_object_static::<IterableIterator<D, D::Headers>>(obj).unwrap();
1160 if this.is_null() { return; } (*this).trace(trc);
1162 })
1163}
1164
1165
1166static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
1167
1168pub(crate) fn init_class_ops<D: DomTypes>() {
1169 CLASS_OPS.set(JSClassOps {
1170 addProperty: None,
1171 delProperty: None,
1172 enumerate: None,
1173 newEnumerate: None,
1174 resolve: None,
1175 mayResolve: None,
1176 finalize: Some(_finalize::<D>),
1177 call: None,
1178 construct: None,
1179 trace: Some(_trace::<D>),
1180 });
1181}
1182
1183pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
1184
1185pub(crate) fn init_domjs_class<D: DomTypes>() {
1186 init_class_ops::<D>();
1187 Class.set(DOMJSClass {
1188 base: JSClass {
1189 name: c"HeadersIterator".as_ptr(),
1190 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
1191 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
1192 ,
1193 cOps: unsafe { CLASS_OPS.get() },
1194 spec: ptr::null(),
1195 ext: ptr::null(),
1196 oOps: ptr::null(),
1197 },
1198 dom_class:
1199DOMClass {
1200 interface_chain: [ PrototypeList::ID::HeadersIterator, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
1201 depth: 0,
1202 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
1203 malloc_size_of: malloc_size_of_including_raw_self::<IterableIterator<D, D::Headers>> as unsafe fn(&mut _, _) -> _,
1204 global: Globals::EMPTY,
1205},
1206 });
1207}
1208
1209#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
1210(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<IterableIterator<D, D::Headers>>, _can_gc: CanGc) -> DomRoot<IterableIterator<D, D::Headers>>{
1211
1212 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
1213
1214 let scope = scope.reflector().get_jsobject();
1215 assert!(!scope.get().is_null());
1216 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
1217 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
1218
1219 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
1220 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
1221 assert!(!canonical_proto.is_null());
1222
1223
1224 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
1225 if let Some(given) = given_proto {
1226 proto.set(*given);
1227 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
1228 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
1229 }
1230 } else {
1231 proto.set(*canonical_proto);
1232 }
1233 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
1234 cx.raw_cx(),
1235 &Class.get().base,
1236 proto.handle(),
1237 ));
1238 assert!(!obj.is_null());
1239 JS_SetReservedSlot(
1240 obj.get(),
1241 DOM_OBJECT_SLOT,
1242 &PrivateValue(raw.as_ptr() as *const libc::c_void),
1243 );
1244
1245 let root = raw.reflect_with(obj.get());
1246
1247
1248
1249 DomRoot::from_ref(&*root)
1250}
1251
1252pub trait HeadersIteratorMethods<D: DomTypes> {
1253 fn Next(&self, r#cx: SafeJSContext) -> Fallible<NonNull<JSObject>>;
1254}
1255static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
1256
1257pub(crate) fn init_sMethods_specs<D: DomTypes>() {
1258 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1259 JSFunctionSpec {
1260 name: JSPropertySpec_Name { string_: c"next".as_ptr() },
1261 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { next_methodinfo.get() } as *const _ as *const JSJitInfo },
1262 nargs: 0,
1263 flags: (JSPROP_ENUMERATE) as u16,
1264 selfHostedName: ptr::null()
1265 },
1266 JSFunctionSpec {
1267 name: JSPropertySpec_Name { string_: ptr::null() },
1268 call: JSNativeWrapper { op: None, info: ptr::null() },
1269 nargs: 0,
1270 flags: 0,
1271 selfHostedName: ptr::null()
1272 }]))[..]
1273])));
1274}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
1275
1276pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
1277 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sMethods_specs.get() })[0])])));
1278}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
1279
1280pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
1281 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1282 JSPropertySpec {
1283 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
1284 attributes_: (JSPROP_READONLY),
1285 kind_: (JSPropertySpec_Kind::Value),
1286 u: JSPropertySpec_AccessorsOrValue {
1287 value: JSPropertySpec_ValueWrapper {
1288 type_: JSPropertySpec_ValueWrapper_Type::String,
1289 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
1290 string: c"Headers Iterator".as_ptr(),
1291 }
1292 }
1293 }
1294 }
1295,
1296 JSPropertySpec::ZERO]))[..]
1297])));
1298}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
1299
1300pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
1301 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
1302}
1303pub fn GetProtoObject<D: DomTypes>
1304(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
1305 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::HeadersIterator), CreateInterfaceObjects::<D>, rval)
1307}
1308
1309
1310static PrototypeClass: JSClass = JSClass {
1311 name: c"HeadersIteratorPrototype".as_ptr(),
1312 flags:
1313 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
1315 cOps: ptr::null(),
1316 spec: ptr::null(),
1317 ext: ptr::null(),
1318 oOps: ptr::null(),
1319};
1320
1321unsafe fn CreateInterfaceObjects<D: DomTypes>
1322(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
1323
1324 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
1325 prototype_proto.set(GetRealmIteratorPrototype(cx.raw_cx()));
1326 assert!(!prototype_proto.is_null());
1327
1328 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
1329 create_interface_prototype_object::<D>(cx,
1330 global,
1331 prototype_proto.handle(),
1332 &PrototypeClass,
1333 sMethods.get(),
1334 sAttributes.get(),
1335 &[],
1336 &[],
1337 prototype.handle_mut());
1338 assert!(!prototype.is_null());
1339 assert!((*cache)[PrototypeList::ID::HeadersIterator as usize].is_null());
1340 (*cache)[PrototypeList::ID::HeadersIterator as usize] = prototype.get();
1341 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::HeadersIterator as isize),
1342 ptr::null_mut(),
1343 prototype.get());
1344
1345}
1346
1347
1348 pub(crate) fn init_statics<D: DomTypes>() {
1349
1350 init_domjs_class::<D>();
1351 crate::codegen::GenericBindings::HeadersBinding::HeadersIterator_Binding::init_next_methodinfo::<D>();
1352
1353
1354
1355 init_sMethods_specs::<D>();
1356init_sMethods_prefs::<D>();
1357init_sAttributes_specs::<D>();
1358init_sAttributes_prefs::<D>();
1359 }
1360 }