diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-22 13:27:43 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-22 13:30:13 +0800 |
| commit | 3785202ec5b949cba5501b20729b16f4c29ea626 (patch) | |
| tree | 2a276df54128e73557463af54d626a1a7c250e94 /mingling_macros/src | |
| parent | c2f9fb47832c5e12fe37762616c81b016de00464 (diff) | |
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.
Diffstat (limited to 'mingling_macros/src')
| -rw-r--r-- | mingling_macros/src/dispatcher_chain.rs | 78 | ||||
| -rw-r--r-- | mingling_macros/src/lib.rs | 5 |
2 files changed, 0 insertions, 83 deletions
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<String>); - - #comp_entry - - impl ::mingling::Dispatcher for #command_struct { - fn node(&self) -> ::mingling::Node { - ::mingling::macros::node!(#command_name_str) - } - fn begin(&self, args: Vec<String>) -> ::mingling::ChainProcess { - #pack::new(args).to_render() - } - fn clone_dispatcher(&self) -> Box<dyn ::mingling::Dispatcher> { - 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<String>); - - #comp_entry - - impl ::mingling::Dispatcher for #command_struct { - fn node(&self) -> ::mingling::Node { - ::mingling::macros::node!(#command_name_str) - } - fn begin(&self, args: Vec<String>) -> ::mingling::ChainProcess { - #pack::new(args).to_render() - } - fn clone_dispatcher(&self) -> Box<dyn ::mingling::Dispatcher> { - 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 @@ -59,11 +59,6 @@ pub fn dispatcher(input: TokenStream) -> TokenStream { } #[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) } |
