2017-06-24 06:23:20 -05:00
|
|
|
#![recursion_limit = "1024"]
|
|
|
|
|
|
|
|
extern crate proc_macro;
|
|
|
|
extern crate syn;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate quote;
|
|
|
|
|
|
|
|
mod util;
|
2017-08-02 20:55:33 -05:00
|
|
|
mod derive_enum;
|
|
|
|
mod derive_input_object;
|
2017-08-02 20:49:19 -05:00
|
|
|
mod derive_object;
|
2017-06-24 06:23:20 -05:00
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
|
|
|
#[proc_macro_derive(GraphQLEnum, attributes(graphql))]
|
|
|
|
pub fn derive_enum(input: TokenStream) -> TokenStream {
|
|
|
|
let s = input.to_string();
|
|
|
|
let ast = syn::parse_derive_input(&s).unwrap();
|
2017-08-02 20:55:33 -05:00
|
|
|
let gen = derive_enum::impl_enum(&ast);
|
2017-06-24 06:23:20 -05:00
|
|
|
gen.parse().unwrap()
|
|
|
|
}
|
2017-06-24 13:20:00 -05:00
|
|
|
|
|
|
|
#[proc_macro_derive(GraphQLInputObject, attributes(graphql))]
|
|
|
|
pub fn derive_input_object(input: TokenStream) -> TokenStream {
|
|
|
|
let s = input.to_string();
|
|
|
|
let ast = syn::parse_derive_input(&s).unwrap();
|
2017-08-02 20:55:33 -05:00
|
|
|
let gen = derive_input_object::impl_input_object(&ast);
|
2017-06-24 13:20:00 -05:00
|
|
|
gen.parse().unwrap()
|
|
|
|
}
|
2017-08-02 20:49:19 -05:00
|
|
|
|
|
|
|
#[proc_macro_derive(GraphQLObject, attributes(graphql))]
|
|
|
|
pub fn derive_object(input: TokenStream) -> TokenStream {
|
|
|
|
let s = input.to_string();
|
|
|
|
let ast = syn::parse_derive_input(&s).unwrap();
|
|
|
|
let gen = derive_object::impl_object(&ast);
|
|
|
|
gen.parse().unwrap()
|
|
|
|
}
|