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

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

reader-lookupcljs

(reader-lookup Mod)

used internally

used internally

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

reset-reader-cachescljs

(reset-reader-caches Mod)
(reset-reader-caches Mod priorityCache structCache)

manully reset or overwrite reader cache instances

manully reset or overwrite reader cache instances

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

reader-struct-cachecljs

(reader-struct-cache Mod)

used internally

used internally

reader-priority-cachecljs

(reader-priority-cache Mod)

used internally

used internally

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
    • if provided, reader cache instances will persist across module calls
    • { :handlers {'string' fn<rdr, tag, field-count>} :reader-priority-cache ?ArrayList :reader-struct-cache ?ArrayList } :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
     - if provided, reader cache instances will persist across module calls
     - {
        :handlers  {'string'  fn<rdr, tag, field-count>}
        :reader-priority-cache ?ArrayList
        :reader-struct-cache   ?ArrayList
       }
   :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

reader-cachecljs

(reader-cache coll)

Use to prime reader caches with values AOT. Coll should reduced in cache order: the index becomes the cache lookup code.

Use to prime reader caches with values AOT.
Coll should reduced in cache order: the index becomes the cache lookup code.
sourceraw docstring

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

× close