Skip to content

Update witx to 0.9#59

Merged
alexcrichton merged 7 commits into
bytecodealliance:mainfrom
alexcrichton:witx-next
Feb 19, 2021
Merged

Update witx to 0.9#59
alexcrichton merged 7 commits into
bytecodealliance:mainfrom
alexcrichton:witx-next

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This pulls in the new witx 0.9 crate which notably includes
WebAssembly/WASI#395. This is a large refactoring of how witx signatures
are processed and a large update to the actual syntax of the witx ABIs
themselves.

This commit adjusts to all the new witx APIs and also tweaks idioms in
a few locations as well. Code generation is now less custom to Rust and
instead tries to match almost exactly what the witx crate tells us to
generate. Additionally the representation of types is chosen to more
closely align with interface types in the future where it's impossible
to pass invalid values to the outside world. Notable changes here are:

  • enum-like values are now newtype wrappers around integers to prevent
    invalid values from flowing out.
  • Error traits are now implement directly for the Errno wrapper.
  • The module containing the raw functions now exclusively uses i32/i64
    types and doesn't try to use convenience types in Rust.

This pulls in the new `witx` 0.9 crate which notably includes
WebAssembly/WASI#395. This is a large refactoring of how witx signatures
are processed and a large update to the actual syntax of the witx ABIs
themselves.

This commit adjusts to all the new `witx` APIs and also tweaks idioms in
a few locations as well. Code generation is now less custom to Rust and
instead tries to match almost exactly what the `witx` crate tells us to
generate. Additionally the representation of types is chosen to more
closely align with interface types in the future where it's impossible
to pass invalid values to the outside world. Notable changes here are:

* `enum`-like values are now newtype wrappers around integers to prevent
  invalid values from flowing out.
* Error traits are now implement directly for the `Errno` wrapper.
* The module containing the raw functions now exclusively uses i32/i64
  types and doesn't try to use convenience types in Rust.
@alexcrichton

Copy link
Copy Markdown
Member Author

It should be worth pointing out, however, that WebAssembly/WASI#395 should block this and this should wait probably until that's published on crates.io.

@alexcrichton

Copy link
Copy Markdown
Member Author

Ok should be good for review now!

@alexcrichton alexcrichton merged commit d3c7a34 into bytecodealliance:main Feb 19, 2021
@alexcrichton alexcrichton deleted the witx-next branch February 19, 2021 15:12
@newpavlov

Copy link
Copy Markdown
Contributor

The Error changes are weird. Previously Errno was used for raw results and included "success" state (i.e. code 0). It got then mapped to Result<(), Error>, where Error was a transparent wrapper around NonZeroU16. Now you return Result<(), Errno>, which takes 4 bytes instead of the previous 2. Also the new code does not provide any way of creating Errno from raw codes, which for example is used by getrandom to return error descriptions defined in wasi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants