Create initial reflection system

This commit is contained in:
Werner
2021-12-23 08:46:30 -03:00
parent aa549e37ef
commit 19eebb4085
10 changed files with 174 additions and 0 deletions

18
Macros/Cargo.toml Normal file
View File

@ -0,0 +1,18 @@
[package]
name = "reflection-macros"
version = "0.0.1"
description = "Reflection"
repository = "https://github.com/GuilhermeWerner/Reflection"
license = "MIT"
edition = "2021"
publish = false
[lib]
name = "Reflection_Macros"
proc-macro = true
path = "lib.rs"
[dependencies]
proc-macro2 = "1.0.24"
quote = "1.0.7"
syn = { version = "1.0.48", features = ["full"] }

24
Macros/lib.rs Normal file
View File

@ -0,0 +1,24 @@
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![recursion_limit = "256"]
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};
#[proc_macro_derive(Reflect, attributes(property))]
pub fn reflect(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let name = &ast.ident;
let expanded = quote! {
impl Reflect for #name {}
};
expanded.into()
}
#[proc_macro_attribute]
pub fn function(attr: TokenStream, item: TokenStream) -> TokenStream {
item
}