change proc macro argument parsing to use syn

This commit is contained in:
Pat Hickey
2020-01-30 14:29:53 -08:00
parent e2079c085d
commit 0ba8e73184
4 changed files with 41 additions and 9 deletions

View File

@@ -1,15 +1,16 @@
extern crate proc_macro;
mod config;
mod funcs;
mod module_trait;
mod names;
mod parse;
mod types;
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::parse_macro_input;
use config::Config;
use funcs::define_func;
use module_trait::define_module_trait;
use names::Names;
@@ -17,12 +18,11 @@ use types::define_datatype;
#[proc_macro]
pub fn from_witx(args: TokenStream) -> TokenStream {
let args = TokenStream2::from(args);
let witx_paths = parse::witx_paths(args).expect("parsing macro arguments");
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(&witx_paths).expect("loading witx");
let doc = witx::load(&config.witx_paths()).expect("loading witx");
let types = doc.typenames().map(|t| define_datatype(&names, &t));