github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/bluetooth/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/bluetooth", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_AdapterState": (ptr: Pointer, ref: heap.Ref<any>) => { 8 const x = A.H.get<any>(ref); 9 10 if (typeof x === "undefined") { 11 A.store.Bool(ptr + 14, false); 12 A.store.Ref(ptr + 0, undefined); 13 A.store.Ref(ptr + 4, undefined); 14 A.store.Bool(ptr + 11, false); 15 A.store.Bool(ptr + 8, false); 16 A.store.Bool(ptr + 12, false); 17 A.store.Bool(ptr + 9, false); 18 A.store.Bool(ptr + 13, false); 19 A.store.Bool(ptr + 10, false); 20 } else { 21 A.store.Bool(ptr + 14, true); 22 A.store.Ref(ptr + 0, x["address"]); 23 A.store.Ref(ptr + 4, x["name"]); 24 A.store.Bool(ptr + 11, "powered" in x ? true : false); 25 A.store.Bool(ptr + 8, x["powered"] ? true : false); 26 A.store.Bool(ptr + 12, "available" in x ? true : false); 27 A.store.Bool(ptr + 9, x["available"] ? true : false); 28 A.store.Bool(ptr + 13, "discovering" in x ? true : false); 29 A.store.Bool(ptr + 10, x["discovering"] ? true : false); 30 } 31 }, 32 "load_AdapterState": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 33 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 34 35 x["address"] = A.load.Ref(ptr + 0, undefined); 36 x["name"] = A.load.Ref(ptr + 4, undefined); 37 if (A.load.Bool(ptr + 11)) { 38 x["powered"] = A.load.Bool(ptr + 8); 39 } else { 40 delete x["powered"]; 41 } 42 if (A.load.Bool(ptr + 12)) { 43 x["available"] = A.load.Bool(ptr + 9); 44 } else { 45 delete x["available"]; 46 } 47 if (A.load.Bool(ptr + 13)) { 48 x["discovering"] = A.load.Bool(ptr + 10); 49 } else { 50 delete x["discovering"]; 51 } 52 return create === A.H.TRUE ? A.H.push(x) : ref; 53 }, 54 "constof_FilterType": (ref: heap.Ref<string>): number => { 55 const idx = ["all", "known"].indexOf(A.H.get(ref)); 56 return idx < 0 ? 0 : idx + 1; 57 }, 58 59 "store_BluetoothFilter": (ptr: Pointer, ref: heap.Ref<any>) => { 60 const x = A.H.get<any>(ref); 61 62 if (typeof x === "undefined") { 63 A.store.Bool(ptr + 9, false); 64 A.store.Enum(ptr + 0, -1); 65 A.store.Bool(ptr + 8, false); 66 A.store.Int32(ptr + 4, 0); 67 } else { 68 A.store.Bool(ptr + 9, true); 69 A.store.Enum(ptr + 0, ["all", "known"].indexOf(x["filterType"] as string)); 70 A.store.Bool(ptr + 8, "limit" in x ? true : false); 71 A.store.Int32(ptr + 4, x["limit"] === undefined ? 0 : (x["limit"] as number)); 72 } 73 }, 74 "load_BluetoothFilter": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 75 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 76 77 x["filterType"] = A.load.Enum(ptr + 0, ["all", "known"]); 78 if (A.load.Bool(ptr + 8)) { 79 x["limit"] = A.load.Int32(ptr + 4); 80 } else { 81 delete x["limit"]; 82 } 83 return create === A.H.TRUE ? A.H.push(x) : ref; 84 }, 85 "constof_VendorIdSource": (ref: heap.Ref<string>): number => { 86 const idx = ["bluetooth", "usb"].indexOf(A.H.get(ref)); 87 return idx < 0 ? 0 : idx + 1; 88 }, 89 "constof_DeviceType": (ref: heap.Ref<string>): number => { 90 const idx = [ 91 "computer", 92 "phone", 93 "modem", 94 "audio", 95 "carAudio", 96 "video", 97 "peripheral", 98 "joystick", 99 "gamepad", 100 "keyboard", 101 "mouse", 102 "tablet", 103 "keyboardMouseCombo", 104 ].indexOf(A.H.get(ref)); 105 return idx < 0 ? 0 : idx + 1; 106 }, 107 "constof_Transport": (ref: heap.Ref<string>): number => { 108 const idx = ["invalid", "classic", "le", "dual"].indexOf(A.H.get(ref)); 109 return idx < 0 ? 0 : idx + 1; 110 }, 111 112 "store_Device": (ptr: Pointer, ref: heap.Ref<any>) => { 113 const x = A.H.get<any>(ref); 114 115 if (typeof x === "undefined") { 116 A.store.Bool(ptr + 67, false); 117 A.store.Ref(ptr + 0, undefined); 118 A.store.Ref(ptr + 4, undefined); 119 A.store.Bool(ptr + 56, false); 120 A.store.Int32(ptr + 8, 0); 121 A.store.Enum(ptr + 12, -1); 122 A.store.Bool(ptr + 57, false); 123 A.store.Int32(ptr + 16, 0); 124 A.store.Bool(ptr + 58, false); 125 A.store.Int32(ptr + 20, 0); 126 A.store.Bool(ptr + 59, false); 127 A.store.Int32(ptr + 24, 0); 128 A.store.Enum(ptr + 28, -1); 129 A.store.Bool(ptr + 60, false); 130 A.store.Bool(ptr + 32, false); 131 A.store.Bool(ptr + 61, false); 132 A.store.Bool(ptr + 33, false); 133 A.store.Bool(ptr + 62, false); 134 A.store.Bool(ptr + 34, false); 135 A.store.Bool(ptr + 63, false); 136 A.store.Bool(ptr + 35, false); 137 A.store.Ref(ptr + 36, undefined); 138 A.store.Bool(ptr + 64, false); 139 A.store.Int32(ptr + 40, 0); 140 A.store.Bool(ptr + 65, false); 141 A.store.Int32(ptr + 44, 0); 142 A.store.Enum(ptr + 48, -1); 143 A.store.Bool(ptr + 66, false); 144 A.store.Int32(ptr + 52, 0); 145 } else { 146 A.store.Bool(ptr + 67, true); 147 A.store.Ref(ptr + 0, x["address"]); 148 A.store.Ref(ptr + 4, x["name"]); 149 A.store.Bool(ptr + 56, "deviceClass" in x ? true : false); 150 A.store.Int32(ptr + 8, x["deviceClass"] === undefined ? 0 : (x["deviceClass"] as number)); 151 A.store.Enum(ptr + 12, ["bluetooth", "usb"].indexOf(x["vendorIdSource"] as string)); 152 A.store.Bool(ptr + 57, "vendorId" in x ? true : false); 153 A.store.Int32(ptr + 16, x["vendorId"] === undefined ? 0 : (x["vendorId"] as number)); 154 A.store.Bool(ptr + 58, "productId" in x ? true : false); 155 A.store.Int32(ptr + 20, x["productId"] === undefined ? 0 : (x["productId"] as number)); 156 A.store.Bool(ptr + 59, "deviceId" in x ? true : false); 157 A.store.Int32(ptr + 24, x["deviceId"] === undefined ? 0 : (x["deviceId"] as number)); 158 A.store.Enum( 159 ptr + 28, 160 [ 161 "computer", 162 "phone", 163 "modem", 164 "audio", 165 "carAudio", 166 "video", 167 "peripheral", 168 "joystick", 169 "gamepad", 170 "keyboard", 171 "mouse", 172 "tablet", 173 "keyboardMouseCombo", 174 ].indexOf(x["type"] as string) 175 ); 176 A.store.Bool(ptr + 60, "paired" in x ? true : false); 177 A.store.Bool(ptr + 32, x["paired"] ? true : false); 178 A.store.Bool(ptr + 61, "connected" in x ? true : false); 179 A.store.Bool(ptr + 33, x["connected"] ? true : false); 180 A.store.Bool(ptr + 62, "connecting" in x ? true : false); 181 A.store.Bool(ptr + 34, x["connecting"] ? true : false); 182 A.store.Bool(ptr + 63, "connectable" in x ? true : false); 183 A.store.Bool(ptr + 35, x["connectable"] ? true : false); 184 A.store.Ref(ptr + 36, x["uuids"]); 185 A.store.Bool(ptr + 64, "inquiryRssi" in x ? true : false); 186 A.store.Int32(ptr + 40, x["inquiryRssi"] === undefined ? 0 : (x["inquiryRssi"] as number)); 187 A.store.Bool(ptr + 65, "inquiryTxPower" in x ? true : false); 188 A.store.Int32(ptr + 44, x["inquiryTxPower"] === undefined ? 0 : (x["inquiryTxPower"] as number)); 189 A.store.Enum(ptr + 48, ["invalid", "classic", "le", "dual"].indexOf(x["transport"] as string)); 190 A.store.Bool(ptr + 66, "batteryPercentage" in x ? true : false); 191 A.store.Int32(ptr + 52, x["batteryPercentage"] === undefined ? 0 : (x["batteryPercentage"] as number)); 192 } 193 }, 194 "load_Device": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 195 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 196 197 x["address"] = A.load.Ref(ptr + 0, undefined); 198 x["name"] = A.load.Ref(ptr + 4, undefined); 199 if (A.load.Bool(ptr + 56)) { 200 x["deviceClass"] = A.load.Int32(ptr + 8); 201 } else { 202 delete x["deviceClass"]; 203 } 204 x["vendorIdSource"] = A.load.Enum(ptr + 12, ["bluetooth", "usb"]); 205 if (A.load.Bool(ptr + 57)) { 206 x["vendorId"] = A.load.Int32(ptr + 16); 207 } else { 208 delete x["vendorId"]; 209 } 210 if (A.load.Bool(ptr + 58)) { 211 x["productId"] = A.load.Int32(ptr + 20); 212 } else { 213 delete x["productId"]; 214 } 215 if (A.load.Bool(ptr + 59)) { 216 x["deviceId"] = A.load.Int32(ptr + 24); 217 } else { 218 delete x["deviceId"]; 219 } 220 x["type"] = A.load.Enum(ptr + 28, [ 221 "computer", 222 "phone", 223 "modem", 224 "audio", 225 "carAudio", 226 "video", 227 "peripheral", 228 "joystick", 229 "gamepad", 230 "keyboard", 231 "mouse", 232 "tablet", 233 "keyboardMouseCombo", 234 ]); 235 if (A.load.Bool(ptr + 60)) { 236 x["paired"] = A.load.Bool(ptr + 32); 237 } else { 238 delete x["paired"]; 239 } 240 if (A.load.Bool(ptr + 61)) { 241 x["connected"] = A.load.Bool(ptr + 33); 242 } else { 243 delete x["connected"]; 244 } 245 if (A.load.Bool(ptr + 62)) { 246 x["connecting"] = A.load.Bool(ptr + 34); 247 } else { 248 delete x["connecting"]; 249 } 250 if (A.load.Bool(ptr + 63)) { 251 x["connectable"] = A.load.Bool(ptr + 35); 252 } else { 253 delete x["connectable"]; 254 } 255 x["uuids"] = A.load.Ref(ptr + 36, undefined); 256 if (A.load.Bool(ptr + 64)) { 257 x["inquiryRssi"] = A.load.Int32(ptr + 40); 258 } else { 259 delete x["inquiryRssi"]; 260 } 261 if (A.load.Bool(ptr + 65)) { 262 x["inquiryTxPower"] = A.load.Int32(ptr + 44); 263 } else { 264 delete x["inquiryTxPower"]; 265 } 266 x["transport"] = A.load.Enum(ptr + 48, ["invalid", "classic", "le", "dual"]); 267 if (A.load.Bool(ptr + 66)) { 268 x["batteryPercentage"] = A.load.Int32(ptr + 52); 269 } else { 270 delete x["batteryPercentage"]; 271 } 272 return create === A.H.TRUE ? A.H.push(x) : ref; 273 }, 274 "has_GetAdapterState": (): heap.Ref<boolean> => { 275 if (WEBEXT?.bluetooth && "getAdapterState" in WEBEXT?.bluetooth) { 276 return A.H.TRUE; 277 } 278 return A.H.FALSE; 279 }, 280 "func_GetAdapterState": (fn: Pointer): void => { 281 A.store.Ref(fn, WEBEXT.bluetooth.getAdapterState); 282 }, 283 "call_GetAdapterState": (retPtr: Pointer): void => { 284 const _ret = WEBEXT.bluetooth.getAdapterState(); 285 A.store.Ref(retPtr, _ret); 286 }, 287 "try_GetAdapterState": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 288 try { 289 const _ret = WEBEXT.bluetooth.getAdapterState(); 290 A.store.Ref(retPtr, _ret); 291 return A.H.TRUE; 292 } catch (err: any) { 293 A.store.Ref(errPtr, err); 294 return A.H.FALSE; 295 } 296 }, 297 "has_GetDevice": (): heap.Ref<boolean> => { 298 if (WEBEXT?.bluetooth && "getDevice" in WEBEXT?.bluetooth) { 299 return A.H.TRUE; 300 } 301 return A.H.FALSE; 302 }, 303 "func_GetDevice": (fn: Pointer): void => { 304 A.store.Ref(fn, WEBEXT.bluetooth.getDevice); 305 }, 306 "call_GetDevice": (retPtr: Pointer, deviceAddress: heap.Ref<object>): void => { 307 const _ret = WEBEXT.bluetooth.getDevice(A.H.get<object>(deviceAddress)); 308 A.store.Ref(retPtr, _ret); 309 }, 310 "try_GetDevice": (retPtr: Pointer, errPtr: Pointer, deviceAddress: heap.Ref<object>): heap.Ref<boolean> => { 311 try { 312 const _ret = WEBEXT.bluetooth.getDevice(A.H.get<object>(deviceAddress)); 313 A.store.Ref(retPtr, _ret); 314 return A.H.TRUE; 315 } catch (err: any) { 316 A.store.Ref(errPtr, err); 317 return A.H.FALSE; 318 } 319 }, 320 "has_GetDevices": (): heap.Ref<boolean> => { 321 if (WEBEXT?.bluetooth && "getDevices" in WEBEXT?.bluetooth) { 322 return A.H.TRUE; 323 } 324 return A.H.FALSE; 325 }, 326 "func_GetDevices": (fn: Pointer): void => { 327 A.store.Ref(fn, WEBEXT.bluetooth.getDevices); 328 }, 329 "call_GetDevices": (retPtr: Pointer, filter: Pointer): void => { 330 const filter_ffi = {}; 331 332 filter_ffi["filterType"] = A.load.Enum(filter + 0, ["all", "known"]); 333 if (A.load.Bool(filter + 8)) { 334 filter_ffi["limit"] = A.load.Int32(filter + 4); 335 } 336 337 const _ret = WEBEXT.bluetooth.getDevices(filter_ffi); 338 A.store.Ref(retPtr, _ret); 339 }, 340 "try_GetDevices": (retPtr: Pointer, errPtr: Pointer, filter: Pointer): heap.Ref<boolean> => { 341 try { 342 const filter_ffi = {}; 343 344 filter_ffi["filterType"] = A.load.Enum(filter + 0, ["all", "known"]); 345 if (A.load.Bool(filter + 8)) { 346 filter_ffi["limit"] = A.load.Int32(filter + 4); 347 } 348 349 const _ret = WEBEXT.bluetooth.getDevices(filter_ffi); 350 A.store.Ref(retPtr, _ret); 351 return A.H.TRUE; 352 } catch (err: any) { 353 A.store.Ref(errPtr, err); 354 return A.H.FALSE; 355 } 356 }, 357 "has_OnAdapterStateChanged": (): heap.Ref<boolean> => { 358 if (WEBEXT?.bluetooth?.onAdapterStateChanged && "addListener" in WEBEXT?.bluetooth?.onAdapterStateChanged) { 359 return A.H.TRUE; 360 } 361 return A.H.FALSE; 362 }, 363 "func_OnAdapterStateChanged": (fn: Pointer): void => { 364 A.store.Ref(fn, WEBEXT.bluetooth.onAdapterStateChanged.addListener); 365 }, 366 "call_OnAdapterStateChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 367 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.addListener(A.H.get<object>(callback)); 368 }, 369 "try_OnAdapterStateChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 370 try { 371 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.addListener(A.H.get<object>(callback)); 372 return A.H.TRUE; 373 } catch (err: any) { 374 A.store.Ref(errPtr, err); 375 return A.H.FALSE; 376 } 377 }, 378 "has_OffAdapterStateChanged": (): heap.Ref<boolean> => { 379 if (WEBEXT?.bluetooth?.onAdapterStateChanged && "removeListener" in WEBEXT?.bluetooth?.onAdapterStateChanged) { 380 return A.H.TRUE; 381 } 382 return A.H.FALSE; 383 }, 384 "func_OffAdapterStateChanged": (fn: Pointer): void => { 385 A.store.Ref(fn, WEBEXT.bluetooth.onAdapterStateChanged.removeListener); 386 }, 387 "call_OffAdapterStateChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 388 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.removeListener(A.H.get<object>(callback)); 389 }, 390 "try_OffAdapterStateChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 391 try { 392 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.removeListener(A.H.get<object>(callback)); 393 return A.H.TRUE; 394 } catch (err: any) { 395 A.store.Ref(errPtr, err); 396 return A.H.FALSE; 397 } 398 }, 399 "has_HasOnAdapterStateChanged": (): heap.Ref<boolean> => { 400 if (WEBEXT?.bluetooth?.onAdapterStateChanged && "hasListener" in WEBEXT?.bluetooth?.onAdapterStateChanged) { 401 return A.H.TRUE; 402 } 403 return A.H.FALSE; 404 }, 405 "func_HasOnAdapterStateChanged": (fn: Pointer): void => { 406 A.store.Ref(fn, WEBEXT.bluetooth.onAdapterStateChanged.hasListener); 407 }, 408 "call_HasOnAdapterStateChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 409 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.hasListener(A.H.get<object>(callback)); 410 A.store.Bool(retPtr, _ret); 411 }, 412 "try_HasOnAdapterStateChanged": ( 413 retPtr: Pointer, 414 errPtr: Pointer, 415 callback: heap.Ref<object> 416 ): heap.Ref<boolean> => { 417 try { 418 const _ret = WEBEXT.bluetooth.onAdapterStateChanged.hasListener(A.H.get<object>(callback)); 419 A.store.Bool(retPtr, _ret); 420 return A.H.TRUE; 421 } catch (err: any) { 422 A.store.Ref(errPtr, err); 423 return A.H.FALSE; 424 } 425 }, 426 "has_OnDeviceAdded": (): heap.Ref<boolean> => { 427 if (WEBEXT?.bluetooth?.onDeviceAdded && "addListener" in WEBEXT?.bluetooth?.onDeviceAdded) { 428 return A.H.TRUE; 429 } 430 return A.H.FALSE; 431 }, 432 "func_OnDeviceAdded": (fn: Pointer): void => { 433 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceAdded.addListener); 434 }, 435 "call_OnDeviceAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 436 const _ret = WEBEXT.bluetooth.onDeviceAdded.addListener(A.H.get<object>(callback)); 437 }, 438 "try_OnDeviceAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 439 try { 440 const _ret = WEBEXT.bluetooth.onDeviceAdded.addListener(A.H.get<object>(callback)); 441 return A.H.TRUE; 442 } catch (err: any) { 443 A.store.Ref(errPtr, err); 444 return A.H.FALSE; 445 } 446 }, 447 "has_OffDeviceAdded": (): heap.Ref<boolean> => { 448 if (WEBEXT?.bluetooth?.onDeviceAdded && "removeListener" in WEBEXT?.bluetooth?.onDeviceAdded) { 449 return A.H.TRUE; 450 } 451 return A.H.FALSE; 452 }, 453 "func_OffDeviceAdded": (fn: Pointer): void => { 454 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceAdded.removeListener); 455 }, 456 "call_OffDeviceAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 457 const _ret = WEBEXT.bluetooth.onDeviceAdded.removeListener(A.H.get<object>(callback)); 458 }, 459 "try_OffDeviceAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 460 try { 461 const _ret = WEBEXT.bluetooth.onDeviceAdded.removeListener(A.H.get<object>(callback)); 462 return A.H.TRUE; 463 } catch (err: any) { 464 A.store.Ref(errPtr, err); 465 return A.H.FALSE; 466 } 467 }, 468 "has_HasOnDeviceAdded": (): heap.Ref<boolean> => { 469 if (WEBEXT?.bluetooth?.onDeviceAdded && "hasListener" in WEBEXT?.bluetooth?.onDeviceAdded) { 470 return A.H.TRUE; 471 } 472 return A.H.FALSE; 473 }, 474 "func_HasOnDeviceAdded": (fn: Pointer): void => { 475 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceAdded.hasListener); 476 }, 477 "call_HasOnDeviceAdded": (retPtr: Pointer, callback: heap.Ref<object>): void => { 478 const _ret = WEBEXT.bluetooth.onDeviceAdded.hasListener(A.H.get<object>(callback)); 479 A.store.Bool(retPtr, _ret); 480 }, 481 "try_HasOnDeviceAdded": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 482 try { 483 const _ret = WEBEXT.bluetooth.onDeviceAdded.hasListener(A.H.get<object>(callback)); 484 A.store.Bool(retPtr, _ret); 485 return A.H.TRUE; 486 } catch (err: any) { 487 A.store.Ref(errPtr, err); 488 return A.H.FALSE; 489 } 490 }, 491 "has_OnDeviceChanged": (): heap.Ref<boolean> => { 492 if (WEBEXT?.bluetooth?.onDeviceChanged && "addListener" in WEBEXT?.bluetooth?.onDeviceChanged) { 493 return A.H.TRUE; 494 } 495 return A.H.FALSE; 496 }, 497 "func_OnDeviceChanged": (fn: Pointer): void => { 498 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceChanged.addListener); 499 }, 500 "call_OnDeviceChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 501 const _ret = WEBEXT.bluetooth.onDeviceChanged.addListener(A.H.get<object>(callback)); 502 }, 503 "try_OnDeviceChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 504 try { 505 const _ret = WEBEXT.bluetooth.onDeviceChanged.addListener(A.H.get<object>(callback)); 506 return A.H.TRUE; 507 } catch (err: any) { 508 A.store.Ref(errPtr, err); 509 return A.H.FALSE; 510 } 511 }, 512 "has_OffDeviceChanged": (): heap.Ref<boolean> => { 513 if (WEBEXT?.bluetooth?.onDeviceChanged && "removeListener" in WEBEXT?.bluetooth?.onDeviceChanged) { 514 return A.H.TRUE; 515 } 516 return A.H.FALSE; 517 }, 518 "func_OffDeviceChanged": (fn: Pointer): void => { 519 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceChanged.removeListener); 520 }, 521 "call_OffDeviceChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 522 const _ret = WEBEXT.bluetooth.onDeviceChanged.removeListener(A.H.get<object>(callback)); 523 }, 524 "try_OffDeviceChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 525 try { 526 const _ret = WEBEXT.bluetooth.onDeviceChanged.removeListener(A.H.get<object>(callback)); 527 return A.H.TRUE; 528 } catch (err: any) { 529 A.store.Ref(errPtr, err); 530 return A.H.FALSE; 531 } 532 }, 533 "has_HasOnDeviceChanged": (): heap.Ref<boolean> => { 534 if (WEBEXT?.bluetooth?.onDeviceChanged && "hasListener" in WEBEXT?.bluetooth?.onDeviceChanged) { 535 return A.H.TRUE; 536 } 537 return A.H.FALSE; 538 }, 539 "func_HasOnDeviceChanged": (fn: Pointer): void => { 540 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceChanged.hasListener); 541 }, 542 "call_HasOnDeviceChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => { 543 const _ret = WEBEXT.bluetooth.onDeviceChanged.hasListener(A.H.get<object>(callback)); 544 A.store.Bool(retPtr, _ret); 545 }, 546 "try_HasOnDeviceChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 547 try { 548 const _ret = WEBEXT.bluetooth.onDeviceChanged.hasListener(A.H.get<object>(callback)); 549 A.store.Bool(retPtr, _ret); 550 return A.H.TRUE; 551 } catch (err: any) { 552 A.store.Ref(errPtr, err); 553 return A.H.FALSE; 554 } 555 }, 556 "has_OnDeviceRemoved": (): heap.Ref<boolean> => { 557 if (WEBEXT?.bluetooth?.onDeviceRemoved && "addListener" in WEBEXT?.bluetooth?.onDeviceRemoved) { 558 return A.H.TRUE; 559 } 560 return A.H.FALSE; 561 }, 562 "func_OnDeviceRemoved": (fn: Pointer): void => { 563 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceRemoved.addListener); 564 }, 565 "call_OnDeviceRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 566 const _ret = WEBEXT.bluetooth.onDeviceRemoved.addListener(A.H.get<object>(callback)); 567 }, 568 "try_OnDeviceRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 569 try { 570 const _ret = WEBEXT.bluetooth.onDeviceRemoved.addListener(A.H.get<object>(callback)); 571 return A.H.TRUE; 572 } catch (err: any) { 573 A.store.Ref(errPtr, err); 574 return A.H.FALSE; 575 } 576 }, 577 "has_OffDeviceRemoved": (): heap.Ref<boolean> => { 578 if (WEBEXT?.bluetooth?.onDeviceRemoved && "removeListener" in WEBEXT?.bluetooth?.onDeviceRemoved) { 579 return A.H.TRUE; 580 } 581 return A.H.FALSE; 582 }, 583 "func_OffDeviceRemoved": (fn: Pointer): void => { 584 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceRemoved.removeListener); 585 }, 586 "call_OffDeviceRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 587 const _ret = WEBEXT.bluetooth.onDeviceRemoved.removeListener(A.H.get<object>(callback)); 588 }, 589 "try_OffDeviceRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 590 try { 591 const _ret = WEBEXT.bluetooth.onDeviceRemoved.removeListener(A.H.get<object>(callback)); 592 return A.H.TRUE; 593 } catch (err: any) { 594 A.store.Ref(errPtr, err); 595 return A.H.FALSE; 596 } 597 }, 598 "has_HasOnDeviceRemoved": (): heap.Ref<boolean> => { 599 if (WEBEXT?.bluetooth?.onDeviceRemoved && "hasListener" in WEBEXT?.bluetooth?.onDeviceRemoved) { 600 return A.H.TRUE; 601 } 602 return A.H.FALSE; 603 }, 604 "func_HasOnDeviceRemoved": (fn: Pointer): void => { 605 A.store.Ref(fn, WEBEXT.bluetooth.onDeviceRemoved.hasListener); 606 }, 607 "call_HasOnDeviceRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => { 608 const _ret = WEBEXT.bluetooth.onDeviceRemoved.hasListener(A.H.get<object>(callback)); 609 A.store.Bool(retPtr, _ret); 610 }, 611 "try_HasOnDeviceRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 612 try { 613 const _ret = WEBEXT.bluetooth.onDeviceRemoved.hasListener(A.H.get<object>(callback)); 614 A.store.Bool(retPtr, _ret); 615 return A.H.TRUE; 616 } catch (err: any) { 617 A.store.Ref(errPtr, err); 618 return A.H.FALSE; 619 } 620 }, 621 "has_StartDiscovery": (): heap.Ref<boolean> => { 622 if (WEBEXT?.bluetooth && "startDiscovery" in WEBEXT?.bluetooth) { 623 return A.H.TRUE; 624 } 625 return A.H.FALSE; 626 }, 627 "func_StartDiscovery": (fn: Pointer): void => { 628 A.store.Ref(fn, WEBEXT.bluetooth.startDiscovery); 629 }, 630 "call_StartDiscovery": (retPtr: Pointer): void => { 631 const _ret = WEBEXT.bluetooth.startDiscovery(); 632 A.store.Ref(retPtr, _ret); 633 }, 634 "try_StartDiscovery": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 635 try { 636 const _ret = WEBEXT.bluetooth.startDiscovery(); 637 A.store.Ref(retPtr, _ret); 638 return A.H.TRUE; 639 } catch (err: any) { 640 A.store.Ref(errPtr, err); 641 return A.H.FALSE; 642 } 643 }, 644 "has_StopDiscovery": (): heap.Ref<boolean> => { 645 if (WEBEXT?.bluetooth && "stopDiscovery" in WEBEXT?.bluetooth) { 646 return A.H.TRUE; 647 } 648 return A.H.FALSE; 649 }, 650 "func_StopDiscovery": (fn: Pointer): void => { 651 A.store.Ref(fn, WEBEXT.bluetooth.stopDiscovery); 652 }, 653 "call_StopDiscovery": (retPtr: Pointer): void => { 654 const _ret = WEBEXT.bluetooth.stopDiscovery(); 655 A.store.Ref(retPtr, _ret); 656 }, 657 "try_StopDiscovery": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 658 try { 659 const _ret = WEBEXT.bluetooth.stopDiscovery(); 660 A.store.Ref(retPtr, _ret); 661 return A.H.TRUE; 662 } catch (err: any) { 663 A.store.Ref(errPtr, err); 664 return A.H.FALSE; 665 } 666 }, 667 }; 668 });