26#ifndef __CWIST_WASM_TYPEDARRAY_H__
27#define __CWIST_WASM_TYPEDARRAY_H__
31#include <emscripten.h>
37#define CWIST_WASM_EXPORT EMSCRIPTEN_KEEPALIVE
49#define CWIST_WASM_EXPOSE_ARRAY(name, arr, count) \
50 CWIST_WASM_EXPORT const void *name##_ptr(void) { \
51 return (const void *)(arr); \
53 CWIST_WASM_EXPORT size_t name##_len(void) { \
54 return (size_t)(count); \
56#define CWIST_WASM_EXPOSE_I32(name, arr, count) CWIST_WASM_EXPOSE_ARRAY(name, arr, count)
57#define CWIST_WASM_EXPOSE_F64(name, arr, count) CWIST_WASM_EXPOSE_ARRAY(name, arr, count)
58#define CWIST_WASM_EXPOSE_U8(name, arr, count) CWIST_WASM_EXPOSE_ARRAY(name, arr, count)
69#define CWIST_WASM_INSTALL_VIEWS() \
70 EM_JS(void, cwist_wasm_install_views, (void), { \
73 if (typeof Module !== "undefined" && !Module.cwistView) { \
74 Module.cwistView = { \
75 u8: function (p, n) { \
76 return new Uint8Array(HEAPU8.buffer, p, n); \
78 i32: function (p, n) { \
79 return new Int32Array(HEAP32.buffer, p, n); \
81 f64: function (p, n) { \
82 return new Float64Array(HEAPF64.buffer, p, n); \
96static inline const char *cwist_wasm_dispatch_memory(
cwist_app *app,
const char *req_buf,
97 size_t req_len,
size_t *res_len) {
98 if (!res_len)
return NULL;
100 char *res_buf = NULL;
106static inline void cwist_wasm_free(
void *ptr) {
Memory allocation wrappers backed by libttak.
void cwist_free(void *ptr)
Free memory obtained via cwist_alloc/cwist_strdup/etc.
Main Application Context.
Core Application Structure and Lifecycle Management.
int cwist_app_dispatch_memory(cwist_app *app, const char *req_buf, size_t req_len, char **res_buf, size_t *res_len)
Run the full router/middleware/handler pipeline on a raw HTTP/1.x request held in a memory buffer,...