This directory contains a number of examples that demonstrate how to use the WasmKit library.
From this directory:
swift run PrintAdd
swift run Factorial
swift run StringPassing
swift run WASI-HelloStringPassing demonstrates a common UTF-8 string ABI for host <-> guest interop:
- WebAssembly passes a
(ptr: i32, len: i32)pair into an imported host function (printer.print_str), and the host reads the bytes from the module's exportedmemory. - The host allocates space in guest memory by calling an exported
alloc(size: i32) -> i32, writes UTF-8 bytes into the returned region, then calls an exportedchecksum(ptr: i32, len: i32) -> i32.