Wiggle: tweaks to internal interfaces (#1469)

* [wiggle]: wiggle-generate internal interface for Names simplified

im using it in other libraries where I don't want to construct a
wiggle_generate::Config just to use the ctx_type out of it.

* wiggle: define_func can get trait name as argument

this flexibility needed for some customization over in lucet
This commit is contained in:
Pat Hickey
2020-04-06 07:51:17 -07:00
committed by GitHub
parent 45b3ed142c
commit c2cb4ea3ff
3 changed files with 17 additions and 10 deletions

View File

@@ -5,7 +5,11 @@ use crate::lifetimes::anon_lifetime;
use crate::module_trait::passed_by_reference;
use crate::names::Names;
pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream {
pub fn define_func(
names: &Names,
func: &witx::InterfaceFunc,
trait_name: TokenStream,
) -> TokenStream {
let funcname = func.name.as_str();
let ident = names.func(&func.name);
@@ -166,7 +170,7 @@ pub fn define_func(names: &Names, func: &witx::InterfaceFunc) -> TokenStream {
{
log::trace!(#trace_fmt, #(#args),*);
}
let #trait_bindings = match ctx.#ident(#(#trait_args),*) {
let #trait_bindings = match #trait_name::#ident(ctx, #(#trait_args),*) {
Ok(#trait_bindings) => { #trait_rets },
Err(e) => { #ret_err },
};