some changes
This commit is contained in:
+1
-5
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "osui-element"
|
name = "osui-element"
|
||||||
version = "0.1.16"
|
version = "0.1.17"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "The element attribute for defining elements in OSUI"
|
description = "The element attribute for defining elements in OSUI"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
@@ -9,10 +9,6 @@ license = "Apache-2.0"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
path = "./lib.rs"
|
path = "./lib.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "osui-element"
|
|
||||||
path = "./main.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0.89"
|
proc-macro2 = "1.0.89"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{
|
use syn::{
|
||||||
parse::Parser, parse_macro_input, DeriveInput, Fields, GenericParam, ItemFn, Lifetime,
|
parse::Parser, parse_macro_input, DeriveInput, Fields, GenericParam, ItemFn,
|
||||||
LifetimeParam,
|
Lifetime, LifetimeParam,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
@@ -90,30 +90,6 @@ pub fn element(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|||||||
expanded.into()
|
expanded.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn elem_fn(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
let ast = parse_macro_input!(input as DeriveInput);
|
|
||||||
let struct_name = &ast.ident;
|
|
||||||
|
|
||||||
let func_name = syn::Ident::new(
|
|
||||||
&struct_name.to_string().to_lowercase(),
|
|
||||||
proc_macro2::Span::call_site(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let elem_fn = quote! {
|
|
||||||
pub fn #func_name<'a>() -> Box<#struct_name<'a>> {
|
|
||||||
Box::new(#struct_name::default())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let expanded = quote! {
|
|
||||||
#ast
|
|
||||||
#elem_fn
|
|
||||||
};
|
|
||||||
|
|
||||||
expanded.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let input_fn = parse_macro_input!(input as ItemFn);
|
let input_fn = parse_macro_input!(input as ItemFn);
|
||||||
|
|||||||
Reference in New Issue
Block a user