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