Make generator macro take a list of languages and fix bug
Used a repetition pattern to allow the macro to take in a list of
`ident`s which are the language names.
`"$name"` in the expansion meant the string literally including the `$`
sign, this made the tests fail. Using `stringify!($name)` fixes this.
@@ -2,27 +2,21 @@ use proc_macro::TokenStream;
use quote::quote;
macro_rules! gen_inline_macro {
- ($name:ident) => (
+ ($($name:ident),*) => (
+ $(
#[proc_macro]
pub fn $name(input: TokenStream) -> TokenStream {
let token_stream_input = proc_macro2::TokenStream::from(input);
let buffer = token_stream_input.to_string();
let result = quote! {{
- ::metacall::load_from_memory("$name", #buffer.to_string()).unwrap()
+ ::metacall::load_from_memory(stringify!($name), #buffer.to_string()).unwrap()
}};
result.into()
}
+ )*
)
}
-gen_inline_macro!(py);
-gen_inline_macro!(node);
-gen_inline_macro!(ts);
-gen_inline_macro!(cs);
-gen_inline_macro!(rb);
-gen_inline_macro!(cob);
-gen_inline_macro!(rpc);
-gen_inline_macro!(java);
-gen_inline_macro!(wasm);
+gen_inline_macro!(py, node, ts, cs, rb, cob, rpc, java, wasm);
