Liking cljdoc? Tell your friends :D

fress.wasm


assert-fress-mod!cljs

(assert-fress-mod! Mod)
source

attach-protocol!cljs

(attach-protocol! Mod {:keys [read-opts write-opts]})
source

FatPtrcljs

source

IFressWasmModulecljsprotocol

copy-bytescljs

(copy-bytes Mod ptr length)

copy the length bytes from the given address

copy the length bytes from the given address

read-optscljs

(read-opts Mod)

used internally by call

used internally by call

readcljs

(read Mod ptr)
(read Mod ptr opts)

read an object from a ptr, returning [?err ?ok]

read an object from a ptr, returning [?err ?ok]

write-optscljs

(write-opts Mod)

used internally by call

used internally by call

callcljs

(call Mod export-name)
(call Mod export-name obj)

Automatically write-to and read-from a wasm function. See fress.wasm/module-call

Automatically write-to and read-from a wasm function. See fress.wasm/module-call

write-bytescljs

(write-bytes Mod bytes)

write bytes into memory, returning a FatPtr

write bytes into memory, returning a FatPtr

dealloccljs

(dealloc Mod fptr)
(dealloc Mod ptr len)

return ownership of bytes back to rust for them to be freed

return ownership of bytes back to rust for them to be freed

get-exportscljs

(get-exports Mod)

the export object

the export object

get-viewcljs

(get-view Mod)

return a Uint8Array view over module memory

return a Uint8Array view over module memory

writecljs

(write Mod any)
(write Mod any opts)

write an object into memory, returning a FatPtr

write an object into memory, returning a FatPtr

alloccljs

(alloc Mod len)

request a slice of memory of the given length, returning a FatPtr

request a slice of memory of the given length, returning a FatPtr

get-memorycljs

(get-memory Mod)

the module's memory

the module's memory
source

instantiatecljs

(instantiate array-buffer)
(instantiate array-buffer opts)

Instantiate a wasm module and add the IFressWasmModule protocol.

  • opts :imports -> Map<(string|kw), fn>
    • this exposes javascript functions to be called by wasm code. For each fn, there should be a corresponding externs entry in your rust lib.
      • don't forget that wasm can only call functions with scalar values :read-opts
    • passed to read calls internal to IFressWasmModule/call :write-opts
    • passed to write calls internal to IFressWasmModule/call

=> native Promise

Instantiate a wasm module and add the IFressWasmModule protocol.
 + opts
   :imports -> Map<(string|kw), fn>
     - this exposes javascript functions to be called by wasm code. For each
       fn, there should be a corresponding externs entry in your rust lib.
       - don't forget that wasm can only call functions with scalar values
   :read-opts
     - passed to read calls internal to IFressWasmModule/call
   :write-opts
     - passed to write calls internal to IFressWasmModule/call

=> native Promise
sourceraw docstring

module-callcljs

Given a WASM module and the string name of an exported wasm function, call that function, optionally passing any fressian'able object. This function handles all intermediate ptr handling for you.

  • If you pass an object, it will be automatically written into wasm memory and the resulting ptr+len handed off to your specified fn. This assumes that the exported function's signature accepts precisely: your_fn(ptr: *mut u8, len: usize)
    • All wasm functions that you wish to recieve fressian data should have these parameters.
  • if your function returns a ptr it will automatically be read from and returned as [?err ?ok]. your_fn(ptr: *mut u8, len: usize) -> *mut u8
  • If no ptr is given it will return as [nil]
  • panics are automatically handled and returned as [{:type :panic, :msg '...'}] Note: read and write opts must be passed at module instantiation, otherwise this function will become a tangled mess. In the future we may be able to generate code which will obviate the need for this fn. => [?err ?ok]
Given a WASM module and the string name of an exported wasm function, call
that function, optionally passing any fressian'able object. This function
handles all intermediate ptr handling for you.
 + If you pass an object, it will be automatically written into wasm memory
   and the resulting ptr+len handed off to your specified fn. This assumes
   that the exported function's signature accepts *precisely*:
     `your_fn(ptr: *mut u8, len: usize)`
   - All wasm functions that you wish to recieve fressian data should have
     these parameters.
 + if your function returns a ptr it will automatically be read from and
   returned as [?err ?ok].
     `your_fn(ptr: *mut u8, len: usize) -> *mut u8`
 + If no ptr is given it will return as [nil]
 + panics are automatically handled and returned as [{:type :panic, :msg '...'}]
 Note: read and write opts must be passed at module instantiation, otherwise
 this function will become a tangled mess. In the future we may be able to
 generate code which will obviate the need for this fn.
=> [?err ?ok]
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close