rspace_derive/
lib.rs

1/*
2    Appellation: rspace-derive <library>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! derive macros for facilitating the creation of containers, fields, and spaces.
6
7extern crate proc_macro;
8extern crate quote;
9extern crate syn;
10
11#[allow(unused)]
12pub(crate) mod attrs {
13    pub use self::{display_attrs::*, nested::*, root::*};
14
15    mod display_attrs;
16    mod nested;
17    mod root;
18}
19
20pub(crate) mod impls {
21    #[doc(inline)]
22    pub use self::wrapper::*;
23
24    mod wrapper;
25}
26use proc_macro::TokenStream;
27use syn::{DeriveInput, parse_macro_input};
28
29/// The [`Spatial`] macro is designed for single-field structs, implementing additional methods
30/// supporting interactions with the inner value
31#[proc_macro_derive(Spatial, attributes(wrap))]
32pub fn spatial(input: TokenStream) -> TokenStream {
33    // Parse the inputs into the proper struct
34    let ast = parse_macro_input!(input as DeriveInput);
35
36    // Build the impl
37    let res = impls::impl_wrapper(&ast);
38
39    res.into()
40}