use proc_macro::TokenStream; use proc_macro_error2::proc_macro_error; use syn::GenericParam; mod codegen; mod derive_choice_type; mod parsing; mod validation; /// Used to create a node definition. #[proc_macro_error] #[proc_macro_attribute] pub fn node(attr: TokenStream, item: TokenStream) -> TokenStream { // Performs the `node_impl` macro's functionality of attaching an `impl Node for TheGivenStruct` block to the node struct parsing::new_node_fn(attr.into(), item.into()).into() } /// Generate meta-information for an enum. /// /// `#[widget(F)]` on a type indicates the type of widget to use to display/edit the type, currently `Radio` and `Dropdown` are supported. /// /// `#[label("Foo")]` on a variant overrides the default UI label (which is otherwise the name converted to title case). All labels are collected into a [`core::fmt::Display`] impl. /// /// `#[icon("tag"))]` sets the icon to use when a variant is shown in a menu or radio button. /// /// Doc comments on a variant become tooltip text. #[proc_macro_derive(ChoiceType, attributes(widget, menu_separator, label, icon))] pub fn derive_choice_type(input_item: TokenStream) -> TokenStream { TokenStream::from(derive_choice_type::derive_choice_type_impl(input_item.into()).unwrap_or_else(|err| err.to_compile_error())) }