* 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
* 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
* Implement the component-model lexing rules for identifiers.
The [component-model grammer] for kebab-case identifiers now looks
like this:
```
name ::= <word>
| <name>-<word>
word ::= [a-z][0-9a-z]*
| [A-Z][0-9A-Z]*
```
Implement the rules. This continues to use XID rules for the initial
lexing, as that corresponds to what users might accidentally use, so
that we can issue appropriate errors in those cases. The precise
grammer is validated in a separate step.
[component-model grammer]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#instance-definitions
* Add more lexing tests.
* Update the tests in tests/codegen/conventions.wit.
* Comment out identifiers that collide when mapped to snake_case, for now.
See https://github.com/WebAssembly/component-model/issues/118.
Compared to v0.3, heck 0.4 turns off unicode support by default. Only
the teavm crate had turned it on explicitly when it moved to 0.4 on
its own first. This just turns the feature on for the workspace.
Also, uncomment some failing wit items in test cases that were broken
by the roll, and exposed by a recent test harness refactor.
This commit is a large refactor of how testing works in this repository
for wit-bindgen and hosts/guests to simplify the flow of tests and make
it easier to modify and less monolithic. Previously tons of logic was
located in a `test_helpers` macro crate but now that large crate has
been split up to delegate more work to each individual test. Some common
functionality is still present in a `test_helpers` crate but it's more
clear that the `test_helpers::codegen_test` macro is purely responsible
for simply expanding a glob at compile time and delegating to a
macro-per-test.
The tests of Rust & other languages are now also more uniform where
everything "just invokes a macro" where Rust's macros further invoke
proc-macros for the respective generators and other languages delegate
to shared functionality for "generate code" then "run verification
program".
Overall I'm hoping this makes the testing easier to follow and
understand, and in upcoming changes for components it will make it
easier to change each generator, individually, over to components
ideally.
* Implement #163
* Update component to wit printing to use func instead of function
* Run rustfmt
Co-authored-by: Kyle Brown <kyleb@liquidrocketry.com>
* Replace string-literal syntax with a new '@' identifier syntax.
Following up on #119, this removes the string-literal syntax for
identifiers, and introduces a new '@'-prefixed syntax.
'@' identifiers are just like regular identifiers, except they start
with '@' and are never parsed as keywords.
Suggestions for better syntax are welcome.
* Fix tests.
* Switch from '@' to '%'.
* Require interface identifiers to be in `kebab-case`.
Background: Identifiers in wit, such as function and type names, as well
as argument and return value names, are mapped into source languages
following the conventions of the source languages. For example, Rust uses
CamelCase for types and snake_case for functions, while other languages
have other conventions. To ensure that this works reliably, this PR
proposes to define and enforce a naming convention for identifiers in
wit. This is not yet an official proposal, and the specifics are likely
to evolve for a while as the details are worked out.
Specifically, this PR requires identifiers in wit to be `kebab-case`, as
opposed to `snake_case` or `CamelCase`. And, it requires names to be
composed of valid Unicode Identifiers, and it requires identifiers to be
in stream-safe NFC form.
It also requires wit source files to not contain any bidirectional
formatting characters, control codes (other than newline, CR, and tab), or
codepoints that Unicode strongly discourages using.