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

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