use the async keyword as syntax in the macro invocation
This commit is contained in:
@@ -27,7 +27,6 @@ mod kw {
|
||||
syn::custom_keyword!(witx);
|
||||
syn::custom_keyword!(witx_literal);
|
||||
syn::custom_keyword!(errors);
|
||||
syn::custom_keyword!(async_);
|
||||
}
|
||||
|
||||
impl Parse for ConfigField {
|
||||
@@ -45,8 +44,8 @@ impl Parse for ConfigField {
|
||||
input.parse::<kw::errors>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
Ok(ConfigField::Error(input.parse()?))
|
||||
} else if lookahead.peek(kw::async_) {
|
||||
input.parse::<kw::async_>()?;
|
||||
} else if lookahead.peek(Token![async]) {
|
||||
input.parse::<Token![async]>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
Ok(ConfigField::Async(input.parse()?))
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ use syn::parse_macro_input;
|
||||
/// `{ errno => YourErrnoType }`. This allows you to use the `UserErrorConversion`
|
||||
/// trait to map these rich errors into the flat witx type, or to terminate
|
||||
/// WebAssembly execution by trapping.
|
||||
/// * Optional: `async_` takes a set of witx modules and functions which are
|
||||
/// * Optional: `async` takes a set of witx modules and functions which are
|
||||
/// made Rust `async` functions in the module trait.
|
||||
///
|
||||
/// ## Example
|
||||
@@ -61,7 +61,7 @@ use syn::parse_macro_input;
|
||||
/// (result $r (expected $alias_to_float (error $errno)))))
|
||||
/// ",
|
||||
/// errors: { errno => YourRichError },
|
||||
/// async_: { example::double_int_return_float },
|
||||
/// async: { example::double_int_return_float },
|
||||
/// });
|
||||
///
|
||||
/// /// Witx generates a set of traits, which the user must impl on a
|
||||
|
||||
@@ -7,7 +7,7 @@ use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
witx: ["$CARGO_MANIFEST_DIR/tests/atoms.witx"],
|
||||
async_: {
|
||||
async: {
|
||||
atoms::{int_float_args, double_int_return_float}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -39,7 +39,6 @@ mod kw {
|
||||
syn::custom_keyword!(name);
|
||||
syn::custom_keyword!(docs);
|
||||
syn::custom_keyword!(function_override);
|
||||
syn::custom_keyword!(async_);
|
||||
}
|
||||
|
||||
impl Parse for ConfigField {
|
||||
@@ -65,8 +64,8 @@ impl Parse for ConfigField {
|
||||
input.parse::<kw::modules>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
Ok(ConfigField::Modules(input.parse()?))
|
||||
} else if lookahead.peek(kw::async_) {
|
||||
input.parse::<kw::async_>()?;
|
||||
} else if lookahead.peek(Token![async]) {
|
||||
input.parse::<Token![async]>()?;
|
||||
input.parse::<Token![:]>()?;
|
||||
#[cfg(feature = "async")]
|
||||
{
|
||||
@@ -76,7 +75,7 @@ impl Parse for ConfigField {
|
||||
{
|
||||
Err(syn::Error::new(
|
||||
input.span(),
|
||||
"async_ not supported, enable cargo feature \"async\"",
|
||||
"async not supported, enable cargo feature \"async\"",
|
||||
))
|
||||
}
|
||||
} else {
|
||||
@@ -122,7 +121,7 @@ impl Config {
|
||||
#[cfg(feature = "async")]
|
||||
ConfigField::Async(c) => {
|
||||
if async_.is_some() {
|
||||
return Err(Error::new(err_loc, "duplicate `async_` field"));
|
||||
return Err(Error::new(err_loc, "duplicate `async` field"));
|
||||
}
|
||||
async_ = Some(c);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
|
||||
|
||||
wasmtime_wiggle::from_witx!({
|
||||
witx: ["$CARGO_MANIFEST_DIR/tests/atoms.witx"],
|
||||
async_: {
|
||||
async: {
|
||||
atoms::{double_int_return_float}
|
||||
}
|
||||
});
|
||||
@@ -16,7 +16,7 @@ wasmtime_wiggle::wasmtime_integration!({
|
||||
witx: ["$CARGO_MANIFEST_DIR/tests/atoms.witx"],
|
||||
ctx: Ctx,
|
||||
modules: { atoms => { name: Atoms } },
|
||||
async_: {
|
||||
async: {
|
||||
atoms::double_int_return_float
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user