wasmerio / wasmer-java

☕ WebAssembly runtime for Java
https://medium.com/wasmer/announcing-the-first-java-library-to-run-webassembly-wasmer-jni-89e319d2ac7c
MIT License
593 stars 55 forks source link

feat(exports) Use a unified `instance.exports` API #29

Closed Hywan closed 4 years ago

Hywan commented 4 years ago

Fix #24.

This patch renames org.wasmer.ExportedFunction to org.wasmer.exports.Function.

Function and Memory now implements the new org.wasmer.exports.Export interface. instance.exports thus contains both Function or Memory objects. Consequently Exports.get returns a generic Export object. To get the exported function (Function) or the exported memory (Memory), the user has 2 choices:

  1. Downcast manually, i.e. (Function<Object, Object[]>) instance.exports.get("sum") or (Memory) instance.exports.get("memory"),
  2. Call helpers, i.e. instance.exports.getFunction("sum") or instance.exports.getMemory("memory").

Finally, this patch removes the instance.memories API since it's been merged into instance.exports.