summaryrefslogtreecommitdiff
path: root/mingling_macros/src/renderer.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-01 15:48:41 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-01 15:48:41 +0800
commit3de10ca22cca06c4d9069984d0e66e370a331dde (patch)
tree7e8a9b035c360c016cde848b3442d3e1d5dcac5e /mingling_macros/src/renderer.rs
parentf3d6f76dfd07c35dabc11aa86d86c3671cd283c5 (diff)
Replace typeid-based dispatch with enum-based dispatch
- Add `Groupped` trait and `member_id` to `AnyOutput` - Add generic parameter `G` to `Dispatcher`, `Chain`, `Program` etc - Remove `hint` module and its marker types - Update macros to support explicit group specification - Add `gen_program` macro for generating enum-based programs - Add `GroupProcess` marker type for type-level grouping
Diffstat (limited to 'mingling_macros/src/renderer.rs')
-rw-r--r--mingling_macros/src/renderer.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/mingling_macros/src/renderer.rs b/mingling_macros/src/renderer.rs
index 21c20c8..0e32b40 100644
--- a/mingling_macros/src/renderer.rs
+++ b/mingling_macros/src/renderer.rs
@@ -4,7 +4,7 @@
//! generating structs that implement the `Renderer` trait from functions.
use proc_macro::TokenStream;
-use quote::quote;
+use quote::{ToTokens, quote};
use syn::spanned::Spanned;
use syn::{FnArg, ItemFn, Pat, PatType, ReturnType, Signature, Type, TypePath, parse_macro_input};
@@ -106,22 +106,29 @@ pub fn renderer_attr(item: TokenStream) -> TokenStream {
};
let renderer_exist_entry = quote! {
- id if id == std::any::TypeId::of::<#previous_type>() => true,
+ Self::#previous_type => true,
};
let mut renderers = crate::RENDERERS.lock().unwrap();
let mut renderer_exist = crate::RENDERERS_EXIST.lock().unwrap();
+ let mut packed_types = crate::PACKED_TYPES.lock().unwrap();
let renderer_entry_str = renderer_entry.to_string();
let renderer_exist_entry_str = renderer_exist_entry.to_string();
+ let previous_type_str = previous_type.to_token_stream().to_string();
if !renderers.contains(&renderer_entry_str) {
renderers.push(renderer_entry_str);
}
+
if !renderer_exist.contains(&renderer_exist_entry_str) {
renderer_exist.push(renderer_exist_entry_str);
}
+ if !packed_types.contains(&previous_type_str) {
+ packed_types.push(previous_type_str);
+ }
+
// Generate the struct and implementation
// We need to create a wrapper function that adds the r parameter
let expanded = quote! {