Minor refactors to make wiggle-generate reusable externally (#34)

* wiggle-generate: pass witx doc in explicitly

* wiggle-generate: Names takes &Config, minor refactor for reuse
This commit is contained in:
Pat Hickey
2020-03-06 16:55:05 -08:00
committed by GitHub
parent c78416912c
commit 6e3ec6a96d
5 changed files with 20 additions and 22 deletions

View File

@@ -14,9 +14,7 @@ pub use module_trait::define_module_trait;
pub use names::Names;
pub use types::define_datatype;
pub fn generate(config: Config) -> TokenStream {
let doc = witx::load(&config.witx.paths).expect("loading witx");
pub fn generate(doc: &witx::Document, config: &Config) -> TokenStream {
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));