1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::import::base::*;
6
7pub use self::MediaError_Binding::{MediaErrorConstants, Wrap, MediaErrorMethods, GetProtoObject, DefineDOMInterface};
8pub mod MediaError_Binding {
9use crate::import::module::*;
10
11unsafe extern "C" fn get_code<D: DomTypes>
12(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
13 let mut result = false;
14 wrap_panic(&mut || result = (|| {
15 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
16 let this = &*(this as *const D::MediaError);
17 let result: u16 = this.Code();
18
19 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
20 return true;
21 })());
22 result
23}
24
25
26static code_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
27
28pub(crate) fn init_code_getterinfo<D: DomTypes>() {
29 code_getterinfo.set(JSJitInfo {
30 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
31 getter: Some(get_code::<D>)
32 },
33 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
34 protoID: PrototypeList::ID::MediaError as u16,
35 },
36 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
37 _bitfield_align_1: [],
38 _bitfield_1: __BindgenBitfieldUnit::new(
39 new_jsjitinfo_bitfield_1!(
40 JSJitInfo_OpType::Getter as u8,
41 JSJitInfo_AliasSet::AliasEverything as u8,
42 JSValueType::JSVAL_TYPE_INT32 as u8,
43 true,
44 false,
45 false,
46 false,
47 false,
48 false,
49 0,
50 ).to_ne_bytes()
51 ),
52});
53}
54unsafe extern "C" fn get_message<D: DomTypes>
55(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
56 let mut result = false;
57 wrap_panic(&mut || result = (|| {
58 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
59 let this = &*(this as *const D::MediaError);
60 let result: DOMString = this.Message();
61
62 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
63 return true;
64 })());
65 result
66}
67
68
69static message_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
70
71pub(crate) fn init_message_getterinfo<D: DomTypes>() {
72 message_getterinfo.set(JSJitInfo {
73 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
74 getter: Some(get_message::<D>)
75 },
76 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
77 protoID: PrototypeList::ID::MediaError as u16,
78 },
79 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
80 _bitfield_align_1: [],
81 _bitfield_1: __BindgenBitfieldUnit::new(
82 new_jsjitinfo_bitfield_1!(
83 JSJitInfo_OpType::Getter as u8,
84 JSJitInfo_AliasSet::AliasEverything as u8,
85 JSValueType::JSVAL_TYPE_STRING as u8,
86 true,
87 false,
88 false,
89 false,
90 false,
91 false,
92 0,
93 ).to_ne_bytes()
94 ),
95});
96}
97unsafe extern "C" fn _finalize<D: DomTypes>
98(_cx: *mut GCContext, obj: *mut JSObject){
99 wrap_panic(&mut || {
100
101 let this = native_from_object_static::<D::MediaError>(obj).unwrap();
102 finalize_common(this);
103 })
104}
105
106unsafe extern "C" fn _trace<D: DomTypes>
107(trc: *mut JSTracer, obj: *mut JSObject){
108 wrap_panic(&mut || {
109
110 let this = native_from_object_static::<D::MediaError>(obj).unwrap();
111 if this.is_null() { return; } (*this).trace(trc);
113 })
114}
115
116pub mod MediaErrorConstants {
117 pub const MEDIA_ERR_ABORTED: u16 = 1;
118 pub const MEDIA_ERR_NETWORK: u16 = 2;
119 pub const MEDIA_ERR_DECODE: u16 = 3;
120 pub const MEDIA_ERR_SRC_NOT_SUPPORTED: u16 = 4;
121} static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
124
125pub(crate) fn init_class_ops<D: DomTypes>() {
126 CLASS_OPS.set(JSClassOps {
127 addProperty: None,
128 delProperty: None,
129 enumerate: None,
130 newEnumerate: None,
131 resolve: None,
132 mayResolve: None,
133 finalize: Some(_finalize::<D>),
134 call: None,
135 construct: None,
136 trace: Some(_trace::<D>),
137 });
138}
139
140pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
141
142pub(crate) fn init_domjs_class<D: DomTypes>() {
143 init_class_ops::<D>();
144 Class.set(DOMJSClass {
145 base: JSClass {
146 name: c"MediaError".as_ptr(),
147 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
148 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
149 ,
150 cOps: unsafe { CLASS_OPS.get() },
151 spec: ptr::null(),
152 ext: ptr::null(),
153 oOps: ptr::null(),
154 },
155 dom_class:
156DOMClass {
157 interface_chain: [ PrototypeList::ID::MediaError, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
158 depth: 0,
159 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
160 malloc_size_of: malloc_size_of_including_raw_self::<D::MediaError> as unsafe fn(&mut _, _) -> _,
161 global: Globals::EMPTY,
162},
163 });
164}
165
166#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
167(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::MediaError>, _can_gc: CanGc) -> DomRoot<D::MediaError>{
168
169 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
170
171 let scope = scope.reflector().get_jsobject();
172 assert!(!scope.get().is_null());
173 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
174 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
175
176 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
177 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
178 assert!(!canonical_proto.is_null());
179
180
181 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
182 if let Some(given) = given_proto {
183 proto.set(*given);
184 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
185 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
186 }
187 } else {
188 proto.set(*canonical_proto);
189 }
190 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
191 cx.raw_cx(),
192 &Class.get().base,
193 proto.handle(),
194 ));
195 assert!(!obj.is_null());
196 JS_SetReservedSlot(
197 obj.get(),
198 DOM_OBJECT_SLOT,
199 &PrivateValue(raw.as_ptr() as *const libc::c_void),
200 );
201
202 let root = raw.reflect_with(obj.get());
203
204
205
206 DomRoot::from_ref(&*root)
207}
208
209pub trait MediaErrorMethods<D: DomTypes> {
210 fn Code(&self, ) -> u16;
211 fn Message(&self, ) -> DOMString;
212}
213static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
214
215pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
216 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
217 JSPropertySpec {
218 name: JSPropertySpec_Name { string_: c"code".as_ptr() },
219 attributes_: (JSPROP_ENUMERATE),
220 kind_: (JSPropertySpec_Kind::NativeAccessor),
221 u: JSPropertySpec_AccessorsOrValue {
222 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
223 getter: JSPropertySpec_Accessor {
224 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { code_getterinfo.get() } },
225 },
226 setter: JSPropertySpec_Accessor {
227 native: JSNativeWrapper { op: None, info: ptr::null() },
228 }
229 }
230 }
231 }
232,
233 JSPropertySpec {
234 name: JSPropertySpec_Name { string_: c"message".as_ptr() },
235 attributes_: (JSPROP_ENUMERATE),
236 kind_: (JSPropertySpec_Kind::NativeAccessor),
237 u: JSPropertySpec_AccessorsOrValue {
238 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
239 getter: JSPropertySpec_Accessor {
240 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { message_getterinfo.get() } },
241 },
242 setter: JSPropertySpec_Accessor {
243 native: JSNativeWrapper { op: None, info: ptr::null() },
244 }
245 }
246 }
247 }
248,
249 JSPropertySpec::ZERO]))[..]
250,
251&Box::leak(Box::new([
252 JSPropertySpec {
253 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
254 attributes_: (JSPROP_READONLY),
255 kind_: (JSPropertySpec_Kind::Value),
256 u: JSPropertySpec_AccessorsOrValue {
257 value: JSPropertySpec_ValueWrapper {
258 type_: JSPropertySpec_ValueWrapper_Type::String,
259 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
260 string: c"MediaError".as_ptr(),
261 }
262 }
263 }
264 }
265,
266 JSPropertySpec::ZERO]))[..]
267])));
268}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
269
270pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
271 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
272 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
273}static sConstants_specs: ThreadUnsafeOnceLock<&[&[ConstantSpec]]> = ThreadUnsafeOnceLock::new();
274
275pub(crate) fn init_sConstants_specs<D: DomTypes>() {
276 sConstants_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
277 ConstantSpec { name: c"MEDIA_ERR_ABORTED", value: ConstantVal::Int(1) },
278 ConstantSpec { name: c"MEDIA_ERR_NETWORK", value: ConstantVal::Int(2) },
279 ConstantSpec { name: c"MEDIA_ERR_DECODE", value: ConstantVal::Int(3) },
280 ConstantSpec { name: c"MEDIA_ERR_SRC_NOT_SUPPORTED", value: ConstantVal::Int(4) }]))[..]
281])));
282}static sConstants: ThreadUnsafeOnceLock<&[Guard<&[ConstantSpec]>]> = ThreadUnsafeOnceLock::new();
283
284pub(crate) fn init_sConstants_prefs<D: DomTypes>() {
285 sConstants.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sConstants_specs.get() })[0])])));
286}
287pub fn GetProtoObject<D: DomTypes>
288(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
289 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::MediaError), CreateInterfaceObjects::<D>, rval)
291}
292
293
294static PrototypeClass: JSClass = JSClass {
295 name: c"MediaErrorPrototype".as_ptr(),
296 flags:
297 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
299 cOps: ptr::null(),
300 spec: ptr::null(),
301 ext: ptr::null(),
302 oOps: ptr::null(),
303};
304
305
306static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
307
308pub(crate) fn init_interface_object<D: DomTypes>() {
309 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
310 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
311 b"function MediaError() {\n [native code]\n}",
312 PrototypeList::ID::MediaError,
313 0,
314 ));
315}
316
317pub fn DefineDOMInterface<D: DomTypes>
318(cx: SafeJSContext, global: HandleObject){
319 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::MediaError),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
320}
321
322pub fn ConstructorEnabled<D: DomTypes>
323(aCx: SafeJSContext, aObj: HandleObject) -> bool{
324 is_exposed_in(aObj, Globals::WINDOW)
325}
326
327unsafe fn CreateInterfaceObjects<D: DomTypes>
328(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
329
330 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
331 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
332 assert!(!prototype_proto.is_null());
333
334 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
335 create_interface_prototype_object::<D>(cx,
336 global,
337 prototype_proto.handle(),
338 &PrototypeClass,
339 &[],
340 sAttributes.get(),
341 sConstants.get(),
342 &[],
343 prototype.handle_mut());
344 assert!(!prototype.is_null());
345 assert!((*cache)[PrototypeList::ID::MediaError as usize].is_null());
346 (*cache)[PrototypeList::ID::MediaError as usize] = prototype.get();
347 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::MediaError as isize),
348 ptr::null_mut(),
349 prototype.get());
350
351 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
352 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
353
354 assert!(!interface_proto.is_null());
355
356 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
357 create_noncallback_interface_object::<D>(cx,
358 global,
359 interface_proto.handle(),
360 INTERFACE_OBJECT_CLASS.get(),
361 &[],
362 &[],
363 sConstants.get(),
364 prototype.handle(),
365 c"MediaError",
366 0,
367 &[],
368 interface.handle_mut());
369 assert!(!interface.is_null());
370}
371
372
373 pub(crate) fn init_statics<D: DomTypes>() {
374 init_interface_object::<D>();
375 init_domjs_class::<D>();
376
377 init_code_getterinfo::<D>();
378init_message_getterinfo::<D>();
379
380
381 init_sAttributes_specs::<D>();
382init_sAttributes_prefs::<D>();
383init_sConstants_specs::<D>();
384init_sConstants_prefs::<D>();
385 }
386 }