aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-09 15:13:38 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-09 15:13:38 +0800
commit1b67e1143f367d00e955c2780dbdefab463836e1 (patch)
tree41b93757bba91e2e0eb112d9b5bdb3dfbb3c4c36 /mingling_macros/src
parent4764c3c818e3da16a3cba3b9877d9beb635e4237 (diff)
Rename DefaultProgram to ThisProgram and remove ThisProgram marker
Diffstat (limited to 'mingling_macros/src')
-rw-r--r--mingling_macros/src/chain.rs10
-rw-r--r--mingling_macros/src/dispatcher_chain.rs18
-rw-r--r--mingling_macros/src/groupped.rs4
-rw-r--r--mingling_macros/src/lib.rs2
-rw-r--r--mingling_macros/src/pack.rs20
-rw-r--r--mingling_macros/src/program_setup.rs10
6 files changed, 32 insertions, 32 deletions
diff --git a/mingling_macros/src/chain.rs b/mingling_macros/src/chain.rs
index 7b519a1..924931e 100644
--- a/mingling_macros/src/chain.rs
+++ b/mingling_macros/src/chain.rs
@@ -61,10 +61,10 @@ fn extract_return_type(sig: &Signature) -> syn::Result<TypePath> {
pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Parse the attribute arguments (e.g., MyProgram from #[chain(MyProgram)])
- // If no argument is provided, use DefaultProgram
+ // If no argument is provided, use ThisProgram
let (group_name, use_crate_prefix) = if attr.is_empty() {
(
- Ident::new("DefaultProgram", proc_macro2::Span::call_site()),
+ Ident::new("ThisProgram", proc_macro2::Span::call_site()),
true,
)
} else {
@@ -128,11 +128,11 @@ pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
#(#fn_attrs)*
#vis struct #struct_name;
- impl ::mingling::Chain<DefaultProgram> for #struct_name {
+ impl ::mingling::Chain<ThisProgram> for #struct_name {
type Previous = #previous_type;
async fn proc(#prev_param: Self::Previous) ->
- ::mingling::ChainProcess<DefaultProgram>
+ ::mingling::ChainProcess<ThisProgram>
{
let _ = NextProcess;
// Call the original function
@@ -143,7 +143,7 @@ pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Keep the original function for internal use
#(#fn_attrs)*
#vis async fn #fn_name(#prev_param: #previous_type)
- -> ::mingling::ChainProcess<DefaultProgram>
+ -> ::mingling::ChainProcess<ThisProgram>
{
#fn_body
}
diff --git a/mingling_macros/src/dispatcher_chain.rs b/mingling_macros/src/dispatcher_chain.rs
index dc02c33..f531424 100644
--- a/mingling_macros/src/dispatcher_chain.rs
+++ b/mingling_macros/src/dispatcher_chain.rs
@@ -77,7 +77,7 @@ pub fn dispatcher_chain(input: TokenStream) -> TokenStream {
command_struct,
pack,
} => (
- Ident::new("DefaultProgram", proc_macro2::Span::call_site()),
+ Ident::new("ThisProgram", proc_macro2::Span::call_site()),
command_name,
command_struct,
pack,
@@ -88,21 +88,21 @@ pub fn dispatcher_chain(input: TokenStream) -> TokenStream {
let command_name_str = command_name.value();
let expanded = if use_default {
- // For default case, use DefaultProgram
+ // For default case, use ThisProgram
quote! {
#[derive(Debug, Default)]
pub struct #command_struct;
- ::mingling::macros::pack!(DefaultProgram, #pack = Vec<String>);
+ ::mingling::macros::pack!(ThisProgram, #pack = Vec<String>);
- impl ::mingling::Dispatcher<DefaultProgram> for #command_struct {
+ impl ::mingling::Dispatcher<ThisProgram> for #command_struct {
fn node(&self) -> ::mingling::Node {
::mingling::macros::node!(#command_name_str)
}
- fn begin(&self, args: Vec<String>) -> ::mingling::ChainProcess<DefaultProgram> {
+ fn begin(&self, args: Vec<String>) -> ::mingling::ChainProcess<ThisProgram> {
#pack::new(args).to_chain()
}
- fn clone_dispatcher(&self) -> Box<dyn ::mingling::Dispatcher<DefaultProgram>> {
+ fn clone_dispatcher(&self) -> Box<dyn ::mingling::Dispatcher<ThisProgram>> {
Box::new(#command_struct)
}
}
@@ -149,7 +149,7 @@ pub fn dispatcher_render(input: TokenStream) -> TokenStream {
command_struct,
pack,
} => (
- Ident::new("DefaultProgram", proc_macro2::Span::call_site()),
+ Ident::new("ThisProgram", proc_macro2::Span::call_site()),
command_name,
command_struct,
pack,
@@ -160,12 +160,12 @@ pub fn dispatcher_render(input: TokenStream) -> TokenStream {
let command_name_str = command_name.value();
let expanded = if use_default {
- // For default case, use DefaultProgram
+ // For default case, use ThisProgram
quote! {
#[derive(Debug, Default)]
pub struct #command_struct;
- ::mingling::macros::pack!(DefaultProgram, #pack = Vec<String>);
+ ::mingling::macros::pack!(ThisProgram, #pack = Vec<String>);
impl ::mingling::Dispatcher for #command_struct {
fn node(&self) -> ::mingling::Node {
diff --git a/mingling_macros/src/groupped.rs b/mingling_macros/src/groupped.rs
index 2f9934f..032e60b 100644
--- a/mingling_macros/src/groupped.rs
+++ b/mingling_macros/src/groupped.rs
@@ -29,7 +29,7 @@ pub fn derive_groupped(input: TokenStream) -> TokenStream {
// Parse attributes to find #[group(...)]
let group_ident = parse_group_attribute(&input.attrs)
- .unwrap_or_else(|| Ident::new("DefaultProgram", Span::call_site()));
+ .unwrap_or_else(|| Ident::new("ThisProgram", Span::call_site()));
// Generate the Groupped trait implementation
let expanded = quote! {
@@ -51,7 +51,7 @@ pub fn derive_groupped_serialize(input: TokenStream) -> TokenStream {
// Parse attributes to find #[group(...)]
let group_ident = parse_group_attribute(&input_parsed.attrs)
- .unwrap_or_else(|| Ident::new("DefaultProgram", Span::call_site()));
+ .unwrap_or_else(|| Ident::new("ThisProgram", Span::call_site()));
// Generate both Serialize and Groupped implementations
let expanded = quote! {
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index ff43482..d324ddc 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -99,7 +99,7 @@ pub fn derive_groupped_serialize(input: TokenStream) -> TokenStream {
#[proc_macro]
pub fn gen_program(input: TokenStream) -> TokenStream {
let name = if input.is_empty() {
- Ident::new("DefaultProgram", proc_macro2::Span::call_site())
+ Ident::new("ThisProgram", proc_macro2::Span::call_site())
} else {
parse_macro_input!(input as Ident)
};
diff --git a/mingling_macros/src/pack.rs b/mingling_macros/src/pack.rs
index a84010e..226dc35 100644
--- a/mingling_macros/src/pack.rs
+++ b/mingling_macros/src/pack.rs
@@ -69,7 +69,7 @@ pub fn pack(input: TokenStream) -> TokenStream {
type_name,
inner_type,
} => (
- Ident::new("DefaultProgram", proc_macro2::Span::call_site()),
+ Ident::new("ThisProgram", proc_macro2::Span::call_site()),
type_name,
inner_type,
true,
@@ -198,7 +198,7 @@ pub fn pack(input: TokenStream) -> TokenStream {
// Combine all implementations
let expanded = if use_default {
- // For default case, use DefaultProgram
+ // For default case, use ThisProgram
quote! {
#struct_def
@@ -208,13 +208,13 @@ pub fn pack(input: TokenStream) -> TokenStream {
#deref_impl
#default_impl
- impl Into<mingling::AnyOutput<DefaultProgram>> for #type_name {
- fn into(self) -> mingling::AnyOutput<DefaultProgram> {
+ impl Into<mingling::AnyOutput<ThisProgram>> for #type_name {
+ fn into(self) -> mingling::AnyOutput<ThisProgram> {
mingling::AnyOutput::new(self)
}
}
- impl From<#type_name> for mingling::ChainProcess<DefaultProgram> {
+ impl From<#type_name> for mingling::ChainProcess<ThisProgram> {
fn from(value: #type_name) -> Self {
mingling::AnyOutput::new(value).route_chain()
}
@@ -222,19 +222,19 @@ pub fn pack(input: TokenStream) -> TokenStream {
impl #type_name {
/// Converts the wrapper type into a `ChainProcess` for chaining operations.
- pub fn to_chain(self) -> mingling::ChainProcess<DefaultProgram> {
+ pub fn to_chain(self) -> mingling::ChainProcess<ThisProgram> {
mingling::AnyOutput::new(self).route_chain()
}
/// Converts the wrapper type into a `ChainProcess` for rendering operations.
- pub fn to_render(self) -> mingling::ChainProcess<DefaultProgram> {
+ pub fn to_render(self) -> mingling::ChainProcess<ThisProgram> {
mingling::AnyOutput::new(self).route_renderer()
}
}
- impl ::mingling::Groupped<DefaultProgram> for #type_name {
- fn member_id() -> DefaultProgram {
- DefaultProgram::#type_name
+ impl ::mingling::Groupped<ThisProgram> for #type_name {
+ fn member_id() -> ThisProgram {
+ ThisProgram::#type_name
}
}
}
diff --git a/mingling_macros/src/program_setup.rs b/mingling_macros/src/program_setup.rs
index 54da898..4ca9e69 100644
--- a/mingling_macros/src/program_setup.rs
+++ b/mingling_macros/src/program_setup.rs
@@ -99,10 +99,10 @@ fn extract_return_type(sig: &Signature) -> syn::Result<()> {
pub fn setup_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Parse the attribute arguments (e.g., MyProgram from #[setup(MyProgram)])
- // If no argument is provided, use DefaultProgram
+ // If no argument is provided, use ThisProgram
let (program_name, use_crate_prefix) = if attr.is_empty() {
(
- Ident::new("DefaultProgram", proc_macro2::Span::call_site()),
+ Ident::new("ThisProgram", proc_macro2::Span::call_site()),
true,
)
} else {
@@ -160,8 +160,8 @@ pub fn setup_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
#(#fn_attrs)*
#vis struct #struct_name;
- impl ::mingling::setup::ProgramSetup<DefaultProgram, DefaultProgram> for #struct_name {
- fn setup(&mut self, program: &mut ::mingling::Program<DefaultProgram, DefaultProgram>) {
+ impl ::mingling::setup::ProgramSetup<ThisProgram, ThisProgram> for #struct_name {
+ fn setup(&mut self, program: &mut ::mingling::Program<ThisProgram, ThisProgram>) {
let _ = ThisProgram;
// Call the original function with the actual Program type
#fn_name(program);
@@ -170,7 +170,7 @@ pub fn setup_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Keep the original function for internal use
#(#fn_attrs)*
- #vis fn #fn_name(#program_param: &mut ::mingling::Program<DefaultProgram, DefaultProgram>) {
+ #vis fn #fn_name(#program_param: &mut ::mingling::Program<ThisProgram, ThisProgram>) {
#fn_body
}
}