wasm-wrapper-gen
JavaScript wrapper generation for rust code targeting wasm32-unknown-unknown.
This repository is currently very WIP, but there's a full working example Cargo project in examples/simple_summation/
.
General overview:
wasm-wrapper-gen
is composed of two interlocking parts:
wasm-wrapper-gen
provides thejs_fn!()
macro which generatesextern "C"
functionswasm-wrapper-gen-build
is a build-script utility which scrapes the source for usages ofjs_fn!()
and generates a JavaScript file which binds to those exported functions.
Example usage:
main.rs
:
// return values not yet supported
// macro provided by wasm-wrapper-gen
js_fn!
build.rs
:
extern crate wasm_wrapper_gen_build;
Cargo.toml
:
[]
= "simple_summation"
= "0.1.0"
= ["David Ross <daboross@daboross.net>"]
[]
= "0.0.1"
[]
= "0.0.1"
And finally, usage from within node.js:
const fs = require;
const SimpleSummation = require;
;