extern crate proc_macro;
#[cfg(feature = "idl-build")]
use {anchor_syn::idl::build::gen_idl_print_function_for_constant, quote::quote, syn};
#[proc_macro_attribute]
pub fn constant(
_attr: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
#[cfg(feature = "idl-build")]
{
let ts = match syn::parse(input).unwrap() {
syn::Item::Const(item) => {
let idl_print = gen_idl_print_function_for_constant(&item);
quote! {
#item
#idl_print
}
}
item => quote! {#item},
};
return proc_macro::TokenStream::from(quote! {
#ts
});
};
#[allow(unreachable_code)]
input
}