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

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package speechrecognitionprivate
     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/speechrecognitionprivate/bindings"
    11  )
    12  
    13  type OnStartCallbackFunc func(this js.Ref, typ SpeechRecognitionType) js.Ref
    14  
    15  func (fn OnStartCallbackFunc) Register() js.Func[func(typ SpeechRecognitionType)] {
    16  	return js.RegisterCallback[func(typ SpeechRecognitionType)](
    17  		fn, abi.FuncPCABIInternal(fn),
    18  	)
    19  }
    20  
    21  func (fn OnStartCallbackFunc) DispatchCallback(
    22  	targetPC uintptr, ctx *js.CallbackContext,
    23  ) {
    24  	args := ctx.Args()
    25  	if len(args) != 1+1 /* js this */ ||
    26  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
    27  		js.ThrowInvalidCallbackInvocation()
    28  	}
    29  
    30  	if ctx.Return(fn(
    31  		args[0],
    32  
    33  		SpeechRecognitionType(0).FromRef(args[0+1]),
    34  	)) {
    35  		return
    36  	}
    37  
    38  	js.ThrowCallbackValueNotReturned()
    39  }
    40  
    41  type OnStartCallback[T any] struct {
    42  	Fn  func(arg T, this js.Ref, typ SpeechRecognitionType) js.Ref
    43  	Arg T
    44  }
    45  
    46  func (cb *OnStartCallback[T]) Register() js.Func[func(typ SpeechRecognitionType)] {
    47  	return js.RegisterCallback[func(typ SpeechRecognitionType)](
    48  		cb, abi.FuncPCABIInternal(cb.Fn),
    49  	)
    50  }
    51  
    52  func (cb *OnStartCallback[T]) DispatchCallback(
    53  	targetPC uintptr, ctx *js.CallbackContext,
    54  ) {
    55  	args := ctx.Args()
    56  	if len(args) != 1+1 /* js this */ ||
    57  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
    58  		js.ThrowInvalidCallbackInvocation()
    59  	}
    60  
    61  	if ctx.Return(cb.Fn(
    62  		cb.Arg,
    63  		args[0],
    64  
    65  		SpeechRecognitionType(0).FromRef(args[0+1]),
    66  	)) {
    67  		return
    68  	}
    69  
    70  	js.ThrowCallbackValueNotReturned()
    71  }
    72  
    73  type SpeechRecognitionType uint32
    74  
    75  const (
    76  	_ SpeechRecognitionType = iota
    77  
    78  	SpeechRecognitionType_ON_DEVICE
    79  	SpeechRecognitionType_NETWORK
    80  )
    81  
    82  func (SpeechRecognitionType) FromRef(str js.Ref) SpeechRecognitionType {
    83  	return SpeechRecognitionType(bindings.ConstOfSpeechRecognitionType(str))
    84  }
    85  
    86  func (x SpeechRecognitionType) String() (string, bool) {
    87  	switch x {
    88  	case SpeechRecognitionType_ON_DEVICE:
    89  		return "onDevice", true
    90  	case SpeechRecognitionType_NETWORK:
    91  		return "network", true
    92  	default:
    93  		return "", false
    94  	}
    95  }
    96  
    97  type OnStopCallbackFunc func(this js.Ref) js.Ref
    98  
    99  func (fn OnStopCallbackFunc) Register() js.Func[func()] {
   100  	return js.RegisterCallback[func()](
   101  		fn, abi.FuncPCABIInternal(fn),
   102  	)
   103  }
   104  
   105  func (fn OnStopCallbackFunc) DispatchCallback(
   106  	targetPC uintptr, ctx *js.CallbackContext,
   107  ) {
   108  	args := ctx.Args()
   109  	if len(args) != 0+1 /* js this */ ||
   110  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   111  		js.ThrowInvalidCallbackInvocation()
   112  	}
   113  
   114  	if ctx.Return(fn(
   115  		args[0],
   116  	)) {
   117  		return
   118  	}
   119  
   120  	js.ThrowCallbackValueNotReturned()
   121  }
   122  
   123  type OnStopCallback[T any] struct {
   124  	Fn  func(arg T, this js.Ref) js.Ref
   125  	Arg T
   126  }
   127  
   128  func (cb *OnStopCallback[T]) Register() js.Func[func()] {
   129  	return js.RegisterCallback[func()](
   130  		cb, abi.FuncPCABIInternal(cb.Fn),
   131  	)
   132  }
   133  
   134  func (cb *OnStopCallback[T]) DispatchCallback(
   135  	targetPC uintptr, ctx *js.CallbackContext,
   136  ) {
   137  	args := ctx.Args()
   138  	if len(args) != 0+1 /* js this */ ||
   139  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   140  		js.ThrowInvalidCallbackInvocation()
   141  	}
   142  
   143  	if ctx.Return(cb.Fn(
   144  		cb.Arg,
   145  		args[0],
   146  	)) {
   147  		return
   148  	}
   149  
   150  	js.ThrowCallbackValueNotReturned()
   151  }
   152  
   153  type SpeechRecognitionErrorEvent struct {
   154  	// ClientId is "SpeechRecognitionErrorEvent.clientId"
   155  	//
   156  	// Optional
   157  	//
   158  	// NOTE: FFI_USE_ClientId MUST be set to true to make this field effective.
   159  	ClientId int32
   160  	// Message is "SpeechRecognitionErrorEvent.message"
   161  	//
   162  	// Optional
   163  	Message js.String
   164  
   165  	FFI_USE_ClientId bool // for ClientId.
   166  
   167  	FFI_USE bool
   168  }
   169  
   170  // FromRef calls UpdateFrom and returns a SpeechRecognitionErrorEvent with all fields set.
   171  func (p SpeechRecognitionErrorEvent) FromRef(ref js.Ref) SpeechRecognitionErrorEvent {
   172  	p.UpdateFrom(ref)
   173  	return p
   174  }
   175  
   176  // New creates a new SpeechRecognitionErrorEvent in the application heap.
   177  func (p SpeechRecognitionErrorEvent) New() js.Ref {
   178  	return bindings.SpeechRecognitionErrorEventJSLoad(
   179  		js.Pointer(&p), js.True, 0,
   180  	)
   181  }
   182  
   183  // UpdateFrom copies value of all fields of the heap object to p.
   184  func (p *SpeechRecognitionErrorEvent) UpdateFrom(ref js.Ref) {
   185  	bindings.SpeechRecognitionErrorEventJSStore(
   186  		js.Pointer(p), ref,
   187  	)
   188  }
   189  
   190  // Update writes all fields of the p to the heap object referenced by ref.
   191  func (p *SpeechRecognitionErrorEvent) Update(ref js.Ref) {
   192  	bindings.SpeechRecognitionErrorEventJSLoad(
   193  		js.Pointer(p), js.False, ref,
   194  	)
   195  }
   196  
   197  // FreeMembers frees fields with heap reference, if recursive is true
   198  // free all heap references reachable from p.
   199  func (p *SpeechRecognitionErrorEvent) FreeMembers(recursive bool) {
   200  	js.Free(
   201  		p.Message.Ref(),
   202  	)
   203  	p.Message = p.Message.FromRef(js.Undefined)
   204  }
   205  
   206  type SpeechRecognitionResultEvent struct {
   207  	// ClientId is "SpeechRecognitionResultEvent.clientId"
   208  	//
   209  	// Optional
   210  	//
   211  	// NOTE: FFI_USE_ClientId MUST be set to true to make this field effective.
   212  	ClientId int32
   213  	// Transcript is "SpeechRecognitionResultEvent.transcript"
   214  	//
   215  	// Optional
   216  	Transcript js.String
   217  	// IsFinal is "SpeechRecognitionResultEvent.isFinal"
   218  	//
   219  	// Optional
   220  	//
   221  	// NOTE: FFI_USE_IsFinal MUST be set to true to make this field effective.
   222  	IsFinal bool
   223  
   224  	FFI_USE_ClientId bool // for ClientId.
   225  	FFI_USE_IsFinal  bool // for IsFinal.
   226  
   227  	FFI_USE bool
   228  }
   229  
   230  // FromRef calls UpdateFrom and returns a SpeechRecognitionResultEvent with all fields set.
   231  func (p SpeechRecognitionResultEvent) FromRef(ref js.Ref) SpeechRecognitionResultEvent {
   232  	p.UpdateFrom(ref)
   233  	return p
   234  }
   235  
   236  // New creates a new SpeechRecognitionResultEvent in the application heap.
   237  func (p SpeechRecognitionResultEvent) New() js.Ref {
   238  	return bindings.SpeechRecognitionResultEventJSLoad(
   239  		js.Pointer(&p), js.True, 0,
   240  	)
   241  }
   242  
   243  // UpdateFrom copies value of all fields of the heap object to p.
   244  func (p *SpeechRecognitionResultEvent) UpdateFrom(ref js.Ref) {
   245  	bindings.SpeechRecognitionResultEventJSStore(
   246  		js.Pointer(p), ref,
   247  	)
   248  }
   249  
   250  // Update writes all fields of the p to the heap object referenced by ref.
   251  func (p *SpeechRecognitionResultEvent) Update(ref js.Ref) {
   252  	bindings.SpeechRecognitionResultEventJSLoad(
   253  		js.Pointer(p), js.False, ref,
   254  	)
   255  }
   256  
   257  // FreeMembers frees fields with heap reference, if recursive is true
   258  // free all heap references reachable from p.
   259  func (p *SpeechRecognitionResultEvent) FreeMembers(recursive bool) {
   260  	js.Free(
   261  		p.Transcript.Ref(),
   262  	)
   263  	p.Transcript = p.Transcript.FromRef(js.Undefined)
   264  }
   265  
   266  type SpeechRecognitionStopEvent struct {
   267  	// ClientId is "SpeechRecognitionStopEvent.clientId"
   268  	//
   269  	// Optional
   270  	//
   271  	// NOTE: FFI_USE_ClientId MUST be set to true to make this field effective.
   272  	ClientId int32
   273  
   274  	FFI_USE_ClientId bool // for ClientId.
   275  
   276  	FFI_USE bool
   277  }
   278  
   279  // FromRef calls UpdateFrom and returns a SpeechRecognitionStopEvent with all fields set.
   280  func (p SpeechRecognitionStopEvent) FromRef(ref js.Ref) SpeechRecognitionStopEvent {
   281  	p.UpdateFrom(ref)
   282  	return p
   283  }
   284  
   285  // New creates a new SpeechRecognitionStopEvent in the application heap.
   286  func (p SpeechRecognitionStopEvent) New() js.Ref {
   287  	return bindings.SpeechRecognitionStopEventJSLoad(
   288  		js.Pointer(&p), js.True, 0,
   289  	)
   290  }
   291  
   292  // UpdateFrom copies value of all fields of the heap object to p.
   293  func (p *SpeechRecognitionStopEvent) UpdateFrom(ref js.Ref) {
   294  	bindings.SpeechRecognitionStopEventJSStore(
   295  		js.Pointer(p), ref,
   296  	)
   297  }
   298  
   299  // Update writes all fields of the p to the heap object referenced by ref.
   300  func (p *SpeechRecognitionStopEvent) Update(ref js.Ref) {
   301  	bindings.SpeechRecognitionStopEventJSLoad(
   302  		js.Pointer(p), js.False, ref,
   303  	)
   304  }
   305  
   306  // FreeMembers frees fields with heap reference, if recursive is true
   307  // free all heap references reachable from p.
   308  func (p *SpeechRecognitionStopEvent) FreeMembers(recursive bool) {
   309  }
   310  
   311  type StartOptions struct {
   312  	// ClientId is "StartOptions.clientId"
   313  	//
   314  	// Optional
   315  	//
   316  	// NOTE: FFI_USE_ClientId MUST be set to true to make this field effective.
   317  	ClientId int32
   318  	// Locale is "StartOptions.locale"
   319  	//
   320  	// Optional
   321  	Locale js.String
   322  	// InterimResults is "StartOptions.interimResults"
   323  	//
   324  	// Optional
   325  	//
   326  	// NOTE: FFI_USE_InterimResults MUST be set to true to make this field effective.
   327  	InterimResults bool
   328  
   329  	FFI_USE_ClientId       bool // for ClientId.
   330  	FFI_USE_InterimResults bool // for InterimResults.
   331  
   332  	FFI_USE bool
   333  }
   334  
   335  // FromRef calls UpdateFrom and returns a StartOptions with all fields set.
   336  func (p StartOptions) FromRef(ref js.Ref) StartOptions {
   337  	p.UpdateFrom(ref)
   338  	return p
   339  }
   340  
   341  // New creates a new StartOptions in the application heap.
   342  func (p StartOptions) New() js.Ref {
   343  	return bindings.StartOptionsJSLoad(
   344  		js.Pointer(&p), js.True, 0,
   345  	)
   346  }
   347  
   348  // UpdateFrom copies value of all fields of the heap object to p.
   349  func (p *StartOptions) UpdateFrom(ref js.Ref) {
   350  	bindings.StartOptionsJSStore(
   351  		js.Pointer(p), ref,
   352  	)
   353  }
   354  
   355  // Update writes all fields of the p to the heap object referenced by ref.
   356  func (p *StartOptions) Update(ref js.Ref) {
   357  	bindings.StartOptionsJSLoad(
   358  		js.Pointer(p), js.False, ref,
   359  	)
   360  }
   361  
   362  // FreeMembers frees fields with heap reference, if recursive is true
   363  // free all heap references reachable from p.
   364  func (p *StartOptions) FreeMembers(recursive bool) {
   365  	js.Free(
   366  		p.Locale.Ref(),
   367  	)
   368  	p.Locale = p.Locale.FromRef(js.Undefined)
   369  }
   370  
   371  type StopOptions struct {
   372  	// ClientId is "StopOptions.clientId"
   373  	//
   374  	// Optional
   375  	//
   376  	// NOTE: FFI_USE_ClientId MUST be set to true to make this field effective.
   377  	ClientId int32
   378  
   379  	FFI_USE_ClientId bool // for ClientId.
   380  
   381  	FFI_USE bool
   382  }
   383  
   384  // FromRef calls UpdateFrom and returns a StopOptions with all fields set.
   385  func (p StopOptions) FromRef(ref js.Ref) StopOptions {
   386  	p.UpdateFrom(ref)
   387  	return p
   388  }
   389  
   390  // New creates a new StopOptions in the application heap.
   391  func (p StopOptions) New() js.Ref {
   392  	return bindings.StopOptionsJSLoad(
   393  		js.Pointer(&p), js.True, 0,
   394  	)
   395  }
   396  
   397  // UpdateFrom copies value of all fields of the heap object to p.
   398  func (p *StopOptions) UpdateFrom(ref js.Ref) {
   399  	bindings.StopOptionsJSStore(
   400  		js.Pointer(p), ref,
   401  	)
   402  }
   403  
   404  // Update writes all fields of the p to the heap object referenced by ref.
   405  func (p *StopOptions) Update(ref js.Ref) {
   406  	bindings.StopOptionsJSLoad(
   407  		js.Pointer(p), js.False, ref,
   408  	)
   409  }
   410  
   411  // FreeMembers frees fields with heap reference, if recursive is true
   412  // free all heap references reachable from p.
   413  func (p *StopOptions) FreeMembers(recursive bool) {
   414  }
   415  
   416  type OnErrorEventCallbackFunc func(this js.Ref, event *SpeechRecognitionErrorEvent) js.Ref
   417  
   418  func (fn OnErrorEventCallbackFunc) Register() js.Func[func(event *SpeechRecognitionErrorEvent)] {
   419  	return js.RegisterCallback[func(event *SpeechRecognitionErrorEvent)](
   420  		fn, abi.FuncPCABIInternal(fn),
   421  	)
   422  }
   423  
   424  func (fn OnErrorEventCallbackFunc) DispatchCallback(
   425  	targetPC uintptr, ctx *js.CallbackContext,
   426  ) {
   427  	args := ctx.Args()
   428  	if len(args) != 1+1 /* js this */ ||
   429  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   430  		js.ThrowInvalidCallbackInvocation()
   431  	}
   432  	var arg0 SpeechRecognitionErrorEvent
   433  	arg0.UpdateFrom(args[0+1])
   434  	defer arg0.FreeMembers(true)
   435  
   436  	if ctx.Return(fn(
   437  		args[0],
   438  
   439  		mark.NoEscape(&arg0),
   440  	)) {
   441  		return
   442  	}
   443  
   444  	js.ThrowCallbackValueNotReturned()
   445  }
   446  
   447  type OnErrorEventCallback[T any] struct {
   448  	Fn  func(arg T, this js.Ref, event *SpeechRecognitionErrorEvent) js.Ref
   449  	Arg T
   450  }
   451  
   452  func (cb *OnErrorEventCallback[T]) Register() js.Func[func(event *SpeechRecognitionErrorEvent)] {
   453  	return js.RegisterCallback[func(event *SpeechRecognitionErrorEvent)](
   454  		cb, abi.FuncPCABIInternal(cb.Fn),
   455  	)
   456  }
   457  
   458  func (cb *OnErrorEventCallback[T]) DispatchCallback(
   459  	targetPC uintptr, ctx *js.CallbackContext,
   460  ) {
   461  	args := ctx.Args()
   462  	if len(args) != 1+1 /* js this */ ||
   463  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   464  		js.ThrowInvalidCallbackInvocation()
   465  	}
   466  	var arg0 SpeechRecognitionErrorEvent
   467  	arg0.UpdateFrom(args[0+1])
   468  	defer arg0.FreeMembers(true)
   469  
   470  	if ctx.Return(cb.Fn(
   471  		cb.Arg,
   472  		args[0],
   473  
   474  		mark.NoEscape(&arg0),
   475  	)) {
   476  		return
   477  	}
   478  
   479  	js.ThrowCallbackValueNotReturned()
   480  }
   481  
   482  // HasFuncOnError returns true if the function "WEBEXT.speechRecognitionPrivate.onError.addListener" exists.
   483  func HasFuncOnError() bool {
   484  	return js.True == bindings.HasFuncOnError()
   485  }
   486  
   487  // FuncOnError returns the function "WEBEXT.speechRecognitionPrivate.onError.addListener".
   488  func FuncOnError() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionErrorEvent)])]) {
   489  	bindings.FuncOnError(
   490  		js.Pointer(&fn),
   491  	)
   492  	return
   493  }
   494  
   495  // OnError calls the function "WEBEXT.speechRecognitionPrivate.onError.addListener" directly.
   496  func OnError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret js.Void) {
   497  	bindings.CallOnError(
   498  		js.Pointer(&ret),
   499  		callback.Ref(),
   500  	)
   501  
   502  	return
   503  }
   504  
   505  // TryOnError calls the function "WEBEXT.speechRecognitionPrivate.onError.addListener"
   506  // in a try/catch block and returns (_, err, ok = false) when it went through
   507  // the catch clause.
   508  func TryOnError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret js.Void, exception js.Any, ok bool) {
   509  	ok = js.True == bindings.TryOnError(
   510  		js.Pointer(&ret), js.Pointer(&exception),
   511  		callback.Ref(),
   512  	)
   513  
   514  	return
   515  }
   516  
   517  // HasFuncOffError returns true if the function "WEBEXT.speechRecognitionPrivate.onError.removeListener" exists.
   518  func HasFuncOffError() bool {
   519  	return js.True == bindings.HasFuncOffError()
   520  }
   521  
   522  // FuncOffError returns the function "WEBEXT.speechRecognitionPrivate.onError.removeListener".
   523  func FuncOffError() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionErrorEvent)])]) {
   524  	bindings.FuncOffError(
   525  		js.Pointer(&fn),
   526  	)
   527  	return
   528  }
   529  
   530  // OffError calls the function "WEBEXT.speechRecognitionPrivate.onError.removeListener" directly.
   531  func OffError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret js.Void) {
   532  	bindings.CallOffError(
   533  		js.Pointer(&ret),
   534  		callback.Ref(),
   535  	)
   536  
   537  	return
   538  }
   539  
   540  // TryOffError calls the function "WEBEXT.speechRecognitionPrivate.onError.removeListener"
   541  // in a try/catch block and returns (_, err, ok = false) when it went through
   542  // the catch clause.
   543  func TryOffError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret js.Void, exception js.Any, ok bool) {
   544  	ok = js.True == bindings.TryOffError(
   545  		js.Pointer(&ret), js.Pointer(&exception),
   546  		callback.Ref(),
   547  	)
   548  
   549  	return
   550  }
   551  
   552  // HasFuncHasOnError returns true if the function "WEBEXT.speechRecognitionPrivate.onError.hasListener" exists.
   553  func HasFuncHasOnError() bool {
   554  	return js.True == bindings.HasFuncHasOnError()
   555  }
   556  
   557  // FuncHasOnError returns the function "WEBEXT.speechRecognitionPrivate.onError.hasListener".
   558  func FuncHasOnError() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) bool]) {
   559  	bindings.FuncHasOnError(
   560  		js.Pointer(&fn),
   561  	)
   562  	return
   563  }
   564  
   565  // HasOnError calls the function "WEBEXT.speechRecognitionPrivate.onError.hasListener" directly.
   566  func HasOnError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret bool) {
   567  	bindings.CallHasOnError(
   568  		js.Pointer(&ret),
   569  		callback.Ref(),
   570  	)
   571  
   572  	return
   573  }
   574  
   575  // TryHasOnError calls the function "WEBEXT.speechRecognitionPrivate.onError.hasListener"
   576  // in a try/catch block and returns (_, err, ok = false) when it went through
   577  // the catch clause.
   578  func TryHasOnError(callback js.Func[func(event *SpeechRecognitionErrorEvent)]) (ret bool, exception js.Any, ok bool) {
   579  	ok = js.True == bindings.TryHasOnError(
   580  		js.Pointer(&ret), js.Pointer(&exception),
   581  		callback.Ref(),
   582  	)
   583  
   584  	return
   585  }
   586  
   587  type OnResultEventCallbackFunc func(this js.Ref, event *SpeechRecognitionResultEvent) js.Ref
   588  
   589  func (fn OnResultEventCallbackFunc) Register() js.Func[func(event *SpeechRecognitionResultEvent)] {
   590  	return js.RegisterCallback[func(event *SpeechRecognitionResultEvent)](
   591  		fn, abi.FuncPCABIInternal(fn),
   592  	)
   593  }
   594  
   595  func (fn OnResultEventCallbackFunc) DispatchCallback(
   596  	targetPC uintptr, ctx *js.CallbackContext,
   597  ) {
   598  	args := ctx.Args()
   599  	if len(args) != 1+1 /* js this */ ||
   600  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   601  		js.ThrowInvalidCallbackInvocation()
   602  	}
   603  	var arg0 SpeechRecognitionResultEvent
   604  	arg0.UpdateFrom(args[0+1])
   605  	defer arg0.FreeMembers(true)
   606  
   607  	if ctx.Return(fn(
   608  		args[0],
   609  
   610  		mark.NoEscape(&arg0),
   611  	)) {
   612  		return
   613  	}
   614  
   615  	js.ThrowCallbackValueNotReturned()
   616  }
   617  
   618  type OnResultEventCallback[T any] struct {
   619  	Fn  func(arg T, this js.Ref, event *SpeechRecognitionResultEvent) js.Ref
   620  	Arg T
   621  }
   622  
   623  func (cb *OnResultEventCallback[T]) Register() js.Func[func(event *SpeechRecognitionResultEvent)] {
   624  	return js.RegisterCallback[func(event *SpeechRecognitionResultEvent)](
   625  		cb, abi.FuncPCABIInternal(cb.Fn),
   626  	)
   627  }
   628  
   629  func (cb *OnResultEventCallback[T]) DispatchCallback(
   630  	targetPC uintptr, ctx *js.CallbackContext,
   631  ) {
   632  	args := ctx.Args()
   633  	if len(args) != 1+1 /* js this */ ||
   634  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   635  		js.ThrowInvalidCallbackInvocation()
   636  	}
   637  	var arg0 SpeechRecognitionResultEvent
   638  	arg0.UpdateFrom(args[0+1])
   639  	defer arg0.FreeMembers(true)
   640  
   641  	if ctx.Return(cb.Fn(
   642  		cb.Arg,
   643  		args[0],
   644  
   645  		mark.NoEscape(&arg0),
   646  	)) {
   647  		return
   648  	}
   649  
   650  	js.ThrowCallbackValueNotReturned()
   651  }
   652  
   653  // HasFuncOnResult returns true if the function "WEBEXT.speechRecognitionPrivate.onResult.addListener" exists.
   654  func HasFuncOnResult() bool {
   655  	return js.True == bindings.HasFuncOnResult()
   656  }
   657  
   658  // FuncOnResult returns the function "WEBEXT.speechRecognitionPrivate.onResult.addListener".
   659  func FuncOnResult() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionResultEvent)])]) {
   660  	bindings.FuncOnResult(
   661  		js.Pointer(&fn),
   662  	)
   663  	return
   664  }
   665  
   666  // OnResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.addListener" directly.
   667  func OnResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret js.Void) {
   668  	bindings.CallOnResult(
   669  		js.Pointer(&ret),
   670  		callback.Ref(),
   671  	)
   672  
   673  	return
   674  }
   675  
   676  // TryOnResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.addListener"
   677  // in a try/catch block and returns (_, err, ok = false) when it went through
   678  // the catch clause.
   679  func TryOnResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret js.Void, exception js.Any, ok bool) {
   680  	ok = js.True == bindings.TryOnResult(
   681  		js.Pointer(&ret), js.Pointer(&exception),
   682  		callback.Ref(),
   683  	)
   684  
   685  	return
   686  }
   687  
   688  // HasFuncOffResult returns true if the function "WEBEXT.speechRecognitionPrivate.onResult.removeListener" exists.
   689  func HasFuncOffResult() bool {
   690  	return js.True == bindings.HasFuncOffResult()
   691  }
   692  
   693  // FuncOffResult returns the function "WEBEXT.speechRecognitionPrivate.onResult.removeListener".
   694  func FuncOffResult() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionResultEvent)])]) {
   695  	bindings.FuncOffResult(
   696  		js.Pointer(&fn),
   697  	)
   698  	return
   699  }
   700  
   701  // OffResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.removeListener" directly.
   702  func OffResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret js.Void) {
   703  	bindings.CallOffResult(
   704  		js.Pointer(&ret),
   705  		callback.Ref(),
   706  	)
   707  
   708  	return
   709  }
   710  
   711  // TryOffResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.removeListener"
   712  // in a try/catch block and returns (_, err, ok = false) when it went through
   713  // the catch clause.
   714  func TryOffResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret js.Void, exception js.Any, ok bool) {
   715  	ok = js.True == bindings.TryOffResult(
   716  		js.Pointer(&ret), js.Pointer(&exception),
   717  		callback.Ref(),
   718  	)
   719  
   720  	return
   721  }
   722  
   723  // HasFuncHasOnResult returns true if the function "WEBEXT.speechRecognitionPrivate.onResult.hasListener" exists.
   724  func HasFuncHasOnResult() bool {
   725  	return js.True == bindings.HasFuncHasOnResult()
   726  }
   727  
   728  // FuncHasOnResult returns the function "WEBEXT.speechRecognitionPrivate.onResult.hasListener".
   729  func FuncHasOnResult() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionResultEvent)]) bool]) {
   730  	bindings.FuncHasOnResult(
   731  		js.Pointer(&fn),
   732  	)
   733  	return
   734  }
   735  
   736  // HasOnResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.hasListener" directly.
   737  func HasOnResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret bool) {
   738  	bindings.CallHasOnResult(
   739  		js.Pointer(&ret),
   740  		callback.Ref(),
   741  	)
   742  
   743  	return
   744  }
   745  
   746  // TryHasOnResult calls the function "WEBEXT.speechRecognitionPrivate.onResult.hasListener"
   747  // in a try/catch block and returns (_, err, ok = false) when it went through
   748  // the catch clause.
   749  func TryHasOnResult(callback js.Func[func(event *SpeechRecognitionResultEvent)]) (ret bool, exception js.Any, ok bool) {
   750  	ok = js.True == bindings.TryHasOnResult(
   751  		js.Pointer(&ret), js.Pointer(&exception),
   752  		callback.Ref(),
   753  	)
   754  
   755  	return
   756  }
   757  
   758  type OnStopEventCallbackFunc func(this js.Ref, event *SpeechRecognitionStopEvent) js.Ref
   759  
   760  func (fn OnStopEventCallbackFunc) Register() js.Func[func(event *SpeechRecognitionStopEvent)] {
   761  	return js.RegisterCallback[func(event *SpeechRecognitionStopEvent)](
   762  		fn, abi.FuncPCABIInternal(fn),
   763  	)
   764  }
   765  
   766  func (fn OnStopEventCallbackFunc) DispatchCallback(
   767  	targetPC uintptr, ctx *js.CallbackContext,
   768  ) {
   769  	args := ctx.Args()
   770  	if len(args) != 1+1 /* js this */ ||
   771  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   772  		js.ThrowInvalidCallbackInvocation()
   773  	}
   774  	var arg0 SpeechRecognitionStopEvent
   775  	arg0.UpdateFrom(args[0+1])
   776  	defer arg0.FreeMembers(true)
   777  
   778  	if ctx.Return(fn(
   779  		args[0],
   780  
   781  		mark.NoEscape(&arg0),
   782  	)) {
   783  		return
   784  	}
   785  
   786  	js.ThrowCallbackValueNotReturned()
   787  }
   788  
   789  type OnStopEventCallback[T any] struct {
   790  	Fn  func(arg T, this js.Ref, event *SpeechRecognitionStopEvent) js.Ref
   791  	Arg T
   792  }
   793  
   794  func (cb *OnStopEventCallback[T]) Register() js.Func[func(event *SpeechRecognitionStopEvent)] {
   795  	return js.RegisterCallback[func(event *SpeechRecognitionStopEvent)](
   796  		cb, abi.FuncPCABIInternal(cb.Fn),
   797  	)
   798  }
   799  
   800  func (cb *OnStopEventCallback[T]) DispatchCallback(
   801  	targetPC uintptr, ctx *js.CallbackContext,
   802  ) {
   803  	args := ctx.Args()
   804  	if len(args) != 1+1 /* js this */ ||
   805  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   806  		js.ThrowInvalidCallbackInvocation()
   807  	}
   808  	var arg0 SpeechRecognitionStopEvent
   809  	arg0.UpdateFrom(args[0+1])
   810  	defer arg0.FreeMembers(true)
   811  
   812  	if ctx.Return(cb.Fn(
   813  		cb.Arg,
   814  		args[0],
   815  
   816  		mark.NoEscape(&arg0),
   817  	)) {
   818  		return
   819  	}
   820  
   821  	js.ThrowCallbackValueNotReturned()
   822  }
   823  
   824  // HasFuncOnStop returns true if the function "WEBEXT.speechRecognitionPrivate.onStop.addListener" exists.
   825  func HasFuncOnStop() bool {
   826  	return js.True == bindings.HasFuncOnStop()
   827  }
   828  
   829  // FuncOnStop returns the function "WEBEXT.speechRecognitionPrivate.onStop.addListener".
   830  func FuncOnStop() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionStopEvent)])]) {
   831  	bindings.FuncOnStop(
   832  		js.Pointer(&fn),
   833  	)
   834  	return
   835  }
   836  
   837  // OnStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.addListener" directly.
   838  func OnStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret js.Void) {
   839  	bindings.CallOnStop(
   840  		js.Pointer(&ret),
   841  		callback.Ref(),
   842  	)
   843  
   844  	return
   845  }
   846  
   847  // TryOnStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.addListener"
   848  // in a try/catch block and returns (_, err, ok = false) when it went through
   849  // the catch clause.
   850  func TryOnStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret js.Void, exception js.Any, ok bool) {
   851  	ok = js.True == bindings.TryOnStop(
   852  		js.Pointer(&ret), js.Pointer(&exception),
   853  		callback.Ref(),
   854  	)
   855  
   856  	return
   857  }
   858  
   859  // HasFuncOffStop returns true if the function "WEBEXT.speechRecognitionPrivate.onStop.removeListener" exists.
   860  func HasFuncOffStop() bool {
   861  	return js.True == bindings.HasFuncOffStop()
   862  }
   863  
   864  // FuncOffStop returns the function "WEBEXT.speechRecognitionPrivate.onStop.removeListener".
   865  func FuncOffStop() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionStopEvent)])]) {
   866  	bindings.FuncOffStop(
   867  		js.Pointer(&fn),
   868  	)
   869  	return
   870  }
   871  
   872  // OffStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.removeListener" directly.
   873  func OffStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret js.Void) {
   874  	bindings.CallOffStop(
   875  		js.Pointer(&ret),
   876  		callback.Ref(),
   877  	)
   878  
   879  	return
   880  }
   881  
   882  // TryOffStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.removeListener"
   883  // in a try/catch block and returns (_, err, ok = false) when it went through
   884  // the catch clause.
   885  func TryOffStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret js.Void, exception js.Any, ok bool) {
   886  	ok = js.True == bindings.TryOffStop(
   887  		js.Pointer(&ret), js.Pointer(&exception),
   888  		callback.Ref(),
   889  	)
   890  
   891  	return
   892  }
   893  
   894  // HasFuncHasOnStop returns true if the function "WEBEXT.speechRecognitionPrivate.onStop.hasListener" exists.
   895  func HasFuncHasOnStop() bool {
   896  	return js.True == bindings.HasFuncHasOnStop()
   897  }
   898  
   899  // FuncHasOnStop returns the function "WEBEXT.speechRecognitionPrivate.onStop.hasListener".
   900  func FuncHasOnStop() (fn js.Func[func(callback js.Func[func(event *SpeechRecognitionStopEvent)]) bool]) {
   901  	bindings.FuncHasOnStop(
   902  		js.Pointer(&fn),
   903  	)
   904  	return
   905  }
   906  
   907  // HasOnStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.hasListener" directly.
   908  func HasOnStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret bool) {
   909  	bindings.CallHasOnStop(
   910  		js.Pointer(&ret),
   911  		callback.Ref(),
   912  	)
   913  
   914  	return
   915  }
   916  
   917  // TryHasOnStop calls the function "WEBEXT.speechRecognitionPrivate.onStop.hasListener"
   918  // in a try/catch block and returns (_, err, ok = false) when it went through
   919  // the catch clause.
   920  func TryHasOnStop(callback js.Func[func(event *SpeechRecognitionStopEvent)]) (ret bool, exception js.Any, ok bool) {
   921  	ok = js.True == bindings.TryHasOnStop(
   922  		js.Pointer(&ret), js.Pointer(&exception),
   923  		callback.Ref(),
   924  	)
   925  
   926  	return
   927  }
   928  
   929  // HasFuncStart returns true if the function "WEBEXT.speechRecognitionPrivate.start" exists.
   930  func HasFuncStart() bool {
   931  	return js.True == bindings.HasFuncStart()
   932  }
   933  
   934  // FuncStart returns the function "WEBEXT.speechRecognitionPrivate.start".
   935  func FuncStart() (fn js.Func[func(options StartOptions) js.Promise[SpeechRecognitionType]]) {
   936  	bindings.FuncStart(
   937  		js.Pointer(&fn),
   938  	)
   939  	return
   940  }
   941  
   942  // Start calls the function "WEBEXT.speechRecognitionPrivate.start" directly.
   943  func Start(options StartOptions) (ret js.Promise[SpeechRecognitionType]) {
   944  	bindings.CallStart(
   945  		js.Pointer(&ret),
   946  		js.Pointer(&options),
   947  	)
   948  
   949  	return
   950  }
   951  
   952  // TryStart calls the function "WEBEXT.speechRecognitionPrivate.start"
   953  // in a try/catch block and returns (_, err, ok = false) when it went through
   954  // the catch clause.
   955  func TryStart(options StartOptions) (ret js.Promise[SpeechRecognitionType], exception js.Any, ok bool) {
   956  	ok = js.True == bindings.TryStart(
   957  		js.Pointer(&ret), js.Pointer(&exception),
   958  		js.Pointer(&options),
   959  	)
   960  
   961  	return
   962  }
   963  
   964  // HasFuncStop returns true if the function "WEBEXT.speechRecognitionPrivate.stop" exists.
   965  func HasFuncStop() bool {
   966  	return js.True == bindings.HasFuncStop()
   967  }
   968  
   969  // FuncStop returns the function "WEBEXT.speechRecognitionPrivate.stop".
   970  func FuncStop() (fn js.Func[func(options StopOptions) js.Promise[js.Void]]) {
   971  	bindings.FuncStop(
   972  		js.Pointer(&fn),
   973  	)
   974  	return
   975  }
   976  
   977  // Stop calls the function "WEBEXT.speechRecognitionPrivate.stop" directly.
   978  func Stop(options StopOptions) (ret js.Promise[js.Void]) {
   979  	bindings.CallStop(
   980  		js.Pointer(&ret),
   981  		js.Pointer(&options),
   982  	)
   983  
   984  	return
   985  }
   986  
   987  // TryStop calls the function "WEBEXT.speechRecognitionPrivate.stop"
   988  // in a try/catch block and returns (_, err, ok = false) when it went through
   989  // the catch clause.
   990  func TryStop(options StopOptions) (ret js.Promise[js.Void], exception js.Any, ok bool) {
   991  	ok = js.True == bindings.TryStop(
   992  		js.Pointer(&ret), js.Pointer(&exception),
   993  		js.Pointer(&options),
   994  	)
   995  
   996  	return
   997  }