script_bindings/home/runner/work/servo/servo/target/debug/build/script_bindings-d55f55d5af1efaee/out/Bindings/
HTMLLabelElementBinding.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::HTMLElementBinding::HTMLElement_Binding;
8use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
9use crate::import::base::*;
10
11pub use self::HTMLLabelElement_Binding::{Wrap, HTMLLabelElementMethods, GetProtoObject, GetConstructorObject, DefineDOMInterface};
12pub mod HTMLLabelElement_Binding {
13use crate::codegen::GenericBindings::ElementBinding::Element_Binding;
14use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
15use crate::codegen::GenericBindings::HTMLElementBinding::HTMLElement_Binding;
16use crate::codegen::GenericBindings::NodeBinding::Node_Binding;
17use crate::import::module::*;
18
19unsafe extern "C" fn get_form<D: DomTypes>
20(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> 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::HTMLLabelElement);
25        let result: Option<DomRoot<D::HTMLFormElement>> = this.GetForm();
26
27        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
28        return true;
29    })());
30    result
31}
32
33
34static form_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
35
36pub(crate) fn init_form_getterinfo<D: DomTypes>() {
37    form_getterinfo.set(JSJitInfo {
38    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
39        getter: Some(get_form::<D>)
40    },
41    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
42        protoID: PrototypeList::ID::HTMLLabelElement as u16,
43    },
44    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
45    _bitfield_align_1: [],
46    _bitfield_1: __BindgenBitfieldUnit::new(
47        new_jsjitinfo_bitfield_1!(
48            JSJitInfo_OpType::Getter as u8,
49            JSJitInfo_AliasSet::AliasEverything as u8,
50            JSValueType::JSVAL_TYPE_UNKNOWN as u8,
51            true,
52            false,
53            false,
54            false,
55            false,
56            false,
57            0,
58        ).to_ne_bytes()
59    ),
60});
61}
62unsafe extern "C" fn get_htmlFor<D: DomTypes>
63(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
64    let mut result = false;
65    wrap_panic(&mut || result = (|| {
66        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
67        let this = &*(this as *const D::HTMLLabelElement);
68        <D as DomHelpers<D>>::push_new_element_queue();
69
70        let result: DOMString = this.HtmlFor();
71        <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
72
73
74        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
75        return true;
76    })());
77    result
78}
79
80unsafe extern "C" fn set_htmlFor<D: DomTypes>
81(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
82    let mut result = false;
83    wrap_panic(&mut || result = (|| {
84        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
85        let this = &*(this as *const D::HTMLLabelElement);
86        let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
87            Ok(ConversionResult::Success(value)) => value,
88            Ok(ConversionResult::Failure(error)) => {
89                throw_type_error(cx.raw_cx(), &error);
90        return false;
91
92            }
93            _ => {
94                return false;
95
96            },
97        }
98        ;
99        <D as DomHelpers<D>>::push_new_element_queue();
100
101        let result: () = this.SetHtmlFor(arg0);
102        <D as DomHelpers<D>>::pop_current_element_queue(CanGc::note());
103
104
105        true
106    })());
107    result
108}
109
110
111static htmlFor_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
112
113pub(crate) fn init_htmlFor_getterinfo<D: DomTypes>() {
114    htmlFor_getterinfo.set(JSJitInfo {
115    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
116        getter: Some(get_htmlFor::<D>)
117    },
118    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
119        protoID: PrototypeList::ID::HTMLLabelElement as u16,
120    },
121    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
122    _bitfield_align_1: [],
123    _bitfield_1: __BindgenBitfieldUnit::new(
124        new_jsjitinfo_bitfield_1!(
125            JSJitInfo_OpType::Getter as u8,
126            JSJitInfo_AliasSet::AliasEverything as u8,
127            JSValueType::JSVAL_TYPE_STRING as u8,
128            true,
129            false,
130            false,
131            false,
132            false,
133            false,
134            0,
135        ).to_ne_bytes()
136    ),
137});
138}
139static htmlFor_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
140
141pub(crate) fn init_htmlFor_setterinfo<D: DomTypes>() {
142    htmlFor_setterinfo.set(JSJitInfo {
143    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
144        setter: Some(set_htmlFor::<D>)
145    },
146    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
147        protoID: PrototypeList::ID::HTMLLabelElement as u16,
148    },
149    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
150    _bitfield_align_1: [],
151    _bitfield_1: __BindgenBitfieldUnit::new(
152        new_jsjitinfo_bitfield_1!(
153            JSJitInfo_OpType::Setter as u8,
154            JSJitInfo_AliasSet::AliasEverything as u8,
155            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
156            false,
157            false,
158            false,
159            false,
160            false,
161            false,
162            0,
163        ).to_ne_bytes()
164    ),
165});
166}
167unsafe extern "C" fn get_control<D: DomTypes>
168(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
169    let mut result = false;
170    wrap_panic(&mut || result = (|| {
171        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
172        let this = &*(this as *const D::HTMLLabelElement);
173        let result: Option<DomRoot<D::HTMLElement>> = this.GetControl();
174
175        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
176        return true;
177    })());
178    result
179}
180
181
182static control_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
183
184pub(crate) fn init_control_getterinfo<D: DomTypes>() {
185    control_getterinfo.set(JSJitInfo {
186    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
187        getter: Some(get_control::<D>)
188    },
189    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
190        protoID: PrototypeList::ID::HTMLLabelElement as u16,
191    },
192    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 4 },
193    _bitfield_align_1: [],
194    _bitfield_1: __BindgenBitfieldUnit::new(
195        new_jsjitinfo_bitfield_1!(
196            JSJitInfo_OpType::Getter as u8,
197            JSJitInfo_AliasSet::AliasEverything as u8,
198            JSValueType::JSVAL_TYPE_UNKNOWN as u8,
199            true,
200            false,
201            false,
202            false,
203            false,
204            false,
205            0,
206        ).to_ne_bytes()
207    ),
208});
209}
210unsafe extern "C" fn _finalize<D: DomTypes>
211(_cx: *mut GCContext, obj: *mut JSObject){
212    wrap_panic(&mut || {
213
214        let this = native_from_object_static::<D::HTMLLabelElement>(obj).unwrap();
215        finalize_common(this);
216    })
217}
218
219unsafe extern "C" fn _trace<D: DomTypes>
220(trc: *mut JSTracer, obj: *mut JSObject){
221    wrap_panic(&mut || {
222
223        let this = native_from_object_static::<D::HTMLLabelElement>(obj).unwrap();
224        if this.is_null() { return; } // GC during obj creation
225        (*this).trace(trc);
226    })
227}
228
229
230static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
231
232pub(crate) fn init_class_ops<D: DomTypes>() {
233    CLASS_OPS.set(JSClassOps {
234        addProperty: None,
235        delProperty: None,
236        enumerate: None,
237        newEnumerate: None,
238        resolve: None,
239        mayResolve: None,
240        finalize: Some(_finalize::<D>),
241        call: None,
242        construct: None,
243        trace: Some(_trace::<D>),
244    });
245}
246
247pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
248
249pub(crate) fn init_domjs_class<D: DomTypes>() {
250    init_class_ops::<D>();
251    Class.set(DOMJSClass {
252        base: JSClass {
253            name: c"HTMLLabelElement".as_ptr(),
254            flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
255                   (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
256                   /* JSCLASS_HAS_RESERVED_SLOTS(1) */,
257            cOps: unsafe { CLASS_OPS.get() },
258            spec: ptr::null(),
259            ext: ptr::null(),
260            oOps: ptr::null(),
261        },
262        dom_class:
263DOMClass {
264    interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::Node, PrototypeList::ID::Element, PrototypeList::ID::HTMLElement, PrototypeList::ID::HTMLLabelElement, PrototypeList::ID::Last ],
265    depth: 4,
266    type_id: crate::codegen::InheritTypes::TopTypeId { eventtarget: (crate::codegen::InheritTypes::EventTargetTypeId::Node(crate::codegen::InheritTypes::NodeTypeId::Element(crate::codegen::InheritTypes::ElementTypeId::HTMLElement(crate::codegen::InheritTypes::HTMLElementTypeId::HTMLLabelElement)))) },
267    malloc_size_of: malloc_size_of_including_raw_self::<D::HTMLLabelElement> as unsafe fn(&mut _, _) -> _,
268    global: Globals::EMPTY,
269},
270    });
271}
272
273#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
274(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::HTMLLabelElement>, _can_gc: CanGc) -> DomRoot<D::HTMLLabelElement>{
275
276    let raw = Root::new(MaybeUnreflectedDom::from_box(object));
277
278    let scope = scope.reflector().get_jsobject();
279    assert!(!scope.get().is_null());
280    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
281    let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
282
283    rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
284    GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
285    assert!(!canonical_proto.is_null());
286
287
288    rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
289    if let Some(given) = given_proto {
290        proto.set(*given);
291        if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
292            assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
293        }
294    } else {
295        proto.set(*canonical_proto);
296    }
297    rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
298        cx.raw_cx(),
299        &Class.get().base,
300        proto.handle(),
301    ));
302    assert!(!obj.is_null());
303    JS_SetReservedSlot(
304        obj.get(),
305        DOM_OBJECT_SLOT,
306        &PrivateValue(raw.as_ptr() as *const libc::c_void),
307    );
308
309    let root = raw.reflect_with(obj.get());
310
311
312
313    DomRoot::from_ref(&*root)
314}
315
316pub trait HTMLLabelElementMethods<D: DomTypes> {
317    fn GetForm(&self, ) -> Option<DomRoot<D::HTMLFormElement>>;
318    fn HtmlFor(&self, ) -> DOMString;
319    fn SetHtmlFor(&self, r#value: DOMString);
320    fn GetControl(&self, ) -> Option<DomRoot<D::HTMLElement>>;
321}
322static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
323
324pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
325    sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
326    JSPropertySpec {
327                    name: JSPropertySpec_Name { string_: c"form".as_ptr() },
328                    attributes_: (JSPROP_ENUMERATE),
329                    kind_: (JSPropertySpec_Kind::NativeAccessor),
330                    u: JSPropertySpec_AccessorsOrValue {
331                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
332                            getter: JSPropertySpec_Accessor {
333                                native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { form_getterinfo.get() } },
334                            },
335                            setter: JSPropertySpec_Accessor {
336                                native: JSNativeWrapper { op: None, info: ptr::null() },
337                            }
338                        }
339                    }
340                }
341,
342    JSPropertySpec {
343                    name: JSPropertySpec_Name { string_: c"htmlFor".as_ptr() },
344                    attributes_: (JSPROP_ENUMERATE),
345                    kind_: (JSPropertySpec_Kind::NativeAccessor),
346                    u: JSPropertySpec_AccessorsOrValue {
347                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
348                            getter: JSPropertySpec_Accessor {
349                                native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { htmlFor_getterinfo.get() } },
350                            },
351                            setter: JSPropertySpec_Accessor {
352                                native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { htmlFor_setterinfo.get() } },
353                            }
354                        }
355                    }
356                }
357,
358    JSPropertySpec {
359                    name: JSPropertySpec_Name { string_: c"control".as_ptr() },
360                    attributes_: (JSPROP_ENUMERATE),
361                    kind_: (JSPropertySpec_Kind::NativeAccessor),
362                    u: JSPropertySpec_AccessorsOrValue {
363                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
364                            getter: JSPropertySpec_Accessor {
365                                native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { control_getterinfo.get() } },
366                            },
367                            setter: JSPropertySpec_Accessor {
368                                native: JSNativeWrapper { op: None, info: ptr::null() },
369                            }
370                        }
371                    }
372                }
373,
374    JSPropertySpec::ZERO]))[..]
375,
376&Box::leak(Box::new([
377    JSPropertySpec {
378                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
379                    attributes_: (JSPROP_READONLY),
380                    kind_: (JSPropertySpec_Kind::Value),
381                    u: JSPropertySpec_AccessorsOrValue {
382                        value: JSPropertySpec_ValueWrapper {
383                            type_: JSPropertySpec_ValueWrapper_Type::String,
384                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
385                                string: c"HTMLLabelElement".as_ptr(),
386                            }
387                        }
388                    }
389                }
390,
391    JSPropertySpec::ZERO]))[..]
392])));
393}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
394
395pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
396    sAttributes.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
397    Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
398}
399pub fn GetProtoObject<D: DomTypes>
400(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
401    /* Get the interface prototype object for this class.  This will create the
402       object as needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::HTMLLabelElement), CreateInterfaceObjects::<D>, rval)
403}
404
405
406static PrototypeClass: JSClass = JSClass {
407    name: c"HTMLLabelElementPrototype".as_ptr(),
408    flags:
409        // JSCLASS_HAS_RESERVED_SLOTS()
410        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
411    cOps: ptr::null(),
412    spec: ptr::null(),
413    ext: ptr::null(),
414    oOps: ptr::null(),
415};
416
417unsafe extern "C" fn _constructor<D: DomTypes>
418(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
419    let mut result = false;
420    wrap_panic(&mut || result = {
421        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
422        let args = CallArgs::from_vp(vp, argc);
423        let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
424
425                        <D as DomHelpers<D>>::call_html_constructor::<D::HTMLLabelElement>(
426                            SafeJSContext::from_ptr(cx.raw_cx()),
427                            &args,
428                            &global,
429                            PrototypeList::ID::HTMLLabelElement,
430                            CreateInterfaceObjects::<D>,
431                            CanGc::note()
432                        )
433
434    });
435    result
436}
437
438
439static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
440
441pub(crate) fn init_interface_object<D: DomTypes>() {
442    INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
443        Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
444        b"function HTMLLabelElement() {\n    [native code]\n}",
445        PrototypeList::ID::HTMLLabelElement,
446        4,
447    ));
448}
449
450pub fn GetConstructorObject<D: DomTypes>
451(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
452    /* Get the interface object for this class.  This will create the object as
453       needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::Constructor(PrototypeList::Constructor::HTMLLabelElement), CreateInterfaceObjects::<D>, rval)
454}
455
456pub fn DefineDOMInterface<D: DomTypes>
457(cx: SafeJSContext, global: HandleObject){
458    define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::HTMLLabelElement),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
459}
460
461pub fn ConstructorEnabled<D: DomTypes>
462(aCx: SafeJSContext, aObj: HandleObject) -> bool{
463    is_exposed_in(aObj, Globals::WINDOW)
464}
465
466unsafe fn CreateInterfaceObjects<D: DomTypes>
467(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
468
469    rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
470    HTMLElement_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
471    assert!(!prototype_proto.is_null());
472
473    rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
474    create_interface_prototype_object::<D>(cx,
475                                      global,
476                                      prototype_proto.handle(),
477                                      &PrototypeClass,
478                                      &[],
479                                      sAttributes.get(),
480                                      &[],
481                                      &[],
482                                      prototype.handle_mut());
483    assert!(!prototype.is_null());
484    assert!((*cache)[PrototypeList::ID::HTMLLabelElement as usize].is_null());
485    (*cache)[PrototypeList::ID::HTMLLabelElement as usize] = prototype.get();
486    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::HTMLLabelElement as isize),
487                                  ptr::null_mut(),
488                                  prototype.get());
489
490    rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
491
492    HTMLElement_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
493
494    assert!(!interface_proto.is_null());
495
496    rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
497    create_noncallback_interface_object::<D>(cx,
498                                        global,
499                                        interface_proto.handle(),
500                                        INTERFACE_OBJECT_CLASS.get(),
501                                        &[],
502                                        &[],
503                                        &[],
504                                        prototype.handle(),
505                                        c"HTMLLabelElement",
506                                        0,
507                                        &[],
508                                        interface.handle_mut());
509    assert!(!interface.is_null());
510
511    assert!((*cache)[PrototypeList::Constructor::HTMLLabelElement as usize].is_null());
512    (*cache)[PrototypeList::Constructor::HTMLLabelElement as usize] = interface.get();
513    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::HTMLLabelElement as isize),
514                                  ptr::null_mut(),
515                                  interface.get());
516
517}
518
519
520        pub(crate) fn init_statics<D: DomTypes>() {
521            init_interface_object::<D>();
522            init_domjs_class::<D>();
523
524            init_form_getterinfo::<D>();
525init_htmlFor_getterinfo::<D>();
526init_control_getterinfo::<D>();
527            init_htmlFor_setterinfo::<D>();
528
529            init_sAttributes_specs::<D>();
530init_sAttributes_prefs::<D>();
531        }
532        } // mod HTMLLabelElement_Binding
533
534