Streamline rhai_generate.

This commit is contained in:
Stephen Chung 2020-09-14 11:40:15 +08:00 committed by J Henry Waugh
parent 1060ff35fd
commit 3dc599c936
2 changed files with 4 additions and 9 deletions

View File

@ -161,7 +161,7 @@ pub fn combine_with_exported_module(args: proc_macro::TokenStream) -> proc_macro
Err(e) => return e.to_compile_error().into(),
};
let tokens = quote! {
#module_path::rhai_generate_into_module(#module_expr);
#module_path::rhai_generate_into_module(#module_expr, true);
};
proc_macro::TokenStream::from(tokens)
}

View File

@ -17,7 +17,7 @@ pub(crate) fn generate_body(
let mut set_fn_stmts: Vec<syn::Stmt> = Vec::new();
let mut set_const_stmts: Vec<syn::Stmt> = Vec::new();
let mut add_mod_blocks: Vec<syn::ExprBlock> = Vec::new();
let mut set_mod_blocks: Vec<syn::ExprBlock> = Vec::new();
let mut set_flattened_mod_blocks: Vec<syn::ExprBlock> = Vec::new();
let str_type_path = syn::parse2::<syn::Path>(quote! { str }).unwrap();
for (const_name, const_type, const_expr) in consts {
@ -55,10 +55,10 @@ pub(crate) fn generate_body(
})
.unwrap(),
);
set_mod_blocks.push(
set_flattened_mod_blocks.push(
syn::parse2::<syn::ExprBlock>(quote! {
#(#cfg_attrs)* {
self::#module_name::rhai_generate_into_module(m);
self::#module_name::rhai_generate_into_module(m, flatten);
}
})
.unwrap(),
@ -155,11 +155,6 @@ pub(crate) fn generate_body(
#(#add_mod_blocks)*
}
}
pub fn rhai_generate_into_module(m: &mut Module) {
#(#set_fn_stmts)*
#(#set_const_stmts)*
#(#set_mod_blocks)*
}
}
})
.unwrap();