aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/chain.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_macros/src/chain.rs')
-rw-r--r--mingling_macros/src/chain.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/mingling_macros/src/chain.rs b/mingling_macros/src/chain.rs
index 134b3c2..47f32e3 100644
--- a/mingling_macros/src/chain.rs
+++ b/mingling_macros/src/chain.rs
@@ -5,6 +5,8 @@ use syn::{
FnArg, Ident, ItemFn, Pat, PatType, ReturnType, Signature, Type, TypePath, parse_macro_input,
};
+use crate::DEFAULT_PROGRAM_NAME;
+
/// Extracted information about a resource injection parameter
struct ResourceInjection {
var_name: Ident,
@@ -132,11 +134,13 @@ fn extract_args_info(sig: &Signature) -> syn::Result<(Pat, TypePath, Vec<Resourc
}
pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
+ let default_program_ident = crate::default_program_ident();
+
// Parse the attribute arguments (e.g., MyProgram from #[chain(MyProgram)])
// If no argument is provided, use ThisProgram
let (group_name, use_crate_prefix) = if attr.is_empty() {
(
- Ident::new("ThisProgram", proc_macro2::Span::call_site()),
+ Ident::new(DEFAULT_PROGRAM_NAME, proc_macro2::Span::call_site()),
true,
)
} else {
@@ -231,7 +235,7 @@ pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Determine the program type for the return type
let program_type = if use_crate_prefix {
- quote! { ThisProgram }
+ quote! { #default_program_ident }
} else {
quote! { #group_name }
};
@@ -386,7 +390,7 @@ pub fn chain_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
::mingling::macros::register_chain!(#previous_type, #struct_name);
- impl ::mingling::Chain<ThisProgram> for #struct_name {
+ impl ::mingling::Chain<#default_program_ident> for #struct_name {
type Previous = #previous_type;
#proc_fn