mirror of
https://github.com/guilhermewerner/reflection
synced 2025-06-16 21:44:19 +00:00
Create initial reflection system
This commit is contained in:
18
Macros/Cargo.toml
Normal file
18
Macros/Cargo.toml
Normal 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
24
Macros/lib.rs
Normal 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
|
||||
}
|
Reference in New Issue
Block a user