feat(derive): implement derive(Action)

This commit is contained in:
nativerv
2024-02-16 04:02:55 +03:00
parent b88f37457b
commit 8d32bcd62c
2 changed files with 22 additions and 2 deletions
+20 -2
View File
@@ -1,7 +1,25 @@
extern crate proc_macro;
use proc_macro::TokenStream;
use syn;
use quote::quote;
use bevy_controls::contract::{Action, ActionInner};
#[proc_macro_derive(Action)]
pub fn action(_input: TokenStream) -> TokenStream {
todo!("urmom")
pub fn action(input: TokenStream) -> TokenStream {
// Construct a representation of Rust code as a syntax tree
// that we can manipulate
let ast = syn::parse(input).unwrap();
// Build the trait implementation
impl_hello_macro(&ast)
}
fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream {
let name = &ast.ident;
let gen = quote! {
impl Action for #name {}
impl ActionInner for #name {}
};
gen.into()
}