wiggle: add support for async traits; ABI func is now generic of ctx

* ctx parameter no longer accepted by wiggle::from_witx macro.
* optional async_ parameter specifies which functions are async.
* re-export async_trait::async_trait, so users don't have to take a dep.
This commit is contained in:
Pat Hickey
2021-03-04 17:26:09 -08:00
parent a5d49c07a7
commit f11cd8e7b1
9 changed files with 260 additions and 97 deletions

View File

@@ -7,20 +7,12 @@ use witx::{BuiltinType, Id, Type, TypeRef, WasmType};
use crate::{lifetimes::LifetimeExt, UserErrorType};
pub struct Names {
ctx_type: Ident,
runtime_mod: TokenStream,
}
impl Names {
pub fn new(ctx_type: &Ident, runtime_mod: TokenStream) -> Names {
Names {
ctx_type: ctx_type.clone(),
runtime_mod,
}
}
pub fn ctx_type(&self) -> Ident {
self.ctx_type.clone()
pub fn new(runtime_mod: TokenStream) -> Names {
Names { runtime_mod }
}
pub fn runtime_mod(&self) -> TokenStream {