github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/bluetoothsocket/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/bluetoothsocket", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "constof_AcceptError": (ref: heap.Ref<string>): number => { 8 const idx = ["system_error", "not_listening"].indexOf(A.H.get(ref)); 9 return idx < 0 ? 0 : idx + 1; 10 }, 11 12 "store_AcceptErrorInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 13 const x = A.H.get<any>(ref); 14 15 if (typeof x === "undefined") { 16 A.store.Bool(ptr + 13, false); 17 A.store.Bool(ptr + 12, false); 18 A.store.Int32(ptr + 0, 0); 19 A.store.Ref(ptr + 4, undefined); 20 A.store.Enum(ptr + 8, -1); 21 } else { 22 A.store.Bool(ptr + 13, true); 23 A.store.Bool(ptr + 12, "socketId" in x ? true : false); 24 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 25 A.store.Ref(ptr + 4, x["errorMessage"]); 26 A.store.Enum(ptr + 8, ["system_error", "not_listening"].indexOf(x["error"] as string)); 27 } 28 }, 29 "load_AcceptErrorInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 30 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 31 32 if (A.load.Bool(ptr + 12)) { 33 x["socketId"] = A.load.Int32(ptr + 0); 34 } else { 35 delete x["socketId"]; 36 } 37 x["errorMessage"] = A.load.Ref(ptr + 4, undefined); 38 x["error"] = A.load.Enum(ptr + 8, ["system_error", "not_listening"]); 39 return create === A.H.TRUE ? A.H.push(x) : ref; 40 }, 41 42 "store_AcceptInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 43 const x = A.H.get<any>(ref); 44 45 if (typeof x === "undefined") { 46 A.store.Bool(ptr + 10, false); 47 A.store.Bool(ptr + 8, false); 48 A.store.Int32(ptr + 0, 0); 49 A.store.Bool(ptr + 9, false); 50 A.store.Int32(ptr + 4, 0); 51 } else { 52 A.store.Bool(ptr + 10, true); 53 A.store.Bool(ptr + 8, "socketId" in x ? true : false); 54 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 55 A.store.Bool(ptr + 9, "clientSocketId" in x ? true : false); 56 A.store.Int32(ptr + 4, x["clientSocketId"] === undefined ? 0 : (x["clientSocketId"] as number)); 57 } 58 }, 59 "load_AcceptInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 60 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 61 62 if (A.load.Bool(ptr + 8)) { 63 x["socketId"] = A.load.Int32(ptr + 0); 64 } else { 65 delete x["socketId"]; 66 } 67 if (A.load.Bool(ptr + 9)) { 68 x["clientSocketId"] = A.load.Int32(ptr + 4); 69 } else { 70 delete x["clientSocketId"]; 71 } 72 return create === A.H.TRUE ? A.H.push(x) : ref; 73 }, 74 75 "store_CreateInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 76 const x = A.H.get<any>(ref); 77 78 if (typeof x === "undefined") { 79 A.store.Bool(ptr + 5, false); 80 A.store.Bool(ptr + 4, false); 81 A.store.Int32(ptr + 0, 0); 82 } else { 83 A.store.Bool(ptr + 5, true); 84 A.store.Bool(ptr + 4, "socketId" in x ? true : false); 85 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 86 } 87 }, 88 "load_CreateInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 89 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 90 91 if (A.load.Bool(ptr + 4)) { 92 x["socketId"] = A.load.Int32(ptr + 0); 93 } else { 94 delete x["socketId"]; 95 } 96 return create === A.H.TRUE ? A.H.push(x) : ref; 97 }, 98 99 "store_SocketInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 100 const x = A.H.get<any>(ref); 101 102 if (typeof x === "undefined") { 103 A.store.Bool(ptr + 33, false); 104 A.store.Bool(ptr + 28, false); 105 A.store.Int32(ptr + 0, 0); 106 A.store.Bool(ptr + 29, false); 107 A.store.Bool(ptr + 4, false); 108 A.store.Ref(ptr + 8, undefined); 109 A.store.Bool(ptr + 30, false); 110 A.store.Int32(ptr + 12, 0); 111 A.store.Bool(ptr + 31, false); 112 A.store.Bool(ptr + 16, false); 113 A.store.Bool(ptr + 32, false); 114 A.store.Bool(ptr + 17, false); 115 A.store.Ref(ptr + 20, undefined); 116 A.store.Ref(ptr + 24, undefined); 117 } else { 118 A.store.Bool(ptr + 33, true); 119 A.store.Bool(ptr + 28, "socketId" in x ? true : false); 120 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 121 A.store.Bool(ptr + 29, "persistent" in x ? true : false); 122 A.store.Bool(ptr + 4, x["persistent"] ? true : false); 123 A.store.Ref(ptr + 8, x["name"]); 124 A.store.Bool(ptr + 30, "bufferSize" in x ? true : false); 125 A.store.Int32(ptr + 12, x["bufferSize"] === undefined ? 0 : (x["bufferSize"] as number)); 126 A.store.Bool(ptr + 31, "paused" in x ? true : false); 127 A.store.Bool(ptr + 16, x["paused"] ? true : false); 128 A.store.Bool(ptr + 32, "connected" in x ? true : false); 129 A.store.Bool(ptr + 17, x["connected"] ? true : false); 130 A.store.Ref(ptr + 20, x["address"]); 131 A.store.Ref(ptr + 24, x["uuid"]); 132 } 133 }, 134 "load_SocketInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 135 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 136 137 if (A.load.Bool(ptr + 28)) { 138 x["socketId"] = A.load.Int32(ptr + 0); 139 } else { 140 delete x["socketId"]; 141 } 142 if (A.load.Bool(ptr + 29)) { 143 x["persistent"] = A.load.Bool(ptr + 4); 144 } else { 145 delete x["persistent"]; 146 } 147 x["name"] = A.load.Ref(ptr + 8, undefined); 148 if (A.load.Bool(ptr + 30)) { 149 x["bufferSize"] = A.load.Int32(ptr + 12); 150 } else { 151 delete x["bufferSize"]; 152 } 153 if (A.load.Bool(ptr + 31)) { 154 x["paused"] = A.load.Bool(ptr + 16); 155 } else { 156 delete x["paused"]; 157 } 158 if (A.load.Bool(ptr + 32)) { 159 x["connected"] = A.load.Bool(ptr + 17); 160 } else { 161 delete x["connected"]; 162 } 163 x["address"] = A.load.Ref(ptr + 20, undefined); 164 x["uuid"] = A.load.Ref(ptr + 24, undefined); 165 return create === A.H.TRUE ? A.H.push(x) : ref; 166 }, 167 168 "store_ListenOptions": (ptr: Pointer, ref: heap.Ref<any>) => { 169 const x = A.H.get<any>(ref); 170 171 if (typeof x === "undefined") { 172 A.store.Bool(ptr + 15, false); 173 A.store.Bool(ptr + 12, false); 174 A.store.Int32(ptr + 0, 0); 175 A.store.Bool(ptr + 13, false); 176 A.store.Int32(ptr + 4, 0); 177 A.store.Bool(ptr + 14, false); 178 A.store.Int32(ptr + 8, 0); 179 } else { 180 A.store.Bool(ptr + 15, true); 181 A.store.Bool(ptr + 12, "channel" in x ? true : false); 182 A.store.Int32(ptr + 0, x["channel"] === undefined ? 0 : (x["channel"] as number)); 183 A.store.Bool(ptr + 13, "psm" in x ? true : false); 184 A.store.Int32(ptr + 4, x["psm"] === undefined ? 0 : (x["psm"] as number)); 185 A.store.Bool(ptr + 14, "backlog" in x ? true : false); 186 A.store.Int32(ptr + 8, x["backlog"] === undefined ? 0 : (x["backlog"] as number)); 187 } 188 }, 189 "load_ListenOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 190 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 191 192 if (A.load.Bool(ptr + 12)) { 193 x["channel"] = A.load.Int32(ptr + 0); 194 } else { 195 delete x["channel"]; 196 } 197 if (A.load.Bool(ptr + 13)) { 198 x["psm"] = A.load.Int32(ptr + 4); 199 } else { 200 delete x["psm"]; 201 } 202 if (A.load.Bool(ptr + 14)) { 203 x["backlog"] = A.load.Int32(ptr + 8); 204 } else { 205 delete x["backlog"]; 206 } 207 return create === A.H.TRUE ? A.H.push(x) : ref; 208 }, 209 "constof_ReceiveError": (ref: heap.Ref<string>): number => { 210 const idx = ["disconnected", "system_error", "not_connected"].indexOf(A.H.get(ref)); 211 return idx < 0 ? 0 : idx + 1; 212 }, 213 214 "store_ReceiveErrorInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 215 const x = A.H.get<any>(ref); 216 217 if (typeof x === "undefined") { 218 A.store.Bool(ptr + 13, false); 219 A.store.Bool(ptr + 12, false); 220 A.store.Int32(ptr + 0, 0); 221 A.store.Ref(ptr + 4, undefined); 222 A.store.Enum(ptr + 8, -1); 223 } else { 224 A.store.Bool(ptr + 13, true); 225 A.store.Bool(ptr + 12, "socketId" in x ? true : false); 226 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 227 A.store.Ref(ptr + 4, x["errorMessage"]); 228 A.store.Enum(ptr + 8, ["disconnected", "system_error", "not_connected"].indexOf(x["error"] as string)); 229 } 230 }, 231 "load_ReceiveErrorInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 232 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 233 234 if (A.load.Bool(ptr + 12)) { 235 x["socketId"] = A.load.Int32(ptr + 0); 236 } else { 237 delete x["socketId"]; 238 } 239 x["errorMessage"] = A.load.Ref(ptr + 4, undefined); 240 x["error"] = A.load.Enum(ptr + 8, ["disconnected", "system_error", "not_connected"]); 241 return create === A.H.TRUE ? A.H.push(x) : ref; 242 }, 243 244 "store_ReceiveInfo": (ptr: Pointer, ref: heap.Ref<any>) => { 245 const x = A.H.get<any>(ref); 246 247 if (typeof x === "undefined") { 248 A.store.Bool(ptr + 9, false); 249 A.store.Bool(ptr + 8, false); 250 A.store.Int32(ptr + 0, 0); 251 A.store.Ref(ptr + 4, undefined); 252 } else { 253 A.store.Bool(ptr + 9, true); 254 A.store.Bool(ptr + 8, "socketId" in x ? true : false); 255 A.store.Int32(ptr + 0, x["socketId"] === undefined ? 0 : (x["socketId"] as number)); 256 A.store.Ref(ptr + 4, x["data"]); 257 } 258 }, 259 "load_ReceiveInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 260 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 261 262 if (A.load.Bool(ptr + 8)) { 263 x["socketId"] = A.load.Int32(ptr + 0); 264 } else { 265 delete x["socketId"]; 266 } 267 x["data"] = A.load.Ref(ptr + 4, undefined); 268 return create === A.H.TRUE ? A.H.push(x) : ref; 269 }, 270 271 "store_SocketProperties": (ptr: Pointer, ref: heap.Ref<any>) => { 272 const x = A.H.get<any>(ref); 273 274 if (typeof x === "undefined") { 275 A.store.Bool(ptr + 14, false); 276 A.store.Bool(ptr + 12, false); 277 A.store.Bool(ptr + 0, false); 278 A.store.Ref(ptr + 4, undefined); 279 A.store.Bool(ptr + 13, false); 280 A.store.Int32(ptr + 8, 0); 281 } else { 282 A.store.Bool(ptr + 14, true); 283 A.store.Bool(ptr + 12, "persistent" in x ? true : false); 284 A.store.Bool(ptr + 0, x["persistent"] ? true : false); 285 A.store.Ref(ptr + 4, x["name"]); 286 A.store.Bool(ptr + 13, "bufferSize" in x ? true : false); 287 A.store.Int32(ptr + 8, x["bufferSize"] === undefined ? 0 : (x["bufferSize"] as number)); 288 } 289 }, 290 "load_SocketProperties": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 291 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 292 293 if (A.load.Bool(ptr + 12)) { 294 x["persistent"] = A.load.Bool(ptr + 0); 295 } else { 296 delete x["persistent"]; 297 } 298 x["name"] = A.load.Ref(ptr + 4, undefined); 299 if (A.load.Bool(ptr + 13)) { 300 x["bufferSize"] = A.load.Int32(ptr + 8); 301 } else { 302 delete x["bufferSize"]; 303 } 304 return create === A.H.TRUE ? A.H.push(x) : ref; 305 }, 306 "has_Close": (): heap.Ref<boolean> => { 307 if (WEBEXT?.bluetoothSocket && "close" in WEBEXT?.bluetoothSocket) { 308 return A.H.TRUE; 309 } 310 return A.H.FALSE; 311 }, 312 "func_Close": (fn: Pointer): void => { 313 A.store.Ref(fn, WEBEXT.bluetoothSocket.close); 314 }, 315 "call_Close": (retPtr: Pointer, socketId: number): void => { 316 const _ret = WEBEXT.bluetoothSocket.close(socketId); 317 A.store.Ref(retPtr, _ret); 318 }, 319 "try_Close": (retPtr: Pointer, errPtr: Pointer, socketId: number): heap.Ref<boolean> => { 320 try { 321 const _ret = WEBEXT.bluetoothSocket.close(socketId); 322 A.store.Ref(retPtr, _ret); 323 return A.H.TRUE; 324 } catch (err: any) { 325 A.store.Ref(errPtr, err); 326 return A.H.FALSE; 327 } 328 }, 329 "has_Connect": (): heap.Ref<boolean> => { 330 if (WEBEXT?.bluetoothSocket && "connect" in WEBEXT?.bluetoothSocket) { 331 return A.H.TRUE; 332 } 333 return A.H.FALSE; 334 }, 335 "func_Connect": (fn: Pointer): void => { 336 A.store.Ref(fn, WEBEXT.bluetoothSocket.connect); 337 }, 338 "call_Connect": (retPtr: Pointer, socketId: number, address: heap.Ref<object>, uuid: heap.Ref<object>): void => { 339 const _ret = WEBEXT.bluetoothSocket.connect(socketId, A.H.get<object>(address), A.H.get<object>(uuid)); 340 A.store.Ref(retPtr, _ret); 341 }, 342 "try_Connect": ( 343 retPtr: Pointer, 344 errPtr: Pointer, 345 socketId: number, 346 address: heap.Ref<object>, 347 uuid: heap.Ref<object> 348 ): heap.Ref<boolean> => { 349 try { 350 const _ret = WEBEXT.bluetoothSocket.connect(socketId, A.H.get<object>(address), A.H.get<object>(uuid)); 351 A.store.Ref(retPtr, _ret); 352 return A.H.TRUE; 353 } catch (err: any) { 354 A.store.Ref(errPtr, err); 355 return A.H.FALSE; 356 } 357 }, 358 "has_Create": (): heap.Ref<boolean> => { 359 if (WEBEXT?.bluetoothSocket && "create" in WEBEXT?.bluetoothSocket) { 360 return A.H.TRUE; 361 } 362 return A.H.FALSE; 363 }, 364 "func_Create": (fn: Pointer): void => { 365 A.store.Ref(fn, WEBEXT.bluetoothSocket.create); 366 }, 367 "call_Create": (retPtr: Pointer, properties: Pointer): void => { 368 const properties_ffi = {}; 369 370 if (A.load.Bool(properties + 12)) { 371 properties_ffi["persistent"] = A.load.Bool(properties + 0); 372 } 373 properties_ffi["name"] = A.load.Ref(properties + 4, undefined); 374 if (A.load.Bool(properties + 13)) { 375 properties_ffi["bufferSize"] = A.load.Int32(properties + 8); 376 } 377 378 const _ret = WEBEXT.bluetoothSocket.create(properties_ffi); 379 A.store.Ref(retPtr, _ret); 380 }, 381 "try_Create": (retPtr: Pointer, errPtr: Pointer, properties: Pointer): heap.Ref<boolean> => { 382 try { 383 const properties_ffi = {}; 384 385 if (A.load.Bool(properties + 12)) { 386 properties_ffi["persistent"] = A.load.Bool(properties + 0); 387 } 388 properties_ffi["name"] = A.load.Ref(properties + 4, undefined); 389 if (A.load.Bool(properties + 13)) { 390 properties_ffi["bufferSize"] = A.load.Int32(properties + 8); 391 } 392 393 const _ret = WEBEXT.bluetoothSocket.create(properties_ffi); 394 A.store.Ref(retPtr, _ret); 395 return A.H.TRUE; 396 } catch (err: any) { 397 A.store.Ref(errPtr, err); 398 return A.H.FALSE; 399 } 400 }, 401 "has_Disconnect": (): heap.Ref<boolean> => { 402 if (WEBEXT?.bluetoothSocket && "disconnect" in WEBEXT?.bluetoothSocket) { 403 return A.H.TRUE; 404 } 405 return A.H.FALSE; 406 }, 407 "func_Disconnect": (fn: Pointer): void => { 408 A.store.Ref(fn, WEBEXT.bluetoothSocket.disconnect); 409 }, 410 "call_Disconnect": (retPtr: Pointer, socketId: number): void => { 411 const _ret = WEBEXT.bluetoothSocket.disconnect(socketId); 412 A.store.Ref(retPtr, _ret); 413 }, 414 "try_Disconnect": (retPtr: Pointer, errPtr: Pointer, socketId: number): heap.Ref<boolean> => { 415 try { 416 const _ret = WEBEXT.bluetoothSocket.disconnect(socketId); 417 A.store.Ref(retPtr, _ret); 418 return A.H.TRUE; 419 } catch (err: any) { 420 A.store.Ref(errPtr, err); 421 return A.H.FALSE; 422 } 423 }, 424 "has_GetInfo": (): heap.Ref<boolean> => { 425 if (WEBEXT?.bluetoothSocket && "getInfo" in WEBEXT?.bluetoothSocket) { 426 return A.H.TRUE; 427 } 428 return A.H.FALSE; 429 }, 430 "func_GetInfo": (fn: Pointer): void => { 431 A.store.Ref(fn, WEBEXT.bluetoothSocket.getInfo); 432 }, 433 "call_GetInfo": (retPtr: Pointer, socketId: number): void => { 434 const _ret = WEBEXT.bluetoothSocket.getInfo(socketId); 435 A.store.Ref(retPtr, _ret); 436 }, 437 "try_GetInfo": (retPtr: Pointer, errPtr: Pointer, socketId: number): heap.Ref<boolean> => { 438 try { 439 const _ret = WEBEXT.bluetoothSocket.getInfo(socketId); 440 A.store.Ref(retPtr, _ret); 441 return A.H.TRUE; 442 } catch (err: any) { 443 A.store.Ref(errPtr, err); 444 return A.H.FALSE; 445 } 446 }, 447 "has_GetSockets": (): heap.Ref<boolean> => { 448 if (WEBEXT?.bluetoothSocket && "getSockets" in WEBEXT?.bluetoothSocket) { 449 return A.H.TRUE; 450 } 451 return A.H.FALSE; 452 }, 453 "func_GetSockets": (fn: Pointer): void => { 454 A.store.Ref(fn, WEBEXT.bluetoothSocket.getSockets); 455 }, 456 "call_GetSockets": (retPtr: Pointer): void => { 457 const _ret = WEBEXT.bluetoothSocket.getSockets(); 458 A.store.Ref(retPtr, _ret); 459 }, 460 "try_GetSockets": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => { 461 try { 462 const _ret = WEBEXT.bluetoothSocket.getSockets(); 463 A.store.Ref(retPtr, _ret); 464 return A.H.TRUE; 465 } catch (err: any) { 466 A.store.Ref(errPtr, err); 467 return A.H.FALSE; 468 } 469 }, 470 "has_ListenUsingL2cap": (): heap.Ref<boolean> => { 471 if (WEBEXT?.bluetoothSocket && "listenUsingL2cap" in WEBEXT?.bluetoothSocket) { 472 return A.H.TRUE; 473 } 474 return A.H.FALSE; 475 }, 476 "func_ListenUsingL2cap": (fn: Pointer): void => { 477 A.store.Ref(fn, WEBEXT.bluetoothSocket.listenUsingL2cap); 478 }, 479 "call_ListenUsingL2cap": (retPtr: Pointer, socketId: number, uuid: heap.Ref<object>, options: Pointer): void => { 480 const options_ffi = {}; 481 482 if (A.load.Bool(options + 12)) { 483 options_ffi["channel"] = A.load.Int32(options + 0); 484 } 485 if (A.load.Bool(options + 13)) { 486 options_ffi["psm"] = A.load.Int32(options + 4); 487 } 488 if (A.load.Bool(options + 14)) { 489 options_ffi["backlog"] = A.load.Int32(options + 8); 490 } 491 492 const _ret = WEBEXT.bluetoothSocket.listenUsingL2cap(socketId, A.H.get<object>(uuid), options_ffi); 493 A.store.Ref(retPtr, _ret); 494 }, 495 "try_ListenUsingL2cap": ( 496 retPtr: Pointer, 497 errPtr: Pointer, 498 socketId: number, 499 uuid: heap.Ref<object>, 500 options: Pointer 501 ): heap.Ref<boolean> => { 502 try { 503 const options_ffi = {}; 504 505 if (A.load.Bool(options + 12)) { 506 options_ffi["channel"] = A.load.Int32(options + 0); 507 } 508 if (A.load.Bool(options + 13)) { 509 options_ffi["psm"] = A.load.Int32(options + 4); 510 } 511 if (A.load.Bool(options + 14)) { 512 options_ffi["backlog"] = A.load.Int32(options + 8); 513 } 514 515 const _ret = WEBEXT.bluetoothSocket.listenUsingL2cap(socketId, A.H.get<object>(uuid), options_ffi); 516 A.store.Ref(retPtr, _ret); 517 return A.H.TRUE; 518 } catch (err: any) { 519 A.store.Ref(errPtr, err); 520 return A.H.FALSE; 521 } 522 }, 523 "has_ListenUsingRfcomm": (): heap.Ref<boolean> => { 524 if (WEBEXT?.bluetoothSocket && "listenUsingRfcomm" in WEBEXT?.bluetoothSocket) { 525 return A.H.TRUE; 526 } 527 return A.H.FALSE; 528 }, 529 "func_ListenUsingRfcomm": (fn: Pointer): void => { 530 A.store.Ref(fn, WEBEXT.bluetoothSocket.listenUsingRfcomm); 531 }, 532 "call_ListenUsingRfcomm": (retPtr: Pointer, socketId: number, uuid: heap.Ref<object>, options: Pointer): void => { 533 const options_ffi = {}; 534 535 if (A.load.Bool(options + 12)) { 536 options_ffi["channel"] = A.load.Int32(options + 0); 537 } 538 if (A.load.Bool(options + 13)) { 539 options_ffi["psm"] = A.load.Int32(options + 4); 540 } 541 if (A.load.Bool(options + 14)) { 542 options_ffi["backlog"] = A.load.Int32(options + 8); 543 } 544 545 const _ret = WEBEXT.bluetoothSocket.listenUsingRfcomm(socketId, A.H.get<object>(uuid), options_ffi); 546 A.store.Ref(retPtr, _ret); 547 }, 548 "try_ListenUsingRfcomm": ( 549 retPtr: Pointer, 550 errPtr: Pointer, 551 socketId: number, 552 uuid: heap.Ref<object>, 553 options: Pointer 554 ): heap.Ref<boolean> => { 555 try { 556 const options_ffi = {}; 557 558 if (A.load.Bool(options + 12)) { 559 options_ffi["channel"] = A.load.Int32(options + 0); 560 } 561 if (A.load.Bool(options + 13)) { 562 options_ffi["psm"] = A.load.Int32(options + 4); 563 } 564 if (A.load.Bool(options + 14)) { 565 options_ffi["backlog"] = A.load.Int32(options + 8); 566 } 567 568 const _ret = WEBEXT.bluetoothSocket.listenUsingRfcomm(socketId, A.H.get<object>(uuid), options_ffi); 569 A.store.Ref(retPtr, _ret); 570 return A.H.TRUE; 571 } catch (err: any) { 572 A.store.Ref(errPtr, err); 573 return A.H.FALSE; 574 } 575 }, 576 "has_OnAccept": (): heap.Ref<boolean> => { 577 if (WEBEXT?.bluetoothSocket?.onAccept && "addListener" in WEBEXT?.bluetoothSocket?.onAccept) { 578 return A.H.TRUE; 579 } 580 return A.H.FALSE; 581 }, 582 "func_OnAccept": (fn: Pointer): void => { 583 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAccept.addListener); 584 }, 585 "call_OnAccept": (retPtr: Pointer, callback: heap.Ref<object>): void => { 586 const _ret = WEBEXT.bluetoothSocket.onAccept.addListener(A.H.get<object>(callback)); 587 }, 588 "try_OnAccept": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 589 try { 590 const _ret = WEBEXT.bluetoothSocket.onAccept.addListener(A.H.get<object>(callback)); 591 return A.H.TRUE; 592 } catch (err: any) { 593 A.store.Ref(errPtr, err); 594 return A.H.FALSE; 595 } 596 }, 597 "has_OffAccept": (): heap.Ref<boolean> => { 598 if (WEBEXT?.bluetoothSocket?.onAccept && "removeListener" in WEBEXT?.bluetoothSocket?.onAccept) { 599 return A.H.TRUE; 600 } 601 return A.H.FALSE; 602 }, 603 "func_OffAccept": (fn: Pointer): void => { 604 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAccept.removeListener); 605 }, 606 "call_OffAccept": (retPtr: Pointer, callback: heap.Ref<object>): void => { 607 const _ret = WEBEXT.bluetoothSocket.onAccept.removeListener(A.H.get<object>(callback)); 608 }, 609 "try_OffAccept": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 610 try { 611 const _ret = WEBEXT.bluetoothSocket.onAccept.removeListener(A.H.get<object>(callback)); 612 return A.H.TRUE; 613 } catch (err: any) { 614 A.store.Ref(errPtr, err); 615 return A.H.FALSE; 616 } 617 }, 618 "has_HasOnAccept": (): heap.Ref<boolean> => { 619 if (WEBEXT?.bluetoothSocket?.onAccept && "hasListener" in WEBEXT?.bluetoothSocket?.onAccept) { 620 return A.H.TRUE; 621 } 622 return A.H.FALSE; 623 }, 624 "func_HasOnAccept": (fn: Pointer): void => { 625 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAccept.hasListener); 626 }, 627 "call_HasOnAccept": (retPtr: Pointer, callback: heap.Ref<object>): void => { 628 const _ret = WEBEXT.bluetoothSocket.onAccept.hasListener(A.H.get<object>(callback)); 629 A.store.Bool(retPtr, _ret); 630 }, 631 "try_HasOnAccept": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 632 try { 633 const _ret = WEBEXT.bluetoothSocket.onAccept.hasListener(A.H.get<object>(callback)); 634 A.store.Bool(retPtr, _ret); 635 return A.H.TRUE; 636 } catch (err: any) { 637 A.store.Ref(errPtr, err); 638 return A.H.FALSE; 639 } 640 }, 641 "has_OnAcceptError": (): heap.Ref<boolean> => { 642 if (WEBEXT?.bluetoothSocket?.onAcceptError && "addListener" in WEBEXT?.bluetoothSocket?.onAcceptError) { 643 return A.H.TRUE; 644 } 645 return A.H.FALSE; 646 }, 647 "func_OnAcceptError": (fn: Pointer): void => { 648 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAcceptError.addListener); 649 }, 650 "call_OnAcceptError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 651 const _ret = WEBEXT.bluetoothSocket.onAcceptError.addListener(A.H.get<object>(callback)); 652 }, 653 "try_OnAcceptError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 654 try { 655 const _ret = WEBEXT.bluetoothSocket.onAcceptError.addListener(A.H.get<object>(callback)); 656 return A.H.TRUE; 657 } catch (err: any) { 658 A.store.Ref(errPtr, err); 659 return A.H.FALSE; 660 } 661 }, 662 "has_OffAcceptError": (): heap.Ref<boolean> => { 663 if (WEBEXT?.bluetoothSocket?.onAcceptError && "removeListener" in WEBEXT?.bluetoothSocket?.onAcceptError) { 664 return A.H.TRUE; 665 } 666 return A.H.FALSE; 667 }, 668 "func_OffAcceptError": (fn: Pointer): void => { 669 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAcceptError.removeListener); 670 }, 671 "call_OffAcceptError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 672 const _ret = WEBEXT.bluetoothSocket.onAcceptError.removeListener(A.H.get<object>(callback)); 673 }, 674 "try_OffAcceptError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 675 try { 676 const _ret = WEBEXT.bluetoothSocket.onAcceptError.removeListener(A.H.get<object>(callback)); 677 return A.H.TRUE; 678 } catch (err: any) { 679 A.store.Ref(errPtr, err); 680 return A.H.FALSE; 681 } 682 }, 683 "has_HasOnAcceptError": (): heap.Ref<boolean> => { 684 if (WEBEXT?.bluetoothSocket?.onAcceptError && "hasListener" in WEBEXT?.bluetoothSocket?.onAcceptError) { 685 return A.H.TRUE; 686 } 687 return A.H.FALSE; 688 }, 689 "func_HasOnAcceptError": (fn: Pointer): void => { 690 A.store.Ref(fn, WEBEXT.bluetoothSocket.onAcceptError.hasListener); 691 }, 692 "call_HasOnAcceptError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 693 const _ret = WEBEXT.bluetoothSocket.onAcceptError.hasListener(A.H.get<object>(callback)); 694 A.store.Bool(retPtr, _ret); 695 }, 696 "try_HasOnAcceptError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 697 try { 698 const _ret = WEBEXT.bluetoothSocket.onAcceptError.hasListener(A.H.get<object>(callback)); 699 A.store.Bool(retPtr, _ret); 700 return A.H.TRUE; 701 } catch (err: any) { 702 A.store.Ref(errPtr, err); 703 return A.H.FALSE; 704 } 705 }, 706 "has_OnReceive": (): heap.Ref<boolean> => { 707 if (WEBEXT?.bluetoothSocket?.onReceive && "addListener" in WEBEXT?.bluetoothSocket?.onReceive) { 708 return A.H.TRUE; 709 } 710 return A.H.FALSE; 711 }, 712 "func_OnReceive": (fn: Pointer): void => { 713 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceive.addListener); 714 }, 715 "call_OnReceive": (retPtr: Pointer, callback: heap.Ref<object>): void => { 716 const _ret = WEBEXT.bluetoothSocket.onReceive.addListener(A.H.get<object>(callback)); 717 }, 718 "try_OnReceive": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 719 try { 720 const _ret = WEBEXT.bluetoothSocket.onReceive.addListener(A.H.get<object>(callback)); 721 return A.H.TRUE; 722 } catch (err: any) { 723 A.store.Ref(errPtr, err); 724 return A.H.FALSE; 725 } 726 }, 727 "has_OffReceive": (): heap.Ref<boolean> => { 728 if (WEBEXT?.bluetoothSocket?.onReceive && "removeListener" in WEBEXT?.bluetoothSocket?.onReceive) { 729 return A.H.TRUE; 730 } 731 return A.H.FALSE; 732 }, 733 "func_OffReceive": (fn: Pointer): void => { 734 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceive.removeListener); 735 }, 736 "call_OffReceive": (retPtr: Pointer, callback: heap.Ref<object>): void => { 737 const _ret = WEBEXT.bluetoothSocket.onReceive.removeListener(A.H.get<object>(callback)); 738 }, 739 "try_OffReceive": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 740 try { 741 const _ret = WEBEXT.bluetoothSocket.onReceive.removeListener(A.H.get<object>(callback)); 742 return A.H.TRUE; 743 } catch (err: any) { 744 A.store.Ref(errPtr, err); 745 return A.H.FALSE; 746 } 747 }, 748 "has_HasOnReceive": (): heap.Ref<boolean> => { 749 if (WEBEXT?.bluetoothSocket?.onReceive && "hasListener" in WEBEXT?.bluetoothSocket?.onReceive) { 750 return A.H.TRUE; 751 } 752 return A.H.FALSE; 753 }, 754 "func_HasOnReceive": (fn: Pointer): void => { 755 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceive.hasListener); 756 }, 757 "call_HasOnReceive": (retPtr: Pointer, callback: heap.Ref<object>): void => { 758 const _ret = WEBEXT.bluetoothSocket.onReceive.hasListener(A.H.get<object>(callback)); 759 A.store.Bool(retPtr, _ret); 760 }, 761 "try_HasOnReceive": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 762 try { 763 const _ret = WEBEXT.bluetoothSocket.onReceive.hasListener(A.H.get<object>(callback)); 764 A.store.Bool(retPtr, _ret); 765 return A.H.TRUE; 766 } catch (err: any) { 767 A.store.Ref(errPtr, err); 768 return A.H.FALSE; 769 } 770 }, 771 "has_OnReceiveError": (): heap.Ref<boolean> => { 772 if (WEBEXT?.bluetoothSocket?.onReceiveError && "addListener" in WEBEXT?.bluetoothSocket?.onReceiveError) { 773 return A.H.TRUE; 774 } 775 return A.H.FALSE; 776 }, 777 "func_OnReceiveError": (fn: Pointer): void => { 778 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceiveError.addListener); 779 }, 780 "call_OnReceiveError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 781 const _ret = WEBEXT.bluetoothSocket.onReceiveError.addListener(A.H.get<object>(callback)); 782 }, 783 "try_OnReceiveError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 784 try { 785 const _ret = WEBEXT.bluetoothSocket.onReceiveError.addListener(A.H.get<object>(callback)); 786 return A.H.TRUE; 787 } catch (err: any) { 788 A.store.Ref(errPtr, err); 789 return A.H.FALSE; 790 } 791 }, 792 "has_OffReceiveError": (): heap.Ref<boolean> => { 793 if (WEBEXT?.bluetoothSocket?.onReceiveError && "removeListener" in WEBEXT?.bluetoothSocket?.onReceiveError) { 794 return A.H.TRUE; 795 } 796 return A.H.FALSE; 797 }, 798 "func_OffReceiveError": (fn: Pointer): void => { 799 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceiveError.removeListener); 800 }, 801 "call_OffReceiveError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 802 const _ret = WEBEXT.bluetoothSocket.onReceiveError.removeListener(A.H.get<object>(callback)); 803 }, 804 "try_OffReceiveError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 805 try { 806 const _ret = WEBEXT.bluetoothSocket.onReceiveError.removeListener(A.H.get<object>(callback)); 807 return A.H.TRUE; 808 } catch (err: any) { 809 A.store.Ref(errPtr, err); 810 return A.H.FALSE; 811 } 812 }, 813 "has_HasOnReceiveError": (): heap.Ref<boolean> => { 814 if (WEBEXT?.bluetoothSocket?.onReceiveError && "hasListener" in WEBEXT?.bluetoothSocket?.onReceiveError) { 815 return A.H.TRUE; 816 } 817 return A.H.FALSE; 818 }, 819 "func_HasOnReceiveError": (fn: Pointer): void => { 820 A.store.Ref(fn, WEBEXT.bluetoothSocket.onReceiveError.hasListener); 821 }, 822 "call_HasOnReceiveError": (retPtr: Pointer, callback: heap.Ref<object>): void => { 823 const _ret = WEBEXT.bluetoothSocket.onReceiveError.hasListener(A.H.get<object>(callback)); 824 A.store.Bool(retPtr, _ret); 825 }, 826 "try_HasOnReceiveError": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => { 827 try { 828 const _ret = WEBEXT.bluetoothSocket.onReceiveError.hasListener(A.H.get<object>(callback)); 829 A.store.Bool(retPtr, _ret); 830 return A.H.TRUE; 831 } catch (err: any) { 832 A.store.Ref(errPtr, err); 833 return A.H.FALSE; 834 } 835 }, 836 "has_Send": (): heap.Ref<boolean> => { 837 if (WEBEXT?.bluetoothSocket && "send" in WEBEXT?.bluetoothSocket) { 838 return A.H.TRUE; 839 } 840 return A.H.FALSE; 841 }, 842 "func_Send": (fn: Pointer): void => { 843 A.store.Ref(fn, WEBEXT.bluetoothSocket.send); 844 }, 845 "call_Send": (retPtr: Pointer, socketId: number, data: heap.Ref<object>): void => { 846 const _ret = WEBEXT.bluetoothSocket.send(socketId, A.H.get<object>(data)); 847 A.store.Ref(retPtr, _ret); 848 }, 849 "try_Send": (retPtr: Pointer, errPtr: Pointer, socketId: number, data: heap.Ref<object>): heap.Ref<boolean> => { 850 try { 851 const _ret = WEBEXT.bluetoothSocket.send(socketId, A.H.get<object>(data)); 852 A.store.Ref(retPtr, _ret); 853 return A.H.TRUE; 854 } catch (err: any) { 855 A.store.Ref(errPtr, err); 856 return A.H.FALSE; 857 } 858 }, 859 "has_SetPaused": (): heap.Ref<boolean> => { 860 if (WEBEXT?.bluetoothSocket && "setPaused" in WEBEXT?.bluetoothSocket) { 861 return A.H.TRUE; 862 } 863 return A.H.FALSE; 864 }, 865 "func_SetPaused": (fn: Pointer): void => { 866 A.store.Ref(fn, WEBEXT.bluetoothSocket.setPaused); 867 }, 868 "call_SetPaused": (retPtr: Pointer, socketId: number, paused: heap.Ref<boolean>): void => { 869 const _ret = WEBEXT.bluetoothSocket.setPaused(socketId, paused === A.H.TRUE); 870 A.store.Ref(retPtr, _ret); 871 }, 872 "try_SetPaused": ( 873 retPtr: Pointer, 874 errPtr: Pointer, 875 socketId: number, 876 paused: heap.Ref<boolean> 877 ): heap.Ref<boolean> => { 878 try { 879 const _ret = WEBEXT.bluetoothSocket.setPaused(socketId, paused === A.H.TRUE); 880 A.store.Ref(retPtr, _ret); 881 return A.H.TRUE; 882 } catch (err: any) { 883 A.store.Ref(errPtr, err); 884 return A.H.FALSE; 885 } 886 }, 887 "has_Update": (): heap.Ref<boolean> => { 888 if (WEBEXT?.bluetoothSocket && "update" in WEBEXT?.bluetoothSocket) { 889 return A.H.TRUE; 890 } 891 return A.H.FALSE; 892 }, 893 "func_Update": (fn: Pointer): void => { 894 A.store.Ref(fn, WEBEXT.bluetoothSocket.update); 895 }, 896 "call_Update": (retPtr: Pointer, socketId: number, properties: Pointer): void => { 897 const properties_ffi = {}; 898 899 if (A.load.Bool(properties + 12)) { 900 properties_ffi["persistent"] = A.load.Bool(properties + 0); 901 } 902 properties_ffi["name"] = A.load.Ref(properties + 4, undefined); 903 if (A.load.Bool(properties + 13)) { 904 properties_ffi["bufferSize"] = A.load.Int32(properties + 8); 905 } 906 907 const _ret = WEBEXT.bluetoothSocket.update(socketId, properties_ffi); 908 A.store.Ref(retPtr, _ret); 909 }, 910 "try_Update": (retPtr: Pointer, errPtr: Pointer, socketId: number, properties: Pointer): heap.Ref<boolean> => { 911 try { 912 const properties_ffi = {}; 913 914 if (A.load.Bool(properties + 12)) { 915 properties_ffi["persistent"] = A.load.Bool(properties + 0); 916 } 917 properties_ffi["name"] = A.load.Ref(properties + 4, undefined); 918 if (A.load.Bool(properties + 13)) { 919 properties_ffi["bufferSize"] = A.load.Int32(properties + 8); 920 } 921 922 const _ret = WEBEXT.bluetoothSocket.update(socketId, properties_ffi); 923 A.store.Ref(retPtr, _ret); 924 return A.H.TRUE; 925 } catch (err: any) { 926 A.store.Ref(errPtr, err); 927 return A.H.FALSE; 928 } 929 }, 930 }; 931 });