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