chiark / gitweb /
config macros: Provide `per_client` and `global` attrs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 17:44:40 +0000 (18:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 18:47:56 +0000 (19:47 +0100)
These set the SKL explicitly.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
macros/macros.rs

index 1233b4103d5fdd15c3c13a4e9b373192e9191f39..b6d4bf3b5844658ef1ddbc1f7cbff962b78d98e8 100644 (file)
@@ -21,6 +21,7 @@ use itertools::Itertools;
 ///
 ///  * `limited`, `server`, `client`: cooked sets of settings;
 ///    default `SKL` is `PerClient` except for `limited`
+///  * `global` and `per_client`: set the SKL.
 ///  * `special(method, SKL)`
 ///
 /// Generated code
@@ -44,7 +45,8 @@ use itertools::Itertools;
 /// }
 /// ```
 #[proc_macro_derive(ResolveConfig, attributes(
-  limited, server, client, computed, special
+  limited, server, client, computed, special,
+  per_client, global,
 ))]
 pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
   let input = parse_macro_input!(input as DeriveInput);
@@ -67,6 +69,14 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
     for attr in &field.attrs {
       let atspan = attr.path.segments.last().unwrap().ident.span();
       if attr.tokens.is_empty() {
+        if &attr.path == &parse_quote!{ per_client } {
+          skl = Some(quote_spanned!{fname_span=> SectionKindList::PerClient });
+          continue;
+        } else if &attr.path == &parse_quote!{ global } {
+          skl = Some(quote_spanned!{fname_span=>
+                                    SectionKindList::Global });
+          continue;
+        }
         method = attr.path.to_token_stream();
         if &attr.path == &parse_quote!{ limited } {
           skl = Some(quote_spanned!{atspan=> SectionKindList::Limited });