From 3785202ec5b949cba5501b20729b16f4c29ea626 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 22 Apr 2026 13:27:43 +0800 Subject: Add new_with_args and dispatch_args_dynamic to Program Remove Display bound from Group type parameter and delete dispatcher_render macro. This is a breaking change. --- mingling_macros/src/dispatcher_chain.rs | 78 --------------------------------- mingling_macros/src/lib.rs | 5 --- 2 files changed, 83 deletions(-) (limited to 'mingling_macros') diff --git a/mingling_macros/src/dispatcher_chain.rs b/mingling_macros/src/dispatcher_chain.rs index 4038600..6223a81 100644 --- a/mingling_macros/src/dispatcher_chain.rs +++ b/mingling_macros/src/dispatcher_chain.rs @@ -145,84 +145,6 @@ pub fn dispatcher_chain(input: TokenStream) -> TokenStream { expanded.into() } -pub fn dispatcher_render(input: TokenStream) -> TokenStream { - // Parse the input - let dispatcher_input = syn::parse_macro_input!(input as DispatcherChainInput); - - // Determine if we're using default or explicit group - let (group_name, command_name, command_struct, pack, use_default) = match dispatcher_input { - DispatcherChainInput::Explicit { - group_name, - command_name, - command_struct, - pack, - } => (group_name, command_name, command_struct, pack, false), - DispatcherChainInput::Default { - command_name, - command_struct, - pack, - } => ( - Ident::new("ThisProgram", proc_macro2::Span::call_site()), - command_name, - command_struct, - pack, - true, - ), - }; - - let command_name_str = command_name.value(); - - let comp_entry = get_comp_entry(&pack); - - let expanded = if use_default { - // For default case, use ThisProgram - quote! { - #[derive(Debug, Default)] - pub struct #command_struct; - - ::mingling::macros::pack!(ThisProgram, #pack = Vec); - - #comp_entry - - impl ::mingling::Dispatcher for #command_struct { - fn node(&self) -> ::mingling::Node { - ::mingling::macros::node!(#command_name_str) - } - fn begin(&self, args: Vec) -> ::mingling::ChainProcess { - #pack::new(args).to_render() - } - fn clone_dispatcher(&self) -> Box { - Box::new(#command_struct) - } - } - } - } else { - // For explicit case, use the provided group_name - quote! { - #[derive(Debug, Default)] - pub struct #command_struct; - - ::mingling::macros::pack!(#group_name, #pack = Vec); - - #comp_entry - - impl ::mingling::Dispatcher for #command_struct { - fn node(&self) -> ::mingling::Node { - ::mingling::macros::node!(#command_name_str) - } - fn begin(&self, args: Vec) -> ::mingling::ChainProcess { - #pack::new(args).to_render() - } - fn clone_dispatcher(&self) -> Box { - Box::new(#command_struct) - } - } - } - }; - - expanded.into() -} - #[cfg(feature = "comp")] fn get_comp_entry(entry_name: &Ident) -> proc_macro2::TokenStream { let comp_entry = quote! { diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index 8df8ad7..a1493ba 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -58,11 +58,6 @@ pub fn dispatcher(input: TokenStream) -> TokenStream { dispatcher_chain::dispatcher_chain(input) } -#[proc_macro] -pub fn dispatcher_render(input: TokenStream) -> TokenStream { - dispatcher_chain::dispatcher_render(input) -} - #[proc_macro] pub fn r_print(input: TokenStream) -> TokenStream { render::r_print(input) -- cgit