Foreign function interface

Example code using this new FFI for a basic todo app: https://gist.github.com/davexunit/e6ea8da921bcce7ed9c77035139a9527

The new stuff:

  • New %wasm-import form
  • New define-foreign macro to make it easy to define imports
  • New external? and external-null? predicates
  • New procedure->external to wrap Scheme procedures for use in JS DOM event listeners, etc.
  • Reflection interface now supports user import specification to provide the host functions for the FFI

Issues/questions:

  • Potential for name collisions when using %wasm-import to declare an import. Shouldn't be an issue for define-foreign due to the use of gensym. (which, btw, I added gensym to the primitives module... is that OK?)
  • %wasm-import compiles a 0 valued continuation. Should it do something different?
  • Names. I keep swapping between "foreign" and "host" in the names of things. Needs some consistency.
  • There's some stuff I don't understand about the expansion-time environment. Could we get more useful stuff into it and clean up the define-foreign macro a bit?

TODO:

  • Needs some tests.

Fixes #70 (closed)

Edited by David Thompson

Merge request reports

Loading