#![forbid(unsafe_code)]
mod attribute;
mod data;
mod derive;
mod utils;
use syn::{parse_macro_input, AttributeArgs, DeriveInput};
#[proc_macro_derive(EntObject, attributes(ent))]
pub fn derive_ent_object(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
utils::do_derive(derive::do_derive_ent_object)(input)
}
#[proc_macro_derive(EntFilter, attributes(ent))]
pub fn derive_ent_filter(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
utils::do_derive(derive::do_derive_ent_filter)(input)
}
#[proc_macro_attribute]
pub fn gql_ent(
args: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let args = parse_macro_input!(args as AttributeArgs);
let input = parse_macro_input!(input as DeriveInput);
let expanded = utils::entity_crate()
.and_then(|root| attribute::do_gql_ent(root, args, input))
.unwrap_or_else(|x| x.write_errors());
proc_macro::TokenStream::from(expanded)
}