hpl_toolkit_attribute_honeycomb_context/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
extern crate proc_macro;
mod renderer;
use syn::parse_macro_input;

#[proc_macro_attribute]
pub fn honeycomb_context(
    args: proc_macro::TokenStream,
    input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
    let context = parse_macro_input!(input as syn::ItemStruct);
    let args = args.to_string();

    let is_compression = args.contains("compression");

    renderer::HoneycombContext::new(
        context,
        renderer::HoneycombContextFlags {
            global: args.contains("global"),
            compression_program: is_compression,
            noop_program: is_compression || args.contains("noop"),
        },
    )
    .render()
}