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

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package guestviewinternal
     5  
     6  import (
     7  	"github.com/primecitizens/pcz/std/ffi/js"
     8  	"github.com/primecitizens/pcz/std/plat/js/webext/guestviewinternal/bindings"
     9  )
    10  
    11  type Size struct {
    12  	// Height is "Size.height"
    13  	//
    14  	// Required
    15  	Height int64
    16  	// Width is "Size.width"
    17  	//
    18  	// Required
    19  	Width int64
    20  
    21  	FFI_USE bool
    22  }
    23  
    24  // FromRef calls UpdateFrom and returns a Size with all fields set.
    25  func (p Size) FromRef(ref js.Ref) Size {
    26  	p.UpdateFrom(ref)
    27  	return p
    28  }
    29  
    30  // New creates a new Size in the application heap.
    31  func (p Size) New() js.Ref {
    32  	return bindings.SizeJSLoad(
    33  		js.Pointer(&p), js.True, 0,
    34  	)
    35  }
    36  
    37  // UpdateFrom copies value of all fields of the heap object to p.
    38  func (p *Size) UpdateFrom(ref js.Ref) {
    39  	bindings.SizeJSStore(
    40  		js.Pointer(p), ref,
    41  	)
    42  }
    43  
    44  // Update writes all fields of the p to the heap object referenced by ref.
    45  func (p *Size) Update(ref js.Ref) {
    46  	bindings.SizeJSLoad(
    47  		js.Pointer(p), js.False, ref,
    48  	)
    49  }
    50  
    51  // FreeMembers frees fields with heap reference, if recursive is true
    52  // free all heap references reachable from p.
    53  func (p *Size) FreeMembers(recursive bool) {
    54  }
    55  
    56  type SizeParams struct {
    57  	// EnableAutoSize is "SizeParams.enableAutoSize"
    58  	//
    59  	// Optional
    60  	//
    61  	// NOTE: FFI_USE_EnableAutoSize MUST be set to true to make this field effective.
    62  	EnableAutoSize bool
    63  	// Max is "SizeParams.max"
    64  	//
    65  	// Optional
    66  	//
    67  	// NOTE: Max.FFI_USE MUST be set to true to get Max used.
    68  	Max Size
    69  	// Min is "SizeParams.min"
    70  	//
    71  	// Optional
    72  	//
    73  	// NOTE: Min.FFI_USE MUST be set to true to get Min used.
    74  	Min Size
    75  	// Normal is "SizeParams.normal"
    76  	//
    77  	// Optional
    78  	//
    79  	// NOTE: Normal.FFI_USE MUST be set to true to get Normal used.
    80  	Normal Size
    81  
    82  	FFI_USE_EnableAutoSize bool // for EnableAutoSize.
    83  
    84  	FFI_USE bool
    85  }
    86  
    87  // FromRef calls UpdateFrom and returns a SizeParams with all fields set.
    88  func (p SizeParams) FromRef(ref js.Ref) SizeParams {
    89  	p.UpdateFrom(ref)
    90  	return p
    91  }
    92  
    93  // New creates a new SizeParams in the application heap.
    94  func (p SizeParams) New() js.Ref {
    95  	return bindings.SizeParamsJSLoad(
    96  		js.Pointer(&p), js.True, 0,
    97  	)
    98  }
    99  
   100  // UpdateFrom copies value of all fields of the heap object to p.
   101  func (p *SizeParams) UpdateFrom(ref js.Ref) {
   102  	bindings.SizeParamsJSStore(
   103  		js.Pointer(p), ref,
   104  	)
   105  }
   106  
   107  // Update writes all fields of the p to the heap object referenced by ref.
   108  func (p *SizeParams) Update(ref js.Ref) {
   109  	bindings.SizeParamsJSLoad(
   110  		js.Pointer(p), js.False, ref,
   111  	)
   112  }
   113  
   114  // FreeMembers frees fields with heap reference, if recursive is true
   115  // free all heap references reachable from p.
   116  func (p *SizeParams) FreeMembers(recursive bool) {
   117  	if recursive {
   118  		p.Max.FreeMembers(true)
   119  		p.Min.FreeMembers(true)
   120  		p.Normal.FreeMembers(true)
   121  	}
   122  }
   123  
   124  // HasFuncCreateGuest returns true if the function "WEBEXT.guestViewInternal.createGuest" exists.
   125  func HasFuncCreateGuest() bool {
   126  	return js.True == bindings.HasFuncCreateGuest()
   127  }
   128  
   129  // FuncCreateGuest returns the function "WEBEXT.guestViewInternal.createGuest".
   130  func FuncCreateGuest() (fn js.Func[func(viewType js.String, ownerRoutingId int64, createParams js.Any) js.Promise[js.BigInt[int64]]]) {
   131  	bindings.FuncCreateGuest(
   132  		js.Pointer(&fn),
   133  	)
   134  	return
   135  }
   136  
   137  // CreateGuest calls the function "WEBEXT.guestViewInternal.createGuest" directly.
   138  func CreateGuest(viewType js.String, ownerRoutingId int64, createParams js.Any) (ret js.Promise[js.BigInt[int64]]) {
   139  	bindings.CallCreateGuest(
   140  		js.Pointer(&ret),
   141  		viewType.Ref(),
   142  		float64(ownerRoutingId),
   143  		createParams.Ref(),
   144  	)
   145  
   146  	return
   147  }
   148  
   149  // TryCreateGuest calls the function "WEBEXT.guestViewInternal.createGuest"
   150  // in a try/catch block and returns (_, err, ok = false) when it went through
   151  // the catch clause.
   152  func TryCreateGuest(viewType js.String, ownerRoutingId int64, createParams js.Any) (ret js.Promise[js.BigInt[int64]], exception js.Any, ok bool) {
   153  	ok = js.True == bindings.TryCreateGuest(
   154  		js.Pointer(&ret), js.Pointer(&exception),
   155  		viewType.Ref(),
   156  		float64(ownerRoutingId),
   157  		createParams.Ref(),
   158  	)
   159  
   160  	return
   161  }
   162  
   163  // HasFuncDestroyUnattachedGuest returns true if the function "WEBEXT.guestViewInternal.destroyUnattachedGuest" exists.
   164  func HasFuncDestroyUnattachedGuest() bool {
   165  	return js.True == bindings.HasFuncDestroyUnattachedGuest()
   166  }
   167  
   168  // FuncDestroyUnattachedGuest returns the function "WEBEXT.guestViewInternal.destroyUnattachedGuest".
   169  func FuncDestroyUnattachedGuest() (fn js.Func[func(instanceId int64)]) {
   170  	bindings.FuncDestroyUnattachedGuest(
   171  		js.Pointer(&fn),
   172  	)
   173  	return
   174  }
   175  
   176  // DestroyUnattachedGuest calls the function "WEBEXT.guestViewInternal.destroyUnattachedGuest" directly.
   177  func DestroyUnattachedGuest(instanceId int64) (ret js.Void) {
   178  	bindings.CallDestroyUnattachedGuest(
   179  		js.Pointer(&ret),
   180  		float64(instanceId),
   181  	)
   182  
   183  	return
   184  }
   185  
   186  // TryDestroyUnattachedGuest calls the function "WEBEXT.guestViewInternal.destroyUnattachedGuest"
   187  // in a try/catch block and returns (_, err, ok = false) when it went through
   188  // the catch clause.
   189  func TryDestroyUnattachedGuest(instanceId int64) (ret js.Void, exception js.Any, ok bool) {
   190  	ok = js.True == bindings.TryDestroyUnattachedGuest(
   191  		js.Pointer(&ret), js.Pointer(&exception),
   192  		float64(instanceId),
   193  	)
   194  
   195  	return
   196  }
   197  
   198  // HasFuncSetSize returns true if the function "WEBEXT.guestViewInternal.setSize" exists.
   199  func HasFuncSetSize() bool {
   200  	return js.True == bindings.HasFuncSetSize()
   201  }
   202  
   203  // FuncSetSize returns the function "WEBEXT.guestViewInternal.setSize".
   204  func FuncSetSize() (fn js.Func[func(instanceId int64, params SizeParams) js.Promise[js.Void]]) {
   205  	bindings.FuncSetSize(
   206  		js.Pointer(&fn),
   207  	)
   208  	return
   209  }
   210  
   211  // SetSize calls the function "WEBEXT.guestViewInternal.setSize" directly.
   212  func SetSize(instanceId int64, params SizeParams) (ret js.Promise[js.Void]) {
   213  	bindings.CallSetSize(
   214  		js.Pointer(&ret),
   215  		float64(instanceId),
   216  		js.Pointer(&params),
   217  	)
   218  
   219  	return
   220  }
   221  
   222  // TrySetSize calls the function "WEBEXT.guestViewInternal.setSize"
   223  // in a try/catch block and returns (_, err, ok = false) when it went through
   224  // the catch clause.
   225  func TrySetSize(instanceId int64, params SizeParams) (ret js.Promise[js.Void], exception js.Any, ok bool) {
   226  	ok = js.True == bindings.TrySetSize(
   227  		js.Pointer(&ret), js.Pointer(&exception),
   228  		float64(instanceId),
   229  		js.Pointer(&params),
   230  	)
   231  
   232  	return
   233  }