github.com/primecitizens/pcz/std@v0.2.1/ffi/js/array/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 array
     7  
     8  import (
     9  	"unsafe"
    10  
    11  	"github.com/primecitizens/pcz/std/ffi/js/bindings"
    12  )
    13  
    14  //go:wasmimport ffi/js/array new
    15  //go:noescape
    16  func New(
    17  	cap uint32,
    18  	elemSz uint32,
    19  	signed bindings.Ref,
    20  	float bindings.Ref,
    21  ) bindings.Ref
    22  
    23  //go:wasmimport ffi/js/array length
    24  //go:noescape
    25  func Length(arr bindings.Ref) int64
    26  
    27  //go:wasmimport ffi/js/array slice
    28  //go:noescape
    29  func Slice(
    30  	arr bindings.Ref,
    31  	start uint32,
    32  	end uint32,
    33  ) bindings.Ref
    34  
    35  //go:wasmimport ffi/js/array set
    36  //go:noescape
    37  func Set(a, b bindings.Ref)
    38  
    39  //go:wasmimport ffi/js/array append
    40  //go:noescape
    41  func Append(
    42  	refJsArray bindings.Ref,
    43  	take bindings.Ref, // for elemSz = 0 only
    44  	elemSz uint32,
    45  	signed bindings.Ref,
    46  	float bindings.Ref,
    47  	offsetInJsArray uint32,
    48  	goArray unsafe.Pointer,
    49  	goArrayLen uint32,
    50  ) uint32
    51  
    52  //go:wasmimport ffi/js/array copy
    53  //go:noescape
    54  func Copy(
    55  	refJsArray bindings.Ref,
    56  	elemSz uint32,
    57  	signed bindings.Ref,
    58  	float bindings.Ref,
    59  	offsetInJsArray uint32,
    60  	outGoArray unsafe.Pointer,
    61  	outGoArrayLen uint32,
    62  ) uint32
    63  
    64  //go:wasmimport ffi/js/array buffer
    65  //go:noescape
    66  func Buffer(ref bindings.Ref, take bindings.Ref) bindings.Ref
    67  
    68  //go:wasmimport ffi/js/array fromBuffer
    69  //go:noescape
    70  func FromBuffer(
    71  	take bindings.Ref,
    72  	refBuf bindings.Ref,
    73  	elemSz uint32,
    74  	signed bindings.Ref,
    75  	float bindings.Ref,
    76  ) bindings.Ref
    77  
    78  //go:wasmimport ffi/js/array byteOffset
    79  //go:noescape
    80  func ByteOffset(ref bindings.Ref) uint32
    81  
    82  //go:wasmimport ffi/js/array byteLength
    83  //go:noescape
    84  func ByteLength(ref bindings.Ref) uint32
    85  
    86  //go:wasmimport ffi/js/array nth
    87  //go:noescape
    88  func Nth(
    89  	arr bindings.Ref,
    90  	elemSz uint32,
    91  	signed bindings.Ref,
    92  	float bindings.Ref,
    93  	nth uint32,
    94  	ptr unsafe.Pointer,
    95  ) bindings.Ref
    96  
    97  //go:wasmimport ffi/js/array nthNum
    98  //go:noescape
    99  func NthNum(
   100  	self bindings.Ref,
   101  	i uint32,
   102  	outNum unsafe.Pointer,
   103  ) bindings.Ref
   104  
   105  //go:wasmimport ffi/js/array nthBool
   106  //go:noescape
   107  func NthBool(
   108  	self bindings.Ref,
   109  	i uint32,
   110  	outBool unsafe.Pointer,
   111  ) bindings.Ref
   112  
   113  //go:wasmimport ffi/js/array setNth
   114  //go:noescape
   115  func SetNth(
   116  	self bindings.Ref,
   117  	elemSz uint32,
   118  	signed bindings.Ref,
   119  	float bindings.Ref,
   120  	i uint32,
   121  	take bindings.Ref,
   122  	ptr unsafe.Pointer,
   123  ) bindings.Ref
   124  
   125  //go:wasmimport ffi/js/array setNthNum
   126  //go:noescape
   127  func SetNthNum(
   128  	self bindings.Ref,
   129  	i uint32,
   130  	val float64,
   131  ) bindings.Ref
   132  
   133  //go:wasmimport ffi/js/array setNthBool
   134  //go:noescape
   135  func SetNthBool(
   136  	self bindings.Ref,
   137  	i uint32,
   138  	val bindings.Ref,
   139  ) bindings.Ref
   140  
   141  //go:wasmimport ffi/js/array setNthString
   142  //go:noescape
   143  func SetNthString(
   144  	self bindings.Ref,
   145  	i uint32,
   146  	str unsafe.Pointer,
   147  	len uint32,
   148  ) bindings.Ref