github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/bluetoothsocket/apis_js_wasm.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package bluetoothsocket
     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/bluetoothsocket/bindings"
    11  )
    12  
    13  type AcceptError uint32
    14  
    15  const (
    16  	_ AcceptError = iota
    17  
    18  	AcceptError_SYSTEM_ERROR
    19  	AcceptError_NOT_LISTENING
    20  )
    21  
    22  func (AcceptError) FromRef(str js.Ref) AcceptError {
    23  	return AcceptError(bindings.ConstOfAcceptError(str))
    24  }
    25  
    26  func (x AcceptError) String() (string, bool) {
    27  	switch x {
    28  	case AcceptError_SYSTEM_ERROR:
    29  		return "system_error", true
    30  	case AcceptError_NOT_LISTENING:
    31  		return "not_listening", true
    32  	default:
    33  		return "", false
    34  	}
    35  }
    36  
    37  type AcceptErrorInfo struct {
    38  	// SocketId is "AcceptErrorInfo.socketId"
    39  	//
    40  	// Optional
    41  	//
    42  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
    43  	SocketId int32
    44  	// ErrorMessage is "AcceptErrorInfo.errorMessage"
    45  	//
    46  	// Optional
    47  	ErrorMessage js.String
    48  	// Error is "AcceptErrorInfo.error"
    49  	//
    50  	// Optional
    51  	Error AcceptError
    52  
    53  	FFI_USE_SocketId bool // for SocketId.
    54  
    55  	FFI_USE bool
    56  }
    57  
    58  // FromRef calls UpdateFrom and returns a AcceptErrorInfo with all fields set.
    59  func (p AcceptErrorInfo) FromRef(ref js.Ref) AcceptErrorInfo {
    60  	p.UpdateFrom(ref)
    61  	return p
    62  }
    63  
    64  // New creates a new AcceptErrorInfo in the application heap.
    65  func (p AcceptErrorInfo) New() js.Ref {
    66  	return bindings.AcceptErrorInfoJSLoad(
    67  		js.Pointer(&p), js.True, 0,
    68  	)
    69  }
    70  
    71  // UpdateFrom copies value of all fields of the heap object to p.
    72  func (p *AcceptErrorInfo) UpdateFrom(ref js.Ref) {
    73  	bindings.AcceptErrorInfoJSStore(
    74  		js.Pointer(p), ref,
    75  	)
    76  }
    77  
    78  // Update writes all fields of the p to the heap object referenced by ref.
    79  func (p *AcceptErrorInfo) Update(ref js.Ref) {
    80  	bindings.AcceptErrorInfoJSLoad(
    81  		js.Pointer(p), js.False, ref,
    82  	)
    83  }
    84  
    85  // FreeMembers frees fields with heap reference, if recursive is true
    86  // free all heap references reachable from p.
    87  func (p *AcceptErrorInfo) FreeMembers(recursive bool) {
    88  	js.Free(
    89  		p.ErrorMessage.Ref(),
    90  	)
    91  	p.ErrorMessage = p.ErrorMessage.FromRef(js.Undefined)
    92  }
    93  
    94  type AcceptInfo struct {
    95  	// SocketId is "AcceptInfo.socketId"
    96  	//
    97  	// Optional
    98  	//
    99  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
   100  	SocketId int32
   101  	// ClientSocketId is "AcceptInfo.clientSocketId"
   102  	//
   103  	// Optional
   104  	//
   105  	// NOTE: FFI_USE_ClientSocketId MUST be set to true to make this field effective.
   106  	ClientSocketId int32
   107  
   108  	FFI_USE_SocketId       bool // for SocketId.
   109  	FFI_USE_ClientSocketId bool // for ClientSocketId.
   110  
   111  	FFI_USE bool
   112  }
   113  
   114  // FromRef calls UpdateFrom and returns a AcceptInfo with all fields set.
   115  func (p AcceptInfo) FromRef(ref js.Ref) AcceptInfo {
   116  	p.UpdateFrom(ref)
   117  	return p
   118  }
   119  
   120  // New creates a new AcceptInfo in the application heap.
   121  func (p AcceptInfo) New() js.Ref {
   122  	return bindings.AcceptInfoJSLoad(
   123  		js.Pointer(&p), js.True, 0,
   124  	)
   125  }
   126  
   127  // UpdateFrom copies value of all fields of the heap object to p.
   128  func (p *AcceptInfo) UpdateFrom(ref js.Ref) {
   129  	bindings.AcceptInfoJSStore(
   130  		js.Pointer(p), ref,
   131  	)
   132  }
   133  
   134  // Update writes all fields of the p to the heap object referenced by ref.
   135  func (p *AcceptInfo) Update(ref js.Ref) {
   136  	bindings.AcceptInfoJSLoad(
   137  		js.Pointer(p), js.False, ref,
   138  	)
   139  }
   140  
   141  // FreeMembers frees fields with heap reference, if recursive is true
   142  // free all heap references reachable from p.
   143  func (p *AcceptInfo) FreeMembers(recursive bool) {
   144  }
   145  
   146  type CloseCallbackFunc func(this js.Ref) js.Ref
   147  
   148  func (fn CloseCallbackFunc) Register() js.Func[func()] {
   149  	return js.RegisterCallback[func()](
   150  		fn, abi.FuncPCABIInternal(fn),
   151  	)
   152  }
   153  
   154  func (fn CloseCallbackFunc) DispatchCallback(
   155  	targetPC uintptr, ctx *js.CallbackContext,
   156  ) {
   157  	args := ctx.Args()
   158  	if len(args) != 0+1 /* js this */ ||
   159  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   160  		js.ThrowInvalidCallbackInvocation()
   161  	}
   162  
   163  	if ctx.Return(fn(
   164  		args[0],
   165  	)) {
   166  		return
   167  	}
   168  
   169  	js.ThrowCallbackValueNotReturned()
   170  }
   171  
   172  type CloseCallback[T any] struct {
   173  	Fn  func(arg T, this js.Ref) js.Ref
   174  	Arg T
   175  }
   176  
   177  func (cb *CloseCallback[T]) Register() js.Func[func()] {
   178  	return js.RegisterCallback[func()](
   179  		cb, abi.FuncPCABIInternal(cb.Fn),
   180  	)
   181  }
   182  
   183  func (cb *CloseCallback[T]) DispatchCallback(
   184  	targetPC uintptr, ctx *js.CallbackContext,
   185  ) {
   186  	args := ctx.Args()
   187  	if len(args) != 0+1 /* js this */ ||
   188  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   189  		js.ThrowInvalidCallbackInvocation()
   190  	}
   191  
   192  	if ctx.Return(cb.Fn(
   193  		cb.Arg,
   194  		args[0],
   195  	)) {
   196  		return
   197  	}
   198  
   199  	js.ThrowCallbackValueNotReturned()
   200  }
   201  
   202  type ConnectCallbackFunc func(this js.Ref) js.Ref
   203  
   204  func (fn ConnectCallbackFunc) Register() js.Func[func()] {
   205  	return js.RegisterCallback[func()](
   206  		fn, abi.FuncPCABIInternal(fn),
   207  	)
   208  }
   209  
   210  func (fn ConnectCallbackFunc) DispatchCallback(
   211  	targetPC uintptr, ctx *js.CallbackContext,
   212  ) {
   213  	args := ctx.Args()
   214  	if len(args) != 0+1 /* js this */ ||
   215  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   216  		js.ThrowInvalidCallbackInvocation()
   217  	}
   218  
   219  	if ctx.Return(fn(
   220  		args[0],
   221  	)) {
   222  		return
   223  	}
   224  
   225  	js.ThrowCallbackValueNotReturned()
   226  }
   227  
   228  type ConnectCallback[T any] struct {
   229  	Fn  func(arg T, this js.Ref) js.Ref
   230  	Arg T
   231  }
   232  
   233  func (cb *ConnectCallback[T]) Register() js.Func[func()] {
   234  	return js.RegisterCallback[func()](
   235  		cb, abi.FuncPCABIInternal(cb.Fn),
   236  	)
   237  }
   238  
   239  func (cb *ConnectCallback[T]) DispatchCallback(
   240  	targetPC uintptr, ctx *js.CallbackContext,
   241  ) {
   242  	args := ctx.Args()
   243  	if len(args) != 0+1 /* js this */ ||
   244  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   245  		js.ThrowInvalidCallbackInvocation()
   246  	}
   247  
   248  	if ctx.Return(cb.Fn(
   249  		cb.Arg,
   250  		args[0],
   251  	)) {
   252  		return
   253  	}
   254  
   255  	js.ThrowCallbackValueNotReturned()
   256  }
   257  
   258  type CreateCallbackFunc func(this js.Ref, createInfo *CreateInfo) js.Ref
   259  
   260  func (fn CreateCallbackFunc) Register() js.Func[func(createInfo *CreateInfo)] {
   261  	return js.RegisterCallback[func(createInfo *CreateInfo)](
   262  		fn, abi.FuncPCABIInternal(fn),
   263  	)
   264  }
   265  
   266  func (fn CreateCallbackFunc) DispatchCallback(
   267  	targetPC uintptr, ctx *js.CallbackContext,
   268  ) {
   269  	args := ctx.Args()
   270  	if len(args) != 1+1 /* js this */ ||
   271  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   272  		js.ThrowInvalidCallbackInvocation()
   273  	}
   274  	var arg0 CreateInfo
   275  	arg0.UpdateFrom(args[0+1])
   276  	defer arg0.FreeMembers(true)
   277  
   278  	if ctx.Return(fn(
   279  		args[0],
   280  
   281  		mark.NoEscape(&arg0),
   282  	)) {
   283  		return
   284  	}
   285  
   286  	js.ThrowCallbackValueNotReturned()
   287  }
   288  
   289  type CreateCallback[T any] struct {
   290  	Fn  func(arg T, this js.Ref, createInfo *CreateInfo) js.Ref
   291  	Arg T
   292  }
   293  
   294  func (cb *CreateCallback[T]) Register() js.Func[func(createInfo *CreateInfo)] {
   295  	return js.RegisterCallback[func(createInfo *CreateInfo)](
   296  		cb, abi.FuncPCABIInternal(cb.Fn),
   297  	)
   298  }
   299  
   300  func (cb *CreateCallback[T]) DispatchCallback(
   301  	targetPC uintptr, ctx *js.CallbackContext,
   302  ) {
   303  	args := ctx.Args()
   304  	if len(args) != 1+1 /* js this */ ||
   305  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   306  		js.ThrowInvalidCallbackInvocation()
   307  	}
   308  	var arg0 CreateInfo
   309  	arg0.UpdateFrom(args[0+1])
   310  	defer arg0.FreeMembers(true)
   311  
   312  	if ctx.Return(cb.Fn(
   313  		cb.Arg,
   314  		args[0],
   315  
   316  		mark.NoEscape(&arg0),
   317  	)) {
   318  		return
   319  	}
   320  
   321  	js.ThrowCallbackValueNotReturned()
   322  }
   323  
   324  type CreateInfo struct {
   325  	// SocketId is "CreateInfo.socketId"
   326  	//
   327  	// Optional
   328  	//
   329  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
   330  	SocketId int32
   331  
   332  	FFI_USE_SocketId bool // for SocketId.
   333  
   334  	FFI_USE bool
   335  }
   336  
   337  // FromRef calls UpdateFrom and returns a CreateInfo with all fields set.
   338  func (p CreateInfo) FromRef(ref js.Ref) CreateInfo {
   339  	p.UpdateFrom(ref)
   340  	return p
   341  }
   342  
   343  // New creates a new CreateInfo in the application heap.
   344  func (p CreateInfo) New() js.Ref {
   345  	return bindings.CreateInfoJSLoad(
   346  		js.Pointer(&p), js.True, 0,
   347  	)
   348  }
   349  
   350  // UpdateFrom copies value of all fields of the heap object to p.
   351  func (p *CreateInfo) UpdateFrom(ref js.Ref) {
   352  	bindings.CreateInfoJSStore(
   353  		js.Pointer(p), ref,
   354  	)
   355  }
   356  
   357  // Update writes all fields of the p to the heap object referenced by ref.
   358  func (p *CreateInfo) Update(ref js.Ref) {
   359  	bindings.CreateInfoJSLoad(
   360  		js.Pointer(p), js.False, ref,
   361  	)
   362  }
   363  
   364  // FreeMembers frees fields with heap reference, if recursive is true
   365  // free all heap references reachable from p.
   366  func (p *CreateInfo) FreeMembers(recursive bool) {
   367  }
   368  
   369  type DisconnectCallbackFunc func(this js.Ref) js.Ref
   370  
   371  func (fn DisconnectCallbackFunc) Register() js.Func[func()] {
   372  	return js.RegisterCallback[func()](
   373  		fn, abi.FuncPCABIInternal(fn),
   374  	)
   375  }
   376  
   377  func (fn DisconnectCallbackFunc) DispatchCallback(
   378  	targetPC uintptr, ctx *js.CallbackContext,
   379  ) {
   380  	args := ctx.Args()
   381  	if len(args) != 0+1 /* js this */ ||
   382  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   383  		js.ThrowInvalidCallbackInvocation()
   384  	}
   385  
   386  	if ctx.Return(fn(
   387  		args[0],
   388  	)) {
   389  		return
   390  	}
   391  
   392  	js.ThrowCallbackValueNotReturned()
   393  }
   394  
   395  type DisconnectCallback[T any] struct {
   396  	Fn  func(arg T, this js.Ref) js.Ref
   397  	Arg T
   398  }
   399  
   400  func (cb *DisconnectCallback[T]) Register() js.Func[func()] {
   401  	return js.RegisterCallback[func()](
   402  		cb, abi.FuncPCABIInternal(cb.Fn),
   403  	)
   404  }
   405  
   406  func (cb *DisconnectCallback[T]) DispatchCallback(
   407  	targetPC uintptr, ctx *js.CallbackContext,
   408  ) {
   409  	args := ctx.Args()
   410  	if len(args) != 0+1 /* js this */ ||
   411  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   412  		js.ThrowInvalidCallbackInvocation()
   413  	}
   414  
   415  	if ctx.Return(cb.Fn(
   416  		cb.Arg,
   417  		args[0],
   418  	)) {
   419  		return
   420  	}
   421  
   422  	js.ThrowCallbackValueNotReturned()
   423  }
   424  
   425  type GetInfoCallbackFunc func(this js.Ref, socketInfo *SocketInfo) js.Ref
   426  
   427  func (fn GetInfoCallbackFunc) Register() js.Func[func(socketInfo *SocketInfo)] {
   428  	return js.RegisterCallback[func(socketInfo *SocketInfo)](
   429  		fn, abi.FuncPCABIInternal(fn),
   430  	)
   431  }
   432  
   433  func (fn GetInfoCallbackFunc) DispatchCallback(
   434  	targetPC uintptr, ctx *js.CallbackContext,
   435  ) {
   436  	args := ctx.Args()
   437  	if len(args) != 1+1 /* js this */ ||
   438  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   439  		js.ThrowInvalidCallbackInvocation()
   440  	}
   441  	var arg0 SocketInfo
   442  	arg0.UpdateFrom(args[0+1])
   443  	defer arg0.FreeMembers(true)
   444  
   445  	if ctx.Return(fn(
   446  		args[0],
   447  
   448  		mark.NoEscape(&arg0),
   449  	)) {
   450  		return
   451  	}
   452  
   453  	js.ThrowCallbackValueNotReturned()
   454  }
   455  
   456  type GetInfoCallback[T any] struct {
   457  	Fn  func(arg T, this js.Ref, socketInfo *SocketInfo) js.Ref
   458  	Arg T
   459  }
   460  
   461  func (cb *GetInfoCallback[T]) Register() js.Func[func(socketInfo *SocketInfo)] {
   462  	return js.RegisterCallback[func(socketInfo *SocketInfo)](
   463  		cb, abi.FuncPCABIInternal(cb.Fn),
   464  	)
   465  }
   466  
   467  func (cb *GetInfoCallback[T]) DispatchCallback(
   468  	targetPC uintptr, ctx *js.CallbackContext,
   469  ) {
   470  	args := ctx.Args()
   471  	if len(args) != 1+1 /* js this */ ||
   472  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   473  		js.ThrowInvalidCallbackInvocation()
   474  	}
   475  	var arg0 SocketInfo
   476  	arg0.UpdateFrom(args[0+1])
   477  	defer arg0.FreeMembers(true)
   478  
   479  	if ctx.Return(cb.Fn(
   480  		cb.Arg,
   481  		args[0],
   482  
   483  		mark.NoEscape(&arg0),
   484  	)) {
   485  		return
   486  	}
   487  
   488  	js.ThrowCallbackValueNotReturned()
   489  }
   490  
   491  type SocketInfo struct {
   492  	// SocketId is "SocketInfo.socketId"
   493  	//
   494  	// Optional
   495  	//
   496  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
   497  	SocketId int32
   498  	// Persistent is "SocketInfo.persistent"
   499  	//
   500  	// Optional
   501  	//
   502  	// NOTE: FFI_USE_Persistent MUST be set to true to make this field effective.
   503  	Persistent bool
   504  	// Name is "SocketInfo.name"
   505  	//
   506  	// Optional
   507  	Name js.String
   508  	// BufferSize is "SocketInfo.bufferSize"
   509  	//
   510  	// Optional
   511  	//
   512  	// NOTE: FFI_USE_BufferSize MUST be set to true to make this field effective.
   513  	BufferSize int32
   514  	// Paused is "SocketInfo.paused"
   515  	//
   516  	// Optional
   517  	//
   518  	// NOTE: FFI_USE_Paused MUST be set to true to make this field effective.
   519  	Paused bool
   520  	// Connected is "SocketInfo.connected"
   521  	//
   522  	// Optional
   523  	//
   524  	// NOTE: FFI_USE_Connected MUST be set to true to make this field effective.
   525  	Connected bool
   526  	// Address is "SocketInfo.address"
   527  	//
   528  	// Optional
   529  	Address js.String
   530  	// Uuid is "SocketInfo.uuid"
   531  	//
   532  	// Optional
   533  	Uuid js.String
   534  
   535  	FFI_USE_SocketId   bool // for SocketId.
   536  	FFI_USE_Persistent bool // for Persistent.
   537  	FFI_USE_BufferSize bool // for BufferSize.
   538  	FFI_USE_Paused     bool // for Paused.
   539  	FFI_USE_Connected  bool // for Connected.
   540  
   541  	FFI_USE bool
   542  }
   543  
   544  // FromRef calls UpdateFrom and returns a SocketInfo with all fields set.
   545  func (p SocketInfo) FromRef(ref js.Ref) SocketInfo {
   546  	p.UpdateFrom(ref)
   547  	return p
   548  }
   549  
   550  // New creates a new SocketInfo in the application heap.
   551  func (p SocketInfo) New() js.Ref {
   552  	return bindings.SocketInfoJSLoad(
   553  		js.Pointer(&p), js.True, 0,
   554  	)
   555  }
   556  
   557  // UpdateFrom copies value of all fields of the heap object to p.
   558  func (p *SocketInfo) UpdateFrom(ref js.Ref) {
   559  	bindings.SocketInfoJSStore(
   560  		js.Pointer(p), ref,
   561  	)
   562  }
   563  
   564  // Update writes all fields of the p to the heap object referenced by ref.
   565  func (p *SocketInfo) Update(ref js.Ref) {
   566  	bindings.SocketInfoJSLoad(
   567  		js.Pointer(p), js.False, ref,
   568  	)
   569  }
   570  
   571  // FreeMembers frees fields with heap reference, if recursive is true
   572  // free all heap references reachable from p.
   573  func (p *SocketInfo) FreeMembers(recursive bool) {
   574  	js.Free(
   575  		p.Name.Ref(),
   576  		p.Address.Ref(),
   577  		p.Uuid.Ref(),
   578  	)
   579  	p.Name = p.Name.FromRef(js.Undefined)
   580  	p.Address = p.Address.FromRef(js.Undefined)
   581  	p.Uuid = p.Uuid.FromRef(js.Undefined)
   582  }
   583  
   584  type GetSocketsCallbackFunc func(this js.Ref, sockets js.Array[SocketInfo]) js.Ref
   585  
   586  func (fn GetSocketsCallbackFunc) Register() js.Func[func(sockets js.Array[SocketInfo])] {
   587  	return js.RegisterCallback[func(sockets js.Array[SocketInfo])](
   588  		fn, abi.FuncPCABIInternal(fn),
   589  	)
   590  }
   591  
   592  func (fn GetSocketsCallbackFunc) DispatchCallback(
   593  	targetPC uintptr, ctx *js.CallbackContext,
   594  ) {
   595  	args := ctx.Args()
   596  	if len(args) != 1+1 /* js this */ ||
   597  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   598  		js.ThrowInvalidCallbackInvocation()
   599  	}
   600  
   601  	if ctx.Return(fn(
   602  		args[0],
   603  
   604  		js.Array[SocketInfo]{}.FromRef(args[0+1]),
   605  	)) {
   606  		return
   607  	}
   608  
   609  	js.ThrowCallbackValueNotReturned()
   610  }
   611  
   612  type GetSocketsCallback[T any] struct {
   613  	Fn  func(arg T, this js.Ref, sockets js.Array[SocketInfo]) js.Ref
   614  	Arg T
   615  }
   616  
   617  func (cb *GetSocketsCallback[T]) Register() js.Func[func(sockets js.Array[SocketInfo])] {
   618  	return js.RegisterCallback[func(sockets js.Array[SocketInfo])](
   619  		cb, abi.FuncPCABIInternal(cb.Fn),
   620  	)
   621  }
   622  
   623  func (cb *GetSocketsCallback[T]) DispatchCallback(
   624  	targetPC uintptr, ctx *js.CallbackContext,
   625  ) {
   626  	args := ctx.Args()
   627  	if len(args) != 1+1 /* js this */ ||
   628  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   629  		js.ThrowInvalidCallbackInvocation()
   630  	}
   631  
   632  	if ctx.Return(cb.Fn(
   633  		cb.Arg,
   634  		args[0],
   635  
   636  		js.Array[SocketInfo]{}.FromRef(args[0+1]),
   637  	)) {
   638  		return
   639  	}
   640  
   641  	js.ThrowCallbackValueNotReturned()
   642  }
   643  
   644  type ListenCallbackFunc func(this js.Ref) js.Ref
   645  
   646  func (fn ListenCallbackFunc) Register() js.Func[func()] {
   647  	return js.RegisterCallback[func()](
   648  		fn, abi.FuncPCABIInternal(fn),
   649  	)
   650  }
   651  
   652  func (fn ListenCallbackFunc) DispatchCallback(
   653  	targetPC uintptr, ctx *js.CallbackContext,
   654  ) {
   655  	args := ctx.Args()
   656  	if len(args) != 0+1 /* js this */ ||
   657  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   658  		js.ThrowInvalidCallbackInvocation()
   659  	}
   660  
   661  	if ctx.Return(fn(
   662  		args[0],
   663  	)) {
   664  		return
   665  	}
   666  
   667  	js.ThrowCallbackValueNotReturned()
   668  }
   669  
   670  type ListenCallback[T any] struct {
   671  	Fn  func(arg T, this js.Ref) js.Ref
   672  	Arg T
   673  }
   674  
   675  func (cb *ListenCallback[T]) Register() js.Func[func()] {
   676  	return js.RegisterCallback[func()](
   677  		cb, abi.FuncPCABIInternal(cb.Fn),
   678  	)
   679  }
   680  
   681  func (cb *ListenCallback[T]) DispatchCallback(
   682  	targetPC uintptr, ctx *js.CallbackContext,
   683  ) {
   684  	args := ctx.Args()
   685  	if len(args) != 0+1 /* js this */ ||
   686  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   687  		js.ThrowInvalidCallbackInvocation()
   688  	}
   689  
   690  	if ctx.Return(cb.Fn(
   691  		cb.Arg,
   692  		args[0],
   693  	)) {
   694  		return
   695  	}
   696  
   697  	js.ThrowCallbackValueNotReturned()
   698  }
   699  
   700  type ListenOptions struct {
   701  	// Channel is "ListenOptions.channel"
   702  	//
   703  	// Optional
   704  	//
   705  	// NOTE: FFI_USE_Channel MUST be set to true to make this field effective.
   706  	Channel int32
   707  	// Psm is "ListenOptions.psm"
   708  	//
   709  	// Optional
   710  	//
   711  	// NOTE: FFI_USE_Psm MUST be set to true to make this field effective.
   712  	Psm int32
   713  	// Backlog is "ListenOptions.backlog"
   714  	//
   715  	// Optional
   716  	//
   717  	// NOTE: FFI_USE_Backlog MUST be set to true to make this field effective.
   718  	Backlog int32
   719  
   720  	FFI_USE_Channel bool // for Channel.
   721  	FFI_USE_Psm     bool // for Psm.
   722  	FFI_USE_Backlog bool // for Backlog.
   723  
   724  	FFI_USE bool
   725  }
   726  
   727  // FromRef calls UpdateFrom and returns a ListenOptions with all fields set.
   728  func (p ListenOptions) FromRef(ref js.Ref) ListenOptions {
   729  	p.UpdateFrom(ref)
   730  	return p
   731  }
   732  
   733  // New creates a new ListenOptions in the application heap.
   734  func (p ListenOptions) New() js.Ref {
   735  	return bindings.ListenOptionsJSLoad(
   736  		js.Pointer(&p), js.True, 0,
   737  	)
   738  }
   739  
   740  // UpdateFrom copies value of all fields of the heap object to p.
   741  func (p *ListenOptions) UpdateFrom(ref js.Ref) {
   742  	bindings.ListenOptionsJSStore(
   743  		js.Pointer(p), ref,
   744  	)
   745  }
   746  
   747  // Update writes all fields of the p to the heap object referenced by ref.
   748  func (p *ListenOptions) Update(ref js.Ref) {
   749  	bindings.ListenOptionsJSLoad(
   750  		js.Pointer(p), js.False, ref,
   751  	)
   752  }
   753  
   754  // FreeMembers frees fields with heap reference, if recursive is true
   755  // free all heap references reachable from p.
   756  func (p *ListenOptions) FreeMembers(recursive bool) {
   757  }
   758  
   759  type ReceiveError uint32
   760  
   761  const (
   762  	_ ReceiveError = iota
   763  
   764  	ReceiveError_DISCONNECTED
   765  	ReceiveError_SYSTEM_ERROR
   766  	ReceiveError_NOT_CONNECTED
   767  )
   768  
   769  func (ReceiveError) FromRef(str js.Ref) ReceiveError {
   770  	return ReceiveError(bindings.ConstOfReceiveError(str))
   771  }
   772  
   773  func (x ReceiveError) String() (string, bool) {
   774  	switch x {
   775  	case ReceiveError_DISCONNECTED:
   776  		return "disconnected", true
   777  	case ReceiveError_SYSTEM_ERROR:
   778  		return "system_error", true
   779  	case ReceiveError_NOT_CONNECTED:
   780  		return "not_connected", true
   781  	default:
   782  		return "", false
   783  	}
   784  }
   785  
   786  type ReceiveErrorInfo struct {
   787  	// SocketId is "ReceiveErrorInfo.socketId"
   788  	//
   789  	// Optional
   790  	//
   791  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
   792  	SocketId int32
   793  	// ErrorMessage is "ReceiveErrorInfo.errorMessage"
   794  	//
   795  	// Optional
   796  	ErrorMessage js.String
   797  	// Error is "ReceiveErrorInfo.error"
   798  	//
   799  	// Optional
   800  	Error ReceiveError
   801  
   802  	FFI_USE_SocketId bool // for SocketId.
   803  
   804  	FFI_USE bool
   805  }
   806  
   807  // FromRef calls UpdateFrom and returns a ReceiveErrorInfo with all fields set.
   808  func (p ReceiveErrorInfo) FromRef(ref js.Ref) ReceiveErrorInfo {
   809  	p.UpdateFrom(ref)
   810  	return p
   811  }
   812  
   813  // New creates a new ReceiveErrorInfo in the application heap.
   814  func (p ReceiveErrorInfo) New() js.Ref {
   815  	return bindings.ReceiveErrorInfoJSLoad(
   816  		js.Pointer(&p), js.True, 0,
   817  	)
   818  }
   819  
   820  // UpdateFrom copies value of all fields of the heap object to p.
   821  func (p *ReceiveErrorInfo) UpdateFrom(ref js.Ref) {
   822  	bindings.ReceiveErrorInfoJSStore(
   823  		js.Pointer(p), ref,
   824  	)
   825  }
   826  
   827  // Update writes all fields of the p to the heap object referenced by ref.
   828  func (p *ReceiveErrorInfo) Update(ref js.Ref) {
   829  	bindings.ReceiveErrorInfoJSLoad(
   830  		js.Pointer(p), js.False, ref,
   831  	)
   832  }
   833  
   834  // FreeMembers frees fields with heap reference, if recursive is true
   835  // free all heap references reachable from p.
   836  func (p *ReceiveErrorInfo) FreeMembers(recursive bool) {
   837  	js.Free(
   838  		p.ErrorMessage.Ref(),
   839  	)
   840  	p.ErrorMessage = p.ErrorMessage.FromRef(js.Undefined)
   841  }
   842  
   843  type ReceiveInfo struct {
   844  	// SocketId is "ReceiveInfo.socketId"
   845  	//
   846  	// Optional
   847  	//
   848  	// NOTE: FFI_USE_SocketId MUST be set to true to make this field effective.
   849  	SocketId int32
   850  	// Data is "ReceiveInfo.data"
   851  	//
   852  	// Optional
   853  	Data js.ArrayBuffer
   854  
   855  	FFI_USE_SocketId bool // for SocketId.
   856  
   857  	FFI_USE bool
   858  }
   859  
   860  // FromRef calls UpdateFrom and returns a ReceiveInfo with all fields set.
   861  func (p ReceiveInfo) FromRef(ref js.Ref) ReceiveInfo {
   862  	p.UpdateFrom(ref)
   863  	return p
   864  }
   865  
   866  // New creates a new ReceiveInfo in the application heap.
   867  func (p ReceiveInfo) New() js.Ref {
   868  	return bindings.ReceiveInfoJSLoad(
   869  		js.Pointer(&p), js.True, 0,
   870  	)
   871  }
   872  
   873  // UpdateFrom copies value of all fields of the heap object to p.
   874  func (p *ReceiveInfo) UpdateFrom(ref js.Ref) {
   875  	bindings.ReceiveInfoJSStore(
   876  		js.Pointer(p), ref,
   877  	)
   878  }
   879  
   880  // Update writes all fields of the p to the heap object referenced by ref.
   881  func (p *ReceiveInfo) Update(ref js.Ref) {
   882  	bindings.ReceiveInfoJSLoad(
   883  		js.Pointer(p), js.False, ref,
   884  	)
   885  }
   886  
   887  // FreeMembers frees fields with heap reference, if recursive is true
   888  // free all heap references reachable from p.
   889  func (p *ReceiveInfo) FreeMembers(recursive bool) {
   890  	js.Free(
   891  		p.Data.Ref(),
   892  	)
   893  	p.Data = p.Data.FromRef(js.Undefined)
   894  }
   895  
   896  type SendCallbackFunc func(this js.Ref, bytesSent int32) js.Ref
   897  
   898  func (fn SendCallbackFunc) Register() js.Func[func(bytesSent int32)] {
   899  	return js.RegisterCallback[func(bytesSent int32)](
   900  		fn, abi.FuncPCABIInternal(fn),
   901  	)
   902  }
   903  
   904  func (fn SendCallbackFunc) DispatchCallback(
   905  	targetPC uintptr, ctx *js.CallbackContext,
   906  ) {
   907  	args := ctx.Args()
   908  	if len(args) != 1+1 /* js this */ ||
   909  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   910  		js.ThrowInvalidCallbackInvocation()
   911  	}
   912  
   913  	if ctx.Return(fn(
   914  		args[0],
   915  
   916  		js.Number[int32]{}.FromRef(args[0+1]).Get(),
   917  	)) {
   918  		return
   919  	}
   920  
   921  	js.ThrowCallbackValueNotReturned()
   922  }
   923  
   924  type SendCallback[T any] struct {
   925  	Fn  func(arg T, this js.Ref, bytesSent int32) js.Ref
   926  	Arg T
   927  }
   928  
   929  func (cb *SendCallback[T]) Register() js.Func[func(bytesSent int32)] {
   930  	return js.RegisterCallback[func(bytesSent int32)](
   931  		cb, abi.FuncPCABIInternal(cb.Fn),
   932  	)
   933  }
   934  
   935  func (cb *SendCallback[T]) DispatchCallback(
   936  	targetPC uintptr, ctx *js.CallbackContext,
   937  ) {
   938  	args := ctx.Args()
   939  	if len(args) != 1+1 /* js this */ ||
   940  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   941  		js.ThrowInvalidCallbackInvocation()
   942  	}
   943  
   944  	if ctx.Return(cb.Fn(
   945  		cb.Arg,
   946  		args[0],
   947  
   948  		js.Number[int32]{}.FromRef(args[0+1]).Get(),
   949  	)) {
   950  		return
   951  	}
   952  
   953  	js.ThrowCallbackValueNotReturned()
   954  }
   955  
   956  type SetPausedCallbackFunc func(this js.Ref) js.Ref
   957  
   958  func (fn SetPausedCallbackFunc) Register() js.Func[func()] {
   959  	return js.RegisterCallback[func()](
   960  		fn, abi.FuncPCABIInternal(fn),
   961  	)
   962  }
   963  
   964  func (fn SetPausedCallbackFunc) DispatchCallback(
   965  	targetPC uintptr, ctx *js.CallbackContext,
   966  ) {
   967  	args := ctx.Args()
   968  	if len(args) != 0+1 /* js this */ ||
   969  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   970  		js.ThrowInvalidCallbackInvocation()
   971  	}
   972  
   973  	if ctx.Return(fn(
   974  		args[0],
   975  	)) {
   976  		return
   977  	}
   978  
   979  	js.ThrowCallbackValueNotReturned()
   980  }
   981  
   982  type SetPausedCallback[T any] struct {
   983  	Fn  func(arg T, this js.Ref) js.Ref
   984  	Arg T
   985  }
   986  
   987  func (cb *SetPausedCallback[T]) Register() js.Func[func()] {
   988  	return js.RegisterCallback[func()](
   989  		cb, abi.FuncPCABIInternal(cb.Fn),
   990  	)
   991  }
   992  
   993  func (cb *SetPausedCallback[T]) DispatchCallback(
   994  	targetPC uintptr, ctx *js.CallbackContext,
   995  ) {
   996  	args := ctx.Args()
   997  	if len(args) != 0+1 /* js this */ ||
   998  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   999  		js.ThrowInvalidCallbackInvocation()
  1000  	}
  1001  
  1002  	if ctx.Return(cb.Fn(
  1003  		cb.Arg,
  1004  		args[0],
  1005  	)) {
  1006  		return
  1007  	}
  1008  
  1009  	js.ThrowCallbackValueNotReturned()
  1010  }
  1011  
  1012  type SocketProperties struct {
  1013  	// Persistent is "SocketProperties.persistent"
  1014  	//
  1015  	// Optional
  1016  	//
  1017  	// NOTE: FFI_USE_Persistent MUST be set to true to make this field effective.
  1018  	Persistent bool
  1019  	// Name is "SocketProperties.name"
  1020  	//
  1021  	// Optional
  1022  	Name js.String
  1023  	// BufferSize is "SocketProperties.bufferSize"
  1024  	//
  1025  	// Optional
  1026  	//
  1027  	// NOTE: FFI_USE_BufferSize MUST be set to true to make this field effective.
  1028  	BufferSize int32
  1029  
  1030  	FFI_USE_Persistent bool // for Persistent.
  1031  	FFI_USE_BufferSize bool // for BufferSize.
  1032  
  1033  	FFI_USE bool
  1034  }
  1035  
  1036  // FromRef calls UpdateFrom and returns a SocketProperties with all fields set.
  1037  func (p SocketProperties) FromRef(ref js.Ref) SocketProperties {
  1038  	p.UpdateFrom(ref)
  1039  	return p
  1040  }
  1041  
  1042  // New creates a new SocketProperties in the application heap.
  1043  func (p SocketProperties) New() js.Ref {
  1044  	return bindings.SocketPropertiesJSLoad(
  1045  		js.Pointer(&p), js.True, 0,
  1046  	)
  1047  }
  1048  
  1049  // UpdateFrom copies value of all fields of the heap object to p.
  1050  func (p *SocketProperties) UpdateFrom(ref js.Ref) {
  1051  	bindings.SocketPropertiesJSStore(
  1052  		js.Pointer(p), ref,
  1053  	)
  1054  }
  1055  
  1056  // Update writes all fields of the p to the heap object referenced by ref.
  1057  func (p *SocketProperties) Update(ref js.Ref) {
  1058  	bindings.SocketPropertiesJSLoad(
  1059  		js.Pointer(p), js.False, ref,
  1060  	)
  1061  }
  1062  
  1063  // FreeMembers frees fields with heap reference, if recursive is true
  1064  // free all heap references reachable from p.
  1065  func (p *SocketProperties) FreeMembers(recursive bool) {
  1066  	js.Free(
  1067  		p.Name.Ref(),
  1068  	)
  1069  	p.Name = p.Name.FromRef(js.Undefined)
  1070  }
  1071  
  1072  type UpdateCallbackFunc func(this js.Ref) js.Ref
  1073  
  1074  func (fn UpdateCallbackFunc) Register() js.Func[func()] {
  1075  	return js.RegisterCallback[func()](
  1076  		fn, abi.FuncPCABIInternal(fn),
  1077  	)
  1078  }
  1079  
  1080  func (fn UpdateCallbackFunc) DispatchCallback(
  1081  	targetPC uintptr, ctx *js.CallbackContext,
  1082  ) {
  1083  	args := ctx.Args()
  1084  	if len(args) != 0+1 /* js this */ ||
  1085  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
  1086  		js.ThrowInvalidCallbackInvocation()
  1087  	}
  1088  
  1089  	if ctx.Return(fn(
  1090  		args[0],
  1091  	)) {
  1092  		return
  1093  	}
  1094  
  1095  	js.ThrowCallbackValueNotReturned()
  1096  }
  1097  
  1098  type UpdateCallback[T any] struct {
  1099  	Fn  func(arg T, this js.Ref) js.Ref
  1100  	Arg T
  1101  }
  1102  
  1103  func (cb *UpdateCallback[T]) Register() js.Func[func()] {
  1104  	return js.RegisterCallback[func()](
  1105  		cb, abi.FuncPCABIInternal(cb.Fn),
  1106  	)
  1107  }
  1108  
  1109  func (cb *UpdateCallback[T]) DispatchCallback(
  1110  	targetPC uintptr, ctx *js.CallbackContext,
  1111  ) {
  1112  	args := ctx.Args()
  1113  	if len(args) != 0+1 /* js this */ ||
  1114  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
  1115  		js.ThrowInvalidCallbackInvocation()
  1116  	}
  1117  
  1118  	if ctx.Return(cb.Fn(
  1119  		cb.Arg,
  1120  		args[0],
  1121  	)) {
  1122  		return
  1123  	}
  1124  
  1125  	js.ThrowCallbackValueNotReturned()
  1126  }
  1127  
  1128  // HasFuncClose returns true if the function "WEBEXT.bluetoothSocket.close" exists.
  1129  func HasFuncClose() bool {
  1130  	return js.True == bindings.HasFuncClose()
  1131  }
  1132  
  1133  // FuncClose returns the function "WEBEXT.bluetoothSocket.close".
  1134  func FuncClose() (fn js.Func[func(socketId int32) js.Promise[js.Void]]) {
  1135  	bindings.FuncClose(
  1136  		js.Pointer(&fn),
  1137  	)
  1138  	return
  1139  }
  1140  
  1141  // Close calls the function "WEBEXT.bluetoothSocket.close" directly.
  1142  func Close(socketId int32) (ret js.Promise[js.Void]) {
  1143  	bindings.CallClose(
  1144  		js.Pointer(&ret),
  1145  		int32(socketId),
  1146  	)
  1147  
  1148  	return
  1149  }
  1150  
  1151  // TryClose calls the function "WEBEXT.bluetoothSocket.close"
  1152  // in a try/catch block and returns (_, err, ok = false) when it went through
  1153  // the catch clause.
  1154  func TryClose(socketId int32) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  1155  	ok = js.True == bindings.TryClose(
  1156  		js.Pointer(&ret), js.Pointer(&exception),
  1157  		int32(socketId),
  1158  	)
  1159  
  1160  	return
  1161  }
  1162  
  1163  // HasFuncConnect returns true if the function "WEBEXT.bluetoothSocket.connect" exists.
  1164  func HasFuncConnect() bool {
  1165  	return js.True == bindings.HasFuncConnect()
  1166  }
  1167  
  1168  // FuncConnect returns the function "WEBEXT.bluetoothSocket.connect".
  1169  func FuncConnect() (fn js.Func[func(socketId int32, address js.String, uuid js.String) js.Promise[js.Void]]) {
  1170  	bindings.FuncConnect(
  1171  		js.Pointer(&fn),
  1172  	)
  1173  	return
  1174  }
  1175  
  1176  // Connect calls the function "WEBEXT.bluetoothSocket.connect" directly.
  1177  func Connect(socketId int32, address js.String, uuid js.String) (ret js.Promise[js.Void]) {
  1178  	bindings.CallConnect(
  1179  		js.Pointer(&ret),
  1180  		int32(socketId),
  1181  		address.Ref(),
  1182  		uuid.Ref(),
  1183  	)
  1184  
  1185  	return
  1186  }
  1187  
  1188  // TryConnect calls the function "WEBEXT.bluetoothSocket.connect"
  1189  // in a try/catch block and returns (_, err, ok = false) when it went through
  1190  // the catch clause.
  1191  func TryConnect(socketId int32, address js.String, uuid js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  1192  	ok = js.True == bindings.TryConnect(
  1193  		js.Pointer(&ret), js.Pointer(&exception),
  1194  		int32(socketId),
  1195  		address.Ref(),
  1196  		uuid.Ref(),
  1197  	)
  1198  
  1199  	return
  1200  }
  1201  
  1202  // HasFuncCreate returns true if the function "WEBEXT.bluetoothSocket.create" exists.
  1203  func HasFuncCreate() bool {
  1204  	return js.True == bindings.HasFuncCreate()
  1205  }
  1206  
  1207  // FuncCreate returns the function "WEBEXT.bluetoothSocket.create".
  1208  func FuncCreate() (fn js.Func[func(properties SocketProperties) js.Promise[CreateInfo]]) {
  1209  	bindings.FuncCreate(
  1210  		js.Pointer(&fn),
  1211  	)
  1212  	return
  1213  }
  1214  
  1215  // Create calls the function "WEBEXT.bluetoothSocket.create" directly.
  1216  func Create(properties SocketProperties) (ret js.Promise[CreateInfo]) {
  1217  	bindings.CallCreate(
  1218  		js.Pointer(&ret),
  1219  		js.Pointer(&properties),
  1220  	)
  1221  
  1222  	return
  1223  }
  1224  
  1225  // TryCreate calls the function "WEBEXT.bluetoothSocket.create"
  1226  // in a try/catch block and returns (_, err, ok = false) when it went through
  1227  // the catch clause.
  1228  func TryCreate(properties SocketProperties) (ret js.Promise[CreateInfo], exception js.Any, ok bool) {
  1229  	ok = js.True == bindings.TryCreate(
  1230  		js.Pointer(&ret), js.Pointer(&exception),
  1231  		js.Pointer(&properties),
  1232  	)
  1233  
  1234  	return
  1235  }
  1236  
  1237  // HasFuncDisconnect returns true if the function "WEBEXT.bluetoothSocket.disconnect" exists.
  1238  func HasFuncDisconnect() bool {
  1239  	return js.True == bindings.HasFuncDisconnect()
  1240  }
  1241  
  1242  // FuncDisconnect returns the function "WEBEXT.bluetoothSocket.disconnect".
  1243  func FuncDisconnect() (fn js.Func[func(socketId int32) js.Promise[js.Void]]) {
  1244  	bindings.FuncDisconnect(
  1245  		js.Pointer(&fn),
  1246  	)
  1247  	return
  1248  }
  1249  
  1250  // Disconnect calls the function "WEBEXT.bluetoothSocket.disconnect" directly.
  1251  func Disconnect(socketId int32) (ret js.Promise[js.Void]) {
  1252  	bindings.CallDisconnect(
  1253  		js.Pointer(&ret),
  1254  		int32(socketId),
  1255  	)
  1256  
  1257  	return
  1258  }
  1259  
  1260  // TryDisconnect calls the function "WEBEXT.bluetoothSocket.disconnect"
  1261  // in a try/catch block and returns (_, err, ok = false) when it went through
  1262  // the catch clause.
  1263  func TryDisconnect(socketId int32) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  1264  	ok = js.True == bindings.TryDisconnect(
  1265  		js.Pointer(&ret), js.Pointer(&exception),
  1266  		int32(socketId),
  1267  	)
  1268  
  1269  	return
  1270  }
  1271  
  1272  // HasFuncGetInfo returns true if the function "WEBEXT.bluetoothSocket.getInfo" exists.
  1273  func HasFuncGetInfo() bool {
  1274  	return js.True == bindings.HasFuncGetInfo()
  1275  }
  1276  
  1277  // FuncGetInfo returns the function "WEBEXT.bluetoothSocket.getInfo".
  1278  func FuncGetInfo() (fn js.Func[func(socketId int32) js.Promise[SocketInfo]]) {
  1279  	bindings.FuncGetInfo(
  1280  		js.Pointer(&fn),
  1281  	)
  1282  	return
  1283  }
  1284  
  1285  // GetInfo calls the function "WEBEXT.bluetoothSocket.getInfo" directly.
  1286  func GetInfo(socketId int32) (ret js.Promise[SocketInfo]) {
  1287  	bindings.CallGetInfo(
  1288  		js.Pointer(&ret),
  1289  		int32(socketId),
  1290  	)
  1291  
  1292  	return
  1293  }
  1294  
  1295  // TryGetInfo calls the function "WEBEXT.bluetoothSocket.getInfo"
  1296  // in a try/catch block and returns (_, err, ok = false) when it went through
  1297  // the catch clause.
  1298  func TryGetInfo(socketId int32) (ret js.Promise[SocketInfo], exception js.Any, ok bool) {
  1299  	ok = js.True == bindings.TryGetInfo(
  1300  		js.Pointer(&ret), js.Pointer(&exception),
  1301  		int32(socketId),
  1302  	)
  1303  
  1304  	return
  1305  }
  1306  
  1307  // HasFuncGetSockets returns true if the function "WEBEXT.bluetoothSocket.getSockets" exists.
  1308  func HasFuncGetSockets() bool {
  1309  	return js.True == bindings.HasFuncGetSockets()
  1310  }
  1311  
  1312  // FuncGetSockets returns the function "WEBEXT.bluetoothSocket.getSockets".
  1313  func FuncGetSockets() (fn js.Func[func() js.Promise[js.Array[SocketInfo]]]) {
  1314  	bindings.FuncGetSockets(
  1315  		js.Pointer(&fn),
  1316  	)
  1317  	return
  1318  }
  1319  
  1320  // GetSockets calls the function "WEBEXT.bluetoothSocket.getSockets" directly.
  1321  func GetSockets() (ret js.Promise[js.Array[SocketInfo]]) {
  1322  	bindings.CallGetSockets(
  1323  		js.Pointer(&ret),
  1324  	)
  1325  
  1326  	return
  1327  }
  1328  
  1329  // TryGetSockets calls the function "WEBEXT.bluetoothSocket.getSockets"
  1330  // in a try/catch block and returns (_, err, ok = false) when it went through
  1331  // the catch clause.
  1332  func TryGetSockets() (ret js.Promise[js.Array[SocketInfo]], exception js.Any, ok bool) {
  1333  	ok = js.True == bindings.TryGetSockets(
  1334  		js.Pointer(&ret), js.Pointer(&exception),
  1335  	)
  1336  
  1337  	return
  1338  }
  1339  
  1340  // HasFuncListenUsingL2cap returns true if the function "WEBEXT.bluetoothSocket.listenUsingL2cap" exists.
  1341  func HasFuncListenUsingL2cap() bool {
  1342  	return js.True == bindings.HasFuncListenUsingL2cap()
  1343  }
  1344  
  1345  // FuncListenUsingL2cap returns the function "WEBEXT.bluetoothSocket.listenUsingL2cap".
  1346  func FuncListenUsingL2cap() (fn js.Func[func(socketId int32, uuid js.String, options ListenOptions) js.Promise[js.Void]]) {
  1347  	bindings.FuncListenUsingL2cap(
  1348  		js.Pointer(&fn),
  1349  	)
  1350  	return
  1351  }
  1352  
  1353  // ListenUsingL2cap calls the function "WEBEXT.bluetoothSocket.listenUsingL2cap" directly.
  1354  func ListenUsingL2cap(socketId int32, uuid js.String, options ListenOptions) (ret js.Promise[js.Void]) {
  1355  	bindings.CallListenUsingL2cap(
  1356  		js.Pointer(&ret),
  1357  		int32(socketId),
  1358  		uuid.Ref(),
  1359  		js.Pointer(&options),
  1360  	)
  1361  
  1362  	return
  1363  }
  1364  
  1365  // TryListenUsingL2cap calls the function "WEBEXT.bluetoothSocket.listenUsingL2cap"
  1366  // in a try/catch block and returns (_, err, ok = false) when it went through
  1367  // the catch clause.
  1368  func TryListenUsingL2cap(socketId int32, uuid js.String, options ListenOptions) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  1369  	ok = js.True == bindings.TryListenUsingL2cap(
  1370  		js.Pointer(&ret), js.Pointer(&exception),
  1371  		int32(socketId),
  1372  		uuid.Ref(),
  1373  		js.Pointer(&options),
  1374  	)
  1375  
  1376  	return
  1377  }
  1378  
  1379  // HasFuncListenUsingRfcomm returns true if the function "WEBEXT.bluetoothSocket.listenUsingRfcomm" exists.
  1380  func HasFuncListenUsingRfcomm() bool {
  1381  	return js.True == bindings.HasFuncListenUsingRfcomm()
  1382  }
  1383  
  1384  // FuncListenUsingRfcomm returns the function "WEBEXT.bluetoothSocket.listenUsingRfcomm".
  1385  func FuncListenUsingRfcomm() (fn js.Func[func(socketId int32, uuid js.String, options ListenOptions) js.Promise[js.Void]]) {
  1386  	bindings.FuncListenUsingRfcomm(
  1387  		js.Pointer(&fn),
  1388  	)
  1389  	return
  1390  }
  1391  
  1392  // ListenUsingRfcomm calls the function "WEBEXT.bluetoothSocket.listenUsingRfcomm" directly.
  1393  func ListenUsingRfcomm(socketId int32, uuid js.String, options ListenOptions) (ret js.Promise[js.Void]) {
  1394  	bindings.CallListenUsingRfcomm(
  1395  		js.Pointer(&ret),
  1396  		int32(socketId),
  1397  		uuid.Ref(),
  1398  		js.Pointer(&options),
  1399  	)
  1400  
  1401  	return
  1402  }
  1403  
  1404  // TryListenUsingRfcomm calls the function "WEBEXT.bluetoothSocket.listenUsingRfcomm"
  1405  // in a try/catch block and returns (_, err, ok = false) when it went through
  1406  // the catch clause.
  1407  func TryListenUsingRfcomm(socketId int32, uuid js.String, options ListenOptions) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  1408  	ok = js.True == bindings.TryListenUsingRfcomm(
  1409  		js.Pointer(&ret), js.Pointer(&exception),
  1410  		int32(socketId),
  1411  		uuid.Ref(),
  1412  		js.Pointer(&options),
  1413  	)
  1414  
  1415  	return
  1416  }
  1417  
  1418  type OnAcceptEventCallbackFunc func(this js.Ref, info *AcceptInfo) js.Ref
  1419  
  1420  func (fn OnAcceptEventCallbackFunc) Register() js.Func[func(info *AcceptInfo)] {
  1421  	return js.RegisterCallback[func(info *AcceptInfo)](
  1422  		fn, abi.FuncPCABIInternal(fn),
  1423  	)
  1424  }
  1425  
  1426  func (fn OnAcceptEventCallbackFunc) DispatchCallback(
  1427  	targetPC uintptr, ctx *js.CallbackContext,
  1428  ) {
  1429  	args := ctx.Args()
  1430  	if len(args) != 1+1 /* js this */ ||
  1431  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
  1432  		js.ThrowInvalidCallbackInvocation()
  1433  	}
  1434  	var arg0 AcceptInfo
  1435  	arg0.UpdateFrom(args[0+1])
  1436  	defer arg0.FreeMembers(true)
  1437  
  1438  	if ctx.Return(fn(
  1439  		args[0],
  1440  
  1441  		mark.NoEscape(&arg0),
  1442  	)) {
  1443  		return
  1444  	}
  1445  
  1446  	js.ThrowCallbackValueNotReturned()
  1447  }
  1448  
  1449  type OnAcceptEventCallback[T any] struct {
  1450  	Fn  func(arg T, this js.Ref, info *AcceptInfo) js.Ref
  1451  	Arg T
  1452  }
  1453  
  1454  func (cb *OnAcceptEventCallback[T]) Register() js.Func[func(info *AcceptInfo)] {
  1455  	return js.RegisterCallback[func(info *AcceptInfo)](
  1456  		cb, abi.FuncPCABIInternal(cb.Fn),
  1457  	)
  1458  }
  1459  
  1460  func (cb *OnAcceptEventCallback[T]) DispatchCallback(
  1461  	targetPC uintptr, ctx *js.CallbackContext,
  1462  ) {
  1463  	args := ctx.Args()
  1464  	if len(args) != 1+1 /* js this */ ||
  1465  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
  1466  		js.ThrowInvalidCallbackInvocation()
  1467  	}
  1468  	var arg0 AcceptInfo
  1469  	arg0.UpdateFrom(args[0+1])
  1470  	defer arg0.FreeMembers(true)
  1471  
  1472  	if ctx.Return(cb.Fn(
  1473  		cb.Arg,
  1474  		args[0],
  1475  
  1476  		mark.NoEscape(&arg0),
  1477  	)) {
  1478  		return
  1479  	}
  1480  
  1481  	js.ThrowCallbackValueNotReturned()
  1482  }
  1483  
  1484  // HasFuncOnAccept returns true if the function "WEBEXT.bluetoothSocket.onAccept.addListener" exists.
  1485  func HasFuncOnAccept() bool {
  1486  	return js.True == bindings.HasFuncOnAccept()
  1487  }
  1488  
  1489  // FuncOnAccept returns the function "WEBEXT.bluetoothSocket.onAccept.addListener".
  1490  func FuncOnAccept() (fn js.Func[func(callback js.Func[func(info *AcceptInfo)])]) {
  1491  	bindings.FuncOnAccept(
  1492  		js.Pointer(&fn),
  1493  	)
  1494  	return
  1495  }
  1496  
  1497  // OnAccept calls the function "WEBEXT.bluetoothSocket.onAccept.addListener" directly.
  1498  func OnAccept(callback js.Func[func(info *AcceptInfo)]) (ret js.Void) {
  1499  	bindings.CallOnAccept(
  1500  		js.Pointer(&ret),
  1501  		callback.Ref(),
  1502  	)
  1503  
  1504  	return
  1505  }
  1506  
  1507  // TryOnAccept calls the function "WEBEXT.bluetoothSocket.onAccept.addListener"
  1508  // in a try/catch block and returns (_, err, ok = false) when it went through
  1509  // the catch clause.
  1510  func TryOnAccept(callback js.Func[func(info *AcceptInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1511  	ok = js.True == bindings.TryOnAccept(
  1512  		js.Pointer(&ret), js.Pointer(&exception),
  1513  		callback.Ref(),
  1514  	)
  1515  
  1516  	return
  1517  }
  1518  
  1519  // HasFuncOffAccept returns true if the function "WEBEXT.bluetoothSocket.onAccept.removeListener" exists.
  1520  func HasFuncOffAccept() bool {
  1521  	return js.True == bindings.HasFuncOffAccept()
  1522  }
  1523  
  1524  // FuncOffAccept returns the function "WEBEXT.bluetoothSocket.onAccept.removeListener".
  1525  func FuncOffAccept() (fn js.Func[func(callback js.Func[func(info *AcceptInfo)])]) {
  1526  	bindings.FuncOffAccept(
  1527  		js.Pointer(&fn),
  1528  	)
  1529  	return
  1530  }
  1531  
  1532  // OffAccept calls the function "WEBEXT.bluetoothSocket.onAccept.removeListener" directly.
  1533  func OffAccept(callback js.Func[func(info *AcceptInfo)]) (ret js.Void) {
  1534  	bindings.CallOffAccept(
  1535  		js.Pointer(&ret),
  1536  		callback.Ref(),
  1537  	)
  1538  
  1539  	return
  1540  }
  1541  
  1542  // TryOffAccept calls the function "WEBEXT.bluetoothSocket.onAccept.removeListener"
  1543  // in a try/catch block and returns (_, err, ok = false) when it went through
  1544  // the catch clause.
  1545  func TryOffAccept(callback js.Func[func(info *AcceptInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1546  	ok = js.True == bindings.TryOffAccept(
  1547  		js.Pointer(&ret), js.Pointer(&exception),
  1548  		callback.Ref(),
  1549  	)
  1550  
  1551  	return
  1552  }
  1553  
  1554  // HasFuncHasOnAccept returns true if the function "WEBEXT.bluetoothSocket.onAccept.hasListener" exists.
  1555  func HasFuncHasOnAccept() bool {
  1556  	return js.True == bindings.HasFuncHasOnAccept()
  1557  }
  1558  
  1559  // FuncHasOnAccept returns the function "WEBEXT.bluetoothSocket.onAccept.hasListener".
  1560  func FuncHasOnAccept() (fn js.Func[func(callback js.Func[func(info *AcceptInfo)]) bool]) {
  1561  	bindings.FuncHasOnAccept(
  1562  		js.Pointer(&fn),
  1563  	)
  1564  	return
  1565  }
  1566  
  1567  // HasOnAccept calls the function "WEBEXT.bluetoothSocket.onAccept.hasListener" directly.
  1568  func HasOnAccept(callback js.Func[func(info *AcceptInfo)]) (ret bool) {
  1569  	bindings.CallHasOnAccept(
  1570  		js.Pointer(&ret),
  1571  		callback.Ref(),
  1572  	)
  1573  
  1574  	return
  1575  }
  1576  
  1577  // TryHasOnAccept calls the function "WEBEXT.bluetoothSocket.onAccept.hasListener"
  1578  // in a try/catch block and returns (_, err, ok = false) when it went through
  1579  // the catch clause.
  1580  func TryHasOnAccept(callback js.Func[func(info *AcceptInfo)]) (ret bool, exception js.Any, ok bool) {
  1581  	ok = js.True == bindings.TryHasOnAccept(
  1582  		js.Pointer(&ret), js.Pointer(&exception),
  1583  		callback.Ref(),
  1584  	)
  1585  
  1586  	return
  1587  }
  1588  
  1589  type OnAcceptErrorEventCallbackFunc func(this js.Ref, info *AcceptErrorInfo) js.Ref
  1590  
  1591  func (fn OnAcceptErrorEventCallbackFunc) Register() js.Func[func(info *AcceptErrorInfo)] {
  1592  	return js.RegisterCallback[func(info *AcceptErrorInfo)](
  1593  		fn, abi.FuncPCABIInternal(fn),
  1594  	)
  1595  }
  1596  
  1597  func (fn OnAcceptErrorEventCallbackFunc) DispatchCallback(
  1598  	targetPC uintptr, ctx *js.CallbackContext,
  1599  ) {
  1600  	args := ctx.Args()
  1601  	if len(args) != 1+1 /* js this */ ||
  1602  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
  1603  		js.ThrowInvalidCallbackInvocation()
  1604  	}
  1605  	var arg0 AcceptErrorInfo
  1606  	arg0.UpdateFrom(args[0+1])
  1607  	defer arg0.FreeMembers(true)
  1608  
  1609  	if ctx.Return(fn(
  1610  		args[0],
  1611  
  1612  		mark.NoEscape(&arg0),
  1613  	)) {
  1614  		return
  1615  	}
  1616  
  1617  	js.ThrowCallbackValueNotReturned()
  1618  }
  1619  
  1620  type OnAcceptErrorEventCallback[T any] struct {
  1621  	Fn  func(arg T, this js.Ref, info *AcceptErrorInfo) js.Ref
  1622  	Arg T
  1623  }
  1624  
  1625  func (cb *OnAcceptErrorEventCallback[T]) Register() js.Func[func(info *AcceptErrorInfo)] {
  1626  	return js.RegisterCallback[func(info *AcceptErrorInfo)](
  1627  		cb, abi.FuncPCABIInternal(cb.Fn),
  1628  	)
  1629  }
  1630  
  1631  func (cb *OnAcceptErrorEventCallback[T]) DispatchCallback(
  1632  	targetPC uintptr, ctx *js.CallbackContext,
  1633  ) {
  1634  	args := ctx.Args()
  1635  	if len(args) != 1+1 /* js this */ ||
  1636  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
  1637  		js.ThrowInvalidCallbackInvocation()
  1638  	}
  1639  	var arg0 AcceptErrorInfo
  1640  	arg0.UpdateFrom(args[0+1])
  1641  	defer arg0.FreeMembers(true)
  1642  
  1643  	if ctx.Return(cb.Fn(
  1644  		cb.Arg,
  1645  		args[0],
  1646  
  1647  		mark.NoEscape(&arg0),
  1648  	)) {
  1649  		return
  1650  	}
  1651  
  1652  	js.ThrowCallbackValueNotReturned()
  1653  }
  1654  
  1655  // HasFuncOnAcceptError returns true if the function "WEBEXT.bluetoothSocket.onAcceptError.addListener" exists.
  1656  func HasFuncOnAcceptError() bool {
  1657  	return js.True == bindings.HasFuncOnAcceptError()
  1658  }
  1659  
  1660  // FuncOnAcceptError returns the function "WEBEXT.bluetoothSocket.onAcceptError.addListener".
  1661  func FuncOnAcceptError() (fn js.Func[func(callback js.Func[func(info *AcceptErrorInfo)])]) {
  1662  	bindings.FuncOnAcceptError(
  1663  		js.Pointer(&fn),
  1664  	)
  1665  	return
  1666  }
  1667  
  1668  // OnAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.addListener" directly.
  1669  func OnAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret js.Void) {
  1670  	bindings.CallOnAcceptError(
  1671  		js.Pointer(&ret),
  1672  		callback.Ref(),
  1673  	)
  1674  
  1675  	return
  1676  }
  1677  
  1678  // TryOnAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.addListener"
  1679  // in a try/catch block and returns (_, err, ok = false) when it went through
  1680  // the catch clause.
  1681  func TryOnAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1682  	ok = js.True == bindings.TryOnAcceptError(
  1683  		js.Pointer(&ret), js.Pointer(&exception),
  1684  		callback.Ref(),
  1685  	)
  1686  
  1687  	return
  1688  }
  1689  
  1690  // HasFuncOffAcceptError returns true if the function "WEBEXT.bluetoothSocket.onAcceptError.removeListener" exists.
  1691  func HasFuncOffAcceptError() bool {
  1692  	return js.True == bindings.HasFuncOffAcceptError()
  1693  }
  1694  
  1695  // FuncOffAcceptError returns the function "WEBEXT.bluetoothSocket.onAcceptError.removeListener".
  1696  func FuncOffAcceptError() (fn js.Func[func(callback js.Func[func(info *AcceptErrorInfo)])]) {
  1697  	bindings.FuncOffAcceptError(
  1698  		js.Pointer(&fn),
  1699  	)
  1700  	return
  1701  }
  1702  
  1703  // OffAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.removeListener" directly.
  1704  func OffAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret js.Void) {
  1705  	bindings.CallOffAcceptError(
  1706  		js.Pointer(&ret),
  1707  		callback.Ref(),
  1708  	)
  1709  
  1710  	return
  1711  }
  1712  
  1713  // TryOffAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.removeListener"
  1714  // in a try/catch block and returns (_, err, ok = false) when it went through
  1715  // the catch clause.
  1716  func TryOffAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1717  	ok = js.True == bindings.TryOffAcceptError(
  1718  		js.Pointer(&ret), js.Pointer(&exception),
  1719  		callback.Ref(),
  1720  	)
  1721  
  1722  	return
  1723  }
  1724  
  1725  // HasFuncHasOnAcceptError returns true if the function "WEBEXT.bluetoothSocket.onAcceptError.hasListener" exists.
  1726  func HasFuncHasOnAcceptError() bool {
  1727  	return js.True == bindings.HasFuncHasOnAcceptError()
  1728  }
  1729  
  1730  // FuncHasOnAcceptError returns the function "WEBEXT.bluetoothSocket.onAcceptError.hasListener".
  1731  func FuncHasOnAcceptError() (fn js.Func[func(callback js.Func[func(info *AcceptErrorInfo)]) bool]) {
  1732  	bindings.FuncHasOnAcceptError(
  1733  		js.Pointer(&fn),
  1734  	)
  1735  	return
  1736  }
  1737  
  1738  // HasOnAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.hasListener" directly.
  1739  func HasOnAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret bool) {
  1740  	bindings.CallHasOnAcceptError(
  1741  		js.Pointer(&ret),
  1742  		callback.Ref(),
  1743  	)
  1744  
  1745  	return
  1746  }
  1747  
  1748  // TryHasOnAcceptError calls the function "WEBEXT.bluetoothSocket.onAcceptError.hasListener"
  1749  // in a try/catch block and returns (_, err, ok = false) when it went through
  1750  // the catch clause.
  1751  func TryHasOnAcceptError(callback js.Func[func(info *AcceptErrorInfo)]) (ret bool, exception js.Any, ok bool) {
  1752  	ok = js.True == bindings.TryHasOnAcceptError(
  1753  		js.Pointer(&ret), js.Pointer(&exception),
  1754  		callback.Ref(),
  1755  	)
  1756  
  1757  	return
  1758  }
  1759  
  1760  type OnReceiveEventCallbackFunc func(this js.Ref, info *ReceiveInfo) js.Ref
  1761  
  1762  func (fn OnReceiveEventCallbackFunc) Register() js.Func[func(info *ReceiveInfo)] {
  1763  	return js.RegisterCallback[func(info *ReceiveInfo)](
  1764  		fn, abi.FuncPCABIInternal(fn),
  1765  	)
  1766  }
  1767  
  1768  func (fn OnReceiveEventCallbackFunc) DispatchCallback(
  1769  	targetPC uintptr, ctx *js.CallbackContext,
  1770  ) {
  1771  	args := ctx.Args()
  1772  	if len(args) != 1+1 /* js this */ ||
  1773  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
  1774  		js.ThrowInvalidCallbackInvocation()
  1775  	}
  1776  	var arg0 ReceiveInfo
  1777  	arg0.UpdateFrom(args[0+1])
  1778  	defer arg0.FreeMembers(true)
  1779  
  1780  	if ctx.Return(fn(
  1781  		args[0],
  1782  
  1783  		mark.NoEscape(&arg0),
  1784  	)) {
  1785  		return
  1786  	}
  1787  
  1788  	js.ThrowCallbackValueNotReturned()
  1789  }
  1790  
  1791  type OnReceiveEventCallback[T any] struct {
  1792  	Fn  func(arg T, this js.Ref, info *ReceiveInfo) js.Ref
  1793  	Arg T
  1794  }
  1795  
  1796  func (cb *OnReceiveEventCallback[T]) Register() js.Func[func(info *ReceiveInfo)] {
  1797  	return js.RegisterCallback[func(info *ReceiveInfo)](
  1798  		cb, abi.FuncPCABIInternal(cb.Fn),
  1799  	)
  1800  }
  1801  
  1802  func (cb *OnReceiveEventCallback[T]) DispatchCallback(
  1803  	targetPC uintptr, ctx *js.CallbackContext,
  1804  ) {
  1805  	args := ctx.Args()
  1806  	if len(args) != 1+1 /* js this */ ||
  1807  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
  1808  		js.ThrowInvalidCallbackInvocation()
  1809  	}
  1810  	var arg0 ReceiveInfo
  1811  	arg0.UpdateFrom(args[0+1])
  1812  	defer arg0.FreeMembers(true)
  1813  
  1814  	if ctx.Return(cb.Fn(
  1815  		cb.Arg,
  1816  		args[0],
  1817  
  1818  		mark.NoEscape(&arg0),
  1819  	)) {
  1820  		return
  1821  	}
  1822  
  1823  	js.ThrowCallbackValueNotReturned()
  1824  }
  1825  
  1826  // HasFuncOnReceive returns true if the function "WEBEXT.bluetoothSocket.onReceive.addListener" exists.
  1827  func HasFuncOnReceive() bool {
  1828  	return js.True == bindings.HasFuncOnReceive()
  1829  }
  1830  
  1831  // FuncOnReceive returns the function "WEBEXT.bluetoothSocket.onReceive.addListener".
  1832  func FuncOnReceive() (fn js.Func[func(callback js.Func[func(info *ReceiveInfo)])]) {
  1833  	bindings.FuncOnReceive(
  1834  		js.Pointer(&fn),
  1835  	)
  1836  	return
  1837  }
  1838  
  1839  // OnReceive calls the function "WEBEXT.bluetoothSocket.onReceive.addListener" directly.
  1840  func OnReceive(callback js.Func[func(info *ReceiveInfo)]) (ret js.Void) {
  1841  	bindings.CallOnReceive(
  1842  		js.Pointer(&ret),
  1843  		callback.Ref(),
  1844  	)
  1845  
  1846  	return
  1847  }
  1848  
  1849  // TryOnReceive calls the function "WEBEXT.bluetoothSocket.onReceive.addListener"
  1850  // in a try/catch block and returns (_, err, ok = false) when it went through
  1851  // the catch clause.
  1852  func TryOnReceive(callback js.Func[func(info *ReceiveInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1853  	ok = js.True == bindings.TryOnReceive(
  1854  		js.Pointer(&ret), js.Pointer(&exception),
  1855  		callback.Ref(),
  1856  	)
  1857  
  1858  	return
  1859  }
  1860  
  1861  // HasFuncOffReceive returns true if the function "WEBEXT.bluetoothSocket.onReceive.removeListener" exists.
  1862  func HasFuncOffReceive() bool {
  1863  	return js.True == bindings.HasFuncOffReceive()
  1864  }
  1865  
  1866  // FuncOffReceive returns the function "WEBEXT.bluetoothSocket.onReceive.removeListener".
  1867  func FuncOffReceive() (fn js.Func[func(callback js.Func[func(info *ReceiveInfo)])]) {
  1868  	bindings.FuncOffReceive(
  1869  		js.Pointer(&fn),
  1870  	)
  1871  	return
  1872  }
  1873  
  1874  // OffReceive calls the function "WEBEXT.bluetoothSocket.onReceive.removeListener" directly.
  1875  func OffReceive(callback js.Func[func(info *ReceiveInfo)]) (ret js.Void) {
  1876  	bindings.CallOffReceive(
  1877  		js.Pointer(&ret),
  1878  		callback.Ref(),
  1879  	)
  1880  
  1881  	return
  1882  }
  1883  
  1884  // TryOffReceive calls the function "WEBEXT.bluetoothSocket.onReceive.removeListener"
  1885  // in a try/catch block and returns (_, err, ok = false) when it went through
  1886  // the catch clause.
  1887  func TryOffReceive(callback js.Func[func(info *ReceiveInfo)]) (ret js.Void, exception js.Any, ok bool) {
  1888  	ok = js.True == bindings.TryOffReceive(
  1889  		js.Pointer(&ret), js.Pointer(&exception),
  1890  		callback.Ref(),
  1891  	)
  1892  
  1893  	return
  1894  }
  1895  
  1896  // HasFuncHasOnReceive returns true if the function "WEBEXT.bluetoothSocket.onReceive.hasListener" exists.
  1897  func HasFuncHasOnReceive() bool {
  1898  	return js.True == bindings.HasFuncHasOnReceive()
  1899  }
  1900  
  1901  // FuncHasOnReceive returns the function "WEBEXT.bluetoothSocket.onReceive.hasListener".
  1902  func FuncHasOnReceive() (fn js.Func[func(callback js.Func[func(info *ReceiveInfo)]) bool]) {
  1903  	bindings.FuncHasOnReceive(
  1904  		js.Pointer(&fn),
  1905  	)
  1906  	return
  1907  }
  1908  
  1909  // HasOnReceive calls the function "WEBEXT.bluetoothSocket.onReceive.hasListener" directly.
  1910  func HasOnReceive(callback js.Func[func(info *ReceiveInfo)]) (ret bool) {
  1911  	bindings.CallHasOnReceive(
  1912  		js.Pointer(&ret),
  1913  		callback.Ref(),
  1914  	)
  1915  
  1916  	return
  1917  }
  1918  
  1919  // TryHasOnReceive calls the function "WEBEXT.bluetoothSocket.onReceive.hasListener"
  1920  // in a try/catch block and returns (_, err, ok = false) when it went through
  1921  // the catch clause.
  1922  func TryHasOnReceive(callback js.Func[func(info *ReceiveInfo)]) (ret bool, exception js.Any, ok bool) {
  1923  	ok = js.True == bindings.TryHasOnReceive(
  1924  		js.Pointer(&ret), js.Pointer(&exception),
  1925  		callback.Ref(),
  1926  	)
  1927  
  1928  	return
  1929  }
  1930  
  1931  type OnReceiveErrorEventCallbackFunc func(this js.Ref, info *ReceiveErrorInfo) js.Ref
  1932  
  1933  func (fn OnReceiveErrorEventCallbackFunc) Register() js.Func[func(info *ReceiveErrorInfo)] {
  1934  	return js.RegisterCallback[func(info *ReceiveErrorInfo)](
  1935  		fn, abi.FuncPCABIInternal(fn),
  1936  	)
  1937  }
  1938  
  1939  func (fn OnReceiveErrorEventCallbackFunc) DispatchCallback(
  1940  	targetPC uintptr, ctx *js.CallbackContext,
  1941  ) {
  1942  	args := ctx.Args()
  1943  	if len(args) != 1+1 /* js this */ ||
  1944  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
  1945  		js.ThrowInvalidCallbackInvocation()
  1946  	}
  1947  	var arg0 ReceiveErrorInfo
  1948  	arg0.UpdateFrom(args[0+1])
  1949  	defer arg0.FreeMembers(true)
  1950  
  1951  	if ctx.Return(fn(
  1952  		args[0],
  1953  
  1954  		mark.NoEscape(&arg0),
  1955  	)) {
  1956  		return
  1957  	}
  1958  
  1959  	js.ThrowCallbackValueNotReturned()
  1960  }
  1961  
  1962  type OnReceiveErrorEventCallback[T any] struct {
  1963  	Fn  func(arg T, this js.Ref, info *ReceiveErrorInfo) js.Ref
  1964  	Arg T
  1965  }
  1966  
  1967  func (cb *OnReceiveErrorEventCallback[T]) Register() js.Func[func(info *ReceiveErrorInfo)] {
  1968  	return js.RegisterCallback[func(info *ReceiveErrorInfo)](
  1969  		cb, abi.FuncPCABIInternal(cb.Fn),
  1970  	)
  1971  }
  1972  
  1973  func (cb *OnReceiveErrorEventCallback[T]) DispatchCallback(
  1974  	targetPC uintptr, ctx *js.CallbackContext,
  1975  ) {
  1976  	args := ctx.Args()
  1977  	if len(args) != 1+1 /* js this */ ||
  1978  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
  1979  		js.ThrowInvalidCallbackInvocation()
  1980  	}
  1981  	var arg0 ReceiveErrorInfo
  1982  	arg0.UpdateFrom(args[0+1])
  1983  	defer arg0.FreeMembers(true)
  1984  
  1985  	if ctx.Return(cb.Fn(
  1986  		cb.Arg,
  1987  		args[0],
  1988  
  1989  		mark.NoEscape(&arg0),
  1990  	)) {
  1991  		return
  1992  	}
  1993  
  1994  	js.ThrowCallbackValueNotReturned()
  1995  }
  1996  
  1997  // HasFuncOnReceiveError returns true if the function "WEBEXT.bluetoothSocket.onReceiveError.addListener" exists.
  1998  func HasFuncOnReceiveError() bool {
  1999  	return js.True == bindings.HasFuncOnReceiveError()
  2000  }
  2001  
  2002  // FuncOnReceiveError returns the function "WEBEXT.bluetoothSocket.onReceiveError.addListener".
  2003  func FuncOnReceiveError() (fn js.Func[func(callback js.Func[func(info *ReceiveErrorInfo)])]) {
  2004  	bindings.FuncOnReceiveError(
  2005  		js.Pointer(&fn),
  2006  	)
  2007  	return
  2008  }
  2009  
  2010  // OnReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.addListener" directly.
  2011  func OnReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret js.Void) {
  2012  	bindings.CallOnReceiveError(
  2013  		js.Pointer(&ret),
  2014  		callback.Ref(),
  2015  	)
  2016  
  2017  	return
  2018  }
  2019  
  2020  // TryOnReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.addListener"
  2021  // in a try/catch block and returns (_, err, ok = false) when it went through
  2022  // the catch clause.
  2023  func TryOnReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret js.Void, exception js.Any, ok bool) {
  2024  	ok = js.True == bindings.TryOnReceiveError(
  2025  		js.Pointer(&ret), js.Pointer(&exception),
  2026  		callback.Ref(),
  2027  	)
  2028  
  2029  	return
  2030  }
  2031  
  2032  // HasFuncOffReceiveError returns true if the function "WEBEXT.bluetoothSocket.onReceiveError.removeListener" exists.
  2033  func HasFuncOffReceiveError() bool {
  2034  	return js.True == bindings.HasFuncOffReceiveError()
  2035  }
  2036  
  2037  // FuncOffReceiveError returns the function "WEBEXT.bluetoothSocket.onReceiveError.removeListener".
  2038  func FuncOffReceiveError() (fn js.Func[func(callback js.Func[func(info *ReceiveErrorInfo)])]) {
  2039  	bindings.FuncOffReceiveError(
  2040  		js.Pointer(&fn),
  2041  	)
  2042  	return
  2043  }
  2044  
  2045  // OffReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.removeListener" directly.
  2046  func OffReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret js.Void) {
  2047  	bindings.CallOffReceiveError(
  2048  		js.Pointer(&ret),
  2049  		callback.Ref(),
  2050  	)
  2051  
  2052  	return
  2053  }
  2054  
  2055  // TryOffReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.removeListener"
  2056  // in a try/catch block and returns (_, err, ok = false) when it went through
  2057  // the catch clause.
  2058  func TryOffReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret js.Void, exception js.Any, ok bool) {
  2059  	ok = js.True == bindings.TryOffReceiveError(
  2060  		js.Pointer(&ret), js.Pointer(&exception),
  2061  		callback.Ref(),
  2062  	)
  2063  
  2064  	return
  2065  }
  2066  
  2067  // HasFuncHasOnReceiveError returns true if the function "WEBEXT.bluetoothSocket.onReceiveError.hasListener" exists.
  2068  func HasFuncHasOnReceiveError() bool {
  2069  	return js.True == bindings.HasFuncHasOnReceiveError()
  2070  }
  2071  
  2072  // FuncHasOnReceiveError returns the function "WEBEXT.bluetoothSocket.onReceiveError.hasListener".
  2073  func FuncHasOnReceiveError() (fn js.Func[func(callback js.Func[func(info *ReceiveErrorInfo)]) bool]) {
  2074  	bindings.FuncHasOnReceiveError(
  2075  		js.Pointer(&fn),
  2076  	)
  2077  	return
  2078  }
  2079  
  2080  // HasOnReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.hasListener" directly.
  2081  func HasOnReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret bool) {
  2082  	bindings.CallHasOnReceiveError(
  2083  		js.Pointer(&ret),
  2084  		callback.Ref(),
  2085  	)
  2086  
  2087  	return
  2088  }
  2089  
  2090  // TryHasOnReceiveError calls the function "WEBEXT.bluetoothSocket.onReceiveError.hasListener"
  2091  // in a try/catch block and returns (_, err, ok = false) when it went through
  2092  // the catch clause.
  2093  func TryHasOnReceiveError(callback js.Func[func(info *ReceiveErrorInfo)]) (ret bool, exception js.Any, ok bool) {
  2094  	ok = js.True == bindings.TryHasOnReceiveError(
  2095  		js.Pointer(&ret), js.Pointer(&exception),
  2096  		callback.Ref(),
  2097  	)
  2098  
  2099  	return
  2100  }
  2101  
  2102  // HasFuncSend returns true if the function "WEBEXT.bluetoothSocket.send" exists.
  2103  func HasFuncSend() bool {
  2104  	return js.True == bindings.HasFuncSend()
  2105  }
  2106  
  2107  // FuncSend returns the function "WEBEXT.bluetoothSocket.send".
  2108  func FuncSend() (fn js.Func[func(socketId int32, data js.ArrayBuffer) js.Promise[js.Number[int32]]]) {
  2109  	bindings.FuncSend(
  2110  		js.Pointer(&fn),
  2111  	)
  2112  	return
  2113  }
  2114  
  2115  // Send calls the function "WEBEXT.bluetoothSocket.send" directly.
  2116  func Send(socketId int32, data js.ArrayBuffer) (ret js.Promise[js.Number[int32]]) {
  2117  	bindings.CallSend(
  2118  		js.Pointer(&ret),
  2119  		int32(socketId),
  2120  		data.Ref(),
  2121  	)
  2122  
  2123  	return
  2124  }
  2125  
  2126  // TrySend calls the function "WEBEXT.bluetoothSocket.send"
  2127  // in a try/catch block and returns (_, err, ok = false) when it went through
  2128  // the catch clause.
  2129  func TrySend(socketId int32, data js.ArrayBuffer) (ret js.Promise[js.Number[int32]], exception js.Any, ok bool) {
  2130  	ok = js.True == bindings.TrySend(
  2131  		js.Pointer(&ret), js.Pointer(&exception),
  2132  		int32(socketId),
  2133  		data.Ref(),
  2134  	)
  2135  
  2136  	return
  2137  }
  2138  
  2139  // HasFuncSetPaused returns true if the function "WEBEXT.bluetoothSocket.setPaused" exists.
  2140  func HasFuncSetPaused() bool {
  2141  	return js.True == bindings.HasFuncSetPaused()
  2142  }
  2143  
  2144  // FuncSetPaused returns the function "WEBEXT.bluetoothSocket.setPaused".
  2145  func FuncSetPaused() (fn js.Func[func(socketId int32, paused bool) js.Promise[js.Void]]) {
  2146  	bindings.FuncSetPaused(
  2147  		js.Pointer(&fn),
  2148  	)
  2149  	return
  2150  }
  2151  
  2152  // SetPaused calls the function "WEBEXT.bluetoothSocket.setPaused" directly.
  2153  func SetPaused(socketId int32, paused bool) (ret js.Promise[js.Void]) {
  2154  	bindings.CallSetPaused(
  2155  		js.Pointer(&ret),
  2156  		int32(socketId),
  2157  		js.Bool(bool(paused)),
  2158  	)
  2159  
  2160  	return
  2161  }
  2162  
  2163  // TrySetPaused calls the function "WEBEXT.bluetoothSocket.setPaused"
  2164  // in a try/catch block and returns (_, err, ok = false) when it went through
  2165  // the catch clause.
  2166  func TrySetPaused(socketId int32, paused bool) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  2167  	ok = js.True == bindings.TrySetPaused(
  2168  		js.Pointer(&ret), js.Pointer(&exception),
  2169  		int32(socketId),
  2170  		js.Bool(bool(paused)),
  2171  	)
  2172  
  2173  	return
  2174  }
  2175  
  2176  // HasFuncUpdate returns true if the function "WEBEXT.bluetoothSocket.update" exists.
  2177  func HasFuncUpdate() bool {
  2178  	return js.True == bindings.HasFuncUpdate()
  2179  }
  2180  
  2181  // FuncUpdate returns the function "WEBEXT.bluetoothSocket.update".
  2182  func FuncUpdate() (fn js.Func[func(socketId int32, properties SocketProperties) js.Promise[js.Void]]) {
  2183  	bindings.FuncUpdate(
  2184  		js.Pointer(&fn),
  2185  	)
  2186  	return
  2187  }
  2188  
  2189  // Update calls the function "WEBEXT.bluetoothSocket.update" directly.
  2190  func Update(socketId int32, properties SocketProperties) (ret js.Promise[js.Void]) {
  2191  	bindings.CallUpdate(
  2192  		js.Pointer(&ret),
  2193  		int32(socketId),
  2194  		js.Pointer(&properties),
  2195  	)
  2196  
  2197  	return
  2198  }
  2199  
  2200  // TryUpdate calls the function "WEBEXT.bluetoothSocket.update"
  2201  // in a try/catch block and returns (_, err, ok = false) when it went through
  2202  // the catch clause.
  2203  func TryUpdate(socketId int32, properties SocketProperties) (ret js.Promise[js.Void], exception js.Any, ok bool) {
  2204  	ok = js.True == bindings.TryUpdate(
  2205  		js.Pointer(&ret), js.Pointer(&exception),
  2206  		int32(socketId),
  2207  		js.Pointer(&properties),
  2208  	)
  2209  
  2210  	return
  2211  }