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