Add a wasmtime::component::bindgen! macro (#5317)

* Import Wasmtime support from the `wit-bindgen` repo

This commit imports the `wit-bindgen-gen-host-wasmtime-rust` crate from
the `wit-bindgen` repository into the upstream Wasmtime repository. I've
chosen to not import the full history here since the crate is relatively
small and doesn't have a ton of complexity. While the history of the
crate is quite long the current iteration of the crate's history is
relatively short so there's not a ton of import there anyway. The
thinking is that this can now continue to evolve in-tree.

* Refactor `wasmtime-component-macro` a bit

Make room for a `wit_bindgen` macro to slot in.

* Add initial support for a `bindgen` macro

* Add tests for `wasmtime::component::bindgen!`

* Improve error forgetting `async` feature

* Add end-to-end tests for bindgen

* Add an audit of `unicase`

* Add a license to the test-helpers crate

* Add vet entry for `pulldown-cmark`

* Update publish script with new crate

* Try to fix publish script

* Update audits

* Update lock file
This commit is contained in:
Alex Crichton
2022-12-06 13:06:00 -06:00
committed by GitHub
parent 293bb5b334
commit 2329ecc341
43 changed files with 4336 additions and 1212 deletions

View File

@@ -0,0 +1,146 @@
interface variants {
enum e1 {
a,
}
e1-arg: func(x: e1)
e1-result: func() -> e1
union u1 {
u32,
float32,
}
u1-arg: func(x: u1)
u1-result: func() -> u1
record empty {}
variant v1 {
a,
b(u1),
c(e1),
d(string),
e(empty),
f,
g(u32),
}
v1-arg: func(x: v1)
v1-result: func() -> v1
bool-arg: func(x: bool)
bool-result: func() -> bool
option-arg: func(
a: option<bool>,
b: option<tuple<>>,
c: option<u32>,
d: option<e1>,
e: option<float32>,
f: option<u1>,
g: option<option<bool>>,
)
option-result: func() -> tuple<
option<bool>,
option<tuple<>>,
option<u32>,
option<e1>,
option<float32>,
option<u1>,
option<option<bool>>,
>
variant casts1 {
a(s32),
b(float32),
}
variant casts2 {
a(float64),
b(float32),
}
variant casts3 {
a(float64),
b(u64),
}
variant casts4 {
a(u32),
b(s64),
}
variant casts5 {
a(float32),
b(s64),
}
variant casts6 {
a(tuple<float32, u32>),
b(tuple<u32, u32>),
}
casts: func(
a: casts1,
b: casts2,
c: casts3,
d: casts4,
e: casts5,
f: casts6,
) -> tuple<
casts1,
casts2,
casts3,
casts4,
casts5,
casts6,
>
result-arg: func(
a: result,
b: result<_, e1>,
c: result<e1>,
d: result<tuple<>, tuple<>>,
e: result<u32, v1>,
f: result<string, list<u8>>,
)
result-result: func() -> tuple<
result,
result<_, e1>,
result<e1>,
result<tuple<>, tuple<>>,
result<u32, v1>,
result<string, list<u8>>,
>
enum my-errno {
bad1,
bad2,
}
return-result-sugar: func() -> result<s32, my-errno>
return-result-sugar2: func() -> result<_, my-errno>
return-result-sugar3: func() -> result<my-errno, my-errno>
return-result-sugar4: func() -> result<tuple<s32, u32>, my-errno>
return-option-sugar: func() -> option<s32>
return-option-sugar2: func() -> option<my-errno>
result-simple: func() -> result<u32, s32>
record is-clone {
v1: v1,
}
is-clone-arg: func(a: is-clone)
is-clone-return: func() -> is-clone
return-named-option: func() -> (a: option<u8>)
return-named-result: func() -> (a: result<u8, my-errno>)
}
world my-world {
import imports: variants
export exports: variants
default export variants
}