Conversation
# Conflicts: # Cargo.toml # wasmi/tests/spec/testsuite
Externals implementation
|
[clabot:check] |
|
It looks like @pepyakin signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
| } | ||
| _ => panic!("unknown function index"), | ||
| #[wasmi_derive::derive_externals] | ||
| impl<'a> Runtime<'a> { |
There was a problem hiding this comment.
is this example tested anywhere?
because otherwise there are no tests!
There was a problem hiding this comment.
Also, there will no longer be example for implementing host without procedural macro?
There was a problem hiding this comment.
Yes, except from tests.
I don't think it is worthwhile to keep implementing Externals manually here since this example doesn't do anything interesting and can be easily changed with the proc-macro.
|
[clabot:check] |
|
It looks like @pepyakin signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
|
[clabot:check] |
|
It looks like @pepyakin signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
This way it shouldn't matter if anybody e.g. imports other `Option` or redefines `Result`.
| pub ty: Box<syn::Type>, | ||
| } | ||
|
|
||
| /// Parse an incoming stream of tokens into externalities definition. |
There was a problem hiding this comment.
what is "externalities" in wasmi terms?
wouldn't even "externals" be a foreign term for WebAssembly?
There was a problem hiding this comment.
Yes, I'd agree that this term migrated from other projects here. What would you propose here?
There was a problem hiding this comment.
maybe "host bindings", "host functions" or simply "host" (if it later can be modified that way that it works not only with functions) to keep with WebAssembly terminology
also, the attribute name (now "derive_externals") might also reflect this
There was a problem hiding this comment.
yeah, but I'm afraid we are really too far down the road to do that. There is already Externals trait. But yeah would be up to change the doc.
| ) | ||
| } | ||
|
|
||
| pub struct CompileError { |
There was a problem hiding this comment.
Thanks a lot, nice to know!
|
Low priority for now, closing... |
This PR introduces wasmi-derive: a crate that allows users to generate implementations of
Externalsthat wraps a given impl block.Here is an example:
the
[derive_externals]macro will generate aExternalsimplementation forNonStaticExternals<'a>and it will also add inherent method calledresolverfor getting an instance ofModuleImportResolver.Types that implement
wasmi::derive_support::IntoWasmValueare supported in argument type positions and types that implementwasmi::derive_support::IntoWasmResultare supported in return type positions.The macro is simple by itself, however it generates code that depends on type-inference and uses a couple of tricks.