we now parse witx paths and the ctx type name in the macro invocation

This commit is contained in:
Pat Hickey
2020-01-30 16:38:16 -08:00
parent 0ba8e73184
commit 29c3ef9d09
5 changed files with 96 additions and 55 deletions

View File

@@ -20,9 +20,9 @@ use types::define_datatype;
pub fn from_witx(args: TokenStream) -> TokenStream {
let config = parse_macro_input!(args as Config);
let names = Names::new(); // TODO parse the names from the invocation of the macro, or from a file?
let doc = witx::load(&config.witx.paths).expect("loading witx");
let doc = witx::load(&config.witx_paths()).expect("loading witx");
let names = Names::new(config); // TODO parse the names from the invocation of the macro, or from a file?
let types = doc.typenames().map(|t| define_datatype(&names, &t));
@@ -30,9 +30,10 @@ pub fn from_witx(args: TokenStream) -> TokenStream {
let modname = names.module(&module.name);
let fs = module.funcs().map(|f| define_func(&names, &f));
let modtrait = define_module_trait(&names, &module);
let ctx_type = names.ctx_type();
quote!(
mod #modname {
use super::WasiCtx;
use super::#ctx_type;
use super::types::*;
#(#fs)*