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::DOMPointBinding::DOMPointInit;
6use crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRButtonStateInit;
7use crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
8use crate::codegen::GenericBindings::XRInputSourceBinding::XRHandedness;
9use crate::codegen::GenericBindings::XRInputSourceBinding::XRHandednessValues;
10use crate::codegen::GenericBindings::XRInputSourceBinding::XRTargetRayMode;
11use crate::codegen::GenericBindings::XRInputSourceBinding::XRTargetRayModeValues;
12use crate::codegen::GenericBindings::XRSessionBinding::XRVisibilityState;
13use crate::codegen::GenericBindings::XRSessionBinding::XRVisibilityStateValues;
14use crate::codegen::GenericBindings::XRViewBinding::XREye;
15use crate::codegen::GenericBindings::XRViewBinding::XREyeValues;
16use crate::import::base::*;
17
18
19#[repr(usize)]
20#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
21pub enum FakeXRRegionType {
22 Point,
23 Plane,
24 Mesh
25}
26pub mod FakeXRRegionTypeValues {
27
28 use crate::utils::find_enum_value;
29 use js::conversions::ConversionResult;
30 use js::conversions::FromJSValConvertible;
31 use js::conversions::ToJSValConvertible;
32 use js::context::RawJSContext;
33 use js::rust::HandleValue;
34 use js::rust::MutableHandleValue;
35 use js::jsval::JSVal;
36
37 pub(crate) const pairs: &[(&str, super::FakeXRRegionType)] = &[
38 ("point", super::FakeXRRegionType::Point),
39 ("plane", super::FakeXRRegionType::Plane),
40 ("mesh", super::FakeXRRegionType::Mesh),
41 ];
42
43 impl super::FakeXRRegionType {
44 pub fn as_str(&self) -> &'static str {
45 pairs[*self as usize].0
46 }
47 }
48
49 impl Default for super::FakeXRRegionType {
50 fn default() -> super::FakeXRRegionType {
51 pairs[0].1
52 }
53 }
54
55 impl std::str::FromStr for super::FakeXRRegionType {
56 type Err = ();
57
58 fn from_str(s: &str) -> Result<Self, Self::Err> {
59 pairs
60 .iter()
61 .find(|&&(key, _)| s == key)
62 .map(|&(_, ev)| ev)
63 .ok_or(())
64 }
65 }
66
67 impl ToJSValConvertible for super::FakeXRRegionType {
68 unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
69 pairs[*self as usize].0.to_jsval(cx, rval);
70 }
71 }
72
73 impl FromJSValConvertible for super::FakeXRRegionType {
74 type Config = ();
75 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
76 -> Result<ConversionResult<super::FakeXRRegionType>, ()> {
77 match find_enum_value(cx, value, pairs) {
78 Err(_) => Err(()),
79 Ok((None, search)) => {
80 Ok(ConversionResult::Failure(
81 format!("'{}' is not a valid enum value for enumeration 'FakeXRRegionType'.", search).into()
82 ))
83 }
84 Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
85 }
86 }
87 }
88 } #[derive(JSTraceable)]
91pub struct FakeXRViewInit {
92 pub eye: XREye,
93 pub fieldOfView: Option<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRFieldOfViewInit>,
94 pub projectionMatrix: Vec<Finite<f32>>,
95 pub resolution: crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDeviceResolution,
96 pub viewOffset: crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit,
97}
98
99impl FakeXRViewInit {
100
101 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
102 -> Result<ConversionResult<FakeXRViewInit>, ()> {
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 = FakeXRViewInit {
113 eye: {
114 rooted!(&in(cx) let mut rval = UndefinedValue());
115 if get_dictionary_property(cx.raw_cx(), object.handle(), "eye", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
116 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); return Err(());
120
121 }
122 _ => {
123 return Err(());
124
125 },
126 }
127
128 } else {
129 throw_type_error(cx.raw_cx(), "Missing required member \"eye\".");
130 return Err(());
131 }
132 },
133 fieldOfView: {
134 rooted!(&in(cx) let mut rval = UndefinedValue());
135 if get_dictionary_property(cx.raw_cx(), object.handle(), "fieldOfView", 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 projectionMatrix: {
154 rooted!(&in(cx) let mut rval = UndefinedValue());
155 if get_dictionary_property(cx.raw_cx(), object.handle(), "projectionMatrix", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
156 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
157 Ok(ConversionResult::Success(value)) => value,
158 Ok(ConversionResult::Failure(error)) => {
159 throw_type_error(cx.raw_cx(), &error);
160 return Err(());
161
162 }
163 _ => {
164 return Err(());
165
166 },
167 }
168
169 } else {
170 throw_type_error(cx.raw_cx(), "Missing required member \"projectionMatrix\".");
171 return Err(());
172 }
173 },
174 resolution: {
175 rooted!(&in(cx) let mut rval = UndefinedValue());
176 if get_dictionary_property(cx.raw_cx(), object.handle(), "resolution", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
177 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
178 Ok(ConversionResult::Success(value)) => value,
179 Ok(ConversionResult::Failure(error)) => {
180 throw_type_error(cx.raw_cx(), &error);
181 return Err(());
182
183 }
184 _ => {
185 return Err(());
186
187 },
188 }
189
190 } else {
191 throw_type_error(cx.raw_cx(), "Missing required member \"resolution\".");
192 return Err(());
193 }
194 },
195 viewOffset: {
196 rooted!(&in(cx) let mut rval = UndefinedValue());
197 if get_dictionary_property(cx.raw_cx(), object.handle(), "viewOffset", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
198 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
199 Ok(ConversionResult::Success(value)) => value,
200 Ok(ConversionResult::Failure(error)) => {
201 throw_type_error(cx.raw_cx(), &error);
202 return Err(());
203
204 }
205 _ => {
206 return Err(());
207
208 },
209 }
210
211 } else {
212 throw_type_error(cx.raw_cx(), "Missing required member \"viewOffset\".");
213 return Err(());
214 }
215 },
216 };
217 Ok(ConversionResult::Success(dictionary))
218 }
219 }
220}
221
222impl FromJSValConvertible for FakeXRViewInit {
223 type Config = ();
224 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
225 -> Result<ConversionResult<FakeXRViewInit>, ()> {
226 FakeXRViewInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
227 }
228}
229
230impl FakeXRViewInit {
231 #[allow(clippy::wrong_self_convention)]
232 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
233 let eye = &self.eye;
234 rooted!(in(cx) let mut eye_js = UndefinedValue());
235 eye.to_jsval(cx, eye_js.handle_mut());
236 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "eye", eye_js.handle()).unwrap();
237 if let Some(ref fieldOfView) = self.fieldOfView {
238 rooted!(in(cx) let mut fieldOfView_js = UndefinedValue());
239 fieldOfView.to_jsval(cx, fieldOfView_js.handle_mut());
240 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "fieldOfView", fieldOfView_js.handle()).unwrap();
241 }
242 let projectionMatrix = &self.projectionMatrix;
243 rooted!(in(cx) let mut projectionMatrix_js = UndefinedValue());
244 projectionMatrix.to_jsval(cx, projectionMatrix_js.handle_mut());
245 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "projectionMatrix", projectionMatrix_js.handle()).unwrap();
246 let resolution = &self.resolution;
247 rooted!(in(cx) let mut resolution_js = UndefinedValue());
248 resolution.to_jsval(cx, resolution_js.handle_mut());
249 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "resolution", resolution_js.handle()).unwrap();
250 let viewOffset = &self.viewOffset;
251 rooted!(in(cx) let mut viewOffset_js = UndefinedValue());
252 viewOffset.to_jsval(cx, viewOffset_js.handle_mut());
253 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "viewOffset", viewOffset_js.handle()).unwrap();
254 }
255}
256
257impl ToJSValConvertible for FakeXRViewInit {
258 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
259 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
260 self.to_jsobject(cx, obj.handle_mut());
261 rval.set(ObjectOrNullValue(obj.get()))
262 }
263}
264
265
266#[derive(JSTraceable)]
267pub struct FakeXRDeviceResolution {
268 pub height: i32,
269 pub width: i32,
270}
271
272impl FakeXRDeviceResolution {
273
274 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
275 -> Result<ConversionResult<FakeXRDeviceResolution>, ()> {
276 unsafe {
277 let object = if val.get().is_null_or_undefined() {
278 ptr::null_mut()
279 } else if val.get().is_object() {
280 val.get().to_object()
281 } else {
282 return Ok(ConversionResult::Failure("Value is not an object.".into()));
283 };
284 rooted!(&in(cx) let object = object);
285 let dictionary = FakeXRDeviceResolution {
286 height: {
287 rooted!(&in(cx) let mut rval = UndefinedValue());
288 if get_dictionary_property(cx.raw_cx(), object.handle(), "height", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
289 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
290 Ok(ConversionResult::Success(value)) => value,
291 Ok(ConversionResult::Failure(error)) => {
292 throw_type_error(cx.raw_cx(), &error);
293 return Err(());
294
295 }
296 _ => {
297 return Err(());
298
299 },
300 }
301
302 } else {
303 throw_type_error(cx.raw_cx(), "Missing required member \"height\".");
304 return Err(());
305 }
306 },
307 width: {
308 rooted!(&in(cx) let mut rval = UndefinedValue());
309 if get_dictionary_property(cx.raw_cx(), object.handle(), "width", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
310 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
311 Ok(ConversionResult::Success(value)) => value,
312 Ok(ConversionResult::Failure(error)) => {
313 throw_type_error(cx.raw_cx(), &error);
314 return Err(());
315
316 }
317 _ => {
318 return Err(());
319
320 },
321 }
322
323 } else {
324 throw_type_error(cx.raw_cx(), "Missing required member \"width\".");
325 return Err(());
326 }
327 },
328 };
329 Ok(ConversionResult::Success(dictionary))
330 }
331 }
332}
333
334impl FromJSValConvertible for FakeXRDeviceResolution {
335 type Config = ();
336 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
337 -> Result<ConversionResult<FakeXRDeviceResolution>, ()> {
338 FakeXRDeviceResolution::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
339 }
340}
341
342impl FakeXRDeviceResolution {
343 #[allow(clippy::wrong_self_convention)]
344 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
345 let height = &self.height;
346 rooted!(in(cx) let mut height_js = UndefinedValue());
347 height.to_jsval(cx, height_js.handle_mut());
348 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "height", height_js.handle()).unwrap();
349 let width = &self.width;
350 rooted!(in(cx) let mut width_js = UndefinedValue());
351 width.to_jsval(cx, width_js.handle_mut());
352 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "width", width_js.handle()).unwrap();
353 }
354}
355
356impl ToJSValConvertible for FakeXRDeviceResolution {
357 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
358 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
359 self.to_jsobject(cx, obj.handle_mut());
360 rval.set(ObjectOrNullValue(obj.get()))
361 }
362}
363
364
365#[derive(JSTraceable)]
366pub struct FakeXRBoundsPoint {
367 pub x: Option<Finite<f64>>,
368 pub z: Option<Finite<f64>>,
369}
370impl Default for FakeXRBoundsPoint {
371 fn default() -> Self {
372 Self::empty()
373 }
374}
375
376impl FakeXRBoundsPoint {
377 pub fn empty() -> Self {
378 Self {
379 x: None,
380 z: None,
381 }
382 }
383 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
384 -> Result<ConversionResult<FakeXRBoundsPoint>, ()> {
385 unsafe {
386 let object = if val.get().is_null_or_undefined() {
387 ptr::null_mut()
388 } else if val.get().is_object() {
389 val.get().to_object()
390 } else {
391 return Ok(ConversionResult::Failure("Value is not an object.".into()));
392 };
393 rooted!(&in(cx) let object = object);
394 let dictionary = FakeXRBoundsPoint {
395 x: {
396 rooted!(&in(cx) let mut rval = UndefinedValue());
397 if get_dictionary_property(cx.raw_cx(), object.handle(), "x", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
398 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
399 Ok(ConversionResult::Success(value)) => value,
400 Ok(ConversionResult::Failure(error)) => {
401 throw_type_error(cx.raw_cx(), &error);
402 return Err(());
403
404 }
405 _ => {
406 return Err(());
407
408 },
409 }
410 )
411 } else {
412 None
413 }
414 },
415 z: {
416 rooted!(&in(cx) let mut rval = UndefinedValue());
417 if get_dictionary_property(cx.raw_cx(), object.handle(), "z", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
418 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
419 Ok(ConversionResult::Success(value)) => value,
420 Ok(ConversionResult::Failure(error)) => {
421 throw_type_error(cx.raw_cx(), &error);
422 return Err(());
423
424 }
425 _ => {
426 return Err(());
427
428 },
429 }
430 )
431 } else {
432 None
433 }
434 },
435 };
436 Ok(ConversionResult::Success(dictionary))
437 }
438 }
439}
440
441impl FromJSValConvertible for FakeXRBoundsPoint {
442 type Config = ();
443 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
444 -> Result<ConversionResult<FakeXRBoundsPoint>, ()> {
445 FakeXRBoundsPoint::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
446 }
447}
448
449impl FakeXRBoundsPoint {
450 #[allow(clippy::wrong_self_convention)]
451 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
452 if let Some(ref x) = self.x {
453 rooted!(in(cx) let mut x_js = UndefinedValue());
454 x.to_jsval(cx, x_js.handle_mut());
455 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "x", x_js.handle()).unwrap();
456 }
457 if let Some(ref z) = self.z {
458 rooted!(in(cx) let mut z_js = UndefinedValue());
459 z.to_jsval(cx, z_js.handle_mut());
460 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "z", z_js.handle()).unwrap();
461 }
462 }
463}
464
465impl ToJSValConvertible for FakeXRBoundsPoint {
466 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
467 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
468 self.to_jsobject(cx, obj.handle_mut());
469 rval.set(ObjectOrNullValue(obj.get()))
470 }
471}
472
473
474#[derive(JSTraceable)]
475pub struct FakeXRRigidTransformInit {
476 pub orientation: Vec<Finite<f32>>,
477 pub position: Vec<Finite<f32>>,
478}
479
480impl FakeXRRigidTransformInit {
481
482 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
483 -> Result<ConversionResult<FakeXRRigidTransformInit>, ()> {
484 unsafe {
485 let object = if val.get().is_null_or_undefined() {
486 ptr::null_mut()
487 } else if val.get().is_object() {
488 val.get().to_object()
489 } else {
490 return Ok(ConversionResult::Failure("Value is not an object.".into()));
491 };
492 rooted!(&in(cx) let object = object);
493 let dictionary = FakeXRRigidTransformInit {
494 orientation: {
495 rooted!(&in(cx) let mut rval = UndefinedValue());
496 if get_dictionary_property(cx.raw_cx(), object.handle(), "orientation", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
497 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
498 Ok(ConversionResult::Success(value)) => value,
499 Ok(ConversionResult::Failure(error)) => {
500 throw_type_error(cx.raw_cx(), &error);
501 return Err(());
502
503 }
504 _ => {
505 return Err(());
506
507 },
508 }
509
510 } else {
511 throw_type_error(cx.raw_cx(), "Missing required member \"orientation\".");
512 return Err(());
513 }
514 },
515 position: {
516 rooted!(&in(cx) let mut rval = UndefinedValue());
517 if get_dictionary_property(cx.raw_cx(), object.handle(), "position", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
518 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
519 Ok(ConversionResult::Success(value)) => value,
520 Ok(ConversionResult::Failure(error)) => {
521 throw_type_error(cx.raw_cx(), &error);
522 return Err(());
523
524 }
525 _ => {
526 return Err(());
527
528 },
529 }
530
531 } else {
532 throw_type_error(cx.raw_cx(), "Missing required member \"position\".");
533 return Err(());
534 }
535 },
536 };
537 Ok(ConversionResult::Success(dictionary))
538 }
539 }
540}
541
542impl FromJSValConvertible for FakeXRRigidTransformInit {
543 type Config = ();
544 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
545 -> Result<ConversionResult<FakeXRRigidTransformInit>, ()> {
546 FakeXRRigidTransformInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
547 }
548}
549
550impl FakeXRRigidTransformInit {
551 #[allow(clippy::wrong_self_convention)]
552 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
553 let orientation = &self.orientation;
554 rooted!(in(cx) let mut orientation_js = UndefinedValue());
555 orientation.to_jsval(cx, orientation_js.handle_mut());
556 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "orientation", orientation_js.handle()).unwrap();
557 let position = &self.position;
558 rooted!(in(cx) let mut position_js = UndefinedValue());
559 position.to_jsval(cx, position_js.handle_mut());
560 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "position", position_js.handle()).unwrap();
561 }
562}
563
564impl ToJSValConvertible for FakeXRRigidTransformInit {
565 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
566 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
567 self.to_jsobject(cx, obj.handle_mut());
568 rval.set(ObjectOrNullValue(obj.get()))
569 }
570}
571
572
573#[derive(JSTraceable)]
574pub struct FakeXRFieldOfViewInit {
575 pub downDegrees: Finite<f32>,
576 pub leftDegrees: Finite<f32>,
577 pub rightDegrees: Finite<f32>,
578 pub upDegrees: Finite<f32>,
579}
580
581impl FakeXRFieldOfViewInit {
582
583 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
584 -> Result<ConversionResult<FakeXRFieldOfViewInit>, ()> {
585 unsafe {
586 let object = if val.get().is_null_or_undefined() {
587 ptr::null_mut()
588 } else if val.get().is_object() {
589 val.get().to_object()
590 } else {
591 return Ok(ConversionResult::Failure("Value is not an object.".into()));
592 };
593 rooted!(&in(cx) let object = object);
594 let dictionary = FakeXRFieldOfViewInit {
595 downDegrees: {
596 rooted!(&in(cx) let mut rval = UndefinedValue());
597 if get_dictionary_property(cx.raw_cx(), object.handle(), "downDegrees", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
598 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
599 Ok(ConversionResult::Success(value)) => value,
600 Ok(ConversionResult::Failure(error)) => {
601 throw_type_error(cx.raw_cx(), &error);
602 return Err(());
603
604 }
605 _ => {
606 return Err(());
607
608 },
609 }
610
611 } else {
612 throw_type_error(cx.raw_cx(), "Missing required member \"downDegrees\".");
613 return Err(());
614 }
615 },
616 leftDegrees: {
617 rooted!(&in(cx) let mut rval = UndefinedValue());
618 if get_dictionary_property(cx.raw_cx(), object.handle(), "leftDegrees", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
619 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
620 Ok(ConversionResult::Success(value)) => value,
621 Ok(ConversionResult::Failure(error)) => {
622 throw_type_error(cx.raw_cx(), &error);
623 return Err(());
624
625 }
626 _ => {
627 return Err(());
628
629 },
630 }
631
632 } else {
633 throw_type_error(cx.raw_cx(), "Missing required member \"leftDegrees\".");
634 return Err(());
635 }
636 },
637 rightDegrees: {
638 rooted!(&in(cx) let mut rval = UndefinedValue());
639 if get_dictionary_property(cx.raw_cx(), object.handle(), "rightDegrees", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
640 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
641 Ok(ConversionResult::Success(value)) => value,
642 Ok(ConversionResult::Failure(error)) => {
643 throw_type_error(cx.raw_cx(), &error);
644 return Err(());
645
646 }
647 _ => {
648 return Err(());
649
650 },
651 }
652
653 } else {
654 throw_type_error(cx.raw_cx(), "Missing required member \"rightDegrees\".");
655 return Err(());
656 }
657 },
658 upDegrees: {
659 rooted!(&in(cx) let mut rval = UndefinedValue());
660 if get_dictionary_property(cx.raw_cx(), object.handle(), "upDegrees", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
661 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
662 Ok(ConversionResult::Success(value)) => value,
663 Ok(ConversionResult::Failure(error)) => {
664 throw_type_error(cx.raw_cx(), &error);
665 return Err(());
666
667 }
668 _ => {
669 return Err(());
670
671 },
672 }
673
674 } else {
675 throw_type_error(cx.raw_cx(), "Missing required member \"upDegrees\".");
676 return Err(());
677 }
678 },
679 };
680 Ok(ConversionResult::Success(dictionary))
681 }
682 }
683}
684
685impl FromJSValConvertible for FakeXRFieldOfViewInit {
686 type Config = ();
687 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
688 -> Result<ConversionResult<FakeXRFieldOfViewInit>, ()> {
689 FakeXRFieldOfViewInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
690 }
691}
692
693impl FakeXRFieldOfViewInit {
694 #[allow(clippy::wrong_self_convention)]
695 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
696 let downDegrees = &self.downDegrees;
697 rooted!(in(cx) let mut downDegrees_js = UndefinedValue());
698 downDegrees.to_jsval(cx, downDegrees_js.handle_mut());
699 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "downDegrees", downDegrees_js.handle()).unwrap();
700 let leftDegrees = &self.leftDegrees;
701 rooted!(in(cx) let mut leftDegrees_js = UndefinedValue());
702 leftDegrees.to_jsval(cx, leftDegrees_js.handle_mut());
703 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "leftDegrees", leftDegrees_js.handle()).unwrap();
704 let rightDegrees = &self.rightDegrees;
705 rooted!(in(cx) let mut rightDegrees_js = UndefinedValue());
706 rightDegrees.to_jsval(cx, rightDegrees_js.handle_mut());
707 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "rightDegrees", rightDegrees_js.handle()).unwrap();
708 let upDegrees = &self.upDegrees;
709 rooted!(in(cx) let mut upDegrees_js = UndefinedValue());
710 upDegrees.to_jsval(cx, upDegrees_js.handle_mut());
711 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "upDegrees", upDegrees_js.handle()).unwrap();
712 }
713}
714
715impl ToJSValConvertible for FakeXRFieldOfViewInit {
716 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
717 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
718 self.to_jsobject(cx, obj.handle_mut());
719 rval.set(ObjectOrNullValue(obj.get()))
720 }
721}
722
723
724#[derive(JSTraceable)]
725pub struct FakeXRWorldInit {
726 pub hitTestRegions: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRegionInit>,
727}
728
729impl FakeXRWorldInit {
730
731 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
732 -> Result<ConversionResult<FakeXRWorldInit>, ()> {
733 unsafe {
734 let object = if val.get().is_null_or_undefined() {
735 ptr::null_mut()
736 } else if val.get().is_object() {
737 val.get().to_object()
738 } else {
739 return Ok(ConversionResult::Failure("Value is not an object.".into()));
740 };
741 rooted!(&in(cx) let object = object);
742 let dictionary = FakeXRWorldInit {
743 hitTestRegions: {
744 rooted!(&in(cx) let mut rval = UndefinedValue());
745 if get_dictionary_property(cx.raw_cx(), object.handle(), "hitTestRegions", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
746 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
747 Ok(ConversionResult::Success(value)) => value,
748 Ok(ConversionResult::Failure(error)) => {
749 throw_type_error(cx.raw_cx(), &error);
750 return Err(());
751
752 }
753 _ => {
754 return Err(());
755
756 },
757 }
758
759 } else {
760 throw_type_error(cx.raw_cx(), "Missing required member \"hitTestRegions\".");
761 return Err(());
762 }
763 },
764 };
765 Ok(ConversionResult::Success(dictionary))
766 }
767 }
768}
769
770impl FromJSValConvertible for FakeXRWorldInit {
771 type Config = ();
772 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
773 -> Result<ConversionResult<FakeXRWorldInit>, ()> {
774 FakeXRWorldInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
775 }
776}
777
778impl FakeXRWorldInit {
779 #[allow(clippy::wrong_self_convention)]
780 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
781 let hitTestRegions = &self.hitTestRegions;
782 rooted!(in(cx) let mut hitTestRegions_js = UndefinedValue());
783 hitTestRegions.to_jsval(cx, hitTestRegions_js.handle_mut());
784 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "hitTestRegions", hitTestRegions_js.handle()).unwrap();
785 }
786}
787
788impl ToJSValConvertible for FakeXRWorldInit {
789 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
790 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
791 self.to_jsobject(cx, obj.handle_mut());
792 rval.set(ObjectOrNullValue(obj.get()))
793 }
794}
795
796
797#[derive(JSTraceable)]
798pub struct FakeXRRegionInit {
799 pub faces: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRTriangleInit>,
800 pub type_: FakeXRRegionType,
801}
802
803impl FakeXRRegionInit {
804
805 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
806 -> Result<ConversionResult<FakeXRRegionInit>, ()> {
807 unsafe {
808 let object = if val.get().is_null_or_undefined() {
809 ptr::null_mut()
810 } else if val.get().is_object() {
811 val.get().to_object()
812 } else {
813 return Ok(ConversionResult::Failure("Value is not an object.".into()));
814 };
815 rooted!(&in(cx) let object = object);
816 let dictionary = FakeXRRegionInit {
817 faces: {
818 rooted!(&in(cx) let mut rval = UndefinedValue());
819 if get_dictionary_property(cx.raw_cx(), object.handle(), "faces", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
820 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
821 Ok(ConversionResult::Success(value)) => value,
822 Ok(ConversionResult::Failure(error)) => {
823 throw_type_error(cx.raw_cx(), &error);
824 return Err(());
825
826 }
827 _ => {
828 return Err(());
829
830 },
831 }
832
833 } else {
834 throw_type_error(cx.raw_cx(), "Missing required member \"faces\".");
835 return Err(());
836 }
837 },
838 type_: {
839 rooted!(&in(cx) let mut rval = UndefinedValue());
840 if get_dictionary_property(cx.raw_cx(), object.handle(), "type", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
841 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
842 Ok(ConversionResult::Success(value)) => value,
843 Ok(ConversionResult::Failure(error)) => {
844 throw_type_error(cx.raw_cx(), &error); return Err(());
845
846 }
847 _ => {
848 return Err(());
849
850 },
851 }
852
853 } else {
854 throw_type_error(cx.raw_cx(), "Missing required member \"type\".");
855 return Err(());
856 }
857 },
858 };
859 Ok(ConversionResult::Success(dictionary))
860 }
861 }
862}
863
864impl FromJSValConvertible for FakeXRRegionInit {
865 type Config = ();
866 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
867 -> Result<ConversionResult<FakeXRRegionInit>, ()> {
868 FakeXRRegionInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
869 }
870}
871
872impl FakeXRRegionInit {
873 #[allow(clippy::wrong_self_convention)]
874 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
875 let faces = &self.faces;
876 rooted!(in(cx) let mut faces_js = UndefinedValue());
877 faces.to_jsval(cx, faces_js.handle_mut());
878 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "faces", faces_js.handle()).unwrap();
879 let type_ = &self.type_;
880 rooted!(in(cx) let mut type__js = UndefinedValue());
881 type_.to_jsval(cx, type__js.handle_mut());
882 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "type", type__js.handle()).unwrap();
883 }
884}
885
886impl ToJSValConvertible for FakeXRRegionInit {
887 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
888 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
889 self.to_jsobject(cx, obj.handle_mut());
890 rval.set(ObjectOrNullValue(obj.get()))
891 }
892}
893
894
895#[derive(JSTraceable)]
896pub struct FakeXRTriangleInit {
897 pub vertices: Vec<crate::codegen::GenericBindings::DOMPointBinding::DOMPointInit>,
898}
899
900impl FakeXRTriangleInit {
901
902 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
903 -> Result<ConversionResult<FakeXRTriangleInit>, ()> {
904 unsafe {
905 let object = if val.get().is_null_or_undefined() {
906 ptr::null_mut()
907 } else if val.get().is_object() {
908 val.get().to_object()
909 } else {
910 return Ok(ConversionResult::Failure("Value is not an object.".into()));
911 };
912 rooted!(&in(cx) let object = object);
913 let dictionary = FakeXRTriangleInit {
914 vertices: {
915 rooted!(&in(cx) let mut rval = UndefinedValue());
916 if get_dictionary_property(cx.raw_cx(), object.handle(), "vertices", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
917 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
918 Ok(ConversionResult::Success(value)) => value,
919 Ok(ConversionResult::Failure(error)) => {
920 throw_type_error(cx.raw_cx(), &error);
921 return Err(());
922
923 }
924 _ => {
925 return Err(());
926
927 },
928 }
929
930 } else {
931 throw_type_error(cx.raw_cx(), "Missing required member \"vertices\".");
932 return Err(());
933 }
934 },
935 };
936 Ok(ConversionResult::Success(dictionary))
937 }
938 }
939}
940
941impl FromJSValConvertible for FakeXRTriangleInit {
942 type Config = ();
943 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
944 -> Result<ConversionResult<FakeXRTriangleInit>, ()> {
945 FakeXRTriangleInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
946 }
947}
948
949impl FakeXRTriangleInit {
950 #[allow(clippy::wrong_self_convention)]
951 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
952 let vertices = &self.vertices;
953 rooted!(in(cx) let mut vertices_js = UndefinedValue());
954 vertices.to_jsval(cx, vertices_js.handle_mut());
955 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "vertices", vertices_js.handle()).unwrap();
956 }
957}
958
959impl ToJSValConvertible for FakeXRTriangleInit {
960 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
961 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
962 self.to_jsobject(cx, obj.handle_mut());
963 rval.set(ObjectOrNullValue(obj.get()))
964 }
965}
966
967
968pub use self::FakeXRDevice_Binding::{Wrap, FakeXRDeviceMethods, GetProtoObject, DefineDOMInterface};
969pub mod FakeXRDevice_Binding {
970use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRBoundsPoint;
971use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDeviceResolution;
972use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRFieldOfViewInit;
973use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRegionInit;
974use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit;
975use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRViewInit;
976use crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRWorldInit;
977use crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRButtonStateInit;
978use crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
979use crate::codegen::GenericBindings::XRInputSourceBinding::XRHandedness;
980use crate::codegen::GenericBindings::XRInputSourceBinding::XRHandednessValues;
981use crate::codegen::GenericBindings::XRInputSourceBinding::XRTargetRayMode;
982use crate::codegen::GenericBindings::XRInputSourceBinding::XRTargetRayModeValues;
983use crate::codegen::GenericBindings::XRSessionBinding::XRVisibilityState;
984use crate::codegen::GenericBindings::XRSessionBinding::XRVisibilityStateValues;
985use crate::codegen::GenericBindings::XRViewBinding::XREye;
986use crate::codegen::GenericBindings::XRViewBinding::XREyeValues;
987use crate::import::module::*;
988
989unsafe extern "C" fn setViews<D: DomTypes>
990(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
991 let mut result = false;
992 wrap_panic(&mut || result = (|| {
993 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
994 let this = &*(this as *const D::FakeXRDevice);
995 let args = &*args;
996 let argc = args.argc_;
997
998 if argc < 1 {
999 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.setViews\".");
1000 return false;
1001 }
1002 let arg0: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRViewInit> = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1003 Ok(ConversionResult::Success(value)) => value,
1004 Ok(ConversionResult::Failure(error)) => {
1005 throw_type_error(cx.raw_cx(), &error);
1006 return false;
1007
1008 }
1009 _ => {
1010 return false;
1011
1012 },
1013 }
1014 ;
1015 let arg1: Option<Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRViewInit>> = if args.get(1).is_undefined() {
1016 None
1017 } else {
1018 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
1019 Ok(ConversionResult::Success(value)) => value,
1020 Ok(ConversionResult::Failure(error)) => {
1021 throw_type_error(cx.raw_cx(), &error);
1022 return false;
1023
1024 }
1025 _ => {
1026 return false;
1027
1028 },
1029 }
1030 )
1031 };
1032 let result: Result<(), Error> = this.SetViews(arg0, arg1);
1033 let result = match result {
1034 Ok(result) => result,
1035 Err(e) => {
1036 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1037 return false;
1038 },
1039 };
1040
1041 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1042 return true;
1043 })());
1044 result
1045}
1046
1047
1048static setViews_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1049
1050pub(crate) fn init_setViews_methodinfo<D: DomTypes>() {
1051 setViews_methodinfo.set(JSJitInfo {
1052 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1053 method: Some(setViews::<D>)
1054 },
1055 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1056 protoID: PrototypeList::ID::FakeXRDevice as u16,
1057 },
1058 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1059 _bitfield_align_1: [],
1060 _bitfield_1: __BindgenBitfieldUnit::new(
1061 new_jsjitinfo_bitfield_1!(
1062 JSJitInfo_OpType::Method as u8,
1063 JSJitInfo_AliasSet::AliasEverything as u8,
1064 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1065 false,
1066 false,
1067 false,
1068 false,
1069 false,
1070 false,
1071 0,
1072 ).to_ne_bytes()
1073 ),
1074});
1075}
1076unsafe extern "C" fn disconnect<D: DomTypes>
1077(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1078 let mut result = false;
1079 wrap_panic(&mut || result = (|| {
1080 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1081 let this = &*(this as *const D::FakeXRDevice);
1082 let args = &*args;
1083 let argc = args.argc_;
1084 let result: Rc<D::Promise> = this.Disconnect(CanGc::note());
1085
1086 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1087 return true;
1088 })());
1089 result
1090}
1091
1092unsafe extern "C" fn disconnect_promise_wrapper<D: DomTypes>
1093(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1094 let mut result = false;
1095 wrap_panic(&mut || result = (|| {
1096 let ok = disconnect::<D>(cx, _obj, this, args);
1097 if ok {
1098 return true;
1099 }
1100 return exception_to_promise(cx, (*args).rval(), CanGc::note());
1101
1102 })());
1103 result
1104}
1105
1106
1107static disconnect_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1108
1109pub(crate) fn init_disconnect_methodinfo<D: DomTypes>() {
1110 disconnect_methodinfo.set(JSJitInfo {
1111 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1112 method: Some(disconnect_promise_wrapper::<D>)
1113 },
1114 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1115 protoID: PrototypeList::ID::FakeXRDevice as u16,
1116 },
1117 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1118 _bitfield_align_1: [],
1119 _bitfield_1: __BindgenBitfieldUnit::new(
1120 new_jsjitinfo_bitfield_1!(
1121 JSJitInfo_OpType::Method as u8,
1122 JSJitInfo_AliasSet::AliasEverything as u8,
1123 JSValueType::JSVAL_TYPE_OBJECT as u8,
1124 true,
1125 false,
1126 false,
1127 false,
1128 false,
1129 false,
1130 0,
1131 ).to_ne_bytes()
1132 ),
1133});
1134}
1135unsafe extern "C" fn setViewerOrigin<D: DomTypes>
1136(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1137 let mut result = false;
1138 wrap_panic(&mut || result = (|| {
1139 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1140 let this = &*(this as *const D::FakeXRDevice);
1141 let args = &*args;
1142 let argc = args.argc_;
1143
1144 if argc < 1 {
1145 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.setViewerOrigin\".");
1146 return false;
1147 }
1148 let arg0: crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1149 Ok(ConversionResult::Success(value)) => value,
1150 Ok(ConversionResult::Failure(error)) => {
1151 throw_type_error(cx.raw_cx(), &error);
1152 return false;
1153
1154 }
1155 _ => {
1156 return false;
1157
1158 },
1159 }
1160 ;
1161 let arg1: bool = if args.get(1).is_undefined() {
1162 false
1163 } else {
1164 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
1165 Ok(ConversionResult::Success(value)) => value,
1166 Ok(ConversionResult::Failure(error)) => {
1167 throw_type_error(cx.raw_cx(), &error);
1168 return false;
1169
1170 }
1171 _ => {
1172 return false;
1173
1174 },
1175 }
1176
1177 };
1178 let result: Result<(), Error> = this.SetViewerOrigin(&arg0, arg1);
1179 let result = match result {
1180 Ok(result) => result,
1181 Err(e) => {
1182 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1183 return false;
1184 },
1185 };
1186
1187 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1188 return true;
1189 })());
1190 result
1191}
1192
1193
1194static setViewerOrigin_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1195
1196pub(crate) fn init_setViewerOrigin_methodinfo<D: DomTypes>() {
1197 setViewerOrigin_methodinfo.set(JSJitInfo {
1198 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1199 method: Some(setViewerOrigin::<D>)
1200 },
1201 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1202 protoID: PrototypeList::ID::FakeXRDevice as u16,
1203 },
1204 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1205 _bitfield_align_1: [],
1206 _bitfield_1: __BindgenBitfieldUnit::new(
1207 new_jsjitinfo_bitfield_1!(
1208 JSJitInfo_OpType::Method as u8,
1209 JSJitInfo_AliasSet::AliasEverything as u8,
1210 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1211 false,
1212 false,
1213 false,
1214 false,
1215 false,
1216 false,
1217 0,
1218 ).to_ne_bytes()
1219 ),
1220});
1221}
1222unsafe extern "C" fn clearViewerOrigin<D: DomTypes>
1223(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1224 let mut result = false;
1225 wrap_panic(&mut || result = (|| {
1226 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1227 let this = &*(this as *const D::FakeXRDevice);
1228 let args = &*args;
1229 let argc = args.argc_;
1230 let result: () = this.ClearViewerOrigin();
1231
1232 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1233 return true;
1234 })());
1235 result
1236}
1237
1238
1239static clearViewerOrigin_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1240
1241pub(crate) fn init_clearViewerOrigin_methodinfo<D: DomTypes>() {
1242 clearViewerOrigin_methodinfo.set(JSJitInfo {
1243 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1244 method: Some(clearViewerOrigin::<D>)
1245 },
1246 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1247 protoID: PrototypeList::ID::FakeXRDevice as u16,
1248 },
1249 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1250 _bitfield_align_1: [],
1251 _bitfield_1: __BindgenBitfieldUnit::new(
1252 new_jsjitinfo_bitfield_1!(
1253 JSJitInfo_OpType::Method as u8,
1254 JSJitInfo_AliasSet::AliasEverything as u8,
1255 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1256 true,
1257 false,
1258 false,
1259 false,
1260 false,
1261 false,
1262 0,
1263 ).to_ne_bytes()
1264 ),
1265});
1266}
1267unsafe extern "C" fn setFloorOrigin<D: DomTypes>
1268(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1269 let mut result = false;
1270 wrap_panic(&mut || result = (|| {
1271 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1272 let this = &*(this as *const D::FakeXRDevice);
1273 let args = &*args;
1274 let argc = args.argc_;
1275
1276 if argc < 1 {
1277 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.setFloorOrigin\".");
1278 return false;
1279 }
1280 let arg0: crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1281 Ok(ConversionResult::Success(value)) => value,
1282 Ok(ConversionResult::Failure(error)) => {
1283 throw_type_error(cx.raw_cx(), &error);
1284 return false;
1285
1286 }
1287 _ => {
1288 return false;
1289
1290 },
1291 }
1292 ;
1293 let result: Result<(), Error> = this.SetFloorOrigin(&arg0);
1294 let result = match result {
1295 Ok(result) => result,
1296 Err(e) => {
1297 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1298 return false;
1299 },
1300 };
1301
1302 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1303 return true;
1304 })());
1305 result
1306}
1307
1308
1309static setFloorOrigin_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1310
1311pub(crate) fn init_setFloorOrigin_methodinfo<D: DomTypes>() {
1312 setFloorOrigin_methodinfo.set(JSJitInfo {
1313 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1314 method: Some(setFloorOrigin::<D>)
1315 },
1316 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1317 protoID: PrototypeList::ID::FakeXRDevice as u16,
1318 },
1319 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1320 _bitfield_align_1: [],
1321 _bitfield_1: __BindgenBitfieldUnit::new(
1322 new_jsjitinfo_bitfield_1!(
1323 JSJitInfo_OpType::Method as u8,
1324 JSJitInfo_AliasSet::AliasEverything as u8,
1325 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1326 false,
1327 false,
1328 false,
1329 false,
1330 false,
1331 false,
1332 0,
1333 ).to_ne_bytes()
1334 ),
1335});
1336}
1337unsafe extern "C" fn clearFloorOrigin<D: DomTypes>
1338(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1339 let mut result = false;
1340 wrap_panic(&mut || result = (|| {
1341 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1342 let this = &*(this as *const D::FakeXRDevice);
1343 let args = &*args;
1344 let argc = args.argc_;
1345 let result: () = this.ClearFloorOrigin();
1346
1347 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1348 return true;
1349 })());
1350 result
1351}
1352
1353
1354static clearFloorOrigin_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1355
1356pub(crate) fn init_clearFloorOrigin_methodinfo<D: DomTypes>() {
1357 clearFloorOrigin_methodinfo.set(JSJitInfo {
1358 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1359 method: Some(clearFloorOrigin::<D>)
1360 },
1361 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1362 protoID: PrototypeList::ID::FakeXRDevice as u16,
1363 },
1364 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1365 _bitfield_align_1: [],
1366 _bitfield_1: __BindgenBitfieldUnit::new(
1367 new_jsjitinfo_bitfield_1!(
1368 JSJitInfo_OpType::Method as u8,
1369 JSJitInfo_AliasSet::AliasEverything as u8,
1370 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1371 true,
1372 false,
1373 false,
1374 false,
1375 false,
1376 false,
1377 0,
1378 ).to_ne_bytes()
1379 ),
1380});
1381}
1382unsafe extern "C" fn setBoundsGeometry<D: DomTypes>
1383(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1384 let mut result = false;
1385 wrap_panic(&mut || result = (|| {
1386 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1387 let this = &*(this as *const D::FakeXRDevice);
1388 let args = &*args;
1389 let argc = args.argc_;
1390
1391 if argc < 1 {
1392 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.setBoundsGeometry\".");
1393 return false;
1394 }
1395 let arg0: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRBoundsPoint> = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1396 Ok(ConversionResult::Success(value)) => value,
1397 Ok(ConversionResult::Failure(error)) => {
1398 throw_type_error(cx.raw_cx(), &error);
1399 return false;
1400
1401 }
1402 _ => {
1403 return false;
1404
1405 },
1406 }
1407 ;
1408 let result: Result<(), Error> = this.SetBoundsGeometry(arg0);
1409 let result = match result {
1410 Ok(result) => result,
1411 Err(e) => {
1412 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1413 return false;
1414 },
1415 };
1416
1417 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1418 return true;
1419 })());
1420 result
1421}
1422
1423
1424static setBoundsGeometry_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1425
1426pub(crate) fn init_setBoundsGeometry_methodinfo<D: DomTypes>() {
1427 setBoundsGeometry_methodinfo.set(JSJitInfo {
1428 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1429 method: Some(setBoundsGeometry::<D>)
1430 },
1431 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1432 protoID: PrototypeList::ID::FakeXRDevice as u16,
1433 },
1434 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1435 _bitfield_align_1: [],
1436 _bitfield_1: __BindgenBitfieldUnit::new(
1437 new_jsjitinfo_bitfield_1!(
1438 JSJitInfo_OpType::Method as u8,
1439 JSJitInfo_AliasSet::AliasEverything as u8,
1440 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1441 false,
1442 false,
1443 false,
1444 false,
1445 false,
1446 false,
1447 0,
1448 ).to_ne_bytes()
1449 ),
1450});
1451}
1452unsafe extern "C" fn simulateResetPose<D: DomTypes>
1453(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1454 let mut result = false;
1455 wrap_panic(&mut || result = (|| {
1456 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1457 let this = &*(this as *const D::FakeXRDevice);
1458 let args = &*args;
1459 let argc = args.argc_;
1460 let result: () = this.SimulateResetPose();
1461
1462 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1463 return true;
1464 })());
1465 result
1466}
1467
1468
1469static simulateResetPose_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1470
1471pub(crate) fn init_simulateResetPose_methodinfo<D: DomTypes>() {
1472 simulateResetPose_methodinfo.set(JSJitInfo {
1473 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1474 method: Some(simulateResetPose::<D>)
1475 },
1476 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1477 protoID: PrototypeList::ID::FakeXRDevice as u16,
1478 },
1479 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1480 _bitfield_align_1: [],
1481 _bitfield_1: __BindgenBitfieldUnit::new(
1482 new_jsjitinfo_bitfield_1!(
1483 JSJitInfo_OpType::Method as u8,
1484 JSJitInfo_AliasSet::AliasEverything as u8,
1485 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1486 true,
1487 false,
1488 false,
1489 false,
1490 false,
1491 false,
1492 0,
1493 ).to_ne_bytes()
1494 ),
1495});
1496}
1497unsafe extern "C" fn simulateVisibilityChange<D: DomTypes>
1498(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1499 let mut result = false;
1500 wrap_panic(&mut || result = (|| {
1501 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1502 let this = &*(this as *const D::FakeXRDevice);
1503 let args = &*args;
1504 let argc = args.argc_;
1505
1506 if argc < 1 {
1507 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.simulateVisibilityChange\".");
1508 return false;
1509 }
1510 let arg0: XRVisibilityState = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1511 Ok(ConversionResult::Success(value)) => value,
1512 Ok(ConversionResult::Failure(error)) => {
1513 throw_type_error(cx.raw_cx(), &error); return false;
1514
1515 }
1516 _ => {
1517 return false;
1518
1519 },
1520 }
1521 ;
1522 let result: () = this.SimulateVisibilityChange(arg0);
1523
1524 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1525 return true;
1526 })());
1527 result
1528}
1529
1530
1531static simulateVisibilityChange_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1532
1533pub(crate) fn init_simulateVisibilityChange_methodinfo<D: DomTypes>() {
1534 simulateVisibilityChange_methodinfo.set(JSJitInfo {
1535 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1536 method: Some(simulateVisibilityChange::<D>)
1537 },
1538 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1539 protoID: PrototypeList::ID::FakeXRDevice as u16,
1540 },
1541 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1542 _bitfield_align_1: [],
1543 _bitfield_1: __BindgenBitfieldUnit::new(
1544 new_jsjitinfo_bitfield_1!(
1545 JSJitInfo_OpType::Method as u8,
1546 JSJitInfo_AliasSet::AliasEverything as u8,
1547 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1548 false,
1549 false,
1550 false,
1551 false,
1552 false,
1553 false,
1554 0,
1555 ).to_ne_bytes()
1556 ),
1557});
1558}
1559unsafe extern "C" fn simulateInputSourceConnection<D: DomTypes>
1560(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1561 let mut result = false;
1562 wrap_panic(&mut || result = (|| {
1563 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1564 let this = &*(this as *const D::FakeXRDevice);
1565 let args = &*args;
1566 let argc = args.argc_;
1567
1568 if argc < 1 {
1569 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.simulateInputSourceConnection\".");
1570 return false;
1571 }
1572 let arg0: crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRInputSourceInit = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1573 Ok(ConversionResult::Success(value)) => value,
1574 Ok(ConversionResult::Failure(error)) => {
1575 throw_type_error(cx.raw_cx(), &error);
1576 return false;
1577
1578 }
1579 _ => {
1580 return false;
1581
1582 },
1583 }
1584 ;
1585 let result: Result<DomRoot<D::FakeXRInputController>, Error> = this.SimulateInputSourceConnection(&arg0);
1586 let result = match result {
1587 Ok(result) => result,
1588 Err(e) => {
1589 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1590 return false;
1591 },
1592 };
1593
1594 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1595 return true;
1596 })());
1597 result
1598}
1599
1600
1601static simulateInputSourceConnection_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1602
1603pub(crate) fn init_simulateInputSourceConnection_methodinfo<D: DomTypes>() {
1604 simulateInputSourceConnection_methodinfo.set(JSJitInfo {
1605 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1606 method: Some(simulateInputSourceConnection::<D>)
1607 },
1608 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1609 protoID: PrototypeList::ID::FakeXRDevice as u16,
1610 },
1611 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1612 _bitfield_align_1: [],
1613 _bitfield_1: __BindgenBitfieldUnit::new(
1614 new_jsjitinfo_bitfield_1!(
1615 JSJitInfo_OpType::Method as u8,
1616 JSJitInfo_AliasSet::AliasEverything as u8,
1617 JSValueType::JSVAL_TYPE_OBJECT as u8,
1618 false,
1619 false,
1620 false,
1621 false,
1622 false,
1623 false,
1624 0,
1625 ).to_ne_bytes()
1626 ),
1627});
1628}
1629unsafe extern "C" fn setWorld<D: DomTypes>
1630(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1631 let mut result = false;
1632 wrap_panic(&mut || result = (|| {
1633 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1634 let this = &*(this as *const D::FakeXRDevice);
1635 let args = &*args;
1636 let argc = args.argc_;
1637
1638 if argc < 1 {
1639 throw_type_error(cx.raw_cx(), "Not enough arguments to \"FakeXRDevice.setWorld\".");
1640 return false;
1641 }
1642 let arg0: crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRWorldInit = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
1643 Ok(ConversionResult::Success(value)) => value,
1644 Ok(ConversionResult::Failure(error)) => {
1645 throw_type_error(cx.raw_cx(), &error);
1646 return false;
1647
1648 }
1649 _ => {
1650 return false;
1651
1652 },
1653 }
1654 ;
1655 let result: Result<(), Error> = this.SetWorld(&arg0);
1656 let result = match result {
1657 Ok(result) => result,
1658 Err(e) => {
1659 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
1660 return false;
1661 },
1662 };
1663
1664 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1665 return true;
1666 })());
1667 result
1668}
1669
1670
1671static setWorld_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1672
1673pub(crate) fn init_setWorld_methodinfo<D: DomTypes>() {
1674 setWorld_methodinfo.set(JSJitInfo {
1675 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1676 method: Some(setWorld::<D>)
1677 },
1678 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1679 protoID: PrototypeList::ID::FakeXRDevice as u16,
1680 },
1681 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1682 _bitfield_align_1: [],
1683 _bitfield_1: __BindgenBitfieldUnit::new(
1684 new_jsjitinfo_bitfield_1!(
1685 JSJitInfo_OpType::Method as u8,
1686 JSJitInfo_AliasSet::AliasEverything as u8,
1687 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1688 false,
1689 false,
1690 false,
1691 false,
1692 false,
1693 false,
1694 0,
1695 ).to_ne_bytes()
1696 ),
1697});
1698}
1699unsafe extern "C" fn clearWorld<D: DomTypes>
1700(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1701 let mut result = false;
1702 wrap_panic(&mut || result = (|| {
1703 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1704 let this = &*(this as *const D::FakeXRDevice);
1705 let args = &*args;
1706 let argc = args.argc_;
1707 let result: () = this.ClearWorld();
1708
1709 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1710 return true;
1711 })());
1712 result
1713}
1714
1715
1716static clearWorld_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1717
1718pub(crate) fn init_clearWorld_methodinfo<D: DomTypes>() {
1719 clearWorld_methodinfo.set(JSJitInfo {
1720 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1721 method: Some(clearWorld::<D>)
1722 },
1723 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1724 protoID: PrototypeList::ID::FakeXRDevice as u16,
1725 },
1726 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1727 _bitfield_align_1: [],
1728 _bitfield_1: __BindgenBitfieldUnit::new(
1729 new_jsjitinfo_bitfield_1!(
1730 JSJitInfo_OpType::Method as u8,
1731 JSJitInfo_AliasSet::AliasEverything as u8,
1732 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
1733 true,
1734 false,
1735 false,
1736 false,
1737 false,
1738 false,
1739 0,
1740 ).to_ne_bytes()
1741 ),
1742});
1743}
1744unsafe extern "C" fn _finalize<D: DomTypes>
1745(_cx: *mut GCContext, obj: *mut JSObject){
1746 wrap_panic(&mut || {
1747
1748 let this = native_from_object_static::<D::FakeXRDevice>(obj).unwrap();
1749 finalize_common(this);
1750 })
1751}
1752
1753unsafe extern "C" fn _trace<D: DomTypes>
1754(trc: *mut JSTracer, obj: *mut JSObject){
1755 wrap_panic(&mut || {
1756
1757 let this = native_from_object_static::<D::FakeXRDevice>(obj).unwrap();
1758 if this.is_null() { return; } (*this).trace(trc);
1760 })
1761}
1762
1763
1764static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
1765
1766pub(crate) fn init_class_ops<D: DomTypes>() {
1767 CLASS_OPS.set(JSClassOps {
1768 addProperty: None,
1769 delProperty: None,
1770 enumerate: None,
1771 newEnumerate: None,
1772 resolve: None,
1773 mayResolve: None,
1774 finalize: Some(_finalize::<D>),
1775 call: None,
1776 construct: None,
1777 trace: Some(_trace::<D>),
1778 });
1779}
1780
1781pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
1782
1783pub(crate) fn init_domjs_class<D: DomTypes>() {
1784 init_class_ops::<D>();
1785 Class.set(DOMJSClass {
1786 base: JSClass {
1787 name: c"FakeXRDevice".as_ptr(),
1788 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
1789 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
1790 ,
1791 cOps: unsafe { CLASS_OPS.get() },
1792 spec: ptr::null(),
1793 ext: ptr::null(),
1794 oOps: ptr::null(),
1795 },
1796 dom_class:
1797DOMClass {
1798 interface_chain: [ PrototypeList::ID::FakeXRDevice, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
1799 depth: 0,
1800 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
1801 malloc_size_of: malloc_size_of_including_raw_self::<D::FakeXRDevice> as unsafe fn(&mut _, _) -> _,
1802 global: Globals::EMPTY,
1803},
1804 });
1805}
1806
1807#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
1808(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::FakeXRDevice>, _can_gc: CanGc) -> DomRoot<D::FakeXRDevice>{
1809
1810 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
1811
1812 let scope = scope.reflector().get_jsobject();
1813 assert!(!scope.get().is_null());
1814 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
1815 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
1816
1817 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
1818 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
1819 assert!(!canonical_proto.is_null());
1820
1821
1822 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
1823 if let Some(given) = given_proto {
1824 proto.set(*given);
1825 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
1826 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
1827 }
1828 } else {
1829 proto.set(*canonical_proto);
1830 }
1831 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
1832 cx.raw_cx(),
1833 &Class.get().base,
1834 proto.handle(),
1835 ));
1836 assert!(!obj.is_null());
1837 JS_SetReservedSlot(
1838 obj.get(),
1839 DOM_OBJECT_SLOT,
1840 &PrivateValue(raw.as_ptr() as *const libc::c_void),
1841 );
1842
1843 let root = raw.reflect_with(obj.get());
1844
1845
1846
1847 DomRoot::from_ref(&*root)
1848}
1849
1850pub trait FakeXRDeviceMethods<D: DomTypes> {
1851 fn SetViews(&self, r#views: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRViewInit>, r#secondaryViews: Option<Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRViewInit>>) -> Fallible<()>;
1852 fn Disconnect(&self, r#_can_gc: CanGc) -> Rc<D::Promise>;
1853 fn SetViewerOrigin(&self, r#origin: &crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit, r#emulatedPosition: bool) -> Fallible<()>;
1854 fn ClearViewerOrigin(&self, );
1855 fn SetFloorOrigin(&self, r#origin: &crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRRigidTransformInit) -> Fallible<()>;
1856 fn ClearFloorOrigin(&self, );
1857 fn SetBoundsGeometry(&self, r#boundsCoodinates: Vec<crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRBoundsPoint>) -> Fallible<()>;
1858 fn SimulateResetPose(&self, );
1859 fn SimulateVisibilityChange(&self, r#state: XRVisibilityState);
1860 fn SimulateInputSourceConnection(&self, r#init: &crate::codegen::GenericBindings::FakeXRInputControllerBinding::FakeXRInputSourceInit) -> Fallible<DomRoot<D::FakeXRInputController>>;
1861 fn SetWorld(&self, r#world: &crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRWorldInit) -> Fallible<()>;
1862 fn ClearWorld(&self, );
1863}
1864static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
1865
1866pub(crate) fn init_sMethods_specs<D: DomTypes>() {
1867 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1868 JSFunctionSpec {
1869 name: JSPropertySpec_Name { string_: c"setViews".as_ptr() },
1870 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { setViews_methodinfo.get() } as *const _ as *const JSJitInfo },
1871 nargs: 1,
1872 flags: (JSPROP_ENUMERATE) as u16,
1873 selfHostedName: ptr::null()
1874 },
1875 JSFunctionSpec {
1876 name: JSPropertySpec_Name { string_: c"disconnect".as_ptr() },
1877 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { disconnect_methodinfo.get() } as *const _ as *const JSJitInfo },
1878 nargs: 0,
1879 flags: (JSPROP_ENUMERATE) as u16,
1880 selfHostedName: ptr::null()
1881 },
1882 JSFunctionSpec {
1883 name: JSPropertySpec_Name { string_: c"setViewerOrigin".as_ptr() },
1884 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { setViewerOrigin_methodinfo.get() } as *const _ as *const JSJitInfo },
1885 nargs: 1,
1886 flags: (JSPROP_ENUMERATE) as u16,
1887 selfHostedName: ptr::null()
1888 },
1889 JSFunctionSpec {
1890 name: JSPropertySpec_Name { string_: c"clearViewerOrigin".as_ptr() },
1891 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { clearViewerOrigin_methodinfo.get() } as *const _ as *const JSJitInfo },
1892 nargs: 0,
1893 flags: (JSPROP_ENUMERATE) as u16,
1894 selfHostedName: ptr::null()
1895 },
1896 JSFunctionSpec {
1897 name: JSPropertySpec_Name { string_: c"setFloorOrigin".as_ptr() },
1898 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { setFloorOrigin_methodinfo.get() } as *const _ as *const JSJitInfo },
1899 nargs: 1,
1900 flags: (JSPROP_ENUMERATE) as u16,
1901 selfHostedName: ptr::null()
1902 },
1903 JSFunctionSpec {
1904 name: JSPropertySpec_Name { string_: c"clearFloorOrigin".as_ptr() },
1905 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { clearFloorOrigin_methodinfo.get() } as *const _ as *const JSJitInfo },
1906 nargs: 0,
1907 flags: (JSPROP_ENUMERATE) as u16,
1908 selfHostedName: ptr::null()
1909 },
1910 JSFunctionSpec {
1911 name: JSPropertySpec_Name { string_: c"setBoundsGeometry".as_ptr() },
1912 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { setBoundsGeometry_methodinfo.get() } as *const _ as *const JSJitInfo },
1913 nargs: 1,
1914 flags: (JSPROP_ENUMERATE) as u16,
1915 selfHostedName: ptr::null()
1916 },
1917 JSFunctionSpec {
1918 name: JSPropertySpec_Name { string_: c"simulateResetPose".as_ptr() },
1919 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { simulateResetPose_methodinfo.get() } as *const _ as *const JSJitInfo },
1920 nargs: 0,
1921 flags: (JSPROP_ENUMERATE) as u16,
1922 selfHostedName: ptr::null()
1923 },
1924 JSFunctionSpec {
1925 name: JSPropertySpec_Name { string_: c"simulateVisibilityChange".as_ptr() },
1926 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { simulateVisibilityChange_methodinfo.get() } as *const _ as *const JSJitInfo },
1927 nargs: 1,
1928 flags: (JSPROP_ENUMERATE) as u16,
1929 selfHostedName: ptr::null()
1930 },
1931 JSFunctionSpec {
1932 name: JSPropertySpec_Name { string_: c"simulateInputSourceConnection".as_ptr() },
1933 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { simulateInputSourceConnection_methodinfo.get() } as *const _ as *const JSJitInfo },
1934 nargs: 1,
1935 flags: (JSPROP_ENUMERATE) as u16,
1936 selfHostedName: ptr::null()
1937 },
1938 JSFunctionSpec {
1939 name: JSPropertySpec_Name { string_: c"setWorld".as_ptr() },
1940 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { setWorld_methodinfo.get() } as *const _ as *const JSJitInfo },
1941 nargs: 1,
1942 flags: (JSPROP_ENUMERATE) as u16,
1943 selfHostedName: ptr::null()
1944 },
1945 JSFunctionSpec {
1946 name: JSPropertySpec_Name { string_: c"clearWorld".as_ptr() },
1947 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { clearWorld_methodinfo.get() } as *const _ as *const JSJitInfo },
1948 nargs: 0,
1949 flags: (JSPROP_ENUMERATE) as u16,
1950 selfHostedName: ptr::null()
1951 },
1952 JSFunctionSpec {
1953 name: JSPropertySpec_Name { string_: ptr::null() },
1954 call: JSNativeWrapper { op: None, info: ptr::null() },
1955 nargs: 0,
1956 flags: 0,
1957 selfHostedName: ptr::null()
1958 }]))[..]
1959])));
1960}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
1961
1962pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
1963 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
1964}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
1965
1966pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
1967 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1968 JSPropertySpec {
1969 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
1970 attributes_: (JSPROP_READONLY),
1971 kind_: (JSPropertySpec_Kind::Value),
1972 u: JSPropertySpec_AccessorsOrValue {
1973 value: JSPropertySpec_ValueWrapper {
1974 type_: JSPropertySpec_ValueWrapper_Type::String,
1975 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
1976 string: c"FakeXRDevice".as_ptr(),
1977 }
1978 }
1979 }
1980 }
1981,
1982 JSPropertySpec::ZERO]))[..]
1983])));
1984}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
1985
1986pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
1987 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
1988}
1989pub fn GetProtoObject<D: DomTypes>
1990(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
1991 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::FakeXRDevice), CreateInterfaceObjects::<D>, rval)
1993}
1994
1995
1996static PrototypeClass: JSClass = JSClass {
1997 name: c"FakeXRDevicePrototype".as_ptr(),
1998 flags:
1999 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
2001 cOps: ptr::null(),
2002 spec: ptr::null(),
2003 ext: ptr::null(),
2004 oOps: ptr::null(),
2005};
2006
2007
2008static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
2009
2010pub(crate) fn init_interface_object<D: DomTypes>() {
2011 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
2012 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
2013 b"function FakeXRDevice() {\n [native code]\n}",
2014 PrototypeList::ID::FakeXRDevice,
2015 0,
2016 ));
2017}
2018
2019pub fn DefineDOMInterface<D: DomTypes>
2020(cx: SafeJSContext, global: HandleObject){
2021 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::FakeXRDevice),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
2022}
2023
2024pub fn ConstructorEnabled<D: DomTypes>
2025(aCx: SafeJSContext, aObj: HandleObject) -> bool{
2026 is_exposed_in(aObj, Globals::WINDOW) &&
2027 pref!(dom_webxr_test)
2028}
2029
2030unsafe fn CreateInterfaceObjects<D: DomTypes>
2031(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
2032
2033 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
2034 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
2035 assert!(!prototype_proto.is_null());
2036
2037 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
2038 create_interface_prototype_object::<D>(cx,
2039 global,
2040 prototype_proto.handle(),
2041 &PrototypeClass,
2042 sMethods.get(),
2043 sAttributes.get(),
2044 &[],
2045 &[],
2046 prototype.handle_mut());
2047 assert!(!prototype.is_null());
2048 assert!((*cache)[PrototypeList::ID::FakeXRDevice as usize].is_null());
2049 (*cache)[PrototypeList::ID::FakeXRDevice as usize] = prototype.get();
2050 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::FakeXRDevice as isize),
2051 ptr::null_mut(),
2052 prototype.get());
2053
2054 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
2055 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
2056
2057 assert!(!interface_proto.is_null());
2058
2059 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
2060 create_noncallback_interface_object::<D>(cx,
2061 global,
2062 interface_proto.handle(),
2063 INTERFACE_OBJECT_CLASS.get(),
2064 &[],
2065 &[],
2066 &[],
2067 prototype.handle(),
2068 c"FakeXRDevice",
2069 0,
2070 &[],
2071 interface.handle_mut());
2072 assert!(!interface.is_null());
2073}
2074
2075
2076 pub(crate) fn init_statics<D: DomTypes>() {
2077 init_interface_object::<D>();
2078 init_domjs_class::<D>();
2079 crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_setViews_methodinfo::<D>();
2080crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_disconnect_methodinfo::<D>();
2081crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_setViewerOrigin_methodinfo::<D>();
2082crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_clearViewerOrigin_methodinfo::<D>();
2083crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_setFloorOrigin_methodinfo::<D>();
2084crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_clearFloorOrigin_methodinfo::<D>();
2085crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_setBoundsGeometry_methodinfo::<D>();
2086crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_simulateResetPose_methodinfo::<D>();
2087crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_simulateVisibilityChange_methodinfo::<D>();
2088crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_simulateInputSourceConnection_methodinfo::<D>();
2089crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_setWorld_methodinfo::<D>();
2090crate::codegen::GenericBindings::FakeXRDeviceBinding::FakeXRDevice_Binding::init_clearWorld_methodinfo::<D>();
2091
2092
2093
2094 init_sMethods_specs::<D>();
2095init_sMethods_prefs::<D>();
2096init_sAttributes_specs::<D>();
2097init_sAttributes_prefs::<D>();
2098 }
2099 }