change proc macro argument parsing to use syn
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user