1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::import::base::*;
6
7pub use self::XRPose_Binding::{Wrap, XRPoseMethods, GetProtoObject, GetConstructorObject, DefineDOMInterface};
8pub mod XRPose_Binding {
9use crate::import::module::*;
10
11unsafe extern "C" fn get_transform<D: DomTypes>
12(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
13 let mut result = false;
14 wrap_panic(&mut || result = (|| {
15 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
16 let this = &*(this as *const D::XRPose);
17 let result: DomRoot<D::XRRigidTransform> = this.Transform();
18
19 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
20 return true;
21 })());
22 result
23}
24
25
26static transform_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
27
28pub(crate) fn init_transform_getterinfo<D: DomTypes>() {
29 transform_getterinfo.set(JSJitInfo {
30 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
31 getter: Some(get_transform::<D>)
32 },
33 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
34 protoID: PrototypeList::ID::XRPose as u16,
35 },
36 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
37 _bitfield_align_1: [],
38 _bitfield_1: __BindgenBitfieldUnit::new(
39 new_jsjitinfo_bitfield_1!(
40 JSJitInfo_OpType::Getter as u8,
41 JSJitInfo_AliasSet::AliasNone as u8,
42 JSValueType::JSVAL_TYPE_OBJECT as u8,
43 true,
44 true,
45 false,
46 false,
47 false,
48 false,
49 0,
50 ).to_ne_bytes()
51 ),
52});
53}
54unsafe extern "C" fn get_linearVelocity<D: DomTypes>
55(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
56 let mut result = false;
57 wrap_panic(&mut || result = (|| {
58 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
59 let this = &*(this as *const D::XRPose);
60 let result: Option<DomRoot<D::DOMPointReadOnly>> = this.GetLinearVelocity();
61
62 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
63 return true;
64 })());
65 result
66}
67
68
69static linearVelocity_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
70
71pub(crate) fn init_linearVelocity_getterinfo<D: DomTypes>() {
72 linearVelocity_getterinfo.set(JSJitInfo {
73 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
74 getter: Some(get_linearVelocity::<D>)
75 },
76 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
77 protoID: PrototypeList::ID::XRPose as u16,
78 },
79 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
80 _bitfield_align_1: [],
81 _bitfield_1: __BindgenBitfieldUnit::new(
82 new_jsjitinfo_bitfield_1!(
83 JSJitInfo_OpType::Getter as u8,
84 JSJitInfo_AliasSet::AliasNone as u8,
85 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
86 true,
87 true,
88 false,
89 false,
90 false,
91 false,
92 0,
93 ).to_ne_bytes()
94 ),
95});
96}
97unsafe extern "C" fn get_angularVelocity<D: DomTypes>
98(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
99 let mut result = false;
100 wrap_panic(&mut || result = (|| {
101 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
102 let this = &*(this as *const D::XRPose);
103 let result: Option<DomRoot<D::DOMPointReadOnly>> = this.GetAngularVelocity();
104
105 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
106 return true;
107 })());
108 result
109}
110
111
112static angularVelocity_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
113
114pub(crate) fn init_angularVelocity_getterinfo<D: DomTypes>() {
115 angularVelocity_getterinfo.set(JSJitInfo {
116 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
117 getter: Some(get_angularVelocity::<D>)
118 },
119 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
120 protoID: PrototypeList::ID::XRPose as u16,
121 },
122 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
123 _bitfield_align_1: [],
124 _bitfield_1: __BindgenBitfieldUnit::new(
125 new_jsjitinfo_bitfield_1!(
126 JSJitInfo_OpType::Getter as u8,
127 JSJitInfo_AliasSet::AliasNone as u8,
128 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
129 true,
130 true,
131 false,
132 false,
133 false,
134 false,
135 0,
136 ).to_ne_bytes()
137 ),
138});
139}
140unsafe extern "C" fn get_emulatedPosition<D: DomTypes>
141(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
142 let mut result = false;
143 wrap_panic(&mut || result = (|| {
144 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
145 let this = &*(this as *const D::XRPose);
146 let result: bool = this.EmulatedPosition();
147
148 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
149 return true;
150 })());
151 result
152}
153
154
155static emulatedPosition_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
156
157pub(crate) fn init_emulatedPosition_getterinfo<D: DomTypes>() {
158 emulatedPosition_getterinfo.set(JSJitInfo {
159 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
160 getter: Some(get_emulatedPosition::<D>)
161 },
162 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
163 protoID: PrototypeList::ID::XRPose as u16,
164 },
165 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
166 _bitfield_align_1: [],
167 _bitfield_1: __BindgenBitfieldUnit::new(
168 new_jsjitinfo_bitfield_1!(
169 JSJitInfo_OpType::Getter as u8,
170 JSJitInfo_AliasSet::AliasEverything as u8,
171 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
172 true,
173 false,
174 false,
175 false,
176 false,
177 false,
178 0,
179 ).to_ne_bytes()
180 ),
181});
182}
183unsafe extern "C" fn _finalize<D: DomTypes>
184(_cx: *mut GCContext, obj: *mut JSObject){
185 wrap_panic(&mut || {
186
187 let this = native_from_object_static::<D::XRPose>(obj).unwrap();
188 finalize_common(this);
189 })
190}
191
192unsafe extern "C" fn _trace<D: DomTypes>
193(trc: *mut JSTracer, obj: *mut JSObject){
194 wrap_panic(&mut || {
195
196 let this = native_from_object_static::<D::XRPose>(obj).unwrap();
197 if this.is_null() { return; } (*this).trace(trc);
199 })
200}
201
202
203static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
204
205pub(crate) fn init_class_ops<D: DomTypes>() {
206 CLASS_OPS.set(JSClassOps {
207 addProperty: None,
208 delProperty: None,
209 enumerate: None,
210 newEnumerate: None,
211 resolve: None,
212 mayResolve: None,
213 finalize: Some(_finalize::<D>),
214 call: None,
215 construct: None,
216 trace: Some(_trace::<D>),
217 });
218}
219
220pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
221
222pub(crate) fn init_domjs_class<D: DomTypes>() {
223 init_class_ops::<D>();
224 Class.set(DOMJSClass {
225 base: JSClass {
226 name: c"XRPose".as_ptr(),
227 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
228 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
229 ,
230 cOps: unsafe { CLASS_OPS.get() },
231 spec: ptr::null(),
232 ext: ptr::null(),
233 oOps: ptr::null(),
234 },
235 dom_class:
236DOMClass {
237 interface_chain: [ PrototypeList::ID::XRPose, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
238 depth: 0,
239 type_id: crate::codegen::InheritTypes::TopTypeId { xrpose: (crate::codegen::InheritTypes::XRPoseTypeId::XRPose) },
240 malloc_size_of: malloc_size_of_including_raw_self::<D::XRPose> as unsafe fn(&mut _, _) -> _,
241 global: Globals::EMPTY,
242},
243 });
244}
245
246#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
247(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::XRPose>, _can_gc: CanGc) -> DomRoot<D::XRPose>{
248
249 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
250
251 let scope = scope.reflector().get_jsobject();
252 assert!(!scope.get().is_null());
253 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
254 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
255
256 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
257 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
258 assert!(!canonical_proto.is_null());
259
260
261 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
262 if let Some(given) = given_proto {
263 proto.set(*given);
264 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
265 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
266 }
267 } else {
268 proto.set(*canonical_proto);
269 }
270 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
271 cx.raw_cx(),
272 &Class.get().base,
273 proto.handle(),
274 ));
275 assert!(!obj.is_null());
276 JS_SetReservedSlot(
277 obj.get(),
278 DOM_OBJECT_SLOT,
279 &PrivateValue(raw.as_ptr() as *const libc::c_void),
280 );
281
282 let root = raw.reflect_with(obj.get());
283
284
285
286 DomRoot::from_ref(&*root)
287}
288
289pub trait XRPoseMethods<D: DomTypes> {
290 fn Transform(&self, ) -> DomRoot<D::XRRigidTransform>;
291 fn GetLinearVelocity(&self, ) -> Option<DomRoot<D::DOMPointReadOnly>>;
292 fn GetAngularVelocity(&self, ) -> Option<DomRoot<D::DOMPointReadOnly>>;
293 fn EmulatedPosition(&self, ) -> bool;
294}
295static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
296
297pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
298 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
299 JSPropertySpec {
300 name: JSPropertySpec_Name { string_: c"transform".as_ptr() },
301 attributes_: (JSPROP_ENUMERATE),
302 kind_: (JSPropertySpec_Kind::NativeAccessor),
303 u: JSPropertySpec_AccessorsOrValue {
304 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
305 getter: JSPropertySpec_Accessor {
306 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { transform_getterinfo.get() } },
307 },
308 setter: JSPropertySpec_Accessor {
309 native: JSNativeWrapper { op: None, info: ptr::null() },
310 }
311 }
312 }
313 }
314,
315 JSPropertySpec {
316 name: JSPropertySpec_Name { string_: c"linearVelocity".as_ptr() },
317 attributes_: (JSPROP_ENUMERATE),
318 kind_: (JSPropertySpec_Kind::NativeAccessor),
319 u: JSPropertySpec_AccessorsOrValue {
320 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
321 getter: JSPropertySpec_Accessor {
322 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { linearVelocity_getterinfo.get() } },
323 },
324 setter: JSPropertySpec_Accessor {
325 native: JSNativeWrapper { op: None, info: ptr::null() },
326 }
327 }
328 }
329 }
330,
331 JSPropertySpec {
332 name: JSPropertySpec_Name { string_: c"angularVelocity".as_ptr() },
333 attributes_: (JSPROP_ENUMERATE),
334 kind_: (JSPropertySpec_Kind::NativeAccessor),
335 u: JSPropertySpec_AccessorsOrValue {
336 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
337 getter: JSPropertySpec_Accessor {
338 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { angularVelocity_getterinfo.get() } },
339 },
340 setter: JSPropertySpec_Accessor {
341 native: JSNativeWrapper { op: None, info: ptr::null() },
342 }
343 }
344 }
345 }
346,
347 JSPropertySpec {
348 name: JSPropertySpec_Name { string_: c"emulatedPosition".as_ptr() },
349 attributes_: (JSPROP_ENUMERATE),
350 kind_: (JSPropertySpec_Kind::NativeAccessor),
351 u: JSPropertySpec_AccessorsOrValue {
352 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
353 getter: JSPropertySpec_Accessor {
354 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { emulatedPosition_getterinfo.get() } },
355 },
356 setter: JSPropertySpec_Accessor {
357 native: JSNativeWrapper { op: None, info: ptr::null() },
358 }
359 }
360 }
361 }
362,
363 JSPropertySpec::ZERO]))[..]
364,
365&Box::leak(Box::new([
366 JSPropertySpec {
367 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
368 attributes_: (JSPROP_READONLY),
369 kind_: (JSPropertySpec_Kind::Value),
370 u: JSPropertySpec_AccessorsOrValue {
371 value: JSPropertySpec_ValueWrapper {
372 type_: JSPropertySpec_ValueWrapper_Type::String,
373 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
374 string: c"XRPose".as_ptr(),
375 }
376 }
377 }
378 }
379,
380 JSPropertySpec::ZERO]))[..]
381])));
382}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
383
384pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
385 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::SecureContext(),Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
386 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
387}
388pub fn GetProtoObject<D: DomTypes>
389(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
390 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XRPose), CreateInterfaceObjects::<D>, rval)
392}
393
394
395static PrototypeClass: JSClass = JSClass {
396 name: c"XRPosePrototype".as_ptr(),
397 flags:
398 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
400 cOps: ptr::null(),
401 spec: ptr::null(),
402 ext: ptr::null(),
403 oOps: ptr::null(),
404};
405
406
407static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
408
409pub(crate) fn init_interface_object<D: DomTypes>() {
410 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
411 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
412 b"function XRPose() {\n [native code]\n}",
413 PrototypeList::ID::XRPose,
414 0,
415 ));
416}
417
418pub fn GetConstructorObject<D: DomTypes>
419(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
420 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::Constructor(PrototypeList::Constructor::XRPose), CreateInterfaceObjects::<D>, rval)
422}
423
424pub fn DefineDOMInterface<D: DomTypes>
425(cx: SafeJSContext, global: HandleObject){
426 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XRPose),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
427}
428
429pub fn ConstructorEnabled<D: DomTypes>
430(aCx: SafeJSContext, aObj: HandleObject) -> bool{
431 is_exposed_in(aObj, Globals::WINDOW) &&
432 pref!(dom_webxr_enabled) &&
433
434 unsafe {
435 let in_realm_proof = AlreadyInRealm::assert_for_cx(aCx);
436 D::GlobalScope::from_context(*aCx, InRealm::Already(&in_realm_proof)).is_secure_context()
437 }
438
439}
440
441unsafe fn CreateInterfaceObjects<D: DomTypes>
442(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
443
444 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
445 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
446 assert!(!prototype_proto.is_null());
447
448 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
449 create_interface_prototype_object::<D>(cx,
450 global,
451 prototype_proto.handle(),
452 &PrototypeClass,
453 &[],
454 sAttributes.get(),
455 &[],
456 &[],
457 prototype.handle_mut());
458 assert!(!prototype.is_null());
459 assert!((*cache)[PrototypeList::ID::XRPose as usize].is_null());
460 (*cache)[PrototypeList::ID::XRPose as usize] = prototype.get();
461 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::XRPose as isize),
462 ptr::null_mut(),
463 prototype.get());
464
465 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
466 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
467
468 assert!(!interface_proto.is_null());
469
470 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
471 create_noncallback_interface_object::<D>(cx,
472 global,
473 interface_proto.handle(),
474 INTERFACE_OBJECT_CLASS.get(),
475 &[],
476 &[],
477 &[],
478 prototype.handle(),
479 c"XRPose",
480 0,
481 &[],
482 interface.handle_mut());
483 assert!(!interface.is_null());
484
485 assert!((*cache)[PrototypeList::Constructor::XRPose as usize].is_null());
486 (*cache)[PrototypeList::Constructor::XRPose as usize] = interface.get();
487 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::XRPose as isize),
488 ptr::null_mut(),
489 interface.get());
490
491}
492
493
494 pub(crate) fn init_statics<D: DomTypes>() {
495 init_interface_object::<D>();
496 init_domjs_class::<D>();
497
498 init_transform_getterinfo::<D>();
499init_linearVelocity_getterinfo::<D>();
500init_angularVelocity_getterinfo::<D>();
501init_emulatedPosition_getterinfo::<D>();
502
503
504 init_sAttributes_specs::<D>();
505init_sAttributes_prefs::<D>();
506 }
507 }