* Rust: add option for path to wit-bindgen runtime.
This change adds an optional path to the `wit-bindgen` runtime to use for Rust
code generation.
This will allow a different crate from `wit-bindgen` to generate bindings while
also re-exporting `wit-bindgen::rt` at a known path for the generated code to
use.
* Rust: add `runtime_path` macro option and a test.
* C: Namespace types inside of annoymous types
* Go generator should use c generator's name generation
* Optionaly namespace inner types for all anonymous types
* Test more
This commit updates dependencies to latest.
It includes the latest wasm-tools, where support for resources has been stubbed
out with a `todo!`.
Hopefully that won't be too much of an annoyance for those actively developing
support for resources.
Additionally, `indexmap`, which is used extensively on many public APIs, has
been rev'd to a new major version; this resulted in no required source changes.
* Correct the accounting for results containing empty types.
Empty types are special-cased in the C backend because C doesn't allow
zero-sized types. In the case of a result containing an empty type,
when processing the ok side, increment the return value counter even
if the store is omitted due to the value being empty.
Fixes#609.
* Test all the combinations of non-empty, empty, and absent.
* Update rust guest example comments in README.md
* Shorten the explanations on export_host macro
Co-authored-by: Kyle Brown <kylebrw@gmail.com>
---------
Co-authored-by: Kyle Brown <kylebrw@gmail.com>
* Update preview2-prototyping download links
This commit updates the preview2-prototyping command and reactor .wasm
download links as they have been updated.
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
* Change component adapter links to point to wasmtime
This commit updates the link to the component adapters to point to the
wasmtime repository instead of preview2-prototyping.
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
---------
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
* provide more control over type ownership
This is the guest version of https://github.com/bytecodealliance/wasmtime/pull/6648.
This replaces the duplicate_if_necessary parameter to the Rust binding generator
with a new ownership parameter which provides finer-grained control over whether
and how generated types own their fields.
The default is `Ownership::Owning`, which means types own their fields
regardless of how they are used in functions. These types are passed by
reference when used as parameters to guest-exported functions. Note that this
also affects how unnamed types (e.g. `list<list<string>>`) are passed: using a
reference only at the top level (e.g. `&[Vec<String>]` instead of `&[&[&str]]`,
which is more difficult to construct when using non-'static data).
The other option is `Ownership::Borrowing`, which includes a
`duplicate_if_necessary` field, providing the same code generation strategy as
was used prior to this change.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix tests
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix tests, part 2
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Update Rust codegen for new WIT changes
* Update the markdown generation for new WIT
* more-rust
* Update the C generator for new WIT
* Get Rust guest tests compiling
* Get rust host tests working
* Get all C tests passing
* Turn off teavm-java and Go tests for now
* Fixup lockfile after rebase
* Bump crate versions
* Update dependency sources
* Update to wasmtime dep
Add an `end` opcode to the dummy function in the component-type object
produced for the C bindings, which is needed in order for the resulting
binary encoding to validate.
This fixes an issue where exported freestanding functions are intended
to refer to imported types, not exported types. The order of bindings
generation is altered here to ensure that code generators get access to
types only as they're available, ensuring that functions refer to
imported types rather than exported ones.
Closes#573