github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/usb/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package usb 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 "github.com/primecitizens/pcz/std/core/mark" 9 "github.com/primecitizens/pcz/std/ffi/js" 10 "github.com/primecitizens/pcz/std/plat/js/webext/usb/bindings" 11 ) 12 13 type CloseDeviceCallbackFunc func(this js.Ref) js.Ref 14 15 func (fn CloseDeviceCallbackFunc) Register() js.Func[func()] { 16 return js.RegisterCallback[func()]( 17 fn, abi.FuncPCABIInternal(fn), 18 ) 19 } 20 21 func (fn CloseDeviceCallbackFunc) DispatchCallback( 22 targetPC uintptr, ctx *js.CallbackContext, 23 ) { 24 args := ctx.Args() 25 if len(args) != 0+1 /* js this */ || 26 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 27 js.ThrowInvalidCallbackInvocation() 28 } 29 30 if ctx.Return(fn( 31 args[0], 32 )) { 33 return 34 } 35 36 js.ThrowCallbackValueNotReturned() 37 } 38 39 type CloseDeviceCallback[T any] struct { 40 Fn func(arg T, this js.Ref) js.Ref 41 Arg T 42 } 43 44 func (cb *CloseDeviceCallback[T]) Register() js.Func[func()] { 45 return js.RegisterCallback[func()]( 46 cb, abi.FuncPCABIInternal(cb.Fn), 47 ) 48 } 49 50 func (cb *CloseDeviceCallback[T]) DispatchCallback( 51 targetPC uintptr, ctx *js.CallbackContext, 52 ) { 53 args := ctx.Args() 54 if len(args) != 0+1 /* js this */ || 55 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 56 js.ThrowInvalidCallbackInvocation() 57 } 58 59 if ctx.Return(cb.Fn( 60 cb.Arg, 61 args[0], 62 )) { 63 return 64 } 65 66 js.ThrowCallbackValueNotReturned() 67 } 68 69 type TransferType uint32 70 71 const ( 72 _ TransferType = iota 73 74 TransferType_CONTROL 75 TransferType_INTERRUPT 76 TransferType_ISOCHRONOUS 77 TransferType_BULK 78 ) 79 80 func (TransferType) FromRef(str js.Ref) TransferType { 81 return TransferType(bindings.ConstOfTransferType(str)) 82 } 83 84 func (x TransferType) String() (string, bool) { 85 switch x { 86 case TransferType_CONTROL: 87 return "control", true 88 case TransferType_INTERRUPT: 89 return "interrupt", true 90 case TransferType_ISOCHRONOUS: 91 return "isochronous", true 92 case TransferType_BULK: 93 return "bulk", true 94 default: 95 return "", false 96 } 97 } 98 99 type Direction uint32 100 101 const ( 102 _ Direction = iota 103 104 Direction_IN 105 Direction_OUT 106 ) 107 108 func (Direction) FromRef(str js.Ref) Direction { 109 return Direction(bindings.ConstOfDirection(str)) 110 } 111 112 func (x Direction) String() (string, bool) { 113 switch x { 114 case Direction_IN: 115 return "in", true 116 case Direction_OUT: 117 return "out", true 118 default: 119 return "", false 120 } 121 } 122 123 type SynchronizationType uint32 124 125 const ( 126 _ SynchronizationType = iota 127 128 SynchronizationType_ASYNCHRONOUS 129 SynchronizationType_ADAPTIVE 130 SynchronizationType_SYNCHRONOUS 131 ) 132 133 func (SynchronizationType) FromRef(str js.Ref) SynchronizationType { 134 return SynchronizationType(bindings.ConstOfSynchronizationType(str)) 135 } 136 137 func (x SynchronizationType) String() (string, bool) { 138 switch x { 139 case SynchronizationType_ASYNCHRONOUS: 140 return "asynchronous", true 141 case SynchronizationType_ADAPTIVE: 142 return "adaptive", true 143 case SynchronizationType_SYNCHRONOUS: 144 return "synchronous", true 145 default: 146 return "", false 147 } 148 } 149 150 type UsageType uint32 151 152 const ( 153 _ UsageType = iota 154 155 UsageType_DATA 156 UsageType_FEEDBACK 157 UsageType_EXPLICIT_FEEDBACK 158 UsageType_PERIODIC 159 UsageType_NOTIFICATION 160 ) 161 162 func (UsageType) FromRef(str js.Ref) UsageType { 163 return UsageType(bindings.ConstOfUsageType(str)) 164 } 165 166 func (x UsageType) String() (string, bool) { 167 switch x { 168 case UsageType_DATA: 169 return "data", true 170 case UsageType_FEEDBACK: 171 return "feedback", true 172 case UsageType_EXPLICIT_FEEDBACK: 173 return "explicitFeedback", true 174 case UsageType_PERIODIC: 175 return "periodic", true 176 case UsageType_NOTIFICATION: 177 return "notification", true 178 default: 179 return "", false 180 } 181 } 182 183 type EndpointDescriptor struct { 184 // Address is "EndpointDescriptor.address" 185 // 186 // Optional 187 // 188 // NOTE: FFI_USE_Address MUST be set to true to make this field effective. 189 Address int32 190 // Type is "EndpointDescriptor.type" 191 // 192 // Optional 193 Type TransferType 194 // Direction is "EndpointDescriptor.direction" 195 // 196 // Optional 197 Direction Direction 198 // MaximumPacketSize is "EndpointDescriptor.maximumPacketSize" 199 // 200 // Optional 201 // 202 // NOTE: FFI_USE_MaximumPacketSize MUST be set to true to make this field effective. 203 MaximumPacketSize int32 204 // Synchronization is "EndpointDescriptor.synchronization" 205 // 206 // Optional 207 Synchronization SynchronizationType 208 // Usage is "EndpointDescriptor.usage" 209 // 210 // Optional 211 Usage UsageType 212 // PollingInterval is "EndpointDescriptor.pollingInterval" 213 // 214 // Optional 215 // 216 // NOTE: FFI_USE_PollingInterval MUST be set to true to make this field effective. 217 PollingInterval int32 218 // ExtraData is "EndpointDescriptor.extra_data" 219 // 220 // Optional 221 ExtraData js.ArrayBuffer 222 223 FFI_USE_Address bool // for Address. 224 FFI_USE_MaximumPacketSize bool // for MaximumPacketSize. 225 FFI_USE_PollingInterval bool // for PollingInterval. 226 227 FFI_USE bool 228 } 229 230 // FromRef calls UpdateFrom and returns a EndpointDescriptor with all fields set. 231 func (p EndpointDescriptor) FromRef(ref js.Ref) EndpointDescriptor { 232 p.UpdateFrom(ref) 233 return p 234 } 235 236 // New creates a new EndpointDescriptor in the application heap. 237 func (p EndpointDescriptor) New() js.Ref { 238 return bindings.EndpointDescriptorJSLoad( 239 js.Pointer(&p), js.True, 0, 240 ) 241 } 242 243 // UpdateFrom copies value of all fields of the heap object to p. 244 func (p *EndpointDescriptor) UpdateFrom(ref js.Ref) { 245 bindings.EndpointDescriptorJSStore( 246 js.Pointer(p), ref, 247 ) 248 } 249 250 // Update writes all fields of the p to the heap object referenced by ref. 251 func (p *EndpointDescriptor) Update(ref js.Ref) { 252 bindings.EndpointDescriptorJSLoad( 253 js.Pointer(p), js.False, ref, 254 ) 255 } 256 257 // FreeMembers frees fields with heap reference, if recursive is true 258 // free all heap references reachable from p. 259 func (p *EndpointDescriptor) FreeMembers(recursive bool) { 260 js.Free( 261 p.ExtraData.Ref(), 262 ) 263 p.ExtraData = p.ExtraData.FromRef(js.Undefined) 264 } 265 266 type InterfaceDescriptor struct { 267 // InterfaceNumber is "InterfaceDescriptor.interfaceNumber" 268 // 269 // Optional 270 // 271 // NOTE: FFI_USE_InterfaceNumber MUST be set to true to make this field effective. 272 InterfaceNumber int32 273 // AlternateSetting is "InterfaceDescriptor.alternateSetting" 274 // 275 // Optional 276 // 277 // NOTE: FFI_USE_AlternateSetting MUST be set to true to make this field effective. 278 AlternateSetting int32 279 // InterfaceClass is "InterfaceDescriptor.interfaceClass" 280 // 281 // Optional 282 // 283 // NOTE: FFI_USE_InterfaceClass MUST be set to true to make this field effective. 284 InterfaceClass int32 285 // InterfaceSubclass is "InterfaceDescriptor.interfaceSubclass" 286 // 287 // Optional 288 // 289 // NOTE: FFI_USE_InterfaceSubclass MUST be set to true to make this field effective. 290 InterfaceSubclass int32 291 // InterfaceProtocol is "InterfaceDescriptor.interfaceProtocol" 292 // 293 // Optional 294 // 295 // NOTE: FFI_USE_InterfaceProtocol MUST be set to true to make this field effective. 296 InterfaceProtocol int32 297 // Description is "InterfaceDescriptor.description" 298 // 299 // Optional 300 Description js.String 301 // Endpoints is "InterfaceDescriptor.endpoints" 302 // 303 // Optional 304 Endpoints js.Array[EndpointDescriptor] 305 // ExtraData is "InterfaceDescriptor.extra_data" 306 // 307 // Optional 308 ExtraData js.ArrayBuffer 309 310 FFI_USE_InterfaceNumber bool // for InterfaceNumber. 311 FFI_USE_AlternateSetting bool // for AlternateSetting. 312 FFI_USE_InterfaceClass bool // for InterfaceClass. 313 FFI_USE_InterfaceSubclass bool // for InterfaceSubclass. 314 FFI_USE_InterfaceProtocol bool // for InterfaceProtocol. 315 316 FFI_USE bool 317 } 318 319 // FromRef calls UpdateFrom and returns a InterfaceDescriptor with all fields set. 320 func (p InterfaceDescriptor) FromRef(ref js.Ref) InterfaceDescriptor { 321 p.UpdateFrom(ref) 322 return p 323 } 324 325 // New creates a new InterfaceDescriptor in the application heap. 326 func (p InterfaceDescriptor) New() js.Ref { 327 return bindings.InterfaceDescriptorJSLoad( 328 js.Pointer(&p), js.True, 0, 329 ) 330 } 331 332 // UpdateFrom copies value of all fields of the heap object to p. 333 func (p *InterfaceDescriptor) UpdateFrom(ref js.Ref) { 334 bindings.InterfaceDescriptorJSStore( 335 js.Pointer(p), ref, 336 ) 337 } 338 339 // Update writes all fields of the p to the heap object referenced by ref. 340 func (p *InterfaceDescriptor) Update(ref js.Ref) { 341 bindings.InterfaceDescriptorJSLoad( 342 js.Pointer(p), js.False, ref, 343 ) 344 } 345 346 // FreeMembers frees fields with heap reference, if recursive is true 347 // free all heap references reachable from p. 348 func (p *InterfaceDescriptor) FreeMembers(recursive bool) { 349 js.Free( 350 p.Description.Ref(), 351 p.Endpoints.Ref(), 352 p.ExtraData.Ref(), 353 ) 354 p.Description = p.Description.FromRef(js.Undefined) 355 p.Endpoints = p.Endpoints.FromRef(js.Undefined) 356 p.ExtraData = p.ExtraData.FromRef(js.Undefined) 357 } 358 359 type ConfigDescriptor struct { 360 // Active is "ConfigDescriptor.active" 361 // 362 // Optional 363 // 364 // NOTE: FFI_USE_Active MUST be set to true to make this field effective. 365 Active bool 366 // ConfigurationValue is "ConfigDescriptor.configurationValue" 367 // 368 // Optional 369 // 370 // NOTE: FFI_USE_ConfigurationValue MUST be set to true to make this field effective. 371 ConfigurationValue int32 372 // Description is "ConfigDescriptor.description" 373 // 374 // Optional 375 Description js.String 376 // SelfPowered is "ConfigDescriptor.selfPowered" 377 // 378 // Optional 379 // 380 // NOTE: FFI_USE_SelfPowered MUST be set to true to make this field effective. 381 SelfPowered bool 382 // RemoteWakeup is "ConfigDescriptor.remoteWakeup" 383 // 384 // Optional 385 // 386 // NOTE: FFI_USE_RemoteWakeup MUST be set to true to make this field effective. 387 RemoteWakeup bool 388 // MaxPower is "ConfigDescriptor.maxPower" 389 // 390 // Optional 391 // 392 // NOTE: FFI_USE_MaxPower MUST be set to true to make this field effective. 393 MaxPower int32 394 // Interfaces is "ConfigDescriptor.interfaces" 395 // 396 // Optional 397 Interfaces js.Array[InterfaceDescriptor] 398 // ExtraData is "ConfigDescriptor.extra_data" 399 // 400 // Optional 401 ExtraData js.ArrayBuffer 402 403 FFI_USE_Active bool // for Active. 404 FFI_USE_ConfigurationValue bool // for ConfigurationValue. 405 FFI_USE_SelfPowered bool // for SelfPowered. 406 FFI_USE_RemoteWakeup bool // for RemoteWakeup. 407 FFI_USE_MaxPower bool // for MaxPower. 408 409 FFI_USE bool 410 } 411 412 // FromRef calls UpdateFrom and returns a ConfigDescriptor with all fields set. 413 func (p ConfigDescriptor) FromRef(ref js.Ref) ConfigDescriptor { 414 p.UpdateFrom(ref) 415 return p 416 } 417 418 // New creates a new ConfigDescriptor in the application heap. 419 func (p ConfigDescriptor) New() js.Ref { 420 return bindings.ConfigDescriptorJSLoad( 421 js.Pointer(&p), js.True, 0, 422 ) 423 } 424 425 // UpdateFrom copies value of all fields of the heap object to p. 426 func (p *ConfigDescriptor) UpdateFrom(ref js.Ref) { 427 bindings.ConfigDescriptorJSStore( 428 js.Pointer(p), ref, 429 ) 430 } 431 432 // Update writes all fields of the p to the heap object referenced by ref. 433 func (p *ConfigDescriptor) Update(ref js.Ref) { 434 bindings.ConfigDescriptorJSLoad( 435 js.Pointer(p), js.False, ref, 436 ) 437 } 438 439 // FreeMembers frees fields with heap reference, if recursive is true 440 // free all heap references reachable from p. 441 func (p *ConfigDescriptor) FreeMembers(recursive bool) { 442 js.Free( 443 p.Description.Ref(), 444 p.Interfaces.Ref(), 445 p.ExtraData.Ref(), 446 ) 447 p.Description = p.Description.FromRef(js.Undefined) 448 p.Interfaces = p.Interfaces.FromRef(js.Undefined) 449 p.ExtraData = p.ExtraData.FromRef(js.Undefined) 450 } 451 452 type ConnectionHandle struct { 453 // Handle is "ConnectionHandle.handle" 454 // 455 // Optional 456 // 457 // NOTE: FFI_USE_Handle MUST be set to true to make this field effective. 458 Handle int32 459 // VendorId is "ConnectionHandle.vendorId" 460 // 461 // Optional 462 // 463 // NOTE: FFI_USE_VendorId MUST be set to true to make this field effective. 464 VendorId int32 465 // ProductId is "ConnectionHandle.productId" 466 // 467 // Optional 468 // 469 // NOTE: FFI_USE_ProductId MUST be set to true to make this field effective. 470 ProductId int32 471 472 FFI_USE_Handle bool // for Handle. 473 FFI_USE_VendorId bool // for VendorId. 474 FFI_USE_ProductId bool // for ProductId. 475 476 FFI_USE bool 477 } 478 479 // FromRef calls UpdateFrom and returns a ConnectionHandle with all fields set. 480 func (p ConnectionHandle) FromRef(ref js.Ref) ConnectionHandle { 481 p.UpdateFrom(ref) 482 return p 483 } 484 485 // New creates a new ConnectionHandle in the application heap. 486 func (p ConnectionHandle) New() js.Ref { 487 return bindings.ConnectionHandleJSLoad( 488 js.Pointer(&p), js.True, 0, 489 ) 490 } 491 492 // UpdateFrom copies value of all fields of the heap object to p. 493 func (p *ConnectionHandle) UpdateFrom(ref js.Ref) { 494 bindings.ConnectionHandleJSStore( 495 js.Pointer(p), ref, 496 ) 497 } 498 499 // Update writes all fields of the p to the heap object referenced by ref. 500 func (p *ConnectionHandle) Update(ref js.Ref) { 501 bindings.ConnectionHandleJSLoad( 502 js.Pointer(p), js.False, ref, 503 ) 504 } 505 506 // FreeMembers frees fields with heap reference, if recursive is true 507 // free all heap references reachable from p. 508 func (p *ConnectionHandle) FreeMembers(recursive bool) { 509 } 510 511 type Recipient uint32 512 513 const ( 514 _ Recipient = iota 515 516 Recipient_DEVICE 517 Recipient__INTERFACE 518 Recipient_ENDPOINT 519 Recipient_OTHER 520 ) 521 522 func (Recipient) FromRef(str js.Ref) Recipient { 523 return Recipient(bindings.ConstOfRecipient(str)) 524 } 525 526 func (x Recipient) String() (string, bool) { 527 switch x { 528 case Recipient_DEVICE: 529 return "device", true 530 case Recipient__INTERFACE: 531 return "_interface", true 532 case Recipient_ENDPOINT: 533 return "endpoint", true 534 case Recipient_OTHER: 535 return "other", true 536 default: 537 return "", false 538 } 539 } 540 541 type RequestType uint32 542 543 const ( 544 _ RequestType = iota 545 546 RequestType_STANDARD 547 RequestType_CLASS 548 RequestType_VENDOR 549 RequestType_RESERVED 550 ) 551 552 func (RequestType) FromRef(str js.Ref) RequestType { 553 return RequestType(bindings.ConstOfRequestType(str)) 554 } 555 556 func (x RequestType) String() (string, bool) { 557 switch x { 558 case RequestType_STANDARD: 559 return "standard", true 560 case RequestType_CLASS: 561 return "class", true 562 case RequestType_VENDOR: 563 return "vendor", true 564 case RequestType_RESERVED: 565 return "reserved", true 566 default: 567 return "", false 568 } 569 } 570 571 type ControlTransferInfo struct { 572 // Direction is "ControlTransferInfo.direction" 573 // 574 // Optional 575 Direction Direction 576 // Recipient is "ControlTransferInfo.recipient" 577 // 578 // Optional 579 Recipient Recipient 580 // RequestType is "ControlTransferInfo.requestType" 581 // 582 // Optional 583 RequestType RequestType 584 // Request is "ControlTransferInfo.request" 585 // 586 // Optional 587 // 588 // NOTE: FFI_USE_Request MUST be set to true to make this field effective. 589 Request int32 590 // Value is "ControlTransferInfo.value" 591 // 592 // Optional 593 // 594 // NOTE: FFI_USE_Value MUST be set to true to make this field effective. 595 Value int32 596 // Index is "ControlTransferInfo.index" 597 // 598 // Optional 599 // 600 // NOTE: FFI_USE_Index MUST be set to true to make this field effective. 601 Index int32 602 // Length is "ControlTransferInfo.length" 603 // 604 // Optional 605 // 606 // NOTE: FFI_USE_Length MUST be set to true to make this field effective. 607 Length int32 608 // Data is "ControlTransferInfo.data" 609 // 610 // Optional 611 Data js.ArrayBuffer 612 // Timeout is "ControlTransferInfo.timeout" 613 // 614 // Optional 615 // 616 // NOTE: FFI_USE_Timeout MUST be set to true to make this field effective. 617 Timeout int32 618 619 FFI_USE_Request bool // for Request. 620 FFI_USE_Value bool // for Value. 621 FFI_USE_Index bool // for Index. 622 FFI_USE_Length bool // for Length. 623 FFI_USE_Timeout bool // for Timeout. 624 625 FFI_USE bool 626 } 627 628 // FromRef calls UpdateFrom and returns a ControlTransferInfo with all fields set. 629 func (p ControlTransferInfo) FromRef(ref js.Ref) ControlTransferInfo { 630 p.UpdateFrom(ref) 631 return p 632 } 633 634 // New creates a new ControlTransferInfo in the application heap. 635 func (p ControlTransferInfo) New() js.Ref { 636 return bindings.ControlTransferInfoJSLoad( 637 js.Pointer(&p), js.True, 0, 638 ) 639 } 640 641 // UpdateFrom copies value of all fields of the heap object to p. 642 func (p *ControlTransferInfo) UpdateFrom(ref js.Ref) { 643 bindings.ControlTransferInfoJSStore( 644 js.Pointer(p), ref, 645 ) 646 } 647 648 // Update writes all fields of the p to the heap object referenced by ref. 649 func (p *ControlTransferInfo) Update(ref js.Ref) { 650 bindings.ControlTransferInfoJSLoad( 651 js.Pointer(p), js.False, ref, 652 ) 653 } 654 655 // FreeMembers frees fields with heap reference, if recursive is true 656 // free all heap references reachable from p. 657 func (p *ControlTransferInfo) FreeMembers(recursive bool) { 658 js.Free( 659 p.Data.Ref(), 660 ) 661 p.Data = p.Data.FromRef(js.Undefined) 662 } 663 664 type Device struct { 665 // Device is "Device.device" 666 // 667 // Optional 668 // 669 // NOTE: FFI_USE_Device MUST be set to true to make this field effective. 670 Device int32 671 // VendorId is "Device.vendorId" 672 // 673 // Optional 674 // 675 // NOTE: FFI_USE_VendorId MUST be set to true to make this field effective. 676 VendorId int32 677 // ProductId is "Device.productId" 678 // 679 // Optional 680 // 681 // NOTE: FFI_USE_ProductId MUST be set to true to make this field effective. 682 ProductId int32 683 // Version is "Device.version" 684 // 685 // Optional 686 // 687 // NOTE: FFI_USE_Version MUST be set to true to make this field effective. 688 Version int32 689 // ProductName is "Device.productName" 690 // 691 // Optional 692 ProductName js.String 693 // ManufacturerName is "Device.manufacturerName" 694 // 695 // Optional 696 ManufacturerName js.String 697 // SerialNumber is "Device.serialNumber" 698 // 699 // Optional 700 SerialNumber js.String 701 702 FFI_USE_Device bool // for Device. 703 FFI_USE_VendorId bool // for VendorId. 704 FFI_USE_ProductId bool // for ProductId. 705 FFI_USE_Version bool // for Version. 706 707 FFI_USE bool 708 } 709 710 // FromRef calls UpdateFrom and returns a Device with all fields set. 711 func (p Device) FromRef(ref js.Ref) Device { 712 p.UpdateFrom(ref) 713 return p 714 } 715 716 // New creates a new Device in the application heap. 717 func (p Device) New() js.Ref { 718 return bindings.DeviceJSLoad( 719 js.Pointer(&p), js.True, 0, 720 ) 721 } 722 723 // UpdateFrom copies value of all fields of the heap object to p. 724 func (p *Device) UpdateFrom(ref js.Ref) { 725 bindings.DeviceJSStore( 726 js.Pointer(p), ref, 727 ) 728 } 729 730 // Update writes all fields of the p to the heap object referenced by ref. 731 func (p *Device) Update(ref js.Ref) { 732 bindings.DeviceJSLoad( 733 js.Pointer(p), js.False, ref, 734 ) 735 } 736 737 // FreeMembers frees fields with heap reference, if recursive is true 738 // free all heap references reachable from p. 739 func (p *Device) FreeMembers(recursive bool) { 740 js.Free( 741 p.ProductName.Ref(), 742 p.ManufacturerName.Ref(), 743 p.SerialNumber.Ref(), 744 ) 745 p.ProductName = p.ProductName.FromRef(js.Undefined) 746 p.ManufacturerName = p.ManufacturerName.FromRef(js.Undefined) 747 p.SerialNumber = p.SerialNumber.FromRef(js.Undefined) 748 } 749 750 type DeviceFilter struct { 751 // VendorId is "DeviceFilter.vendorId" 752 // 753 // Optional 754 // 755 // NOTE: FFI_USE_VendorId MUST be set to true to make this field effective. 756 VendorId int32 757 // ProductId is "DeviceFilter.productId" 758 // 759 // Optional 760 // 761 // NOTE: FFI_USE_ProductId MUST be set to true to make this field effective. 762 ProductId int32 763 // InterfaceClass is "DeviceFilter.interfaceClass" 764 // 765 // Optional 766 // 767 // NOTE: FFI_USE_InterfaceClass MUST be set to true to make this field effective. 768 InterfaceClass int32 769 // InterfaceSubclass is "DeviceFilter.interfaceSubclass" 770 // 771 // Optional 772 // 773 // NOTE: FFI_USE_InterfaceSubclass MUST be set to true to make this field effective. 774 InterfaceSubclass int32 775 // InterfaceProtocol is "DeviceFilter.interfaceProtocol" 776 // 777 // Optional 778 // 779 // NOTE: FFI_USE_InterfaceProtocol MUST be set to true to make this field effective. 780 InterfaceProtocol int32 781 782 FFI_USE_VendorId bool // for VendorId. 783 FFI_USE_ProductId bool // for ProductId. 784 FFI_USE_InterfaceClass bool // for InterfaceClass. 785 FFI_USE_InterfaceSubclass bool // for InterfaceSubclass. 786 FFI_USE_InterfaceProtocol bool // for InterfaceProtocol. 787 788 FFI_USE bool 789 } 790 791 // FromRef calls UpdateFrom and returns a DeviceFilter with all fields set. 792 func (p DeviceFilter) FromRef(ref js.Ref) DeviceFilter { 793 p.UpdateFrom(ref) 794 return p 795 } 796 797 // New creates a new DeviceFilter in the application heap. 798 func (p DeviceFilter) New() js.Ref { 799 return bindings.DeviceFilterJSLoad( 800 js.Pointer(&p), js.True, 0, 801 ) 802 } 803 804 // UpdateFrom copies value of all fields of the heap object to p. 805 func (p *DeviceFilter) UpdateFrom(ref js.Ref) { 806 bindings.DeviceFilterJSStore( 807 js.Pointer(p), ref, 808 ) 809 } 810 811 // Update writes all fields of the p to the heap object referenced by ref. 812 func (p *DeviceFilter) Update(ref js.Ref) { 813 bindings.DeviceFilterJSLoad( 814 js.Pointer(p), js.False, ref, 815 ) 816 } 817 818 // FreeMembers frees fields with heap reference, if recursive is true 819 // free all heap references reachable from p. 820 func (p *DeviceFilter) FreeMembers(recursive bool) { 821 } 822 823 type DevicePromptOptions struct { 824 // Multiple is "DevicePromptOptions.multiple" 825 // 826 // Optional 827 // 828 // NOTE: FFI_USE_Multiple MUST be set to true to make this field effective. 829 Multiple bool 830 // Filters is "DevicePromptOptions.filters" 831 // 832 // Optional 833 Filters js.Array[DeviceFilter] 834 835 FFI_USE_Multiple bool // for Multiple. 836 837 FFI_USE bool 838 } 839 840 // FromRef calls UpdateFrom and returns a DevicePromptOptions with all fields set. 841 func (p DevicePromptOptions) FromRef(ref js.Ref) DevicePromptOptions { 842 p.UpdateFrom(ref) 843 return p 844 } 845 846 // New creates a new DevicePromptOptions in the application heap. 847 func (p DevicePromptOptions) New() js.Ref { 848 return bindings.DevicePromptOptionsJSLoad( 849 js.Pointer(&p), js.True, 0, 850 ) 851 } 852 853 // UpdateFrom copies value of all fields of the heap object to p. 854 func (p *DevicePromptOptions) UpdateFrom(ref js.Ref) { 855 bindings.DevicePromptOptionsJSStore( 856 js.Pointer(p), ref, 857 ) 858 } 859 860 // Update writes all fields of the p to the heap object referenced by ref. 861 func (p *DevicePromptOptions) Update(ref js.Ref) { 862 bindings.DevicePromptOptionsJSLoad( 863 js.Pointer(p), js.False, ref, 864 ) 865 } 866 867 // FreeMembers frees fields with heap reference, if recursive is true 868 // free all heap references reachable from p. 869 func (p *DevicePromptOptions) FreeMembers(recursive bool) { 870 js.Free( 871 p.Filters.Ref(), 872 ) 873 p.Filters = p.Filters.FromRef(js.Undefined) 874 } 875 876 type EnumerateDevicesAndRequestAccessOptions struct { 877 // VendorId is "EnumerateDevicesAndRequestAccessOptions.vendorId" 878 // 879 // Optional 880 // 881 // NOTE: FFI_USE_VendorId MUST be set to true to make this field effective. 882 VendorId int32 883 // ProductId is "EnumerateDevicesAndRequestAccessOptions.productId" 884 // 885 // Optional 886 // 887 // NOTE: FFI_USE_ProductId MUST be set to true to make this field effective. 888 ProductId int32 889 // InterfaceId is "EnumerateDevicesAndRequestAccessOptions.interfaceId" 890 // 891 // Optional 892 // 893 // NOTE: FFI_USE_InterfaceId MUST be set to true to make this field effective. 894 InterfaceId int32 895 896 FFI_USE_VendorId bool // for VendorId. 897 FFI_USE_ProductId bool // for ProductId. 898 FFI_USE_InterfaceId bool // for InterfaceId. 899 900 FFI_USE bool 901 } 902 903 // FromRef calls UpdateFrom and returns a EnumerateDevicesAndRequestAccessOptions with all fields set. 904 func (p EnumerateDevicesAndRequestAccessOptions) FromRef(ref js.Ref) EnumerateDevicesAndRequestAccessOptions { 905 p.UpdateFrom(ref) 906 return p 907 } 908 909 // New creates a new EnumerateDevicesAndRequestAccessOptions in the application heap. 910 func (p EnumerateDevicesAndRequestAccessOptions) New() js.Ref { 911 return bindings.EnumerateDevicesAndRequestAccessOptionsJSLoad( 912 js.Pointer(&p), js.True, 0, 913 ) 914 } 915 916 // UpdateFrom copies value of all fields of the heap object to p. 917 func (p *EnumerateDevicesAndRequestAccessOptions) UpdateFrom(ref js.Ref) { 918 bindings.EnumerateDevicesAndRequestAccessOptionsJSStore( 919 js.Pointer(p), ref, 920 ) 921 } 922 923 // Update writes all fields of the p to the heap object referenced by ref. 924 func (p *EnumerateDevicesAndRequestAccessOptions) Update(ref js.Ref) { 925 bindings.EnumerateDevicesAndRequestAccessOptionsJSLoad( 926 js.Pointer(p), js.False, ref, 927 ) 928 } 929 930 // FreeMembers frees fields with heap reference, if recursive is true 931 // free all heap references reachable from p. 932 func (p *EnumerateDevicesAndRequestAccessOptions) FreeMembers(recursive bool) { 933 } 934 935 type EnumerateDevicesOptions struct { 936 // VendorId is "EnumerateDevicesOptions.vendorId" 937 // 938 // Optional 939 // 940 // NOTE: FFI_USE_VendorId MUST be set to true to make this field effective. 941 VendorId int32 942 // ProductId is "EnumerateDevicesOptions.productId" 943 // 944 // Optional 945 // 946 // NOTE: FFI_USE_ProductId MUST be set to true to make this field effective. 947 ProductId int32 948 // Filters is "EnumerateDevicesOptions.filters" 949 // 950 // Optional 951 Filters js.Array[DeviceFilter] 952 953 FFI_USE_VendorId bool // for VendorId. 954 FFI_USE_ProductId bool // for ProductId. 955 956 FFI_USE bool 957 } 958 959 // FromRef calls UpdateFrom and returns a EnumerateDevicesOptions with all fields set. 960 func (p EnumerateDevicesOptions) FromRef(ref js.Ref) EnumerateDevicesOptions { 961 p.UpdateFrom(ref) 962 return p 963 } 964 965 // New creates a new EnumerateDevicesOptions in the application heap. 966 func (p EnumerateDevicesOptions) New() js.Ref { 967 return bindings.EnumerateDevicesOptionsJSLoad( 968 js.Pointer(&p), js.True, 0, 969 ) 970 } 971 972 // UpdateFrom copies value of all fields of the heap object to p. 973 func (p *EnumerateDevicesOptions) UpdateFrom(ref js.Ref) { 974 bindings.EnumerateDevicesOptionsJSStore( 975 js.Pointer(p), ref, 976 ) 977 } 978 979 // Update writes all fields of the p to the heap object referenced by ref. 980 func (p *EnumerateDevicesOptions) Update(ref js.Ref) { 981 bindings.EnumerateDevicesOptionsJSLoad( 982 js.Pointer(p), js.False, ref, 983 ) 984 } 985 986 // FreeMembers frees fields with heap reference, if recursive is true 987 // free all heap references reachable from p. 988 func (p *EnumerateDevicesOptions) FreeMembers(recursive bool) { 989 js.Free( 990 p.Filters.Ref(), 991 ) 992 p.Filters = p.Filters.FromRef(js.Undefined) 993 } 994 995 type FindDevicesCallbackFunc func(this js.Ref, handles js.Array[ConnectionHandle]) js.Ref 996 997 func (fn FindDevicesCallbackFunc) Register() js.Func[func(handles js.Array[ConnectionHandle])] { 998 return js.RegisterCallback[func(handles js.Array[ConnectionHandle])]( 999 fn, abi.FuncPCABIInternal(fn), 1000 ) 1001 } 1002 1003 func (fn FindDevicesCallbackFunc) DispatchCallback( 1004 targetPC uintptr, ctx *js.CallbackContext, 1005 ) { 1006 args := ctx.Args() 1007 if len(args) != 1+1 /* js this */ || 1008 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1009 js.ThrowInvalidCallbackInvocation() 1010 } 1011 1012 if ctx.Return(fn( 1013 args[0], 1014 1015 js.Array[ConnectionHandle]{}.FromRef(args[0+1]), 1016 )) { 1017 return 1018 } 1019 1020 js.ThrowCallbackValueNotReturned() 1021 } 1022 1023 type FindDevicesCallback[T any] struct { 1024 Fn func(arg T, this js.Ref, handles js.Array[ConnectionHandle]) js.Ref 1025 Arg T 1026 } 1027 1028 func (cb *FindDevicesCallback[T]) Register() js.Func[func(handles js.Array[ConnectionHandle])] { 1029 return js.RegisterCallback[func(handles js.Array[ConnectionHandle])]( 1030 cb, abi.FuncPCABIInternal(cb.Fn), 1031 ) 1032 } 1033 1034 func (cb *FindDevicesCallback[T]) DispatchCallback( 1035 targetPC uintptr, ctx *js.CallbackContext, 1036 ) { 1037 args := ctx.Args() 1038 if len(args) != 1+1 /* js this */ || 1039 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1040 js.ThrowInvalidCallbackInvocation() 1041 } 1042 1043 if ctx.Return(cb.Fn( 1044 cb.Arg, 1045 args[0], 1046 1047 js.Array[ConnectionHandle]{}.FromRef(args[0+1]), 1048 )) { 1049 return 1050 } 1051 1052 js.ThrowCallbackValueNotReturned() 1053 } 1054 1055 type GenericTransferInfo struct { 1056 // Direction is "GenericTransferInfo.direction" 1057 // 1058 // Optional 1059 Direction Direction 1060 // Endpoint is "GenericTransferInfo.endpoint" 1061 // 1062 // Optional 1063 // 1064 // NOTE: FFI_USE_Endpoint MUST be set to true to make this field effective. 1065 Endpoint int32 1066 // Length is "GenericTransferInfo.length" 1067 // 1068 // Optional 1069 // 1070 // NOTE: FFI_USE_Length MUST be set to true to make this field effective. 1071 Length int32 1072 // Data is "GenericTransferInfo.data" 1073 // 1074 // Optional 1075 Data js.ArrayBuffer 1076 // Timeout is "GenericTransferInfo.timeout" 1077 // 1078 // Optional 1079 // 1080 // NOTE: FFI_USE_Timeout MUST be set to true to make this field effective. 1081 Timeout int32 1082 1083 FFI_USE_Endpoint bool // for Endpoint. 1084 FFI_USE_Length bool // for Length. 1085 FFI_USE_Timeout bool // for Timeout. 1086 1087 FFI_USE bool 1088 } 1089 1090 // FromRef calls UpdateFrom and returns a GenericTransferInfo with all fields set. 1091 func (p GenericTransferInfo) FromRef(ref js.Ref) GenericTransferInfo { 1092 p.UpdateFrom(ref) 1093 return p 1094 } 1095 1096 // New creates a new GenericTransferInfo in the application heap. 1097 func (p GenericTransferInfo) New() js.Ref { 1098 return bindings.GenericTransferInfoJSLoad( 1099 js.Pointer(&p), js.True, 0, 1100 ) 1101 } 1102 1103 // UpdateFrom copies value of all fields of the heap object to p. 1104 func (p *GenericTransferInfo) UpdateFrom(ref js.Ref) { 1105 bindings.GenericTransferInfoJSStore( 1106 js.Pointer(p), ref, 1107 ) 1108 } 1109 1110 // Update writes all fields of the p to the heap object referenced by ref. 1111 func (p *GenericTransferInfo) Update(ref js.Ref) { 1112 bindings.GenericTransferInfoJSLoad( 1113 js.Pointer(p), js.False, ref, 1114 ) 1115 } 1116 1117 // FreeMembers frees fields with heap reference, if recursive is true 1118 // free all heap references reachable from p. 1119 func (p *GenericTransferInfo) FreeMembers(recursive bool) { 1120 js.Free( 1121 p.Data.Ref(), 1122 ) 1123 p.Data = p.Data.FromRef(js.Undefined) 1124 } 1125 1126 type GetConfigurationCallbackFunc func(this js.Ref, config *ConfigDescriptor) js.Ref 1127 1128 func (fn GetConfigurationCallbackFunc) Register() js.Func[func(config *ConfigDescriptor)] { 1129 return js.RegisterCallback[func(config *ConfigDescriptor)]( 1130 fn, abi.FuncPCABIInternal(fn), 1131 ) 1132 } 1133 1134 func (fn GetConfigurationCallbackFunc) DispatchCallback( 1135 targetPC uintptr, ctx *js.CallbackContext, 1136 ) { 1137 args := ctx.Args() 1138 if len(args) != 1+1 /* js this */ || 1139 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1140 js.ThrowInvalidCallbackInvocation() 1141 } 1142 var arg0 ConfigDescriptor 1143 arg0.UpdateFrom(args[0+1]) 1144 defer arg0.FreeMembers(true) 1145 1146 if ctx.Return(fn( 1147 args[0], 1148 1149 mark.NoEscape(&arg0), 1150 )) { 1151 return 1152 } 1153 1154 js.ThrowCallbackValueNotReturned() 1155 } 1156 1157 type GetConfigurationCallback[T any] struct { 1158 Fn func(arg T, this js.Ref, config *ConfigDescriptor) js.Ref 1159 Arg T 1160 } 1161 1162 func (cb *GetConfigurationCallback[T]) Register() js.Func[func(config *ConfigDescriptor)] { 1163 return js.RegisterCallback[func(config *ConfigDescriptor)]( 1164 cb, abi.FuncPCABIInternal(cb.Fn), 1165 ) 1166 } 1167 1168 func (cb *GetConfigurationCallback[T]) DispatchCallback( 1169 targetPC uintptr, ctx *js.CallbackContext, 1170 ) { 1171 args := ctx.Args() 1172 if len(args) != 1+1 /* js this */ || 1173 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1174 js.ThrowInvalidCallbackInvocation() 1175 } 1176 var arg0 ConfigDescriptor 1177 arg0.UpdateFrom(args[0+1]) 1178 defer arg0.FreeMembers(true) 1179 1180 if ctx.Return(cb.Fn( 1181 cb.Arg, 1182 args[0], 1183 1184 mark.NoEscape(&arg0), 1185 )) { 1186 return 1187 } 1188 1189 js.ThrowCallbackValueNotReturned() 1190 } 1191 1192 type GetConfigurationsCallbackFunc func(this js.Ref, configs js.Array[ConfigDescriptor]) js.Ref 1193 1194 func (fn GetConfigurationsCallbackFunc) Register() js.Func[func(configs js.Array[ConfigDescriptor])] { 1195 return js.RegisterCallback[func(configs js.Array[ConfigDescriptor])]( 1196 fn, abi.FuncPCABIInternal(fn), 1197 ) 1198 } 1199 1200 func (fn GetConfigurationsCallbackFunc) DispatchCallback( 1201 targetPC uintptr, ctx *js.CallbackContext, 1202 ) { 1203 args := ctx.Args() 1204 if len(args) != 1+1 /* js this */ || 1205 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1206 js.ThrowInvalidCallbackInvocation() 1207 } 1208 1209 if ctx.Return(fn( 1210 args[0], 1211 1212 js.Array[ConfigDescriptor]{}.FromRef(args[0+1]), 1213 )) { 1214 return 1215 } 1216 1217 js.ThrowCallbackValueNotReturned() 1218 } 1219 1220 type GetConfigurationsCallback[T any] struct { 1221 Fn func(arg T, this js.Ref, configs js.Array[ConfigDescriptor]) js.Ref 1222 Arg T 1223 } 1224 1225 func (cb *GetConfigurationsCallback[T]) Register() js.Func[func(configs js.Array[ConfigDescriptor])] { 1226 return js.RegisterCallback[func(configs js.Array[ConfigDescriptor])]( 1227 cb, abi.FuncPCABIInternal(cb.Fn), 1228 ) 1229 } 1230 1231 func (cb *GetConfigurationsCallback[T]) DispatchCallback( 1232 targetPC uintptr, ctx *js.CallbackContext, 1233 ) { 1234 args := ctx.Args() 1235 if len(args) != 1+1 /* js this */ || 1236 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1237 js.ThrowInvalidCallbackInvocation() 1238 } 1239 1240 if ctx.Return(cb.Fn( 1241 cb.Arg, 1242 args[0], 1243 1244 js.Array[ConfigDescriptor]{}.FromRef(args[0+1]), 1245 )) { 1246 return 1247 } 1248 1249 js.ThrowCallbackValueNotReturned() 1250 } 1251 1252 type GetDevicesCallbackFunc func(this js.Ref, devices js.Array[Device]) js.Ref 1253 1254 func (fn GetDevicesCallbackFunc) Register() js.Func[func(devices js.Array[Device])] { 1255 return js.RegisterCallback[func(devices js.Array[Device])]( 1256 fn, abi.FuncPCABIInternal(fn), 1257 ) 1258 } 1259 1260 func (fn GetDevicesCallbackFunc) DispatchCallback( 1261 targetPC uintptr, ctx *js.CallbackContext, 1262 ) { 1263 args := ctx.Args() 1264 if len(args) != 1+1 /* js this */ || 1265 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1266 js.ThrowInvalidCallbackInvocation() 1267 } 1268 1269 if ctx.Return(fn( 1270 args[0], 1271 1272 js.Array[Device]{}.FromRef(args[0+1]), 1273 )) { 1274 return 1275 } 1276 1277 js.ThrowCallbackValueNotReturned() 1278 } 1279 1280 type GetDevicesCallback[T any] struct { 1281 Fn func(arg T, this js.Ref, devices js.Array[Device]) js.Ref 1282 Arg T 1283 } 1284 1285 func (cb *GetDevicesCallback[T]) Register() js.Func[func(devices js.Array[Device])] { 1286 return js.RegisterCallback[func(devices js.Array[Device])]( 1287 cb, abi.FuncPCABIInternal(cb.Fn), 1288 ) 1289 } 1290 1291 func (cb *GetDevicesCallback[T]) DispatchCallback( 1292 targetPC uintptr, ctx *js.CallbackContext, 1293 ) { 1294 args := ctx.Args() 1295 if len(args) != 1+1 /* js this */ || 1296 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1297 js.ThrowInvalidCallbackInvocation() 1298 } 1299 1300 if ctx.Return(cb.Fn( 1301 cb.Arg, 1302 args[0], 1303 1304 js.Array[Device]{}.FromRef(args[0+1]), 1305 )) { 1306 return 1307 } 1308 1309 js.ThrowCallbackValueNotReturned() 1310 } 1311 1312 type IsochronousTransferInfo struct { 1313 // TransferInfo is "IsochronousTransferInfo.transferInfo" 1314 // 1315 // Optional 1316 // 1317 // NOTE: TransferInfo.FFI_USE MUST be set to true to get TransferInfo used. 1318 TransferInfo GenericTransferInfo 1319 // Packets is "IsochronousTransferInfo.packets" 1320 // 1321 // Optional 1322 // 1323 // NOTE: FFI_USE_Packets MUST be set to true to make this field effective. 1324 Packets int32 1325 // PacketLength is "IsochronousTransferInfo.packetLength" 1326 // 1327 // Optional 1328 // 1329 // NOTE: FFI_USE_PacketLength MUST be set to true to make this field effective. 1330 PacketLength int32 1331 1332 FFI_USE_Packets bool // for Packets. 1333 FFI_USE_PacketLength bool // for PacketLength. 1334 1335 FFI_USE bool 1336 } 1337 1338 // FromRef calls UpdateFrom and returns a IsochronousTransferInfo with all fields set. 1339 func (p IsochronousTransferInfo) FromRef(ref js.Ref) IsochronousTransferInfo { 1340 p.UpdateFrom(ref) 1341 return p 1342 } 1343 1344 // New creates a new IsochronousTransferInfo in the application heap. 1345 func (p IsochronousTransferInfo) New() js.Ref { 1346 return bindings.IsochronousTransferInfoJSLoad( 1347 js.Pointer(&p), js.True, 0, 1348 ) 1349 } 1350 1351 // UpdateFrom copies value of all fields of the heap object to p. 1352 func (p *IsochronousTransferInfo) UpdateFrom(ref js.Ref) { 1353 bindings.IsochronousTransferInfoJSStore( 1354 js.Pointer(p), ref, 1355 ) 1356 } 1357 1358 // Update writes all fields of the p to the heap object referenced by ref. 1359 func (p *IsochronousTransferInfo) Update(ref js.Ref) { 1360 bindings.IsochronousTransferInfoJSLoad( 1361 js.Pointer(p), js.False, ref, 1362 ) 1363 } 1364 1365 // FreeMembers frees fields with heap reference, if recursive is true 1366 // free all heap references reachable from p. 1367 func (p *IsochronousTransferInfo) FreeMembers(recursive bool) { 1368 if recursive { 1369 p.TransferInfo.FreeMembers(true) 1370 } 1371 } 1372 1373 type ListInterfacesCallbackFunc func(this js.Ref, descriptors js.Array[InterfaceDescriptor]) js.Ref 1374 1375 func (fn ListInterfacesCallbackFunc) Register() js.Func[func(descriptors js.Array[InterfaceDescriptor])] { 1376 return js.RegisterCallback[func(descriptors js.Array[InterfaceDescriptor])]( 1377 fn, abi.FuncPCABIInternal(fn), 1378 ) 1379 } 1380 1381 func (fn ListInterfacesCallbackFunc) DispatchCallback( 1382 targetPC uintptr, ctx *js.CallbackContext, 1383 ) { 1384 args := ctx.Args() 1385 if len(args) != 1+1 /* js this */ || 1386 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1387 js.ThrowInvalidCallbackInvocation() 1388 } 1389 1390 if ctx.Return(fn( 1391 args[0], 1392 1393 js.Array[InterfaceDescriptor]{}.FromRef(args[0+1]), 1394 )) { 1395 return 1396 } 1397 1398 js.ThrowCallbackValueNotReturned() 1399 } 1400 1401 type ListInterfacesCallback[T any] struct { 1402 Fn func(arg T, this js.Ref, descriptors js.Array[InterfaceDescriptor]) js.Ref 1403 Arg T 1404 } 1405 1406 func (cb *ListInterfacesCallback[T]) Register() js.Func[func(descriptors js.Array[InterfaceDescriptor])] { 1407 return js.RegisterCallback[func(descriptors js.Array[InterfaceDescriptor])]( 1408 cb, abi.FuncPCABIInternal(cb.Fn), 1409 ) 1410 } 1411 1412 func (cb *ListInterfacesCallback[T]) DispatchCallback( 1413 targetPC uintptr, ctx *js.CallbackContext, 1414 ) { 1415 args := ctx.Args() 1416 if len(args) != 1+1 /* js this */ || 1417 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1418 js.ThrowInvalidCallbackInvocation() 1419 } 1420 1421 if ctx.Return(cb.Fn( 1422 cb.Arg, 1423 args[0], 1424 1425 js.Array[InterfaceDescriptor]{}.FromRef(args[0+1]), 1426 )) { 1427 return 1428 } 1429 1430 js.ThrowCallbackValueNotReturned() 1431 } 1432 1433 type OpenDeviceCallbackFunc func(this js.Ref, handle *ConnectionHandle) js.Ref 1434 1435 func (fn OpenDeviceCallbackFunc) Register() js.Func[func(handle *ConnectionHandle)] { 1436 return js.RegisterCallback[func(handle *ConnectionHandle)]( 1437 fn, abi.FuncPCABIInternal(fn), 1438 ) 1439 } 1440 1441 func (fn OpenDeviceCallbackFunc) DispatchCallback( 1442 targetPC uintptr, ctx *js.CallbackContext, 1443 ) { 1444 args := ctx.Args() 1445 if len(args) != 1+1 /* js this */ || 1446 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1447 js.ThrowInvalidCallbackInvocation() 1448 } 1449 var arg0 ConnectionHandle 1450 arg0.UpdateFrom(args[0+1]) 1451 defer arg0.FreeMembers(true) 1452 1453 if ctx.Return(fn( 1454 args[0], 1455 1456 mark.NoEscape(&arg0), 1457 )) { 1458 return 1459 } 1460 1461 js.ThrowCallbackValueNotReturned() 1462 } 1463 1464 type OpenDeviceCallback[T any] struct { 1465 Fn func(arg T, this js.Ref, handle *ConnectionHandle) js.Ref 1466 Arg T 1467 } 1468 1469 func (cb *OpenDeviceCallback[T]) Register() js.Func[func(handle *ConnectionHandle)] { 1470 return js.RegisterCallback[func(handle *ConnectionHandle)]( 1471 cb, abi.FuncPCABIInternal(cb.Fn), 1472 ) 1473 } 1474 1475 func (cb *OpenDeviceCallback[T]) DispatchCallback( 1476 targetPC uintptr, ctx *js.CallbackContext, 1477 ) { 1478 args := ctx.Args() 1479 if len(args) != 1+1 /* js this */ || 1480 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1481 js.ThrowInvalidCallbackInvocation() 1482 } 1483 var arg0 ConnectionHandle 1484 arg0.UpdateFrom(args[0+1]) 1485 defer arg0.FreeMembers(true) 1486 1487 if ctx.Return(cb.Fn( 1488 cb.Arg, 1489 args[0], 1490 1491 mark.NoEscape(&arg0), 1492 )) { 1493 return 1494 } 1495 1496 js.ThrowCallbackValueNotReturned() 1497 } 1498 1499 type RequestAccessCallbackFunc func(this js.Ref, success bool) js.Ref 1500 1501 func (fn RequestAccessCallbackFunc) Register() js.Func[func(success bool)] { 1502 return js.RegisterCallback[func(success bool)]( 1503 fn, abi.FuncPCABIInternal(fn), 1504 ) 1505 } 1506 1507 func (fn RequestAccessCallbackFunc) DispatchCallback( 1508 targetPC uintptr, ctx *js.CallbackContext, 1509 ) { 1510 args := ctx.Args() 1511 if len(args) != 1+1 /* js this */ || 1512 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1513 js.ThrowInvalidCallbackInvocation() 1514 } 1515 1516 if ctx.Return(fn( 1517 args[0], 1518 1519 args[0+1] == js.True, 1520 )) { 1521 return 1522 } 1523 1524 js.ThrowCallbackValueNotReturned() 1525 } 1526 1527 type RequestAccessCallback[T any] struct { 1528 Fn func(arg T, this js.Ref, success bool) js.Ref 1529 Arg T 1530 } 1531 1532 func (cb *RequestAccessCallback[T]) Register() js.Func[func(success bool)] { 1533 return js.RegisterCallback[func(success bool)]( 1534 cb, abi.FuncPCABIInternal(cb.Fn), 1535 ) 1536 } 1537 1538 func (cb *RequestAccessCallback[T]) DispatchCallback( 1539 targetPC uintptr, ctx *js.CallbackContext, 1540 ) { 1541 args := ctx.Args() 1542 if len(args) != 1+1 /* js this */ || 1543 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1544 js.ThrowInvalidCallbackInvocation() 1545 } 1546 1547 if ctx.Return(cb.Fn( 1548 cb.Arg, 1549 args[0], 1550 1551 args[0+1] == js.True, 1552 )) { 1553 return 1554 } 1555 1556 js.ThrowCallbackValueNotReturned() 1557 } 1558 1559 type ResetDeviceCallbackFunc func(this js.Ref, success bool) js.Ref 1560 1561 func (fn ResetDeviceCallbackFunc) Register() js.Func[func(success bool)] { 1562 return js.RegisterCallback[func(success bool)]( 1563 fn, abi.FuncPCABIInternal(fn), 1564 ) 1565 } 1566 1567 func (fn ResetDeviceCallbackFunc) DispatchCallback( 1568 targetPC uintptr, ctx *js.CallbackContext, 1569 ) { 1570 args := ctx.Args() 1571 if len(args) != 1+1 /* js this */ || 1572 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1573 js.ThrowInvalidCallbackInvocation() 1574 } 1575 1576 if ctx.Return(fn( 1577 args[0], 1578 1579 args[0+1] == js.True, 1580 )) { 1581 return 1582 } 1583 1584 js.ThrowCallbackValueNotReturned() 1585 } 1586 1587 type ResetDeviceCallback[T any] struct { 1588 Fn func(arg T, this js.Ref, success bool) js.Ref 1589 Arg T 1590 } 1591 1592 func (cb *ResetDeviceCallback[T]) Register() js.Func[func(success bool)] { 1593 return js.RegisterCallback[func(success bool)]( 1594 cb, abi.FuncPCABIInternal(cb.Fn), 1595 ) 1596 } 1597 1598 func (cb *ResetDeviceCallback[T]) DispatchCallback( 1599 targetPC uintptr, ctx *js.CallbackContext, 1600 ) { 1601 args := ctx.Args() 1602 if len(args) != 1+1 /* js this */ || 1603 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1604 js.ThrowInvalidCallbackInvocation() 1605 } 1606 1607 if ctx.Return(cb.Fn( 1608 cb.Arg, 1609 args[0], 1610 1611 args[0+1] == js.True, 1612 )) { 1613 return 1614 } 1615 1616 js.ThrowCallbackValueNotReturned() 1617 } 1618 1619 type TransferCallbackFunc func(this js.Ref, info *TransferResultInfo) js.Ref 1620 1621 func (fn TransferCallbackFunc) Register() js.Func[func(info *TransferResultInfo)] { 1622 return js.RegisterCallback[func(info *TransferResultInfo)]( 1623 fn, abi.FuncPCABIInternal(fn), 1624 ) 1625 } 1626 1627 func (fn TransferCallbackFunc) DispatchCallback( 1628 targetPC uintptr, ctx *js.CallbackContext, 1629 ) { 1630 args := ctx.Args() 1631 if len(args) != 1+1 /* js this */ || 1632 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1633 js.ThrowInvalidCallbackInvocation() 1634 } 1635 var arg0 TransferResultInfo 1636 arg0.UpdateFrom(args[0+1]) 1637 defer arg0.FreeMembers(true) 1638 1639 if ctx.Return(fn( 1640 args[0], 1641 1642 mark.NoEscape(&arg0), 1643 )) { 1644 return 1645 } 1646 1647 js.ThrowCallbackValueNotReturned() 1648 } 1649 1650 type TransferCallback[T any] struct { 1651 Fn func(arg T, this js.Ref, info *TransferResultInfo) js.Ref 1652 Arg T 1653 } 1654 1655 func (cb *TransferCallback[T]) Register() js.Func[func(info *TransferResultInfo)] { 1656 return js.RegisterCallback[func(info *TransferResultInfo)]( 1657 cb, abi.FuncPCABIInternal(cb.Fn), 1658 ) 1659 } 1660 1661 func (cb *TransferCallback[T]) DispatchCallback( 1662 targetPC uintptr, ctx *js.CallbackContext, 1663 ) { 1664 args := ctx.Args() 1665 if len(args) != 1+1 /* js this */ || 1666 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1667 js.ThrowInvalidCallbackInvocation() 1668 } 1669 var arg0 TransferResultInfo 1670 arg0.UpdateFrom(args[0+1]) 1671 defer arg0.FreeMembers(true) 1672 1673 if ctx.Return(cb.Fn( 1674 cb.Arg, 1675 args[0], 1676 1677 mark.NoEscape(&arg0), 1678 )) { 1679 return 1680 } 1681 1682 js.ThrowCallbackValueNotReturned() 1683 } 1684 1685 type TransferResultInfo struct { 1686 // ResultCode is "TransferResultInfo.resultCode" 1687 // 1688 // Optional 1689 // 1690 // NOTE: FFI_USE_ResultCode MUST be set to true to make this field effective. 1691 ResultCode int32 1692 // Data is "TransferResultInfo.data" 1693 // 1694 // Optional 1695 Data js.ArrayBuffer 1696 1697 FFI_USE_ResultCode bool // for ResultCode. 1698 1699 FFI_USE bool 1700 } 1701 1702 // FromRef calls UpdateFrom and returns a TransferResultInfo with all fields set. 1703 func (p TransferResultInfo) FromRef(ref js.Ref) TransferResultInfo { 1704 p.UpdateFrom(ref) 1705 return p 1706 } 1707 1708 // New creates a new TransferResultInfo in the application heap. 1709 func (p TransferResultInfo) New() js.Ref { 1710 return bindings.TransferResultInfoJSLoad( 1711 js.Pointer(&p), js.True, 0, 1712 ) 1713 } 1714 1715 // UpdateFrom copies value of all fields of the heap object to p. 1716 func (p *TransferResultInfo) UpdateFrom(ref js.Ref) { 1717 bindings.TransferResultInfoJSStore( 1718 js.Pointer(p), ref, 1719 ) 1720 } 1721 1722 // Update writes all fields of the p to the heap object referenced by ref. 1723 func (p *TransferResultInfo) Update(ref js.Ref) { 1724 bindings.TransferResultInfoJSLoad( 1725 js.Pointer(p), js.False, ref, 1726 ) 1727 } 1728 1729 // FreeMembers frees fields with heap reference, if recursive is true 1730 // free all heap references reachable from p. 1731 func (p *TransferResultInfo) FreeMembers(recursive bool) { 1732 js.Free( 1733 p.Data.Ref(), 1734 ) 1735 p.Data = p.Data.FromRef(js.Undefined) 1736 } 1737 1738 type VoidCallbackFunc func(this js.Ref) js.Ref 1739 1740 func (fn VoidCallbackFunc) Register() js.Func[func()] { 1741 return js.RegisterCallback[func()]( 1742 fn, abi.FuncPCABIInternal(fn), 1743 ) 1744 } 1745 1746 func (fn VoidCallbackFunc) DispatchCallback( 1747 targetPC uintptr, ctx *js.CallbackContext, 1748 ) { 1749 args := ctx.Args() 1750 if len(args) != 0+1 /* js this */ || 1751 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1752 js.ThrowInvalidCallbackInvocation() 1753 } 1754 1755 if ctx.Return(fn( 1756 args[0], 1757 )) { 1758 return 1759 } 1760 1761 js.ThrowCallbackValueNotReturned() 1762 } 1763 1764 type VoidCallback[T any] struct { 1765 Fn func(arg T, this js.Ref) js.Ref 1766 Arg T 1767 } 1768 1769 func (cb *VoidCallback[T]) Register() js.Func[func()] { 1770 return js.RegisterCallback[func()]( 1771 cb, abi.FuncPCABIInternal(cb.Fn), 1772 ) 1773 } 1774 1775 func (cb *VoidCallback[T]) DispatchCallback( 1776 targetPC uintptr, ctx *js.CallbackContext, 1777 ) { 1778 args := ctx.Args() 1779 if len(args) != 0+1 /* js this */ || 1780 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1781 js.ThrowInvalidCallbackInvocation() 1782 } 1783 1784 if ctx.Return(cb.Fn( 1785 cb.Arg, 1786 args[0], 1787 )) { 1788 return 1789 } 1790 1791 js.ThrowCallbackValueNotReturned() 1792 } 1793 1794 // HasFuncBulkTransfer returns true if the function "WEBEXT.usb.bulkTransfer" exists. 1795 func HasFuncBulkTransfer() bool { 1796 return js.True == bindings.HasFuncBulkTransfer() 1797 } 1798 1799 // FuncBulkTransfer returns the function "WEBEXT.usb.bulkTransfer". 1800 func FuncBulkTransfer() (fn js.Func[func(handle ConnectionHandle, transferInfo GenericTransferInfo) js.Promise[TransferResultInfo]]) { 1801 bindings.FuncBulkTransfer( 1802 js.Pointer(&fn), 1803 ) 1804 return 1805 } 1806 1807 // BulkTransfer calls the function "WEBEXT.usb.bulkTransfer" directly. 1808 func BulkTransfer(handle ConnectionHandle, transferInfo GenericTransferInfo) (ret js.Promise[TransferResultInfo]) { 1809 bindings.CallBulkTransfer( 1810 js.Pointer(&ret), 1811 js.Pointer(&handle), 1812 js.Pointer(&transferInfo), 1813 ) 1814 1815 return 1816 } 1817 1818 // TryBulkTransfer calls the function "WEBEXT.usb.bulkTransfer" 1819 // in a try/catch block and returns (_, err, ok = false) when it went through 1820 // the catch clause. 1821 func TryBulkTransfer(handle ConnectionHandle, transferInfo GenericTransferInfo) (ret js.Promise[TransferResultInfo], exception js.Any, ok bool) { 1822 ok = js.True == bindings.TryBulkTransfer( 1823 js.Pointer(&ret), js.Pointer(&exception), 1824 js.Pointer(&handle), 1825 js.Pointer(&transferInfo), 1826 ) 1827 1828 return 1829 } 1830 1831 // HasFuncClaimInterface returns true if the function "WEBEXT.usb.claimInterface" exists. 1832 func HasFuncClaimInterface() bool { 1833 return js.True == bindings.HasFuncClaimInterface() 1834 } 1835 1836 // FuncClaimInterface returns the function "WEBEXT.usb.claimInterface". 1837 func FuncClaimInterface() (fn js.Func[func(handle ConnectionHandle, interfaceNumber int32) js.Promise[js.Void]]) { 1838 bindings.FuncClaimInterface( 1839 js.Pointer(&fn), 1840 ) 1841 return 1842 } 1843 1844 // ClaimInterface calls the function "WEBEXT.usb.claimInterface" directly. 1845 func ClaimInterface(handle ConnectionHandle, interfaceNumber int32) (ret js.Promise[js.Void]) { 1846 bindings.CallClaimInterface( 1847 js.Pointer(&ret), 1848 js.Pointer(&handle), 1849 int32(interfaceNumber), 1850 ) 1851 1852 return 1853 } 1854 1855 // TryClaimInterface calls the function "WEBEXT.usb.claimInterface" 1856 // in a try/catch block and returns (_, err, ok = false) when it went through 1857 // the catch clause. 1858 func TryClaimInterface(handle ConnectionHandle, interfaceNumber int32) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1859 ok = js.True == bindings.TryClaimInterface( 1860 js.Pointer(&ret), js.Pointer(&exception), 1861 js.Pointer(&handle), 1862 int32(interfaceNumber), 1863 ) 1864 1865 return 1866 } 1867 1868 // HasFuncCloseDevice returns true if the function "WEBEXT.usb.closeDevice" exists. 1869 func HasFuncCloseDevice() bool { 1870 return js.True == bindings.HasFuncCloseDevice() 1871 } 1872 1873 // FuncCloseDevice returns the function "WEBEXT.usb.closeDevice". 1874 func FuncCloseDevice() (fn js.Func[func(handle ConnectionHandle) js.Promise[js.Void]]) { 1875 bindings.FuncCloseDevice( 1876 js.Pointer(&fn), 1877 ) 1878 return 1879 } 1880 1881 // CloseDevice calls the function "WEBEXT.usb.closeDevice" directly. 1882 func CloseDevice(handle ConnectionHandle) (ret js.Promise[js.Void]) { 1883 bindings.CallCloseDevice( 1884 js.Pointer(&ret), 1885 js.Pointer(&handle), 1886 ) 1887 1888 return 1889 } 1890 1891 // TryCloseDevice calls the function "WEBEXT.usb.closeDevice" 1892 // in a try/catch block and returns (_, err, ok = false) when it went through 1893 // the catch clause. 1894 func TryCloseDevice(handle ConnectionHandle) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1895 ok = js.True == bindings.TryCloseDevice( 1896 js.Pointer(&ret), js.Pointer(&exception), 1897 js.Pointer(&handle), 1898 ) 1899 1900 return 1901 } 1902 1903 // HasFuncControlTransfer returns true if the function "WEBEXT.usb.controlTransfer" exists. 1904 func HasFuncControlTransfer() bool { 1905 return js.True == bindings.HasFuncControlTransfer() 1906 } 1907 1908 // FuncControlTransfer returns the function "WEBEXT.usb.controlTransfer". 1909 func FuncControlTransfer() (fn js.Func[func(handle ConnectionHandle, transferInfo ControlTransferInfo) js.Promise[TransferResultInfo]]) { 1910 bindings.FuncControlTransfer( 1911 js.Pointer(&fn), 1912 ) 1913 return 1914 } 1915 1916 // ControlTransfer calls the function "WEBEXT.usb.controlTransfer" directly. 1917 func ControlTransfer(handle ConnectionHandle, transferInfo ControlTransferInfo) (ret js.Promise[TransferResultInfo]) { 1918 bindings.CallControlTransfer( 1919 js.Pointer(&ret), 1920 js.Pointer(&handle), 1921 js.Pointer(&transferInfo), 1922 ) 1923 1924 return 1925 } 1926 1927 // TryControlTransfer calls the function "WEBEXT.usb.controlTransfer" 1928 // in a try/catch block and returns (_, err, ok = false) when it went through 1929 // the catch clause. 1930 func TryControlTransfer(handle ConnectionHandle, transferInfo ControlTransferInfo) (ret js.Promise[TransferResultInfo], exception js.Any, ok bool) { 1931 ok = js.True == bindings.TryControlTransfer( 1932 js.Pointer(&ret), js.Pointer(&exception), 1933 js.Pointer(&handle), 1934 js.Pointer(&transferInfo), 1935 ) 1936 1937 return 1938 } 1939 1940 // HasFuncFindDevices returns true if the function "WEBEXT.usb.findDevices" exists. 1941 func HasFuncFindDevices() bool { 1942 return js.True == bindings.HasFuncFindDevices() 1943 } 1944 1945 // FuncFindDevices returns the function "WEBEXT.usb.findDevices". 1946 func FuncFindDevices() (fn js.Func[func(options EnumerateDevicesAndRequestAccessOptions) js.Promise[js.Array[ConnectionHandle]]]) { 1947 bindings.FuncFindDevices( 1948 js.Pointer(&fn), 1949 ) 1950 return 1951 } 1952 1953 // FindDevices calls the function "WEBEXT.usb.findDevices" directly. 1954 func FindDevices(options EnumerateDevicesAndRequestAccessOptions) (ret js.Promise[js.Array[ConnectionHandle]]) { 1955 bindings.CallFindDevices( 1956 js.Pointer(&ret), 1957 js.Pointer(&options), 1958 ) 1959 1960 return 1961 } 1962 1963 // TryFindDevices calls the function "WEBEXT.usb.findDevices" 1964 // in a try/catch block and returns (_, err, ok = false) when it went through 1965 // the catch clause. 1966 func TryFindDevices(options EnumerateDevicesAndRequestAccessOptions) (ret js.Promise[js.Array[ConnectionHandle]], exception js.Any, ok bool) { 1967 ok = js.True == bindings.TryFindDevices( 1968 js.Pointer(&ret), js.Pointer(&exception), 1969 js.Pointer(&options), 1970 ) 1971 1972 return 1973 } 1974 1975 // HasFuncGetConfiguration returns true if the function "WEBEXT.usb.getConfiguration" exists. 1976 func HasFuncGetConfiguration() bool { 1977 return js.True == bindings.HasFuncGetConfiguration() 1978 } 1979 1980 // FuncGetConfiguration returns the function "WEBEXT.usb.getConfiguration". 1981 func FuncGetConfiguration() (fn js.Func[func(handle ConnectionHandle) js.Promise[ConfigDescriptor]]) { 1982 bindings.FuncGetConfiguration( 1983 js.Pointer(&fn), 1984 ) 1985 return 1986 } 1987 1988 // GetConfiguration calls the function "WEBEXT.usb.getConfiguration" directly. 1989 func GetConfiguration(handle ConnectionHandle) (ret js.Promise[ConfigDescriptor]) { 1990 bindings.CallGetConfiguration( 1991 js.Pointer(&ret), 1992 js.Pointer(&handle), 1993 ) 1994 1995 return 1996 } 1997 1998 // TryGetConfiguration calls the function "WEBEXT.usb.getConfiguration" 1999 // in a try/catch block and returns (_, err, ok = false) when it went through 2000 // the catch clause. 2001 func TryGetConfiguration(handle ConnectionHandle) (ret js.Promise[ConfigDescriptor], exception js.Any, ok bool) { 2002 ok = js.True == bindings.TryGetConfiguration( 2003 js.Pointer(&ret), js.Pointer(&exception), 2004 js.Pointer(&handle), 2005 ) 2006 2007 return 2008 } 2009 2010 // HasFuncGetConfigurations returns true if the function "WEBEXT.usb.getConfigurations" exists. 2011 func HasFuncGetConfigurations() bool { 2012 return js.True == bindings.HasFuncGetConfigurations() 2013 } 2014 2015 // FuncGetConfigurations returns the function "WEBEXT.usb.getConfigurations". 2016 func FuncGetConfigurations() (fn js.Func[func(device Device) js.Promise[js.Array[ConfigDescriptor]]]) { 2017 bindings.FuncGetConfigurations( 2018 js.Pointer(&fn), 2019 ) 2020 return 2021 } 2022 2023 // GetConfigurations calls the function "WEBEXT.usb.getConfigurations" directly. 2024 func GetConfigurations(device Device) (ret js.Promise[js.Array[ConfigDescriptor]]) { 2025 bindings.CallGetConfigurations( 2026 js.Pointer(&ret), 2027 js.Pointer(&device), 2028 ) 2029 2030 return 2031 } 2032 2033 // TryGetConfigurations calls the function "WEBEXT.usb.getConfigurations" 2034 // in a try/catch block and returns (_, err, ok = false) when it went through 2035 // the catch clause. 2036 func TryGetConfigurations(device Device) (ret js.Promise[js.Array[ConfigDescriptor]], exception js.Any, ok bool) { 2037 ok = js.True == bindings.TryGetConfigurations( 2038 js.Pointer(&ret), js.Pointer(&exception), 2039 js.Pointer(&device), 2040 ) 2041 2042 return 2043 } 2044 2045 // HasFuncGetDevices returns true if the function "WEBEXT.usb.getDevices" exists. 2046 func HasFuncGetDevices() bool { 2047 return js.True == bindings.HasFuncGetDevices() 2048 } 2049 2050 // FuncGetDevices returns the function "WEBEXT.usb.getDevices". 2051 func FuncGetDevices() (fn js.Func[func(options EnumerateDevicesOptions) js.Promise[js.Array[Device]]]) { 2052 bindings.FuncGetDevices( 2053 js.Pointer(&fn), 2054 ) 2055 return 2056 } 2057 2058 // GetDevices calls the function "WEBEXT.usb.getDevices" directly. 2059 func GetDevices(options EnumerateDevicesOptions) (ret js.Promise[js.Array[Device]]) { 2060 bindings.CallGetDevices( 2061 js.Pointer(&ret), 2062 js.Pointer(&options), 2063 ) 2064 2065 return 2066 } 2067 2068 // TryGetDevices calls the function "WEBEXT.usb.getDevices" 2069 // in a try/catch block and returns (_, err, ok = false) when it went through 2070 // the catch clause. 2071 func TryGetDevices(options EnumerateDevicesOptions) (ret js.Promise[js.Array[Device]], exception js.Any, ok bool) { 2072 ok = js.True == bindings.TryGetDevices( 2073 js.Pointer(&ret), js.Pointer(&exception), 2074 js.Pointer(&options), 2075 ) 2076 2077 return 2078 } 2079 2080 // HasFuncGetUserSelectedDevices returns true if the function "WEBEXT.usb.getUserSelectedDevices" exists. 2081 func HasFuncGetUserSelectedDevices() bool { 2082 return js.True == bindings.HasFuncGetUserSelectedDevices() 2083 } 2084 2085 // FuncGetUserSelectedDevices returns the function "WEBEXT.usb.getUserSelectedDevices". 2086 func FuncGetUserSelectedDevices() (fn js.Func[func(options DevicePromptOptions) js.Promise[js.Array[Device]]]) { 2087 bindings.FuncGetUserSelectedDevices( 2088 js.Pointer(&fn), 2089 ) 2090 return 2091 } 2092 2093 // GetUserSelectedDevices calls the function "WEBEXT.usb.getUserSelectedDevices" directly. 2094 func GetUserSelectedDevices(options DevicePromptOptions) (ret js.Promise[js.Array[Device]]) { 2095 bindings.CallGetUserSelectedDevices( 2096 js.Pointer(&ret), 2097 js.Pointer(&options), 2098 ) 2099 2100 return 2101 } 2102 2103 // TryGetUserSelectedDevices calls the function "WEBEXT.usb.getUserSelectedDevices" 2104 // in a try/catch block and returns (_, err, ok = false) when it went through 2105 // the catch clause. 2106 func TryGetUserSelectedDevices(options DevicePromptOptions) (ret js.Promise[js.Array[Device]], exception js.Any, ok bool) { 2107 ok = js.True == bindings.TryGetUserSelectedDevices( 2108 js.Pointer(&ret), js.Pointer(&exception), 2109 js.Pointer(&options), 2110 ) 2111 2112 return 2113 } 2114 2115 // HasFuncInterruptTransfer returns true if the function "WEBEXT.usb.interruptTransfer" exists. 2116 func HasFuncInterruptTransfer() bool { 2117 return js.True == bindings.HasFuncInterruptTransfer() 2118 } 2119 2120 // FuncInterruptTransfer returns the function "WEBEXT.usb.interruptTransfer". 2121 func FuncInterruptTransfer() (fn js.Func[func(handle ConnectionHandle, transferInfo GenericTransferInfo) js.Promise[TransferResultInfo]]) { 2122 bindings.FuncInterruptTransfer( 2123 js.Pointer(&fn), 2124 ) 2125 return 2126 } 2127 2128 // InterruptTransfer calls the function "WEBEXT.usb.interruptTransfer" directly. 2129 func InterruptTransfer(handle ConnectionHandle, transferInfo GenericTransferInfo) (ret js.Promise[TransferResultInfo]) { 2130 bindings.CallInterruptTransfer( 2131 js.Pointer(&ret), 2132 js.Pointer(&handle), 2133 js.Pointer(&transferInfo), 2134 ) 2135 2136 return 2137 } 2138 2139 // TryInterruptTransfer calls the function "WEBEXT.usb.interruptTransfer" 2140 // in a try/catch block and returns (_, err, ok = false) when it went through 2141 // the catch clause. 2142 func TryInterruptTransfer(handle ConnectionHandle, transferInfo GenericTransferInfo) (ret js.Promise[TransferResultInfo], exception js.Any, ok bool) { 2143 ok = js.True == bindings.TryInterruptTransfer( 2144 js.Pointer(&ret), js.Pointer(&exception), 2145 js.Pointer(&handle), 2146 js.Pointer(&transferInfo), 2147 ) 2148 2149 return 2150 } 2151 2152 // HasFuncIsochronousTransfer returns true if the function "WEBEXT.usb.isochronousTransfer" exists. 2153 func HasFuncIsochronousTransfer() bool { 2154 return js.True == bindings.HasFuncIsochronousTransfer() 2155 } 2156 2157 // FuncIsochronousTransfer returns the function "WEBEXT.usb.isochronousTransfer". 2158 func FuncIsochronousTransfer() (fn js.Func[func(handle ConnectionHandle, transferInfo IsochronousTransferInfo) js.Promise[TransferResultInfo]]) { 2159 bindings.FuncIsochronousTransfer( 2160 js.Pointer(&fn), 2161 ) 2162 return 2163 } 2164 2165 // IsochronousTransfer calls the function "WEBEXT.usb.isochronousTransfer" directly. 2166 func IsochronousTransfer(handle ConnectionHandle, transferInfo IsochronousTransferInfo) (ret js.Promise[TransferResultInfo]) { 2167 bindings.CallIsochronousTransfer( 2168 js.Pointer(&ret), 2169 js.Pointer(&handle), 2170 js.Pointer(&transferInfo), 2171 ) 2172 2173 return 2174 } 2175 2176 // TryIsochronousTransfer calls the function "WEBEXT.usb.isochronousTransfer" 2177 // in a try/catch block and returns (_, err, ok = false) when it went through 2178 // the catch clause. 2179 func TryIsochronousTransfer(handle ConnectionHandle, transferInfo IsochronousTransferInfo) (ret js.Promise[TransferResultInfo], exception js.Any, ok bool) { 2180 ok = js.True == bindings.TryIsochronousTransfer( 2181 js.Pointer(&ret), js.Pointer(&exception), 2182 js.Pointer(&handle), 2183 js.Pointer(&transferInfo), 2184 ) 2185 2186 return 2187 } 2188 2189 // HasFuncListInterfaces returns true if the function "WEBEXT.usb.listInterfaces" exists. 2190 func HasFuncListInterfaces() bool { 2191 return js.True == bindings.HasFuncListInterfaces() 2192 } 2193 2194 // FuncListInterfaces returns the function "WEBEXT.usb.listInterfaces". 2195 func FuncListInterfaces() (fn js.Func[func(handle ConnectionHandle) js.Promise[js.Array[InterfaceDescriptor]]]) { 2196 bindings.FuncListInterfaces( 2197 js.Pointer(&fn), 2198 ) 2199 return 2200 } 2201 2202 // ListInterfaces calls the function "WEBEXT.usb.listInterfaces" directly. 2203 func ListInterfaces(handle ConnectionHandle) (ret js.Promise[js.Array[InterfaceDescriptor]]) { 2204 bindings.CallListInterfaces( 2205 js.Pointer(&ret), 2206 js.Pointer(&handle), 2207 ) 2208 2209 return 2210 } 2211 2212 // TryListInterfaces calls the function "WEBEXT.usb.listInterfaces" 2213 // in a try/catch block and returns (_, err, ok = false) when it went through 2214 // the catch clause. 2215 func TryListInterfaces(handle ConnectionHandle) (ret js.Promise[js.Array[InterfaceDescriptor]], exception js.Any, ok bool) { 2216 ok = js.True == bindings.TryListInterfaces( 2217 js.Pointer(&ret), js.Pointer(&exception), 2218 js.Pointer(&handle), 2219 ) 2220 2221 return 2222 } 2223 2224 type OnDeviceAddedEventCallbackFunc func(this js.Ref, device *Device) js.Ref 2225 2226 func (fn OnDeviceAddedEventCallbackFunc) Register() js.Func[func(device *Device)] { 2227 return js.RegisterCallback[func(device *Device)]( 2228 fn, abi.FuncPCABIInternal(fn), 2229 ) 2230 } 2231 2232 func (fn OnDeviceAddedEventCallbackFunc) DispatchCallback( 2233 targetPC uintptr, ctx *js.CallbackContext, 2234 ) { 2235 args := ctx.Args() 2236 if len(args) != 1+1 /* js this */ || 2237 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 2238 js.ThrowInvalidCallbackInvocation() 2239 } 2240 var arg0 Device 2241 arg0.UpdateFrom(args[0+1]) 2242 defer arg0.FreeMembers(true) 2243 2244 if ctx.Return(fn( 2245 args[0], 2246 2247 mark.NoEscape(&arg0), 2248 )) { 2249 return 2250 } 2251 2252 js.ThrowCallbackValueNotReturned() 2253 } 2254 2255 type OnDeviceAddedEventCallback[T any] struct { 2256 Fn func(arg T, this js.Ref, device *Device) js.Ref 2257 Arg T 2258 } 2259 2260 func (cb *OnDeviceAddedEventCallback[T]) Register() js.Func[func(device *Device)] { 2261 return js.RegisterCallback[func(device *Device)]( 2262 cb, abi.FuncPCABIInternal(cb.Fn), 2263 ) 2264 } 2265 2266 func (cb *OnDeviceAddedEventCallback[T]) DispatchCallback( 2267 targetPC uintptr, ctx *js.CallbackContext, 2268 ) { 2269 args := ctx.Args() 2270 if len(args) != 1+1 /* js this */ || 2271 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 2272 js.ThrowInvalidCallbackInvocation() 2273 } 2274 var arg0 Device 2275 arg0.UpdateFrom(args[0+1]) 2276 defer arg0.FreeMembers(true) 2277 2278 if ctx.Return(cb.Fn( 2279 cb.Arg, 2280 args[0], 2281 2282 mark.NoEscape(&arg0), 2283 )) { 2284 return 2285 } 2286 2287 js.ThrowCallbackValueNotReturned() 2288 } 2289 2290 // HasFuncOnDeviceAdded returns true if the function "WEBEXT.usb.onDeviceAdded.addListener" exists. 2291 func HasFuncOnDeviceAdded() bool { 2292 return js.True == bindings.HasFuncOnDeviceAdded() 2293 } 2294 2295 // FuncOnDeviceAdded returns the function "WEBEXT.usb.onDeviceAdded.addListener". 2296 func FuncOnDeviceAdded() (fn js.Func[func(callback js.Func[func(device *Device)])]) { 2297 bindings.FuncOnDeviceAdded( 2298 js.Pointer(&fn), 2299 ) 2300 return 2301 } 2302 2303 // OnDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.addListener" directly. 2304 func OnDeviceAdded(callback js.Func[func(device *Device)]) (ret js.Void) { 2305 bindings.CallOnDeviceAdded( 2306 js.Pointer(&ret), 2307 callback.Ref(), 2308 ) 2309 2310 return 2311 } 2312 2313 // TryOnDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.addListener" 2314 // in a try/catch block and returns (_, err, ok = false) when it went through 2315 // the catch clause. 2316 func TryOnDeviceAdded(callback js.Func[func(device *Device)]) (ret js.Void, exception js.Any, ok bool) { 2317 ok = js.True == bindings.TryOnDeviceAdded( 2318 js.Pointer(&ret), js.Pointer(&exception), 2319 callback.Ref(), 2320 ) 2321 2322 return 2323 } 2324 2325 // HasFuncOffDeviceAdded returns true if the function "WEBEXT.usb.onDeviceAdded.removeListener" exists. 2326 func HasFuncOffDeviceAdded() bool { 2327 return js.True == bindings.HasFuncOffDeviceAdded() 2328 } 2329 2330 // FuncOffDeviceAdded returns the function "WEBEXT.usb.onDeviceAdded.removeListener". 2331 func FuncOffDeviceAdded() (fn js.Func[func(callback js.Func[func(device *Device)])]) { 2332 bindings.FuncOffDeviceAdded( 2333 js.Pointer(&fn), 2334 ) 2335 return 2336 } 2337 2338 // OffDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.removeListener" directly. 2339 func OffDeviceAdded(callback js.Func[func(device *Device)]) (ret js.Void) { 2340 bindings.CallOffDeviceAdded( 2341 js.Pointer(&ret), 2342 callback.Ref(), 2343 ) 2344 2345 return 2346 } 2347 2348 // TryOffDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.removeListener" 2349 // in a try/catch block and returns (_, err, ok = false) when it went through 2350 // the catch clause. 2351 func TryOffDeviceAdded(callback js.Func[func(device *Device)]) (ret js.Void, exception js.Any, ok bool) { 2352 ok = js.True == bindings.TryOffDeviceAdded( 2353 js.Pointer(&ret), js.Pointer(&exception), 2354 callback.Ref(), 2355 ) 2356 2357 return 2358 } 2359 2360 // HasFuncHasOnDeviceAdded returns true if the function "WEBEXT.usb.onDeviceAdded.hasListener" exists. 2361 func HasFuncHasOnDeviceAdded() bool { 2362 return js.True == bindings.HasFuncHasOnDeviceAdded() 2363 } 2364 2365 // FuncHasOnDeviceAdded returns the function "WEBEXT.usb.onDeviceAdded.hasListener". 2366 func FuncHasOnDeviceAdded() (fn js.Func[func(callback js.Func[func(device *Device)]) bool]) { 2367 bindings.FuncHasOnDeviceAdded( 2368 js.Pointer(&fn), 2369 ) 2370 return 2371 } 2372 2373 // HasOnDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.hasListener" directly. 2374 func HasOnDeviceAdded(callback js.Func[func(device *Device)]) (ret bool) { 2375 bindings.CallHasOnDeviceAdded( 2376 js.Pointer(&ret), 2377 callback.Ref(), 2378 ) 2379 2380 return 2381 } 2382 2383 // TryHasOnDeviceAdded calls the function "WEBEXT.usb.onDeviceAdded.hasListener" 2384 // in a try/catch block and returns (_, err, ok = false) when it went through 2385 // the catch clause. 2386 func TryHasOnDeviceAdded(callback js.Func[func(device *Device)]) (ret bool, exception js.Any, ok bool) { 2387 ok = js.True == bindings.TryHasOnDeviceAdded( 2388 js.Pointer(&ret), js.Pointer(&exception), 2389 callback.Ref(), 2390 ) 2391 2392 return 2393 } 2394 2395 type OnDeviceRemovedEventCallbackFunc func(this js.Ref, device *Device) js.Ref 2396 2397 func (fn OnDeviceRemovedEventCallbackFunc) Register() js.Func[func(device *Device)] { 2398 return js.RegisterCallback[func(device *Device)]( 2399 fn, abi.FuncPCABIInternal(fn), 2400 ) 2401 } 2402 2403 func (fn OnDeviceRemovedEventCallbackFunc) DispatchCallback( 2404 targetPC uintptr, ctx *js.CallbackContext, 2405 ) { 2406 args := ctx.Args() 2407 if len(args) != 1+1 /* js this */ || 2408 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 2409 js.ThrowInvalidCallbackInvocation() 2410 } 2411 var arg0 Device 2412 arg0.UpdateFrom(args[0+1]) 2413 defer arg0.FreeMembers(true) 2414 2415 if ctx.Return(fn( 2416 args[0], 2417 2418 mark.NoEscape(&arg0), 2419 )) { 2420 return 2421 } 2422 2423 js.ThrowCallbackValueNotReturned() 2424 } 2425 2426 type OnDeviceRemovedEventCallback[T any] struct { 2427 Fn func(arg T, this js.Ref, device *Device) js.Ref 2428 Arg T 2429 } 2430 2431 func (cb *OnDeviceRemovedEventCallback[T]) Register() js.Func[func(device *Device)] { 2432 return js.RegisterCallback[func(device *Device)]( 2433 cb, abi.FuncPCABIInternal(cb.Fn), 2434 ) 2435 } 2436 2437 func (cb *OnDeviceRemovedEventCallback[T]) DispatchCallback( 2438 targetPC uintptr, ctx *js.CallbackContext, 2439 ) { 2440 args := ctx.Args() 2441 if len(args) != 1+1 /* js this */ || 2442 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 2443 js.ThrowInvalidCallbackInvocation() 2444 } 2445 var arg0 Device 2446 arg0.UpdateFrom(args[0+1]) 2447 defer arg0.FreeMembers(true) 2448 2449 if ctx.Return(cb.Fn( 2450 cb.Arg, 2451 args[0], 2452 2453 mark.NoEscape(&arg0), 2454 )) { 2455 return 2456 } 2457 2458 js.ThrowCallbackValueNotReturned() 2459 } 2460 2461 // HasFuncOnDeviceRemoved returns true if the function "WEBEXT.usb.onDeviceRemoved.addListener" exists. 2462 func HasFuncOnDeviceRemoved() bool { 2463 return js.True == bindings.HasFuncOnDeviceRemoved() 2464 } 2465 2466 // FuncOnDeviceRemoved returns the function "WEBEXT.usb.onDeviceRemoved.addListener". 2467 func FuncOnDeviceRemoved() (fn js.Func[func(callback js.Func[func(device *Device)])]) { 2468 bindings.FuncOnDeviceRemoved( 2469 js.Pointer(&fn), 2470 ) 2471 return 2472 } 2473 2474 // OnDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.addListener" directly. 2475 func OnDeviceRemoved(callback js.Func[func(device *Device)]) (ret js.Void) { 2476 bindings.CallOnDeviceRemoved( 2477 js.Pointer(&ret), 2478 callback.Ref(), 2479 ) 2480 2481 return 2482 } 2483 2484 // TryOnDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.addListener" 2485 // in a try/catch block and returns (_, err, ok = false) when it went through 2486 // the catch clause. 2487 func TryOnDeviceRemoved(callback js.Func[func(device *Device)]) (ret js.Void, exception js.Any, ok bool) { 2488 ok = js.True == bindings.TryOnDeviceRemoved( 2489 js.Pointer(&ret), js.Pointer(&exception), 2490 callback.Ref(), 2491 ) 2492 2493 return 2494 } 2495 2496 // HasFuncOffDeviceRemoved returns true if the function "WEBEXT.usb.onDeviceRemoved.removeListener" exists. 2497 func HasFuncOffDeviceRemoved() bool { 2498 return js.True == bindings.HasFuncOffDeviceRemoved() 2499 } 2500 2501 // FuncOffDeviceRemoved returns the function "WEBEXT.usb.onDeviceRemoved.removeListener". 2502 func FuncOffDeviceRemoved() (fn js.Func[func(callback js.Func[func(device *Device)])]) { 2503 bindings.FuncOffDeviceRemoved( 2504 js.Pointer(&fn), 2505 ) 2506 return 2507 } 2508 2509 // OffDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.removeListener" directly. 2510 func OffDeviceRemoved(callback js.Func[func(device *Device)]) (ret js.Void) { 2511 bindings.CallOffDeviceRemoved( 2512 js.Pointer(&ret), 2513 callback.Ref(), 2514 ) 2515 2516 return 2517 } 2518 2519 // TryOffDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.removeListener" 2520 // in a try/catch block and returns (_, err, ok = false) when it went through 2521 // the catch clause. 2522 func TryOffDeviceRemoved(callback js.Func[func(device *Device)]) (ret js.Void, exception js.Any, ok bool) { 2523 ok = js.True == bindings.TryOffDeviceRemoved( 2524 js.Pointer(&ret), js.Pointer(&exception), 2525 callback.Ref(), 2526 ) 2527 2528 return 2529 } 2530 2531 // HasFuncHasOnDeviceRemoved returns true if the function "WEBEXT.usb.onDeviceRemoved.hasListener" exists. 2532 func HasFuncHasOnDeviceRemoved() bool { 2533 return js.True == bindings.HasFuncHasOnDeviceRemoved() 2534 } 2535 2536 // FuncHasOnDeviceRemoved returns the function "WEBEXT.usb.onDeviceRemoved.hasListener". 2537 func FuncHasOnDeviceRemoved() (fn js.Func[func(callback js.Func[func(device *Device)]) bool]) { 2538 bindings.FuncHasOnDeviceRemoved( 2539 js.Pointer(&fn), 2540 ) 2541 return 2542 } 2543 2544 // HasOnDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.hasListener" directly. 2545 func HasOnDeviceRemoved(callback js.Func[func(device *Device)]) (ret bool) { 2546 bindings.CallHasOnDeviceRemoved( 2547 js.Pointer(&ret), 2548 callback.Ref(), 2549 ) 2550 2551 return 2552 } 2553 2554 // TryHasOnDeviceRemoved calls the function "WEBEXT.usb.onDeviceRemoved.hasListener" 2555 // in a try/catch block and returns (_, err, ok = false) when it went through 2556 // the catch clause. 2557 func TryHasOnDeviceRemoved(callback js.Func[func(device *Device)]) (ret bool, exception js.Any, ok bool) { 2558 ok = js.True == bindings.TryHasOnDeviceRemoved( 2559 js.Pointer(&ret), js.Pointer(&exception), 2560 callback.Ref(), 2561 ) 2562 2563 return 2564 } 2565 2566 // HasFuncOpenDevice returns true if the function "WEBEXT.usb.openDevice" exists. 2567 func HasFuncOpenDevice() bool { 2568 return js.True == bindings.HasFuncOpenDevice() 2569 } 2570 2571 // FuncOpenDevice returns the function "WEBEXT.usb.openDevice". 2572 func FuncOpenDevice() (fn js.Func[func(device Device) js.Promise[ConnectionHandle]]) { 2573 bindings.FuncOpenDevice( 2574 js.Pointer(&fn), 2575 ) 2576 return 2577 } 2578 2579 // OpenDevice calls the function "WEBEXT.usb.openDevice" directly. 2580 func OpenDevice(device Device) (ret js.Promise[ConnectionHandle]) { 2581 bindings.CallOpenDevice( 2582 js.Pointer(&ret), 2583 js.Pointer(&device), 2584 ) 2585 2586 return 2587 } 2588 2589 // TryOpenDevice calls the function "WEBEXT.usb.openDevice" 2590 // in a try/catch block and returns (_, err, ok = false) when it went through 2591 // the catch clause. 2592 func TryOpenDevice(device Device) (ret js.Promise[ConnectionHandle], exception js.Any, ok bool) { 2593 ok = js.True == bindings.TryOpenDevice( 2594 js.Pointer(&ret), js.Pointer(&exception), 2595 js.Pointer(&device), 2596 ) 2597 2598 return 2599 } 2600 2601 // HasFuncReleaseInterface returns true if the function "WEBEXT.usb.releaseInterface" exists. 2602 func HasFuncReleaseInterface() bool { 2603 return js.True == bindings.HasFuncReleaseInterface() 2604 } 2605 2606 // FuncReleaseInterface returns the function "WEBEXT.usb.releaseInterface". 2607 func FuncReleaseInterface() (fn js.Func[func(handle ConnectionHandle, interfaceNumber int32) js.Promise[js.Void]]) { 2608 bindings.FuncReleaseInterface( 2609 js.Pointer(&fn), 2610 ) 2611 return 2612 } 2613 2614 // ReleaseInterface calls the function "WEBEXT.usb.releaseInterface" directly. 2615 func ReleaseInterface(handle ConnectionHandle, interfaceNumber int32) (ret js.Promise[js.Void]) { 2616 bindings.CallReleaseInterface( 2617 js.Pointer(&ret), 2618 js.Pointer(&handle), 2619 int32(interfaceNumber), 2620 ) 2621 2622 return 2623 } 2624 2625 // TryReleaseInterface calls the function "WEBEXT.usb.releaseInterface" 2626 // in a try/catch block and returns (_, err, ok = false) when it went through 2627 // the catch clause. 2628 func TryReleaseInterface(handle ConnectionHandle, interfaceNumber int32) (ret js.Promise[js.Void], exception js.Any, ok bool) { 2629 ok = js.True == bindings.TryReleaseInterface( 2630 js.Pointer(&ret), js.Pointer(&exception), 2631 js.Pointer(&handle), 2632 int32(interfaceNumber), 2633 ) 2634 2635 return 2636 } 2637 2638 // HasFuncRequestAccess returns true if the function "WEBEXT.usb.requestAccess" exists. 2639 func HasFuncRequestAccess() bool { 2640 return js.True == bindings.HasFuncRequestAccess() 2641 } 2642 2643 // FuncRequestAccess returns the function "WEBEXT.usb.requestAccess". 2644 func FuncRequestAccess() (fn js.Func[func(device Device, interfaceId int32) js.Promise[js.Boolean]]) { 2645 bindings.FuncRequestAccess( 2646 js.Pointer(&fn), 2647 ) 2648 return 2649 } 2650 2651 // RequestAccess calls the function "WEBEXT.usb.requestAccess" directly. 2652 func RequestAccess(device Device, interfaceId int32) (ret js.Promise[js.Boolean]) { 2653 bindings.CallRequestAccess( 2654 js.Pointer(&ret), 2655 js.Pointer(&device), 2656 int32(interfaceId), 2657 ) 2658 2659 return 2660 } 2661 2662 // TryRequestAccess calls the function "WEBEXT.usb.requestAccess" 2663 // in a try/catch block and returns (_, err, ok = false) when it went through 2664 // the catch clause. 2665 func TryRequestAccess(device Device, interfaceId int32) (ret js.Promise[js.Boolean], exception js.Any, ok bool) { 2666 ok = js.True == bindings.TryRequestAccess( 2667 js.Pointer(&ret), js.Pointer(&exception), 2668 js.Pointer(&device), 2669 int32(interfaceId), 2670 ) 2671 2672 return 2673 } 2674 2675 // HasFuncResetDevice returns true if the function "WEBEXT.usb.resetDevice" exists. 2676 func HasFuncResetDevice() bool { 2677 return js.True == bindings.HasFuncResetDevice() 2678 } 2679 2680 // FuncResetDevice returns the function "WEBEXT.usb.resetDevice". 2681 func FuncResetDevice() (fn js.Func[func(handle ConnectionHandle) js.Promise[js.Boolean]]) { 2682 bindings.FuncResetDevice( 2683 js.Pointer(&fn), 2684 ) 2685 return 2686 } 2687 2688 // ResetDevice calls the function "WEBEXT.usb.resetDevice" directly. 2689 func ResetDevice(handle ConnectionHandle) (ret js.Promise[js.Boolean]) { 2690 bindings.CallResetDevice( 2691 js.Pointer(&ret), 2692 js.Pointer(&handle), 2693 ) 2694 2695 return 2696 } 2697 2698 // TryResetDevice calls the function "WEBEXT.usb.resetDevice" 2699 // in a try/catch block and returns (_, err, ok = false) when it went through 2700 // the catch clause. 2701 func TryResetDevice(handle ConnectionHandle) (ret js.Promise[js.Boolean], exception js.Any, ok bool) { 2702 ok = js.True == bindings.TryResetDevice( 2703 js.Pointer(&ret), js.Pointer(&exception), 2704 js.Pointer(&handle), 2705 ) 2706 2707 return 2708 } 2709 2710 // HasFuncSetConfiguration returns true if the function "WEBEXT.usb.setConfiguration" exists. 2711 func HasFuncSetConfiguration() bool { 2712 return js.True == bindings.HasFuncSetConfiguration() 2713 } 2714 2715 // FuncSetConfiguration returns the function "WEBEXT.usb.setConfiguration". 2716 func FuncSetConfiguration() (fn js.Func[func(handle ConnectionHandle, configurationValue int32) js.Promise[js.Void]]) { 2717 bindings.FuncSetConfiguration( 2718 js.Pointer(&fn), 2719 ) 2720 return 2721 } 2722 2723 // SetConfiguration calls the function "WEBEXT.usb.setConfiguration" directly. 2724 func SetConfiguration(handle ConnectionHandle, configurationValue int32) (ret js.Promise[js.Void]) { 2725 bindings.CallSetConfiguration( 2726 js.Pointer(&ret), 2727 js.Pointer(&handle), 2728 int32(configurationValue), 2729 ) 2730 2731 return 2732 } 2733 2734 // TrySetConfiguration calls the function "WEBEXT.usb.setConfiguration" 2735 // in a try/catch block and returns (_, err, ok = false) when it went through 2736 // the catch clause. 2737 func TrySetConfiguration(handle ConnectionHandle, configurationValue int32) (ret js.Promise[js.Void], exception js.Any, ok bool) { 2738 ok = js.True == bindings.TrySetConfiguration( 2739 js.Pointer(&ret), js.Pointer(&exception), 2740 js.Pointer(&handle), 2741 int32(configurationValue), 2742 ) 2743 2744 return 2745 } 2746 2747 // HasFuncSetInterfaceAlternateSetting returns true if the function "WEBEXT.usb.setInterfaceAlternateSetting" exists. 2748 func HasFuncSetInterfaceAlternateSetting() bool { 2749 return js.True == bindings.HasFuncSetInterfaceAlternateSetting() 2750 } 2751 2752 // FuncSetInterfaceAlternateSetting returns the function "WEBEXT.usb.setInterfaceAlternateSetting". 2753 func FuncSetInterfaceAlternateSetting() (fn js.Func[func(handle ConnectionHandle, interfaceNumber int32, alternateSetting int32) js.Promise[js.Void]]) { 2754 bindings.FuncSetInterfaceAlternateSetting( 2755 js.Pointer(&fn), 2756 ) 2757 return 2758 } 2759 2760 // SetInterfaceAlternateSetting calls the function "WEBEXT.usb.setInterfaceAlternateSetting" directly. 2761 func SetInterfaceAlternateSetting(handle ConnectionHandle, interfaceNumber int32, alternateSetting int32) (ret js.Promise[js.Void]) { 2762 bindings.CallSetInterfaceAlternateSetting( 2763 js.Pointer(&ret), 2764 js.Pointer(&handle), 2765 int32(interfaceNumber), 2766 int32(alternateSetting), 2767 ) 2768 2769 return 2770 } 2771 2772 // TrySetInterfaceAlternateSetting calls the function "WEBEXT.usb.setInterfaceAlternateSetting" 2773 // in a try/catch block and returns (_, err, ok = false) when it went through 2774 // the catch clause. 2775 func TrySetInterfaceAlternateSetting(handle ConnectionHandle, interfaceNumber int32, alternateSetting int32) (ret js.Promise[js.Void], exception js.Any, ok bool) { 2776 ok = js.True == bindings.TrySetInterfaceAlternateSetting( 2777 js.Pointer(&ret), js.Pointer(&exception), 2778 js.Pointer(&handle), 2779 int32(interfaceNumber), 2780 int32(alternateSetting), 2781 ) 2782 2783 return 2784 }