ruby.wasm
uses two C extensions to turn Ruby in to a guest module.
The js
extension enables Ruby to use JavaScript APIs.
The witapi
extension exports Ruby's interpreter interface to allow the host to use the Ruby interpreter.
In other words, js
allows Ruby to talk to Javascript and witapi
allows a host to talk to Ruby.
Under each subdirectory, there is a bindgen/*.wit
file outlining the interfaces for each form of communication.
Specifically, bindgen/rb-js-abi-host.wit
describes embedder's requirements and bindgen/rb-js-abi-guest.wit
describes exported API from Ruby interpreter.
The .c
and .h
files are autogenerated from wit-bindgen.
You can read more about it in the contributing guide.
Note that we currently do not use the latest version of wit-bindgen because of how fast it is changing, with features being changed or even removed at times.