2018-07-19 14:57:04 -05:00
|
|
|
#![doc(html_root_url = "https://docs.rs/wasm-bindgen-macro/0.2")]
|
|
|
|
|
2017-12-14 19:31:01 -08:00
|
|
|
extern crate proc_macro;
|
2018-08-01 17:15:27 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate quote;
|
2018-07-29 17:59:46 +02:00
|
|
|
extern crate wasm_bindgen_macro_support as macro_support;
|
2017-12-14 19:31:01 -08:00
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
2018-07-07 10:20:31 -07:00
|
|
|
|
2018-02-07 16:41:33 -08:00
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn wasm_bindgen(attr: TokenStream, input: TokenStream) -> TokenStream {
|
2018-08-01 17:15:27 -05:00
|
|
|
match macro_support::expand(attr.into(), input.into()) {
|
|
|
|
Ok(tokens) => {
|
|
|
|
if cfg!(feature = "xxx_debug_only_print_generated_code") {
|
|
|
|
println!("{}", tokens);
|
|
|
|
}
|
|
|
|
tokens.into()
|
|
|
|
}
|
|
|
|
Err(diagnostic) => (quote! { #diagnostic }).into(),
|
2018-05-25 16:17:54 -07:00
|
|
|
}
|
2018-02-07 16:41:33 -08:00
|
|
|
}
|