use rayon::prelude::*;
use squote::{quote, TokenStream};
use std::collections::*;
#[derive(Default)]
pub struct TypeNamespaces(pub BTreeMap<&'static str, crate::type_tree::TypeTree>);
impl TypeNamespaces {
pub fn gen<'a>(&'a self) -> impl ParallelIterator<Item = TokenStream> + 'a {
self.0.par_iter().map(|(name, tree)| {
let name = crate::to_snake(name);
let name = crate::format_ident(&name);
let tokens = tree.gen().collect::<Vec<_>>();
let foundation = if tree.include_foundation {
quote! { pub use ::windows::*; }
} else {
TokenStream::new()
};
quote! {
#[allow(unused_variables)]
#[allow(non_upper_case_globals)]
pub mod #name {
#(#tokens)*
#foundation
}
}
})
}
}