* 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
* 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 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
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
* Support directory-based codegen tests
Remove the old `*.wit` syntax in the macro as it's no longer necessary.
* Fix duplicate C types being generated
Closes#569
* Fix a Rust compile error
* Update how types are generated in C
Prior to this commit each interface used in C would generate a separate
type per import and per export. For example if a `world` both imported
and exported an interface then distinct, but defined the same way, types
would be generated. Furthermore this same logic was extended to
types-in-worlds which ended up not working well and causing #544.
This commit overhauls how types are generated in C. All used interfaces
now generate one set of types, regardless of whether the interface is
used in an import or an export. Additionally this enables fixing #544 by
generating types for worlds only once at the end instead of
incrementally throughout.
Along the way this updates many names of generated types to be more
appropriate to their scoping constraints. For example types in
interfaces are now namespaced by the name of the interface. Functions
continue to be namespaced by the name of the import/export and disregard
the name of the interface. Ambient types like `record<T, E>` continue to
be prefixed by the name of the world that bindings are generated for.
Closes#544
* Disable go runtime tests
* Disable go codegen tests temporarily
* Fix bindings generation with unused types in Rust
This commit fixes an issue where if a type was imported into an
interface but wasn't actually used anywhere then bindings weren't
correctly generated because inference about whether it was owned or
borrowed didn't run. The fix here is to skip generating bindings for
unused types since they're not actually needed anywhere anyway. If
necessary in the future bindings can be forcibly generated but for now
this is hopefully largely "just" fixing an edge case.
* Ignore the new tests for Go
This pulls in type analysis code from Wasmtime which has a more modern
notion of param/result as owned/borrowed and additionally removes the
need for a `default_param_mode` which caused #513 in the first place.
Closes#513
This fixes the bindings generator for imports between interfaces to
ensure that matches and lifts/lowers/etc all use the right name as
opposed to assuming the name is already in scope.
Closes#485
* Fix multiple return areas being generated for imports in one function
This commit fixes the issues brought up in #444 and #454 by moving the
generation of the local variable to outside the `FunctionBindgen`
structure into just after the function has been generated. That way when
two return areas are requested they'll get unified into one storage.
Closes#444Closes#454
* Exclude the new test on the teavm-java generator
* Update the Rust guest generator
This commit updates the `wit-parser` and `wit-component` dependencies to
the latest 0.4.0 versions on crates.io, namely pulling in support for
`use`. This updates the `*.wit` codegen tests and gets all the codegen
tests working for the `gen-guest-rust` crate. This does not get the
entire repository's tests running.
The major changes here are:
* The `WorldGenerator` trait has been adapted for worlds and the new
APIs of `wit-parser`.
* The Rust guest generator now supports bare function imports as well as
bare function exports.
* The syntax in the Rust macro now mirrors the syntax in the Wasmtime
`bindgen!` macro where `generate!("foo")` will look for the document
`foo.wit` in `$CARGO_MANIFEST_DIR/wit/foo.wit` and look for a `default
world` inside there.
* The codegen and runtime macros have been refactored to get separated
and additionally have conditional compilation working so one generator
can be tested in isolation without requiring all others working.
* The `rust-macro-shared` crate is now removed since Wasmtime no longer
resides here and it's merged directly into the `guest-rust-macro`
crate. Note that many changes happened here since the macro syntax and
integration with `wit-parser` has changed.
Note that no new tests were added in this commit, and that'll be a
follow-up.
* Add support for using types across interfaces to Rust
* Support renaming interfaces in imports
* Get all codegen tests for JS passing again
* Fix build of wasi_snapshot_preview1 for this repo
* Get unions tests building again
* Get the flavorful test compiling again
* Get the records test compiling again
* Get the many arguments test compiling again
* Get the smoke test compiling again
* Get numbers test compiling again
* Get list test compiling again
* Get variants test compiling again
* Get results test compiling again
* Get invalid test compiling again
* Get all runtime JS tests passing
Change a few bits and pieces of the JS host generator as necessary and
temporarily disable other guest generators.
* Use git repo for wit-{component,parser} patch
* Update C generator for new WIT
* Get the bare bones of teavm-java working
Runtime tests will need some more work to get passing.
* Get CLI and markdown crate building again
* Update build of demo
* Use updated crates.io dep for wit-component
* fix Java runtime test regressions (#1)
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Update wasm-tools on CI
* Review comments
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
* Update all codegen tests to world syntax
This enables simplifying codegen tests as well by having each test
exercise imports/exports instead of having all code generators have one
case for imports and one for exports.
* Update codegen tests for the C guest generator
* Update teavm codegen tests for worlds
* Remove the `--name` argument from the CLI
No longer needed as the name is inferred from the `*.wit` world.
* Get all js host generator tests working
Update all `runtime/*` tests with new naming conventions, world files,
etc. Minor updates were made to names as I ended up using different
conventions for the `*.wit` world files than were previously exercised.
This also fixes a few minor issues with the output for the JS generator
in the default ESM mode.
* Get all host-wasmtime tests working with worlds
Various small updates here and there to namings and such.
* Get all Python tests working with worlds
Fix support for exported instances by using correct import paths for
various types/intrinsics/etc. Additionally update the codegen tests to
specify a mypy cache dir to avoid racing between tests.
* Update demo build for worlds
Also fix an issue with the Rust host generator where it used an
interface's name instead of the name of the import for import module names.
* Update demo with world files
* syntax: world + interface
Signed-off-by: Brian H <brian.hardock@fermyon.com>
* Get tests passing
Remove all parsing tests related to `use` along the way to get re-added
once `use` is re-implemented for top-level worlds.
* Update wit-parser tests to worlds
Drop usage of the old `Interface::parse_file` function.
* Add some basic tests for world
Assert some assorted failures as well as a basic successful structure.
* Remove existing support for `use`
This will come back shortly with worlds, but for now nothing uses this
in the repository any more and it's not implemented within the resolver
so temporarily remove it.
* Thread through docs on worlds/interfaces
* Remove docs from imports/exports
They're not threaded anywhere right now so remove them. Can be added
back in if needed in the future.
* Implement temporary stopgap of `default export`
* Fix demo build
Signed-off-by: Brian H <brian.hardock@fermyon.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
* Reimplement the host Python generator with worlds
This commit is the equivalent of #381 but for Wasmtime Python host
bindings. This is a large-scale refactor of the internals of the Python
host generator in which I took quite a few liberties in internal
restructuring as well as output restructuring. The tests are probably
the best to review and better reflect what changed, but there are some
aspects of worlds that the tests are not currently exercising which
we'll want to add with the introduction of worlds in the future.
This means that all host generators are now working with worlds as input
rather than individual `*.wit` files, and the only two remaining
generators are the C and Java generators for guests (which I hope are
easier).
The high level summary of the new output is:
out_dir/
__init__.py # top-level component exports/definitions
types.py # shared type information, currently just `Result`
imports/
__init__.py # only here if something is imported
foo.py # type and protocol definition per interface
exports/
__init__.py # only here if an instance is exported
bar.py # one per exported instance
"Default exports" will show up on the generated structure in
`out_dir/__init__.py` so all runtime tests, for example, do not generate
`exports` at this time. Lots of fiddly stuff went into structuring this
all right to get past `mypy` and additionally try to avoid name
conflicts. It's still somewhat easy to have name conflicts but ideally
they're of the more esoteric category rather than "really easy to run
into".
* Try to fix windows