From: Ian Jackson Date: Sat, 7 Aug 2021 21:25:06 +0000 (+0100) Subject: config macros: wip global X-Git-Tag: hippotat/1.0.0~253 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d88444cd26e29a4cc391d21949a5e22dec25e5c1;p=hippotat.git config macros: wip global Signed-off-by: Ian Jackson --- diff --git a/macros/macros.rs b/macros/macros.rs index 43efcf6..345c756 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -45,6 +45,9 @@ use itertools::Itertools; /// } /// } /// } +/// +/// pub struct InstanceConfigCommon { +/// { /// ``` #[proc_macro_derive(ResolveConfig, attributes( limited, server, client, computed, special, @@ -53,10 +56,18 @@ use itertools::Itertools; pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); - let fields = match input.data { - Data::Struct(DataStruct { fields: syn::Fields::Named(ref f),.. }) => f, + let (fields, top_ident) = match input { + DeriveInput { + ref ident, + data: Data::Struct(DataStruct { + fields: syn::Fields::Named(ref f), + .. + }), + .. + } => (f, ident), _ => panic!(), }; +dbg!(&top_ident); let target = &input.ident; @@ -124,6 +135,9 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { } //dbg!(&output); + let global = syn::Ident::new(&format!("{}Common", top_ident), + top_ident.span()); + let output = quote! { impl #target { const FIELDS: &'static [(&'static str, SectionKindList)] @@ -137,7 +151,11 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { }) } } + + pub struct #global { + } }; + //eprintln!("{}", &output); output.into() }