cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
wasm_entry.h File Reference

(Deprecated) Legacy Emscripten WASM entry points. More...

Go to the source code of this file.

Detailed Description

(Deprecated) Legacy Emscripten WASM entry points.

Deprecated:
The Emscripten browser bundle has been superseded by the WASI component pipeline (issue #203). For new code, build for wasm32-wasip2 using CWIST_WASM_COMPONENT_DEFINE_GUEST() from <cwist/wasm/wasm_component.h>. This header and its functions are retained for v4 LTS ABI compatibility.

A consumer app compiles against libcwist_wasm.a and expands CWIST_WASM_DEFINE_ENTRY(app_symbol) exactly once, after its routes are registered and before the module is used. It exports:

JS side (via the npm package cwist-wasm): const { createCwist } = require('cwist-wasm'); const handle = createCwist(Module); const res = handle({ method: 'GET', path: '/hello' }); // res.status, res.headers, res.body (Uint8Array)

Build the consumer module with the entry exported and the runtime methods the wrapper needs, e.g.:

emcc -O2 -std=c17 -I./include -I./lib -o app.js my_app.c \ libcwist_wasm.a \ -sEXPORTED_FUNCTIONS=_cwist_wasm_dispatch,_cwist_wasm_free,_malloc,_free \ -sEXPORTED_RUNTIME_METHODS=ccall

Emscripten-only, like typedarray.h: everything is guarded by EMSCRIPTEN and this header is a no-op on native toolchains.

Definition in file wasm_entry.h.