From 3de10ca22cca06c4d9069984d0e66e370a331dde Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 1 Apr 2026 15:48:41 +0800 Subject: 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 --- mingling_macros/src/renderer.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'mingling_macros/src/renderer.rs') 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! { -- cgit