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