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::EventHandlerBinding::EventHandlerNonNull;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::import::base::*;
8use crate::record::Record;
9
10#[derive(JSTraceable)]
11#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
12pub struct BluetoothDataFilterInit {
13 pub dataPrefix: Option<GenericUnionTypes::ArrayBufferViewOrArrayBuffer>,
14 pub mask: Option<GenericUnionTypes::ArrayBufferViewOrArrayBuffer>,
15}
16impl Default for BluetoothDataFilterInit {
17 fn default() -> Self {
18 Self {
19 dataPrefix: Default::default(),
20 mask: Default::default(), }
21 }
22}
23
24impl BluetoothDataFilterInit {
25 pub fn empty() -> RootedTraceableBox<Self> {
26 let mut dictionary = RootedTraceableBox::new(Self::default());
27 dictionary.dataPrefix = None;
28 dictionary.mask = None;
29 dictionary
30 }
31 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
32 -> Result<ConversionResult<RootedTraceableBox<BluetoothDataFilterInit>>, ()> {
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 = RootedTraceableBox::new(BluetoothDataFilterInit {
43 dataPrefix: {
44 rooted!(&in(cx) let mut rval = UndefinedValue());
45 if get_dictionary_property(cx.raw_cx(), object.handle(), "dataPrefix", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
46 Some(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 None
61 }
62 },
63 mask: {
64 rooted!(&in(cx) let mut rval = UndefinedValue());
65 if get_dictionary_property(cx.raw_cx(), object.handle(), "mask", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
66 Some(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 None
81 }
82 },
83 });
84 Ok(ConversionResult::Success(dictionary))
85 }
86 }
87}
88
89impl FromJSValConvertible for RootedTraceableBox<BluetoothDataFilterInit> {
90 type Config = ();
91 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
92 -> Result<ConversionResult<RootedTraceableBox<BluetoothDataFilterInit>>, ()> {
93 BluetoothDataFilterInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
94 }
95}
96
97impl BluetoothDataFilterInit {
98 #[allow(clippy::wrong_self_convention)]
99 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
100 if let Some(ref dataPrefix) = self.dataPrefix {
101 rooted!(in(cx) let mut dataPrefix_js = UndefinedValue());
102 dataPrefix.to_jsval(cx, dataPrefix_js.handle_mut());
103 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "dataPrefix", dataPrefix_js.handle()).unwrap();
104 }
105 if let Some(ref mask) = self.mask {
106 rooted!(in(cx) let mut mask_js = UndefinedValue());
107 mask.to_jsval(cx, mask_js.handle_mut());
108 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "mask", mask_js.handle()).unwrap();
109 }
110 }
111}
112
113impl ToJSValConvertible for BluetoothDataFilterInit {
114 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
115 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
116 self.to_jsobject(cx, obj.handle_mut());
117 rval.set(ObjectOrNullValue(obj.get()))
118 }
119}
120
121
122#[derive(JSTraceable)]
123pub struct BluetoothLEScanFilterInit {
124 pub manufacturerData: Option<Record<DOMString, RootedTraceableBox<crate::codegen::GenericBindings::BluetoothBinding::BluetoothDataFilterInit>>>,
125 pub name: Option<DOMString>,
126 pub namePrefix: Option<DOMString>,
127 pub serviceData: Option<Record<DOMString, RootedTraceableBox<crate::codegen::GenericBindings::BluetoothBinding::BluetoothDataFilterInit>>>,
128 pub services: Option<Vec<GenericUnionTypes::StringOrUnsignedLong>>,
129}
130impl Default for BluetoothLEScanFilterInit {
131 fn default() -> Self {
132 Self::empty()
133 }
134}
135
136impl BluetoothLEScanFilterInit {
137 pub fn empty() -> Self {
138 Self {
139 manufacturerData: None,
140 name: None,
141 namePrefix: None,
142 serviceData: None,
143 services: None,
144 }
145 }
146 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
147 -> Result<ConversionResult<BluetoothLEScanFilterInit>, ()> {
148 unsafe {
149 let object = if val.get().is_null_or_undefined() {
150 ptr::null_mut()
151 } else if val.get().is_object() {
152 val.get().to_object()
153 } else {
154 return Ok(ConversionResult::Failure("Value is not an object.".into()));
155 };
156 rooted!(&in(cx) let object = object);
157 let dictionary = BluetoothLEScanFilterInit {
158 manufacturerData: {
159 rooted!(&in(cx) let mut rval = UndefinedValue());
160 if get_dictionary_property(cx.raw_cx(), object.handle(), "manufacturerData", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
161 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
162 Ok(ConversionResult::Success(value)) => value,
163 Ok(ConversionResult::Failure(error)) => {
164 throw_type_error(cx.raw_cx(), &error);
165 return Err(());
166
167 }
168 _ => {
169 return Err(());
170
171 },
172 }
173 )
174 } else {
175 None
176 }
177 },
178 name: {
179 rooted!(&in(cx) let mut rval = UndefinedValue());
180 if get_dictionary_property(cx.raw_cx(), object.handle(), "name", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
181 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
182 Ok(ConversionResult::Success(value)) => value,
183 Ok(ConversionResult::Failure(error)) => {
184 throw_type_error(cx.raw_cx(), &error);
185 return Err(());
186
187 }
188 _ => {
189 return Err(());
190
191 },
192 }
193 )
194 } else {
195 None
196 }
197 },
198 namePrefix: {
199 rooted!(&in(cx) let mut rval = UndefinedValue());
200 if get_dictionary_property(cx.raw_cx(), object.handle(), "namePrefix", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
201 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), StringificationBehavior::Default) {
202 Ok(ConversionResult::Success(value)) => value,
203 Ok(ConversionResult::Failure(error)) => {
204 throw_type_error(cx.raw_cx(), &error);
205 return Err(());
206
207 }
208 _ => {
209 return Err(());
210
211 },
212 }
213 )
214 } else {
215 None
216 }
217 },
218 serviceData: {
219 rooted!(&in(cx) let mut rval = UndefinedValue());
220 if get_dictionary_property(cx.raw_cx(), object.handle(), "serviceData", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
221 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
222 Ok(ConversionResult::Success(value)) => value,
223 Ok(ConversionResult::Failure(error)) => {
224 throw_type_error(cx.raw_cx(), &error);
225 return Err(());
226
227 }
228 _ => {
229 return Err(());
230
231 },
232 }
233 )
234 } else {
235 None
236 }
237 },
238 services: {
239 rooted!(&in(cx) let mut rval = UndefinedValue());
240 if get_dictionary_property(cx.raw_cx(), object.handle(), "services", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
241 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
242 Ok(ConversionResult::Success(value)) => value,
243 Ok(ConversionResult::Failure(error)) => {
244 throw_type_error(cx.raw_cx(), &error);
245 return Err(());
246
247 }
248 _ => {
249 return Err(());
250
251 },
252 }
253 )
254 } else {
255 None
256 }
257 },
258 };
259 Ok(ConversionResult::Success(dictionary))
260 }
261 }
262}
263
264impl FromJSValConvertible for BluetoothLEScanFilterInit {
265 type Config = ();
266 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
267 -> Result<ConversionResult<BluetoothLEScanFilterInit>, ()> {
268 BluetoothLEScanFilterInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
269 }
270}
271
272impl BluetoothLEScanFilterInit {
273 #[allow(clippy::wrong_self_convention)]
274 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
275 if let Some(ref manufacturerData) = self.manufacturerData {
276 rooted!(in(cx) let mut manufacturerData_js = UndefinedValue());
277 manufacturerData.to_jsval(cx, manufacturerData_js.handle_mut());
278 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "manufacturerData", manufacturerData_js.handle()).unwrap();
279 }
280 if let Some(ref name) = self.name {
281 rooted!(in(cx) let mut name_js = UndefinedValue());
282 name.to_jsval(cx, name_js.handle_mut());
283 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "name", name_js.handle()).unwrap();
284 }
285 if let Some(ref namePrefix) = self.namePrefix {
286 rooted!(in(cx) let mut namePrefix_js = UndefinedValue());
287 namePrefix.to_jsval(cx, namePrefix_js.handle_mut());
288 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "namePrefix", namePrefix_js.handle()).unwrap();
289 }
290 if let Some(ref serviceData) = self.serviceData {
291 rooted!(in(cx) let mut serviceData_js = UndefinedValue());
292 serviceData.to_jsval(cx, serviceData_js.handle_mut());
293 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "serviceData", serviceData_js.handle()).unwrap();
294 }
295 if let Some(ref services) = self.services {
296 rooted!(in(cx) let mut services_js = UndefinedValue());
297 services.to_jsval(cx, services_js.handle_mut());
298 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "services", services_js.handle()).unwrap();
299 }
300 }
301}
302
303impl ToJSValConvertible for BluetoothLEScanFilterInit {
304 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
305 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
306 self.to_jsobject(cx, obj.handle_mut());
307 rval.set(ObjectOrNullValue(obj.get()))
308 }
309}
310
311
312#[derive(JSTraceable)]
313pub struct RequestDeviceOptions {
314 pub acceptAllDevices: bool,
315 pub filters: Option<Vec<crate::codegen::GenericBindings::BluetoothBinding::BluetoothLEScanFilterInit>>,
316 pub optionalServices: Vec<GenericUnionTypes::StringOrUnsignedLong>,
317}
318impl Default for RequestDeviceOptions {
319 fn default() -> Self {
320 Self::empty()
321 }
322}
323
324impl RequestDeviceOptions {
325 pub fn empty() -> Self {
326 Self {
327 acceptAllDevices: false,
328 filters: None,
329 optionalServices: Vec::new(),
330 }
331 }
332 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
333 -> Result<ConversionResult<RequestDeviceOptions>, ()> {
334 unsafe {
335 let object = if val.get().is_null_or_undefined() {
336 ptr::null_mut()
337 } else if val.get().is_object() {
338 val.get().to_object()
339 } else {
340 return Ok(ConversionResult::Failure("Value is not an object.".into()));
341 };
342 rooted!(&in(cx) let object = object);
343 let dictionary = RequestDeviceOptions {
344 acceptAllDevices: {
345 rooted!(&in(cx) let mut rval = UndefinedValue());
346 if get_dictionary_property(cx.raw_cx(), object.handle(), "acceptAllDevices", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
347 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
348 Ok(ConversionResult::Success(value)) => value,
349 Ok(ConversionResult::Failure(error)) => {
350 throw_type_error(cx.raw_cx(), &error);
351 return Err(());
352
353 }
354 _ => {
355 return Err(());
356
357 },
358 }
359
360 } else {
361 false
362 }
363 },
364 filters: {
365 rooted!(&in(cx) let mut rval = UndefinedValue());
366 if get_dictionary_property(cx.raw_cx(), object.handle(), "filters", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
367 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
368 Ok(ConversionResult::Success(value)) => value,
369 Ok(ConversionResult::Failure(error)) => {
370 throw_type_error(cx.raw_cx(), &error);
371 return Err(());
372
373 }
374 _ => {
375 return Err(());
376
377 },
378 }
379 )
380 } else {
381 None
382 }
383 },
384 optionalServices: {
385 rooted!(&in(cx) let mut rval = UndefinedValue());
386 if get_dictionary_property(cx.raw_cx(), object.handle(), "optionalServices", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
387 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
388 Ok(ConversionResult::Success(value)) => value,
389 Ok(ConversionResult::Failure(error)) => {
390 throw_type_error(cx.raw_cx(), &error);
391 return Err(());
392
393 }
394 _ => {
395 return Err(());
396
397 },
398 }
399
400 } else {
401 Vec::new()
402 }
403 },
404 };
405 Ok(ConversionResult::Success(dictionary))
406 }
407 }
408}
409
410impl FromJSValConvertible for RequestDeviceOptions {
411 type Config = ();
412 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
413 -> Result<ConversionResult<RequestDeviceOptions>, ()> {
414 RequestDeviceOptions::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
415 }
416}
417
418impl RequestDeviceOptions {
419 #[allow(clippy::wrong_self_convention)]
420 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
421 let acceptAllDevices = &self.acceptAllDevices;
422 rooted!(in(cx) let mut acceptAllDevices_js = UndefinedValue());
423 acceptAllDevices.to_jsval(cx, acceptAllDevices_js.handle_mut());
424 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "acceptAllDevices", acceptAllDevices_js.handle()).unwrap();
425 if let Some(ref filters) = self.filters {
426 rooted!(in(cx) let mut filters_js = UndefinedValue());
427 filters.to_jsval(cx, filters_js.handle_mut());
428 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "filters", filters_js.handle()).unwrap();
429 }
430 let optionalServices = &self.optionalServices;
431 rooted!(in(cx) let mut optionalServices_js = UndefinedValue());
432 optionalServices.to_jsval(cx, optionalServices_js.handle_mut());
433 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "optionalServices", optionalServices_js.handle()).unwrap();
434 }
435}
436
437impl ToJSValConvertible for RequestDeviceOptions {
438 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
439 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
440 self.to_jsobject(cx, obj.handle_mut());
441 rval.set(ObjectOrNullValue(obj.get()))
442 }
443}
444
445
446pub use self::Bluetooth_Binding::{Wrap, BluetoothMethods, GetProtoObject, DefineDOMInterface};
447pub mod Bluetooth_Binding {
448use crate::codegen::GenericBindings::BluetoothBinding::BluetoothLEScanFilterInit;
449use crate::codegen::GenericBindings::BluetoothBinding::RequestDeviceOptions;
450use crate::codegen::GenericBindings::EventHandlerBinding::EventHandlerNonNull;
451use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
452use crate::import::module::*;
453
454unsafe extern "C" fn getAvailability<D: DomTypes>
455(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
456 let mut result = false;
457 wrap_panic(&mut || result = (|| {
458 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
459 let this = &*(this as *const D::Bluetooth);
460 let args = &*args;
461 let argc = args.argc_;
462 let result: Rc<D::Promise> = this.GetAvailability(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
463
464 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
465 return true;
466 })());
467 result
468}
469
470unsafe extern "C" fn getAvailability_promise_wrapper<D: DomTypes>
471(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
472 let mut result = false;
473 wrap_panic(&mut || result = (|| {
474 let ok = getAvailability::<D>(cx, _obj, this, args);
475 if ok {
476 return true;
477 }
478 return exception_to_promise(cx, (*args).rval(), CanGc::note());
479
480 })());
481 result
482}
483
484
485static getAvailability_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
486
487pub(crate) fn init_getAvailability_methodinfo<D: DomTypes>() {
488 getAvailability_methodinfo.set(JSJitInfo {
489 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
490 method: Some(getAvailability_promise_wrapper::<D>)
491 },
492 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
493 protoID: PrototypeList::ID::Bluetooth as u16,
494 },
495 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
496 _bitfield_align_1: [],
497 _bitfield_1: __BindgenBitfieldUnit::new(
498 new_jsjitinfo_bitfield_1!(
499 JSJitInfo_OpType::Method as u8,
500 JSJitInfo_AliasSet::AliasEverything as u8,
501 JSValueType::JSVAL_TYPE_OBJECT as u8,
502 true,
503 false,
504 false,
505 false,
506 false,
507 false,
508 0,
509 ).to_ne_bytes()
510 ),
511});
512}
513unsafe extern "C" fn get_onavailabilitychanged<D: DomTypes>
514(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
515 let mut result = false;
516 wrap_panic(&mut || result = (|| {
517 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
518 let this = &*(this as *const D::Bluetooth);
519 let result: Option<Rc<crate::codegen::GenericBindings::EventHandlerBinding::EventHandlerNonNull<D>>> = this.GetOnavailabilitychanged();
520
521 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
522 return true;
523 })());
524 result
525}
526
527unsafe extern "C" fn set_onavailabilitychanged<D: DomTypes>
528(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
529 let mut result = false;
530 wrap_panic(&mut || result = {
531 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
532 let this = &*(this as *const D::Bluetooth);
533 let arg0: Option<Rc<EventHandlerNonNull<D>>> = if HandleValue::from_raw(args.get(0)).get().is_object() {
534 Some(EventHandlerNonNull::<D>::new(SafeJSContext::from_ptr(cx.raw_cx()), HandleValue::from_raw(args.get(0)).get().to_object()))
535 } else {
536 None
537 };
538 let result: () = this.SetOnavailabilitychanged(arg0);
539
540 true
541 });
542 result
543}
544
545
546static onavailabilitychanged_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
547
548pub(crate) fn init_onavailabilitychanged_getterinfo<D: DomTypes>() {
549 onavailabilitychanged_getterinfo.set(JSJitInfo {
550 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
551 getter: Some(get_onavailabilitychanged::<D>)
552 },
553 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
554 protoID: PrototypeList::ID::Bluetooth as u16,
555 },
556 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
557 _bitfield_align_1: [],
558 _bitfield_1: __BindgenBitfieldUnit::new(
559 new_jsjitinfo_bitfield_1!(
560 JSJitInfo_OpType::Getter as u8,
561 JSJitInfo_AliasSet::AliasEverything as u8,
562 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
563 true,
564 false,
565 false,
566 false,
567 false,
568 false,
569 0,
570 ).to_ne_bytes()
571 ),
572});
573}
574static onavailabilitychanged_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
575
576pub(crate) fn init_onavailabilitychanged_setterinfo<D: DomTypes>() {
577 onavailabilitychanged_setterinfo.set(JSJitInfo {
578 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
579 setter: Some(set_onavailabilitychanged::<D>)
580 },
581 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
582 protoID: PrototypeList::ID::Bluetooth as u16,
583 },
584 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
585 _bitfield_align_1: [],
586 _bitfield_1: __BindgenBitfieldUnit::new(
587 new_jsjitinfo_bitfield_1!(
588 JSJitInfo_OpType::Setter as u8,
589 JSJitInfo_AliasSet::AliasEverything as u8,
590 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
591 false,
592 false,
593 false,
594 false,
595 false,
596 false,
597 0,
598 ).to_ne_bytes()
599 ),
600});
601}
602unsafe extern "C" fn requestDevice<D: DomTypes>
603(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
604 let mut result = false;
605 wrap_panic(&mut || result = (|| {
606 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
607 let this = &*(this as *const D::Bluetooth);
608 let args = &*args;
609 let argc = args.argc_;
610 let arg0: crate::codegen::GenericBindings::BluetoothBinding::RequestDeviceOptions = if args.get(0).is_undefined() {
611 crate::codegen::GenericBindings::BluetoothBinding::RequestDeviceOptions::empty()
612 } else {
613 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
614 Ok(ConversionResult::Success(value)) => value,
615 Ok(ConversionResult::Failure(error)) => {
616 throw_type_error(cx.raw_cx(), &error);
617 return false;
618
619 }
620 _ => {
621 return false;
622
623 },
624 }
625
626 };
627 let result: Rc<D::Promise> = this.RequestDevice(&arg0, InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
628
629 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
630 return true;
631 })());
632 result
633}
634
635unsafe extern "C" fn requestDevice_promise_wrapper<D: DomTypes>
636(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
637 let mut result = false;
638 wrap_panic(&mut || result = (|| {
639 let ok = requestDevice::<D>(cx, _obj, this, args);
640 if ok {
641 return true;
642 }
643 return exception_to_promise(cx, (*args).rval(), CanGc::note());
644
645 })());
646 result
647}
648
649
650static requestDevice_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
651
652pub(crate) fn init_requestDevice_methodinfo<D: DomTypes>() {
653 requestDevice_methodinfo.set(JSJitInfo {
654 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
655 method: Some(requestDevice_promise_wrapper::<D>)
656 },
657 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
658 protoID: PrototypeList::ID::Bluetooth as u16,
659 },
660 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
661 _bitfield_align_1: [],
662 _bitfield_1: __BindgenBitfieldUnit::new(
663 new_jsjitinfo_bitfield_1!(
664 JSJitInfo_OpType::Method as u8,
665 JSJitInfo_AliasSet::AliasEverything as u8,
666 JSValueType::JSVAL_TYPE_OBJECT as u8,
667 false,
668 false,
669 false,
670 false,
671 false,
672 false,
673 0,
674 ).to_ne_bytes()
675 ),
676});
677}
678unsafe extern "C" fn _finalize<D: DomTypes>
679(_cx: *mut GCContext, obj: *mut JSObject){
680 wrap_panic(&mut || {
681
682 let this = native_from_object_static::<D::Bluetooth>(obj).unwrap();
683 finalize_common(this);
684 })
685}
686
687unsafe extern "C" fn _trace<D: DomTypes>
688(trc: *mut JSTracer, obj: *mut JSObject){
689 wrap_panic(&mut || {
690
691 let this = native_from_object_static::<D::Bluetooth>(obj).unwrap();
692 if this.is_null() { return; } (*this).trace(trc);
694 })
695}
696
697
698static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
699
700pub(crate) fn init_class_ops<D: DomTypes>() {
701 CLASS_OPS.set(JSClassOps {
702 addProperty: None,
703 delProperty: None,
704 enumerate: None,
705 newEnumerate: None,
706 resolve: None,
707 mayResolve: None,
708 finalize: Some(_finalize::<D>),
709 call: None,
710 construct: None,
711 trace: Some(_trace::<D>),
712 });
713}
714
715pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
716
717pub(crate) fn init_domjs_class<D: DomTypes>() {
718 init_class_ops::<D>();
719 Class.set(DOMJSClass {
720 base: JSClass {
721 name: c"Bluetooth".as_ptr(),
722 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
723 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
724 ,
725 cOps: unsafe { CLASS_OPS.get() },
726 spec: ptr::null(),
727 ext: ptr::null(),
728 oOps: ptr::null(),
729 },
730 dom_class:
731DOMClass {
732 interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::Bluetooth, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
733 depth: 1,
734 type_id: crate::codegen::InheritTypes::TopTypeId { eventtarget: (crate::codegen::InheritTypes::EventTargetTypeId::Bluetooth) },
735 malloc_size_of: malloc_size_of_including_raw_self::<D::Bluetooth> as unsafe fn(&mut _, _) -> _,
736 global: Globals::EMPTY,
737},
738 });
739}
740
741#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
742(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::Bluetooth>, _can_gc: CanGc) -> DomRoot<D::Bluetooth>{
743
744 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
745
746 let scope = scope.reflector().get_jsobject();
747 assert!(!scope.get().is_null());
748 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
749 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
750
751 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
752 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
753 assert!(!canonical_proto.is_null());
754
755
756 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
757 if let Some(given) = given_proto {
758 proto.set(*given);
759 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
760 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
761 }
762 } else {
763 proto.set(*canonical_proto);
764 }
765 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
766 cx.raw_cx(),
767 &Class.get().base,
768 proto.handle(),
769 ));
770 assert!(!obj.is_null());
771 JS_SetReservedSlot(
772 obj.get(),
773 DOM_OBJECT_SLOT,
774 &PrivateValue(raw.as_ptr() as *const libc::c_void),
775 );
776
777 let root = raw.reflect_with(obj.get());
778
779
780
781 DomRoot::from_ref(&*root)
782}
783
784pub trait BluetoothMethods<D: DomTypes> {
785 fn GetAvailability(&self, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
786 fn GetOnavailabilitychanged(&self, ) -> Option<Rc<crate::codegen::GenericBindings::EventHandlerBinding::EventHandlerNonNull<D>>>;
787 fn SetOnavailabilitychanged(&self, r#value: Option<Rc<EventHandlerNonNull<D>>>);
788 fn RequestDevice(&self, r#options: &crate::codegen::GenericBindings::BluetoothBinding::RequestDeviceOptions, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
789}
790static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
791
792pub(crate) fn init_sMethods_specs<D: DomTypes>() {
793 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
794 JSFunctionSpec {
795 name: JSPropertySpec_Name { string_: c"getAvailability".as_ptr() },
796 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { getAvailability_methodinfo.get() } as *const _ as *const JSJitInfo },
797 nargs: 0,
798 flags: (JSPROP_ENUMERATE) as u16,
799 selfHostedName: ptr::null()
800 },
801 JSFunctionSpec {
802 name: JSPropertySpec_Name { string_: c"requestDevice".as_ptr() },
803 call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { requestDevice_methodinfo.get() } as *const _ as *const JSJitInfo },
804 nargs: 0,
805 flags: (JSPROP_ENUMERATE) as u16,
806 selfHostedName: ptr::null()
807 },
808 JSFunctionSpec {
809 name: JSPropertySpec_Name { string_: ptr::null() },
810 call: JSNativeWrapper { op: None, info: ptr::null() },
811 nargs: 0,
812 flags: 0,
813 selfHostedName: ptr::null()
814 }]))[..]
815])));
816}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
817
818pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
819 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::SecureContext(),Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
820}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
821
822pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
823 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
824 JSPropertySpec {
825 name: JSPropertySpec_Name { string_: c"onavailabilitychanged".as_ptr() },
826 attributes_: (JSPROP_ENUMERATE),
827 kind_: (JSPropertySpec_Kind::NativeAccessor),
828 u: JSPropertySpec_AccessorsOrValue {
829 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
830 getter: JSPropertySpec_Accessor {
831 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { onavailabilitychanged_getterinfo.get() } },
832 },
833 setter: JSPropertySpec_Accessor {
834 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { onavailabilitychanged_setterinfo.get() } },
835 }
836 }
837 }
838 }
839,
840 JSPropertySpec::ZERO]))[..]
841,
842&Box::leak(Box::new([
843 JSPropertySpec {
844 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
845 attributes_: (JSPROP_READONLY),
846 kind_: (JSPropertySpec_Kind::Value),
847 u: JSPropertySpec_AccessorsOrValue {
848 value: JSPropertySpec_ValueWrapper {
849 type_: JSPropertySpec_ValueWrapper_Type::String,
850 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
851 string: c"Bluetooth".as_ptr(),
852 }
853 }
854 }
855 }
856,
857 JSPropertySpec::ZERO]))[..]
858])));
859}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
860
861pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
862 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::SecureContext(),Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
863 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
864}
865pub fn GetProtoObject<D: DomTypes>
866(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
867 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::Bluetooth), CreateInterfaceObjects::<D>, rval)
869}
870
871
872static PrototypeClass: JSClass = JSClass {
873 name: c"BluetoothPrototype".as_ptr(),
874 flags:
875 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
877 cOps: ptr::null(),
878 spec: ptr::null(),
879 ext: ptr::null(),
880 oOps: ptr::null(),
881};
882
883
884static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
885
886pub(crate) fn init_interface_object<D: DomTypes>() {
887 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
888 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
889 b"function Bluetooth() {\n [native code]\n}",
890 PrototypeList::ID::Bluetooth,
891 1,
892 ));
893}
894
895pub fn DefineDOMInterface<D: DomTypes>
896(cx: SafeJSContext, global: HandleObject){
897 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::Bluetooth),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
898}
899
900pub fn ConstructorEnabled<D: DomTypes>
901(aCx: SafeJSContext, aObj: HandleObject) -> bool{
902 is_exposed_in(aObj, Globals::WINDOW) &&
903 pref!(dom_bluetooth_enabled)
904}
905
906unsafe fn CreateInterfaceObjects<D: DomTypes>
907(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
908
909 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
910 EventTarget_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
911 assert!(!prototype_proto.is_null());
912
913 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
914 create_interface_prototype_object::<D>(cx,
915 global,
916 prototype_proto.handle(),
917 &PrototypeClass,
918 sMethods.get(),
919 sAttributes.get(),
920 &[],
921 &[],
922 prototype.handle_mut());
923 assert!(!prototype.is_null());
924 assert!((*cache)[PrototypeList::ID::Bluetooth as usize].is_null());
925 (*cache)[PrototypeList::ID::Bluetooth as usize] = prototype.get();
926 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::Bluetooth as isize),
927 ptr::null_mut(),
928 prototype.get());
929
930 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
931
932 EventTarget_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
933
934 assert!(!interface_proto.is_null());
935
936 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
937 create_noncallback_interface_object::<D>(cx,
938 global,
939 interface_proto.handle(),
940 INTERFACE_OBJECT_CLASS.get(),
941 &[],
942 &[],
943 &[],
944 prototype.handle(),
945 c"Bluetooth",
946 0,
947 &[],
948 interface.handle_mut());
949 assert!(!interface.is_null());
950}
951
952
953 pub(crate) fn init_statics<D: DomTypes>() {
954 init_interface_object::<D>();
955 init_domjs_class::<D>();
956 crate::codegen::GenericBindings::BluetoothBinding::Bluetooth_Binding::init_getAvailability_methodinfo::<D>();
957crate::codegen::GenericBindings::BluetoothBinding::Bluetooth_Binding::init_requestDevice_methodinfo::<D>();
958 init_onavailabilitychanged_getterinfo::<D>();
959 init_onavailabilitychanged_setterinfo::<D>();
960
961 init_sMethods_specs::<D>();
962init_sMethods_prefs::<D>();
963init_sAttributes_specs::<D>();
964init_sAttributes_prefs::<D>();
965 }
966 }