1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
6use crate::import::base::*;
7
8
9#[repr(usize)]
10#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
11pub enum XRSessionMode {
12 Inline,
13 Immersive_vr,
14 Immersive_ar
15}
16pub mod XRSessionModeValues {
17
18 use crate::utils::find_enum_value;
19 use js::conversions::ConversionResult;
20 use js::conversions::FromJSValConvertible;
21 use js::conversions::ToJSValConvertible;
22 use js::context::RawJSContext;
23 use js::rust::HandleValue;
24 use js::rust::MutableHandleValue;
25 use js::jsval::JSVal;
26
27 pub(crate) const pairs: &[(&str, super::XRSessionMode)] = &[
28 ("inline", super::XRSessionMode::Inline),
29 ("immersive-vr", super::XRSessionMode::Immersive_vr),
30 ("immersive-ar", super::XRSessionMode::Immersive_ar),
31 ];
32
33 impl super::XRSessionMode {
34 pub fn as_str(&self) -> &'static str {
35 pairs[*self as usize].0
36 }
37 }
38
39 impl Default for super::XRSessionMode {
40 fn default() -> super::XRSessionMode {
41 pairs[0].1
42 }
43 }
44
45 impl std::str::FromStr for super::XRSessionMode {
46 type Err = ();
47
48 fn from_str(s: &str) -> Result<Self, Self::Err> {
49 pairs
50 .iter()
51 .find(|&&(key, _)| s == key)
52 .map(|&(_, ev)| ev)
53 .ok_or(())
54 }
55 }
56
57 impl ToJSValConvertible for super::XRSessionMode {
58 unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
59 pairs[*self as usize].0.to_jsval(cx, rval);
60 }
61 }
62
63 impl FromJSValConvertible for super::XRSessionMode {
64 type Config = ();
65 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
66 -> Result<ConversionResult<super::XRSessionMode>, ()> {
67 match find_enum_value(cx, value, pairs) {
68 Err(_) => Err(()),
69 Ok((None, search)) => {
70 Ok(ConversionResult::Failure(
71 format!("'{}' is not a valid enum value for enumeration 'XRSessionMode'.", search).into()
72 ))
73 }
74 Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
75 }
76 }
77 }
78 } #[derive(JSTraceable)]
81#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
82pub struct XRSessionInit {
83 pub optionalFeatures: Option<Vec<RootedTraceableBox<Heap<JSVal>>>>,
84 pub requiredFeatures: Option<Vec<RootedTraceableBox<Heap<JSVal>>>>,
85}
86impl Default for XRSessionInit {
87 fn default() -> Self {
88 Self {
89 optionalFeatures: Default::default(),
90 requiredFeatures: Default::default(), }
91 }
92}
93
94impl XRSessionInit {
95 pub fn empty() -> RootedTraceableBox<Self> {
96 let mut dictionary = RootedTraceableBox::new(Self::default());
97 dictionary.optionalFeatures = None;
98 dictionary.requiredFeatures = None;
99 dictionary
100 }
101 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
102 -> Result<ConversionResult<RootedTraceableBox<XRSessionInit>>, ()> {
103 unsafe {
104 let object = if val.get().is_null_or_undefined() {
105 ptr::null_mut()
106 } else if val.get().is_object() {
107 val.get().to_object()
108 } else {
109 return Ok(ConversionResult::Failure("Value is not an object.".into()));
110 };
111 rooted!(&in(cx) let object = object);
112 let dictionary = RootedTraceableBox::new(XRSessionInit {
113 optionalFeatures: {
114 rooted!(&in(cx) let mut rval = UndefinedValue());
115 if get_dictionary_property(cx.raw_cx(), object.handle(), "optionalFeatures", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
116 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
117 Ok(ConversionResult::Success(value)) => value,
118 Ok(ConversionResult::Failure(error)) => {
119 throw_type_error(cx.raw_cx(), &error);
120 return Err(());
121
122 }
123 _ => {
124 return Err(());
125
126 },
127 }
128 )
129 } else {
130 None
131 }
132 },
133 requiredFeatures: {
134 rooted!(&in(cx) let mut rval = UndefinedValue());
135 if get_dictionary_property(cx.raw_cx(), object.handle(), "requiredFeatures", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
136 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
137 Ok(ConversionResult::Success(value)) => value,
138 Ok(ConversionResult::Failure(error)) => {
139 throw_type_error(cx.raw_cx(), &error);
140 return Err(());
141
142 }
143 _ => {
144 return Err(());
145
146 },
147 }
148 )
149 } else {
150 None
151 }
152 },
153 });
154 Ok(ConversionResult::Success(dictionary))
155 }
156 }
157}
158
159impl FromJSValConvertible for RootedTraceableBox<XRSessionInit> {
160 type Config = ();
161 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
162 -> Result<ConversionResult<RootedTraceableBox<XRSessionInit>>, ()> {
163 XRSessionInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
164 }
165}
166
167impl XRSessionInit {
168 #[allow(clippy::wrong_self_convention)]
169 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
170 if let Some(ref optionalFeatures) = self.optionalFeatures {
171 rooted!(in(cx) let mut optionalFeatures_js = UndefinedValue());
172 optionalFeatures.to_jsval(cx, optionalFeatures_js.handle_mut());
173 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "optionalFeatures", optionalFeatures_js.handle()).unwrap();
174 }
175 if let Some(ref requiredFeatures) = self.requiredFeatures {
176 rooted!(in(cx) let mut requiredFeatures_js = UndefinedValue());
177 requiredFeatures.to_jsval(cx, requiredFeatures_js.handle_mut());
178 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "requiredFeatures", requiredFeatures_js.handle()).unwrap();
179 }
180 }
181}
182
183impl ToJSValConvertible for XRSessionInit {
184 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
185 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
186 self.to_jsobject(cx, obj.handle_mut());
187 rval.set(ObjectOrNullValue(obj.get()))
188 }
189}
190
191
192pub use self::XRSystem_Binding::{Wrap, XRSystemMethods, GetProtoObject, DefineDOMInterface};
193pub mod XRSystem_Binding {
194use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
195use crate::codegen::GenericBindings::XRSystemBinding::XRSessionInit;
196use crate::codegen::GenericBindings::XRSystemBinding::XRSessionMode;
197use crate::codegen::GenericBindings::XRSystemBinding::XRSessionModeValues;
198use crate::import::module::*;
199
200unsafe extern "C" fn isSessionSupported<D: DomTypes>
201(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
202 let mut result = false;
203 wrap_panic(&mut || result = (|| {
204 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
205 let this = &*(this as *const D::XRSystem);
206 let args = &*args;
207 let argc = args.argc_;
208
209 if argc < 1 {
210 throw_type_error(cx.raw_cx(), "Not enough arguments to \"XRSystem.isSessionSupported\".");
211 return false;
212 }
213 let arg0: XRSessionMode = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
214 Ok(ConversionResult::Success(value)) => value,
215 Ok(ConversionResult::Failure(error)) => {
216 throw_type_error(cx.raw_cx(), &error); return false;
217
218 }
219 _ => {
220 return false;
221
222 },
223 }
224 ;
225 let result: Rc<D::Promise> = this.IsSessionSupported(arg0, CanGc::note());
226
227 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
228 return true;
229 })());
230 result
231}
232
233unsafe extern "C" fn isSessionSupported_promise_wrapper<D: DomTypes>
234(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
235 let mut result = false;
236 wrap_panic(&mut || result = (|| {
237 let ok = isSessionSupported::<D>(cx, _obj, this, args);
238 if ok {
239 return true;
240 }
241 return exception_to_promise(cx, (*args).rval(), CanGc::note());
242
243 })());
244 result
245}
246
247
248static isSessionSupported_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
249
250pub(crate) fn init_isSessionSupported_methodinfo<D: DomTypes>() {
251 isSessionSupported_methodinfo.set(JSJitInfo {
252 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
253 method: Some(isSessionSupported_promise_wrapper::<D>)
254 },
255 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
256 protoID: PrototypeList::ID::XRSystem as u16,
257 },
258 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
259 _bitfield_align_1: [],
260 _bitfield_1: __BindgenBitfieldUnit::new(
261 new_jsjitinfo_bitfield_1!(
262 JSJitInfo_OpType::Method as u8,
263 JSJitInfo_AliasSet::AliasEverything as u8,
264 JSValueType::JSVAL_TYPE_OBJECT as u8,
265 false,
266 false,
267 false,
268 false,
269 false,
270 false,
271 0,
272 ).to_ne_bytes()
273 ),
274});
275}
276unsafe extern "C" fn requestSession<D: DomTypes>
277(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
278 let mut result = false;
279 wrap_panic(&mut || result = (|| {
280 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
281 let this = &*(this as *const D::XRSystem);
282 let args = &*args;
283 let argc = args.argc_;
284
285 if argc < 1 {
286 throw_type_error(cx.raw_cx(), "Not enough arguments to \"XRSystem.requestSession\".");
287 return false;
288 }
289 let arg0: XRSessionMode = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
290 Ok(ConversionResult::Success(value)) => value,
291 Ok(ConversionResult::Failure(error)) => {
292 throw_type_error(cx.raw_cx(), &error); return false;
293
294 }
295 _ => {
296 return false;
297
298 },
299 }
300 ;
301 let arg1: RootedTraceableBox<crate::codegen::GenericBindings::XRSystemBinding::XRSessionInit> = if args.get(1).is_undefined() {
302 crate::codegen::GenericBindings::XRSystemBinding::XRSessionInit::empty()
303 } else {
304 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
305 Ok(ConversionResult::Success(value)) => value,
306 Ok(ConversionResult::Failure(error)) => {
307 throw_type_error(cx.raw_cx(), &error);
308 return false;
309
310 }
311 _ => {
312 return false;
313
314 },
315 }
316
317 };
318 let result: Rc<D::Promise> = this.RequestSession(arg0, arg1, InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
319
320 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
321 return true;
322 })());
323 result
324}
325
326unsafe extern "C" fn requestSession_promise_wrapper<D: DomTypes>
327(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
328 let mut result = false;
329 wrap_panic(&mut || result = (|| {
330 let ok = requestSession::<D>(cx, _obj, this, args);
331 if ok {
332 return true;
333 }
334 return exception_to_promise(cx, (*args).rval(), CanGc::note());
335
336 })());
337 result
338}
339
340
341static requestSession_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
342
343pub(crate) fn init_requestSession_methodinfo<D: DomTypes>() {
344 requestSession_methodinfo.set(JSJitInfo {
345 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
346 method: Some(requestSession_promise_wrapper::<D>)
347 },
348 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
349 protoID: PrototypeList::ID::XRSystem as u16,
350 },
351 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
352 _bitfield_align_1: [],
353 _bitfield_1: __BindgenBitfieldUnit::new(
354 new_jsjitinfo_bitfield_1!(
355 JSJitInfo_OpType::Method as u8,
356 JSJitInfo_AliasSet::AliasEverything as u8,
357 JSValueType::JSVAL_TYPE_OBJECT as u8,
358 false,
359 false,
360 false,
361 false,
362 false,
363 false,
364 0,
365 ).to_ne_bytes()
366 ),
367});
368}
369unsafe extern "C" fn get_test<D: DomTypes>
370(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
371 let mut result = false;
372 wrap_panic(&mut || result = (|| {
373 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
374 let this = &*(this as *const D::XRSystem);
375 let result: DomRoot<D::XRTest> = this.Test();
376
377 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
378 return true;
379 })());
380 result
381}
382
383
384static test_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
385
386pub(crate) fn init_test_getterinfo<D: DomTypes>() {
387 test_getterinfo.set(JSJitInfo {
388 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
389 getter: Some(get_test::<D>)
390 },
391 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
392 protoID: PrototypeList::ID::XRSystem as u16,
393 },
394 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
395 _bitfield_align_1: [],
396 _bitfield_1: __BindgenBitfieldUnit::new(
397 new_jsjitinfo_bitfield_1!(
398 JSJitInfo_OpType::Getter as u8,
399 JSJitInfo_AliasSet::AliasNone as u8,
400 JSValueType::JSVAL_TYPE_OBJECT as u8,
401 true,
402 true,
403 false,
404 false,
405 false,
406 false,
407 0,
408 ).to_ne_bytes()
409 ),
410});
411}
412unsafe extern "C" fn _finalize<D: DomTypes>
413(_cx: *mut GCContext, obj: *mut JSObject){
414 wrap_panic(&mut || {
415
416 let this = native_from_object_static::<D::XRSystem>(obj).unwrap();
417 finalize_common(this);
418 })
419}
420
421unsafe extern "C" fn _trace<D: DomTypes>
422(trc: *mut JSTracer, obj: *mut JSObject){
423 wrap_panic(&mut || {
424
425 let this = native_from_object_static::<D::XRSystem>(obj).unwrap();
426 if this.is_null() { return; } (*this).trace(trc);
428 })
429}
430
431
432static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
433
434pub(crate) fn init_class_ops<D: DomTypes>() {
435 CLASS_OPS.set(JSClassOps {
436 addProperty: None,
437 delProperty: None,
438 enumerate: None,
439 newEnumerate: None,
440 resolve: None,
441 mayResolve: None,
442 finalize: Some(_finalize::<D>),
443 call: None,
444 construct: None,
445 trace: Some(_trace::<D>),
446 });
447}
448
449pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
450
451pub(crate) fn init_domjs_class<D: DomTypes>() {
452 init_class_ops::<D>();
453 Class.set(DOMJSClass {
454 base: JSClass {
455 name: c"XRSystem".as_ptr(),
456 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
457 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
458 ,
459 cOps: unsafe { CLASS_OPS.get() },
460 spec: ptr::null(),
461 ext: ptr::null(),
462 oOps: ptr::null(),
463 },
464 dom_class:
465DOMClass {
466 interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::XRSystem, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
467 depth: 1,
468 type_id: crate::codegen::InheritTypes::TopTypeId { eventtarget: (crate::codegen::InheritTypes::EventTargetTypeId::XRSystem) },
469 malloc_size_of: malloc_size_of_including_raw_self::<D::XRSystem> as unsafe fn(&mut _, _) -> _,
470 global: Globals::EMPTY,
471},
472 });
473}
474
475#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
476(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::XRSystem>, _can_gc: CanGc) -> DomRoot<D::XRSystem>{
477
478 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
479
480 let scope = scope.reflector().get_jsobject();
481 assert!(!scope.get().is_null());
482 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
483 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
484
485 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
486 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
487 assert!(!canonical_proto.is_null());
488
489
490 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
491 if let Some(given) = given_proto {
492 proto.set(*given);
493 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
494 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
495 }
496 } else {
497 proto.set(*canonical_proto);
498 }
499 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
500 cx.raw_cx(),
501 &Class.get().base,
502 proto.handle(),
503 ));
504 assert!(!obj.is_null());
505 JS_SetReservedSlot(
506 obj.get(),
507 DOM_OBJECT_SLOT,
508 &PrivateValue(raw.as_ptr() as *const libc::c_void),
509 );
510
511 let root = raw.reflect_with(obj.get());
512
513
514
515 DomRoot::from_ref(&*root)
516}
517
518pub trait XRSystemMethods<D: DomTypes> {
519 fn IsSessionSupported(&self, r#mode: XRSessionMode, r#_can_gc: CanGc) -> Rc<D::Promise>;
520 fn RequestSession(&self, r#mode: XRSessionMode, r#parameters: RootedTraceableBox<crate::codegen::GenericBindings::XRSystemBinding::XRSessionInit>, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
521 fn Test(&self, ) -> DomRoot<D::XRTest>;
522}
523static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
524
525pub(crate) fn init_sMethods_specs<D: DomTypes>() {
526 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
527 JSFunctionSpec {
528 name: JSPropertySpec_Name { string_: c"isSessionSupported".as_ptr() },
529 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { isSessionSupported_methodinfo.get() } as *const _ as *const JSJitInfo },
530 nargs: 1,
531 flags: (JSPROP_ENUMERATE) as u16,
532 selfHostedName: ptr::null()
533 },
534 JSFunctionSpec {
535 name: JSPropertySpec_Name { string_: c"requestSession".as_ptr() },
536 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { requestSession_methodinfo.get() } as *const _ as *const JSJitInfo },
537 nargs: 1,
538 flags: (JSPROP_ENUMERATE) as u16,
539 selfHostedName: ptr::null()
540 },
541 JSFunctionSpec {
542 name: JSPropertySpec_Name { string_: ptr::null() },
543 call: JSNativeWrapper { op: None, info: ptr::null() },
544 nargs: 0,
545 flags: 0,
546 selfHostedName: ptr::null()
547 }]))[..]
548])));
549}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
550
551pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
552 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::SecureContext(),Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
553}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
554
555pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
556 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
557 JSPropertySpec {
558 name: JSPropertySpec_Name { string_: c"test".as_ptr() },
559 attributes_: (JSPROP_ENUMERATE),
560 kind_: (JSPropertySpec_Kind::NativeAccessor),
561 u: JSPropertySpec_AccessorsOrValue {
562 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
563 getter: JSPropertySpec_Accessor {
564 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { test_getterinfo.get() } },
565 },
566 setter: JSPropertySpec_Accessor {
567 native: JSNativeWrapper { op: None, info: ptr::null() },
568 }
569 }
570 }
571 }
572,
573 JSPropertySpec::ZERO]))[..]
574,
575&Box::leak(Box::new([
576 JSPropertySpec {
577 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
578 attributes_: (JSPROP_READONLY),
579 kind_: (JSPropertySpec_Kind::Value),
580 u: JSPropertySpec_AccessorsOrValue {
581 value: JSPropertySpec_ValueWrapper {
582 type_: JSPropertySpec_ValueWrapper_Type::String,
583 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
584 string: c"XRSystem".as_ptr(),
585 }
586 }
587 }
588 }
589,
590 JSPropertySpec::ZERO]))[..]
591])));
592}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
593
594pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
595 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::SecureContext(),Condition::Pref("dom_webxr_test"),Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
596 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
597}
598pub fn GetProtoObject<D: DomTypes>
599(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
600 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XRSystem), CreateInterfaceObjects::<D>, rval)
602}
603
604
605static PrototypeClass: JSClass = JSClass {
606 name: c"XRSystemPrototype".as_ptr(),
607 flags:
608 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
610 cOps: ptr::null(),
611 spec: ptr::null(),
612 ext: ptr::null(),
613 oOps: ptr::null(),
614};
615
616
617static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
618
619pub(crate) fn init_interface_object<D: DomTypes>() {
620 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
621 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
622 b"function XRSystem() {\n [native code]\n}",
623 PrototypeList::ID::XRSystem,
624 1,
625 ));
626}
627
628pub fn DefineDOMInterface<D: DomTypes>
629(cx: SafeJSContext, global: HandleObject){
630 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XRSystem),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
631}
632
633pub fn ConstructorEnabled<D: DomTypes>
634(aCx: SafeJSContext, aObj: HandleObject) -> bool{
635 is_exposed_in(aObj, Globals::WINDOW) &&
636 pref!(dom_webxr_enabled) &&
637
638 unsafe {
639 let in_realm_proof = AlreadyInRealm::assert_for_cx(aCx);
640 D::GlobalScope::from_context(*aCx, InRealm::Already(&in_realm_proof)).is_secure_context()
641 }
642
643}
644
645unsafe fn CreateInterfaceObjects<D: DomTypes>
646(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
647
648 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
649 EventTarget_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
650 assert!(!prototype_proto.is_null());
651
652 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
653 create_interface_prototype_object::<D>(cx,
654 global,
655 prototype_proto.handle(),
656 &PrototypeClass,
657 sMethods.get(),
658 sAttributes.get(),
659 &[],
660 &[],
661 prototype.handle_mut());
662 assert!(!prototype.is_null());
663 assert!((*cache)[PrototypeList::ID::XRSystem as usize].is_null());
664 (*cache)[PrototypeList::ID::XRSystem as usize] = prototype.get();
665 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::XRSystem as isize),
666 ptr::null_mut(),
667 prototype.get());
668
669 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
670
671 EventTarget_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
672
673 assert!(!interface_proto.is_null());
674
675 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
676 create_noncallback_interface_object::<D>(cx,
677 global,
678 interface_proto.handle(),
679 INTERFACE_OBJECT_CLASS.get(),
680 &[],
681 &[],
682 &[],
683 prototype.handle(),
684 c"XRSystem",
685 0,
686 &[],
687 interface.handle_mut());
688 assert!(!interface.is_null());
689}
690
691
692 pub(crate) fn init_statics<D: DomTypes>() {
693 init_interface_object::<D>();
694 init_domjs_class::<D>();
695 crate::codegen::GenericBindings::XRSystemBinding::XRSystem_Binding::init_isSessionSupported_methodinfo::<D>();
696crate::codegen::GenericBindings::XRSystemBinding::XRSystem_Binding::init_requestSession_methodinfo::<D>();
697 init_test_getterinfo::<D>();
698
699
700 init_sMethods_specs::<D>();
701init_sMethods_prefs::<D>();
702init_sAttributes_specs::<D>();
703init_sAttributes_prefs::<D>();
704 }
705 }