script_bindings/home/runner/work/servo/servo/target/debug/build/script_bindings-d55f55d5af1efaee/out/Bindings/
CustomElementRegistryBinding.rs

1/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
2
3#![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::ElementBinding::Element_Binding;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
8use crate::import::base::*;
9
10#[derive(JSTraceable)]
11pub struct ElementDefinitionOptions {
12    pub extends: Option<DOMString>,
13}
14impl Default for ElementDefinitionOptions {
15    fn default() -> Self {
16        Self::empty()
17    }
18}
19
20impl ElementDefinitionOptions {
21    pub fn empty() -> Self {
22        Self {
23                extends: None,
24        }
25    }
26    pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
27                      -> Result<ConversionResult<ElementDefinitionOptions>, ()> {
28        unsafe {
29            let object = if val.get().is_null_or_undefined() {
30                ptr::null_mut()
31            } else if val.get().is_object() {
32                val.get().to_object()
33            } else {
34                return Ok(ConversionResult::Failure("Value is not an object.".into()));
35            };
36            rooted!(&in(cx) let object = object);
37        let dictionary = ElementDefinitionOptions {
38                extends: {
39                    rooted!(&in(cx) let mut rval = UndefinedValue());
40                    if get_dictionary_property(cx.raw_cx(), object.handle(), "extends", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
41                            Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
42                                Ok(ConversionResult::Success(value)) => value,
43                                Ok(ConversionResult::Failure(error)) => {
44                                    throw_type_error(cx.raw_cx(), &error);
45                            return Err(());
46
47                                }
48                                _ => {
49                                    return Err(());
50
51                                },
52                            }
53                            )
54                    } else {
55                            None
56                    }
57                },
58        };
59            Ok(ConversionResult::Success(dictionary))
60        }
61    }
62}
63
64impl FromJSValConvertible for ElementDefinitionOptions {
65    type Config = ();
66    unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
67                         -> Result<ConversionResult<ElementDefinitionOptions>, ()> {
68        ElementDefinitionOptions::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
69    }
70}
71
72impl ElementDefinitionOptions {
73    #[allow(clippy::wrong_self_convention)]
74    pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
75        if let Some(ref extends) = self.extends {
76            rooted!(in(cx) let mut extends_js = UndefinedValue());
77            extends.to_jsval(cx, extends_js.handle_mut());
78            set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "extends", extends_js.handle()).unwrap();
79        }
80    }
81}
82
83impl ToJSValConvertible for ElementDefinitionOptions {
84    unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
85        rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
86        self.to_jsobject(cx, obj.handle_mut());
87        rval.set(ObjectOrNullValue(obj.get()))
88    }
89}
90
91
92#[derive(JSTraceable, MallocSizeOf, PartialEq)]
93#[cfg_attr(crown, allow(crown::unrooted_must_root))]
94#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
95pub struct CustomElementConstructor<D: DomTypes> {
96    pub parent: CallbackFunction<D>,
97}
98
99impl<D: DomTypes> CustomElementConstructor<D> {
100
101    pub unsafe fn new(aCx: SafeJSContext, aCallback: *mut JSObject) -> Rc<CustomElementConstructor<D>> {
102        let mut ret = Rc::new(CustomElementConstructor {
103            parent: CallbackFunction::new()
104        });
105        // Note: callback cannot be moved after calling init.
106        match Rc::get_mut(&mut ret) {
107            Some(ref mut callback) => callback.parent.init(aCx, aCallback),
108            None => unreachable!(),
109        };
110        ret
111    }
112
113    pub fn Call_<T: ThisReflector>(&self, thisObj: &T, aExceptionHandling: ExceptionHandling, can_gc: CanGc) -> Fallible<DomRoot<D::HTMLElement>> {
114        let s = CallSetup::<D>::new(self, aExceptionHandling);
115        rooted!(in(*s.get_context()) let mut thisValue: JSVal);
116        let wrap_result = wrap_call_this_value(s.get_context(), thisObj, thisValue.handle_mut());
117        if !wrap_result {
118            return Err(JSFailed);
119        }
120        unsafe { self.Call(s.get_context(), thisValue.handle(), can_gc) }
121    }
122
123    pub fn Call__<>(&self, aExceptionHandling: ExceptionHandling, can_gc: CanGc) -> Fallible<DomRoot<D::HTMLElement>> {
124        let s = CallSetup::<D>::new(self, aExceptionHandling);
125
126        unsafe { self.Call(s.get_context(), HandleValue::undefined(), can_gc) }
127    }
128
129    unsafe fn Call<>(&self, cx: SafeJSContext, aThisObj: HandleValue, can_gc: CanGc) -> Fallible<DomRoot<D::HTMLElement>> {
130        rooted!(&in(cx) let mut rval = UndefinedValue());
131
132
133
134        rooted!(&in(cx) let callable = ObjectValue(self.callback()));
135        rooted!(&in(cx) let rootedThis = aThisObj.get());
136        let ok = Call(
137            cx.raw_cx(), rootedThis.handle(), callable.handle(),
138            &HandleValueArray {
139                length_: 0 as ::libc::size_t,
140                elements_: ptr::null_mut()
141            }, rval.handle_mut());
142        maybe_resume_unwind();
143        if !ok {
144            return Err(JSFailed);
145        }
146        let retval: DomRoot<D::HTMLElement> = if rval.handle().get().is_object() {
147            match root_from_handlevalue(rval.handle(), SafeJSContext::from_ptr(cx.raw_cx())) {
148                Ok(val) => val,
149                Err(()) => {
150                    throw_type_error(cx.raw_cx(), "return value does not implement interface HTMLElement.");
151                    return Err(JSFailed);
152
153                }
154            }
155
156        } else {
157            throw_type_error(cx.raw_cx(), "Return value is not an object.");
158            return Err(JSFailed);
159
160        };
161        Ok(retval)
162
163    }
164}
165
166impl<D: DomTypes> CallbackContainer<D> for CustomElementConstructor<D> {
167    unsafe fn new(cx: SafeJSContext, callback: *mut JSObject) -> Rc<CustomElementConstructor<D>> {
168        CustomElementConstructor::new(cx, callback)
169    }
170
171    fn callback_holder(&self) -> &CallbackObject<D> {
172        self.parent.callback_holder()
173    }
174}
175
176impl<D: DomTypes> ToJSValConvertible for CustomElementConstructor<D> {
177    unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
178        self.callback().to_jsval(cx, rval);
179    }
180}
181
182
183pub use self::CustomElementRegistry_Binding::{Wrap, CustomElementRegistryMethods, GetProtoObject, DefineDOMInterface};
184pub mod CustomElementRegistry_Binding {
185use crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementConstructor;
186use crate::codegen::GenericBindings::CustomElementRegistryBinding::ElementDefinitionOptions;
187use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
188use crate::import::module::*;
189
190unsafe extern "C" fn define<D: DomTypes>
191(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
192    let mut result = false;
193    wrap_panic(&mut || result = (|| {
194        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
195        let this = &*(this as *const D::CustomElementRegistry);
196        let args = &*args;
197        let argc = args.argc_;
198
199        if argc < 2 {
200            throw_type_error(cx.raw_cx(), "Not enough arguments to \"CustomElementRegistry.define\".");
201            return false;
202        }
203        let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
204            Ok(ConversionResult::Success(value)) => value,
205            Ok(ConversionResult::Failure(error)) => {
206                throw_type_error(cx.raw_cx(), &error);
207        return false;
208
209            }
210            _ => {
211                return false;
212
213            },
214        }
215        ;
216        let arg1: Rc<CustomElementConstructor<D>> = if HandleValue::from_raw(args.get(1)).get().is_object() {
217            if IsCallable(HandleValue::from_raw(args.get(1)).get().to_object()) {
218                CustomElementConstructor::<D>::new(SafeJSContext::from_ptr(cx.raw_cx()), HandleValue::from_raw(args.get(1)).get().to_object())
219            } else {
220                throw_type_error(cx.raw_cx(), "Value is not callable.");
221                return false;
222
223            }
224        } else {
225            throw_type_error(cx.raw_cx(), "Value is not an object.");
226            return false;
227
228        };
229        let arg2: crate::codegen::GenericBindings::CustomElementRegistryBinding::ElementDefinitionOptions = if args.get(2).is_undefined() {
230            crate::codegen::GenericBindings::CustomElementRegistryBinding::ElementDefinitionOptions::empty()
231        } else {
232            match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(2)), ()) {
233                Ok(ConversionResult::Success(value)) => value,
234                Ok(ConversionResult::Failure(error)) => {
235                    throw_type_error(cx.raw_cx(), &error);
236            return false;
237
238                }
239                _ => {
240                    return false;
241
242                },
243            }
244
245        };
246        <D as DomHelpers<D>>::push_new_element_queue();
247
248        let result: Result<(), Error> = this.Define(arg0, arg1, &arg2, CanGc::note());
249        <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
250
251        let result = match result {
252            Ok(result) => result,
253            Err(e) => {
254                <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());
255                return false;
256            },
257        };
258
259        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
260        return true;
261    })());
262    result
263}
264
265
266static define_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
267
268pub(crate) fn init_define_methodinfo<D: DomTypes>() {
269    define_methodinfo.set(JSJitInfo {
270    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
271        method: Some(define::<D>)
272    },
273    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
274        protoID: PrototypeList::ID::CustomElementRegistry as u16,
275    },
276    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
277    _bitfield_align_1: [],
278    _bitfield_1: __BindgenBitfieldUnit::new(
279        new_jsjitinfo_bitfield_1!(
280            JSJitInfo_OpType::Method as u8,
281            JSJitInfo_AliasSet::AliasEverything as u8,
282            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
283            false,
284            false,
285            false,
286            false,
287            false,
288            false,
289            0,
290        ).to_ne_bytes()
291    ),
292});
293}
294unsafe extern "C" fn get<D: DomTypes>
295(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
296    let mut result = false;
297    wrap_panic(&mut || result = (|| {
298        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
299        let this = &*(this as *const D::CustomElementRegistry);
300        let args = &*args;
301        let argc = args.argc_;
302
303        if argc < 1 {
304            throw_type_error(cx.raw_cx(), "Not enough arguments to \"CustomElementRegistry.get\".");
305            return false;
306        }
307        let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
308            Ok(ConversionResult::Success(value)) => value,
309            Ok(ConversionResult::Failure(error)) => {
310                throw_type_error(cx.raw_cx(), &error);
311        return false;
312
313            }
314            _ => {
315                return false;
316
317            },
318        }
319        ;
320        rooted!(&in(cx) let mut retval: JSVal);
321        let result: () = this.Get(SafeJSContext::from_ptr(cx.raw_cx()), arg0, retval.handle_mut());
322
323        (retval).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
324        return true;
325    })());
326    result
327}
328
329
330static get_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
331
332pub(crate) fn init_get_methodinfo<D: DomTypes>() {
333    get_methodinfo.set(JSJitInfo {
334    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
335        method: Some(get::<D>)
336    },
337    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
338        protoID: PrototypeList::ID::CustomElementRegistry as u16,
339    },
340    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
341    _bitfield_align_1: [],
342    _bitfield_1: __BindgenBitfieldUnit::new(
343        new_jsjitinfo_bitfield_1!(
344            JSJitInfo_OpType::Method as u8,
345            JSJitInfo_AliasSet::AliasEverything as u8,
346            JSValueType::JSVAL_TYPE_UNKNOWN as u8,
347            false,
348            false,
349            false,
350            false,
351            false,
352            false,
353            0,
354        ).to_ne_bytes()
355    ),
356});
357}
358unsafe extern "C" fn getName<D: DomTypes>
359(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
360    let mut result = false;
361    wrap_panic(&mut || result = (|| {
362        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
363        let this = &*(this as *const D::CustomElementRegistry);
364        let args = &*args;
365        let argc = args.argc_;
366
367        if argc < 1 {
368            throw_type_error(cx.raw_cx(), "Not enough arguments to \"CustomElementRegistry.getName\".");
369            return false;
370        }
371        let arg0: Rc<CustomElementConstructor<D>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
372            if IsCallable(HandleValue::from_raw(args.get(0)).get().to_object()) {
373                CustomElementConstructor::<D>::new(SafeJSContext::from_ptr(cx.raw_cx()), HandleValue::from_raw(args.get(0)).get().to_object())
374            } else {
375                throw_type_error(cx.raw_cx(), "Value is not callable.");
376                return false;
377
378            }
379        } else {
380            throw_type_error(cx.raw_cx(), "Value is not an object.");
381            return false;
382
383        };
384        let result: Option<DOMString> = this.GetName(arg0);
385
386        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
387        return true;
388    })());
389    result
390}
391
392
393static getName_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
394
395pub(crate) fn init_getName_methodinfo<D: DomTypes>() {
396    getName_methodinfo.set(JSJitInfo {
397    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
398        method: Some(getName::<D>)
399    },
400    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
401        protoID: PrototypeList::ID::CustomElementRegistry as u16,
402    },
403    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
404    _bitfield_align_1: [],
405    _bitfield_1: __BindgenBitfieldUnit::new(
406        new_jsjitinfo_bitfield_1!(
407            JSJitInfo_OpType::Method as u8,
408            JSJitInfo_AliasSet::AliasEverything as u8,
409            JSValueType::JSVAL_TYPE_UNKNOWN as u8,
410            false,
411            false,
412            false,
413            false,
414            false,
415            false,
416            0,
417        ).to_ne_bytes()
418    ),
419});
420}
421unsafe extern "C" fn whenDefined<D: DomTypes>
422(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
423    let mut result = false;
424    wrap_panic(&mut || result = (|| {
425        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
426        let this = &*(this as *const D::CustomElementRegistry);
427        let args = &*args;
428        let argc = args.argc_;
429
430        if argc < 1 {
431            throw_type_error(cx.raw_cx(), "Not enough arguments to \"CustomElementRegistry.whenDefined\".");
432            return false;
433        }
434        let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
435            Ok(ConversionResult::Success(value)) => value,
436            Ok(ConversionResult::Failure(error)) => {
437                throw_type_error(cx.raw_cx(), &error);
438        return false;
439
440            }
441            _ => {
442                return false;
443
444            },
445        }
446        ;
447        let result: Rc<D::Promise> = this.WhenDefined(arg0, InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
448
449        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
450        return true;
451    })());
452    result
453}
454
455unsafe extern "C" fn whenDefined_promise_wrapper<D: DomTypes>
456(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
457    let mut result = false;
458    wrap_panic(&mut || result = (|| {
459        let ok = whenDefined::<D>(cx, _obj, this, args);
460        if ok {
461          return true;
462        }
463        return exception_to_promise(cx, (*args).rval(), CanGc::note());
464
465    })());
466    result
467}
468
469
470static whenDefined_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
471
472pub(crate) fn init_whenDefined_methodinfo<D: DomTypes>() {
473    whenDefined_methodinfo.set(JSJitInfo {
474    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
475        method: Some(whenDefined_promise_wrapper::<D>)
476    },
477    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
478        protoID: PrototypeList::ID::CustomElementRegistry as u16,
479    },
480    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
481    _bitfield_align_1: [],
482    _bitfield_1: __BindgenBitfieldUnit::new(
483        new_jsjitinfo_bitfield_1!(
484            JSJitInfo_OpType::Method as u8,
485            JSJitInfo_AliasSet::AliasEverything as u8,
486            JSValueType::JSVAL_TYPE_OBJECT as u8,
487            false,
488            false,
489            false,
490            false,
491            false,
492            false,
493            0,
494        ).to_ne_bytes()
495    ),
496});
497}
498unsafe extern "C" fn upgrade<D: DomTypes>
499(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
500    let mut result = false;
501    wrap_panic(&mut || result = (|| {
502        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
503        let this = &*(this as *const D::CustomElementRegistry);
504        let args = &*args;
505        let argc = args.argc_;
506
507        if argc < 1 {
508            throw_type_error(cx.raw_cx(), "Not enough arguments to \"CustomElementRegistry.upgrade\".");
509            return false;
510        }
511        let arg0: DomRoot<D::Node> = if HandleValue::from_raw(args.get(0)).get().is_object() {
512            match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
513                Ok(val) => val,
514                Err(()) => {
515                    throw_type_error(cx.raw_cx(), "value does not implement interface Node.");
516                    return false;
517
518                }
519            }
520
521        } else {
522            throw_type_error(cx.raw_cx(), "Value is not an object.");
523            return false;
524
525        };
526        <D as DomHelpers<D>>::push_new_element_queue();
527
528        let result: () = this.Upgrade(&arg0);
529        <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
530
531
532        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
533        return true;
534    })());
535    result
536}
537
538
539static upgrade_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
540
541pub(crate) fn init_upgrade_methodinfo<D: DomTypes>() {
542    upgrade_methodinfo.set(JSJitInfo {
543    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
544        method: Some(upgrade::<D>)
545    },
546    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
547        protoID: PrototypeList::ID::CustomElementRegistry as u16,
548    },
549    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
550    _bitfield_align_1: [],
551    _bitfield_1: __BindgenBitfieldUnit::new(
552        new_jsjitinfo_bitfield_1!(
553            JSJitInfo_OpType::Method as u8,
554            JSJitInfo_AliasSet::AliasEverything as u8,
555            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
556            false,
557            false,
558            false,
559            false,
560            false,
561            false,
562            0,
563        ).to_ne_bytes()
564    ),
565});
566}
567unsafe extern "C" fn _finalize<D: DomTypes>
568(_cx: *mut GCContext, obj: *mut JSObject){
569    wrap_panic(&mut || {
570
571        let this = native_from_object_static::<D::CustomElementRegistry>(obj).unwrap();
572        finalize_common(this);
573    })
574}
575
576unsafe extern "C" fn _trace<D: DomTypes>
577(trc: *mut JSTracer, obj: *mut JSObject){
578    wrap_panic(&mut || {
579
580        let this = native_from_object_static::<D::CustomElementRegistry>(obj).unwrap();
581        if this.is_null() { return; } // GC during obj creation
582        (*this).trace(trc);
583    })
584}
585
586
587static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
588
589pub(crate) fn init_class_ops<D: DomTypes>() {
590    CLASS_OPS.set(JSClassOps {
591        addProperty: None,
592        delProperty: None,
593        enumerate: None,
594        newEnumerate: None,
595        resolve: None,
596        mayResolve: None,
597        finalize: Some(_finalize::<D>),
598        call: None,
599        construct: None,
600        trace: Some(_trace::<D>),
601    });
602}
603
604pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
605
606pub(crate) fn init_domjs_class<D: DomTypes>() {
607    init_class_ops::<D>();
608    Class.set(DOMJSClass {
609        base: JSClass {
610            name: c"CustomElementRegistry".as_ptr(),
611            flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
612                   (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
613                   /* JSCLASS_HAS_RESERVED_SLOTS(1) */,
614            cOps: unsafe { CLASS_OPS.get() },
615            spec: ptr::null(),
616            ext: ptr::null(),
617            oOps: ptr::null(),
618        },
619        dom_class:
620DOMClass {
621    interface_chain: [ PrototypeList::ID::CustomElementRegistry, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
622    depth: 0,
623    type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
624    malloc_size_of: malloc_size_of_including_raw_self::<D::CustomElementRegistry> as unsafe fn(&mut _, _) -> _,
625    global: Globals::EMPTY,
626},
627    });
628}
629
630#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
631(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::CustomElementRegistry>, _can_gc: CanGc) -> DomRoot<D::CustomElementRegistry>{
632
633    let raw = Root::new(MaybeUnreflectedDom::from_box(object));
634
635    let scope = scope.reflector().get_jsobject();
636    assert!(!scope.get().is_null());
637    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
638    let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
639
640    rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
641    GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
642    assert!(!canonical_proto.is_null());
643
644
645    rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
646    if let Some(given) = given_proto {
647        proto.set(*given);
648        if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
649            assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
650        }
651    } else {
652        proto.set(*canonical_proto);
653    }
654    rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
655        cx.raw_cx(),
656        &Class.get().base,
657        proto.handle(),
658    ));
659    assert!(!obj.is_null());
660    JS_SetReservedSlot(
661        obj.get(),
662        DOM_OBJECT_SLOT,
663        &PrivateValue(raw.as_ptr() as *const libc::c_void),
664    );
665
666    let root = raw.reflect_with(obj.get());
667
668
669
670    DomRoot::from_ref(&*root)
671}
672
673pub trait CustomElementRegistryMethods<D: DomTypes> {
674    fn Define(&self, r#name: DOMString, r#constructor_: Rc<CustomElementConstructor<D>>, r#options: &crate::codegen::GenericBindings::CustomElementRegistryBinding::ElementDefinitionOptions, r#_can_gc: CanGc) -> Fallible<()>;
675    fn Get(&self, r#cx: SafeJSContext, r#name: DOMString, r#rval: MutableHandleValue);
676    fn GetName(&self, r#constructor: Rc<CustomElementConstructor<D>>) -> Option<DOMString>;
677    fn WhenDefined(&self, r#name: DOMString, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
678    fn Upgrade(&self, r#root: &D::Node);
679}
680static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
681
682pub(crate) fn init_sMethods_specs<D: DomTypes>() {
683    sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
684    JSFunctionSpec {
685        name: JSPropertySpec_Name { string_: c"define".as_ptr() },
686        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { define_methodinfo.get() } as *const _ as *const JSJitInfo },
687        nargs: 2,
688        flags: (JSPROP_ENUMERATE) as u16,
689        selfHostedName: ptr::null()
690    },
691    JSFunctionSpec {
692        name: JSPropertySpec_Name { string_: c"get".as_ptr() },
693        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { get_methodinfo.get() } as *const _ as *const JSJitInfo },
694        nargs: 1,
695        flags: (JSPROP_ENUMERATE) as u16,
696        selfHostedName: ptr::null()
697    },
698    JSFunctionSpec {
699        name: JSPropertySpec_Name { string_: c"getName".as_ptr() },
700        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getName_methodinfo.get() } as *const _ as *const JSJitInfo },
701        nargs: 1,
702        flags: (JSPROP_ENUMERATE) as u16,
703        selfHostedName: ptr::null()
704    },
705    JSFunctionSpec {
706        name: JSPropertySpec_Name { string_: c"whenDefined".as_ptr() },
707        call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { whenDefined_methodinfo.get() } as *const _ as *const JSJitInfo },
708        nargs: 1,
709        flags: (JSPROP_ENUMERATE) as u16,
710        selfHostedName: ptr::null()
711    },
712    JSFunctionSpec {
713        name: JSPropertySpec_Name { string_: c"upgrade".as_ptr() },
714        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { upgrade_methodinfo.get() } as *const _ as *const JSJitInfo },
715        nargs: 1,
716        flags: (JSPROP_ENUMERATE) as u16,
717        selfHostedName: ptr::null()
718    },
719    JSFunctionSpec {
720        name: JSPropertySpec_Name { string_: ptr::null() },
721        call: JSNativeWrapper { op: None, info: ptr::null() },
722        nargs: 0,
723        flags: 0,
724        selfHostedName: ptr::null()
725    }]))[..]
726])));
727}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
728
729pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
730    sMethods.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
731}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
732
733pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
734    sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
735    JSPropertySpec {
736                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
737                    attributes_: (JSPROP_READONLY),
738                    kind_: (JSPropertySpec_Kind::Value),
739                    u: JSPropertySpec_AccessorsOrValue {
740                        value: JSPropertySpec_ValueWrapper {
741                            type_: JSPropertySpec_ValueWrapper_Type::String,
742                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
743                                string: c"CustomElementRegistry".as_ptr(),
744                            }
745                        }
746                    }
747                }
748,
749    JSPropertySpec::ZERO]))[..]
750])));
751}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
752
753pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
754    sAttributes.set(Box::leak(Box::new([    Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
755}
756pub fn GetProtoObject<D: DomTypes>
757(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
758    /* Get the interface prototype object for this class.  This will create the
759       object as needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::CustomElementRegistry), CreateInterfaceObjects::<D>, rval)
760}
761
762
763static PrototypeClass: JSClass = JSClass {
764    name: c"CustomElementRegistryPrototype".as_ptr(),
765    flags:
766        // JSCLASS_HAS_RESERVED_SLOTS()
767        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
768    cOps: ptr::null(),
769    spec: ptr::null(),
770    ext: ptr::null(),
771    oOps: ptr::null(),
772};
773
774
775static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
776
777pub(crate) fn init_interface_object<D: DomTypes>() {
778    INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
779        Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
780        b"function CustomElementRegistry() {\n    [native code]\n}",
781        PrototypeList::ID::CustomElementRegistry,
782        0,
783    ));
784}
785
786pub fn DefineDOMInterface<D: DomTypes>
787(cx: SafeJSContext, global: HandleObject){
788    define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::CustomElementRegistry),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
789}
790
791pub fn ConstructorEnabled<D: DomTypes>
792(aCx: SafeJSContext, aObj: HandleObject) -> bool{
793    is_exposed_in(aObj, Globals::WINDOW)
794}
795
796unsafe fn CreateInterfaceObjects<D: DomTypes>
797(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
798
799    rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
800    prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
801    assert!(!prototype_proto.is_null());
802
803    rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
804    create_interface_prototype_object::<D>(cx,
805                                      global,
806                                      prototype_proto.handle(),
807                                      &PrototypeClass,
808                                      sMethods.get(),
809                                      sAttributes.get(),
810                                      &[],
811                                      &[],
812                                      prototype.handle_mut());
813    assert!(!prototype.is_null());
814    assert!((*cache)[PrototypeList::ID::CustomElementRegistry as usize].is_null());
815    (*cache)[PrototypeList::ID::CustomElementRegistry as usize] = prototype.get();
816    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::CustomElementRegistry as isize),
817                                  ptr::null_mut(),
818                                  prototype.get());
819
820    rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
821    interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
822
823    assert!(!interface_proto.is_null());
824
825    rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
826    create_noncallback_interface_object::<D>(cx,
827                                        global,
828                                        interface_proto.handle(),
829                                        INTERFACE_OBJECT_CLASS.get(),
830                                        &[],
831                                        &[],
832                                        &[],
833                                        prototype.handle(),
834                                        c"CustomElementRegistry",
835                                        0,
836                                        &[],
837                                        interface.handle_mut());
838    assert!(!interface.is_null());
839}
840
841
842        pub(crate) fn init_statics<D: DomTypes>() {
843            init_interface_object::<D>();
844            init_domjs_class::<D>();
845            crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementRegistry_Binding::init_define_methodinfo::<D>();
846crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementRegistry_Binding::init_get_methodinfo::<D>();
847crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementRegistry_Binding::init_getName_methodinfo::<D>();
848crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementRegistry_Binding::init_whenDefined_methodinfo::<D>();
849crate::codegen::GenericBindings::CustomElementRegistryBinding::CustomElementRegistry_Binding::init_upgrade_methodinfo::<D>();
850
851
852
853            init_sMethods_specs::<D>();
854init_sMethods_prefs::<D>();
855init_sAttributes_specs::<D>();
856init_sAttributes_prefs::<D>();
857        }
858        } // mod CustomElementRegistry_Binding
859
860