2017-08-20 06:01:46 +02:00
|
|
|
extern crate proc_macro;
|
|
|
|
extern crate syn;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate quote;
|
|
|
|
|
|
|
|
mod en;
|
|
|
|
mod de;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
use en::{impl_encodable, impl_encodable_wrapper};
|
|
|
|
use de::{impl_decodable, impl_decodable_wrapper};
|
|
|
|
|
|
|
|
#[proc_macro_derive(RlpEncodable)]
|
|
|
|
pub fn encodable(input: TokenStream) -> TokenStream {
|
2018-03-13 12:43:24 +01:00
|
|
|
let ast = syn::parse(input).unwrap();
|
2017-08-20 06:01:46 +02:00
|
|
|
let gen = impl_encodable(&ast);
|
2018-03-13 12:43:24 +01:00
|
|
|
gen.into()
|
2017-08-20 06:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_derive(RlpEncodableWrapper)]
|
|
|
|
pub fn encodable_wrapper(input: TokenStream) -> TokenStream {
|
2018-03-13 12:43:24 +01:00
|
|
|
let ast = syn::parse(input).unwrap();
|
2017-08-20 06:01:46 +02:00
|
|
|
let gen = impl_encodable_wrapper(&ast);
|
2018-03-13 12:43:24 +01:00
|
|
|
gen.into()
|
2017-08-20 06:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_derive(RlpDecodable)]
|
|
|
|
pub fn decodable(input: TokenStream) -> TokenStream {
|
2018-03-13 12:43:24 +01:00
|
|
|
let ast = syn::parse(input).unwrap();
|
2017-08-20 06:01:46 +02:00
|
|
|
let gen = impl_decodable(&ast);
|
2018-03-13 12:43:24 +01:00
|
|
|
gen.into()
|
2017-08-20 06:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[proc_macro_derive(RlpDecodableWrapper)]
|
|
|
|
pub fn decodable_wrapper(input: TokenStream) -> TokenStream {
|
2018-03-13 12:43:24 +01:00
|
|
|
let ast = syn::parse(input).unwrap();
|
2017-08-20 06:01:46 +02:00
|
|
|
let gen = impl_decodable_wrapper(&ast);
|
2018-03-13 12:43:24 +01:00
|
|
|
gen.into()
|
2017-08-20 06:01:46 +02:00
|
|
|
}
|