If you're using Emscripten already (or even if you aren't), their preamble offers some convenient extensions to
ccall(ident, returnType, argTypes, args, opts)
argTypes let you specify the types of parameters and the return value. The possible types are
"number" for any numeric type or C pointer,
"string" for C
char* that represent strings, and
cwrap(ident, returnType, argTypes)
Notably, using the
char* (to stack space) strings.
As of current, I do not believe there are any pre-existing libraries for handling FFI for larger types.
node-ffi exists as a library for handling FFI between the NodeJS runtime and dynamic libraries, and some of its machinery may be reusable for interfacing with a WASM runtime.
Still, I'm open to see what's possible. WASM is still a young, growing beast, and what's a pipe dream today may be possible in the coming years. If you do something cool, make sure to share it!