github.com/primecitizens/pcz/std@v0.2.1/ffi/js/bindings/import_wasm.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  //go:build wasm
     5  
     6  package bindings
     7  
     8  import (
     9  	"unsafe"
    10  )
    11  
    12  //
    13  // Func
    14  //
    15  
    16  //go:wasmimport ffi/js try
    17  //go:noescape
    18  func Try(
    19  	fn Ref,
    20  	this Ref,
    21  	take bool,
    22  	catch Ref,
    23  	finally Ref,
    24  	pArgs unsafe.Pointer,
    25  	count uint32,
    26  	pCaught unsafe.Pointer,
    27  ) Ref
    28  
    29  //go:wasmimport ffi/js call
    30  //go:noescape
    31  func Call(
    32  	fn Ref,
    33  	this Ref,
    34  	take Ref,
    35  	pArgs unsafe.Pointer,
    36  	count uint32,
    37  ) Ref
    38  
    39  //go:wasmimport ffi/js callVoid
    40  //go:noescape
    41  func CallVoid(fn, this, take Ref, pArgs unsafe.Pointer, count uint32)
    42  
    43  //go:wasmimport ffi/js callNum
    44  //go:noescape
    45  func CallNum(fn, this, take Ref, pArgs unsafe.Pointer, count uint32) float64
    46  
    47  //go:wasmimport ffi/js callBool
    48  //go:noescape
    49  func CallBool(fn, this, take Ref, pArgs unsafe.Pointer, count uint32) bool
    50  
    51  //
    52  // Heap
    53  //
    54  
    55  //go:wasmimport ffi/js once
    56  //go:noescape
    57  func Once(ref Ref)
    58  
    59  //go:wasmimport ffi/js clone
    60  //go:noescape
    61  func Clone(ref Ref) Ref
    62  
    63  //go:wasmimport ffi/js instanceof
    64  //go:noescape
    65  func Instanceof(a, b Ref) Ref
    66  
    67  //go:wasmimport ffi/js replace
    68  //go:noescape
    69  func Replace(old, new Ref) Ref
    70  
    71  //go:wasmimport ffi/js replaceNum
    72  //go:noescape
    73  func ReplaceNum(old Ref, n float64) Ref
    74  
    75  //go:wasmimport ffi/js replaceBigInt
    76  //go:noescape
    77  func ReplaceBigInt(old Ref, signed Ref, new unsafe.Pointer) Ref
    78  
    79  //go:wasmimport ffi/js replaceBool
    80  //go:noescape
    81  func ReplaceBool(old Ref, boolean Ref) Ref
    82  
    83  //go:wasmimport ffi/js replaceString
    84  //go:noescape
    85  func ReplaceString(old Ref, str unsafe.Pointer, len uint32) Ref
    86  
    87  //go:wasmimport ffi/js free
    88  //go:noescape
    89  func Free(Ref)
    90  
    91  //go:wasmimport ffi/js batchFree
    92  //go:noescape
    93  func BatchFree(pRefs unsafe.Pointer, count uint32)
    94  
    95  //
    96  // Number
    97  //
    98  
    99  //go:wasmimport ffi/js number
   100  //go:noescape
   101  func Number(n float64) Ref
   102  
   103  //go:wasmimport ffi/js getnum
   104  //go:noescape
   105  func GetNum(ref Ref, pF64 unsafe.Pointer) Ref
   106  
   107  //go:wasmimport ffi/js bigint
   108  //go:noescape
   109  func BigInt(signed Ref, ptr unsafe.Pointer) Ref
   110  
   111  //go:wasmimport ffi/js getBigInt
   112  //go:noescape
   113  func GetBigInt(ref Ref, signed Ref, ptr unsafe.Pointer) Ref
   114  
   115  //
   116  // Object
   117  //
   118  
   119  //go:wasmimport ffi/js new
   120  //go:noescape
   121  func New(constructor Ref, pArgs unsafe.Pointer, count uint32) Ref
   122  
   123  //go:wasmimport ffi/js getPrototype
   124  //go:noescape
   125  func GetPrototype(obj Ref) Ref
   126  
   127  //go:wasmimport ffi/js setPrototype
   128  //go:noescape
   129  func SetPrototype(self Ref, take bool, proto Ref) Ref
   130  
   131  //go:wasmimport ffi/js getPropDesc
   132  //go:noescape
   133  func GetPropDesc(self Ref, pName unsafe.Pointer, lenName uint32) uint32
   134  
   135  //go:wasmimport ffi/js defineProp
   136  //go:noescape
   137  func DefineProp(self Ref, pName unsafe.Pointer, lenName uint32, flags uint32, getter, setter Ref) bool
   138  
   139  //go:wasmimport ffi/js deleteProp
   140  //go:noescape
   141  func DeleteProp(self Ref, pName unsafe.Pointer, sz uint32) bool
   142  
   143  //go:wasmimport ffi/js prop
   144  //go:noescape
   145  func Prop(this Ref, pName unsafe.Pointer, lenName uint32) Ref
   146  
   147  //go:wasmimport ffi/js numProp
   148  //go:noescape
   149  func NumProp(this Ref, pName unsafe.Pointer, lenName uint32) float64
   150  
   151  //go:wasmimport ffi/js boolProp
   152  //go:noescape
   153  func BoolProp(this Ref, pName unsafe.Pointer, lenName uint32) bool
   154  
   155  //go:wasmimport ffi/js propByString
   156  //go:noescape
   157  func PropByString(this, name Ref) Ref
   158  
   159  //go:wasmimport ffi/js numPropByString
   160  //go:noescape
   161  func NumPropByString(this, name Ref) float64
   162  
   163  //go:wasmimport ffi/js boolPropByString
   164  //go:noescape
   165  func BoolPropByString(this, name Ref) bool
   166  
   167  //go:wasmimport ffi/js setProp
   168  //go:noescape
   169  func SetProp(
   170  	this Ref,
   171  	pName unsafe.Pointer,
   172  	lenName uint32,
   173  	take bool,
   174  	val Ref,
   175  ) bool
   176  
   177  //go:wasmimport ffi/js setNumProp
   178  //go:noescape
   179  func SetNumProp(
   180  	this Ref,
   181  	pName unsafe.Pointer,
   182  	lenName uint32,
   183  	val float64,
   184  ) bool
   185  
   186  //go:wasmimport ffi/js setBoolProp
   187  //go:noescape
   188  func SetBoolProp(
   189  	this Ref,
   190  	pName unsafe.Pointer,
   191  	lenName uint32,
   192  	val bool,
   193  ) bool
   194  
   195  //go:wasmimport ffi/js setStringProp
   196  //go:noescape
   197  func SetStringProp(
   198  	this Ref,
   199  	nameptr unsafe.Pointer,
   200  	namesz uint32,
   201  	valptr unsafe.Pointer,
   202  	valsz uint32,
   203  ) bool
   204  
   205  //go:wasmimport ffi/js setPropByString
   206  //go:noescape
   207  func SetPropByString(this, prop, take, val Ref) bool
   208  
   209  //go:wasmimport ffi/js setNumPropByString
   210  //go:noescape
   211  func SetNumPropByString(this, prop Ref, val float64) bool
   212  
   213  //go:wasmimport ffi/js setBoolPropByString
   214  //go:noescape
   215  func SetBoolPropByString(this, prop, val Ref) bool
   216  
   217  //go:wasmimport ffi/js setStringPropByString
   218  //go:noescape
   219  func SetStringPropByString(this, prop, take, val Ref) bool
   220  
   221  //
   222  // String
   223  //
   224  
   225  //go:wasmimport ffi/js decodeUTF8
   226  //go:noescape
   227  func DecodeUTF8(ptr unsafe.Pointer, len uint32) Ref
   228  
   229  //go:wasmimport ffi/js equalsUTF8
   230  //go:noescape
   231  func EqualsUTF8(self Ref, str unsafe.Pointer, len uint32) bool
   232  
   233  //go:wasmimport ffi/js prependUTF8
   234  //go:noescape
   235  func PrependUTF8(self Ref, pStrSlice unsafe.Pointer, count uint32)
   236  
   237  //go:wasmimport ffi/js prependString
   238  //go:noescape
   239  func PrependString(self Ref, take bool, pRefSlice unsafe.Pointer, count uint32)
   240  
   241  //go:wasmimport ffi/js appendUTF8
   242  //go:noescape
   243  func AppendUTF8(self Ref, pStrSlice unsafe.Pointer, count uint32)
   244  
   245  //go:wasmimport ffi/js appendString
   246  //go:noescape
   247  func AppendString(self Ref, take bool, pRefSlice unsafe.Pointer, count uint32)
   248  
   249  //go:wasmimport ffi/js encodeUTF8
   250  //go:noescape
   251  func EncodeUTF8(s Ref, str unsafe.Pointer, len uint32) uint32
   252  
   253  //go:wasmimport ffi/js sizeUTF8
   254  //go:noescape
   255  func SizeUTF8(s Ref) uint32