diff options
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | mingling_macros/src/func/dispatcher.rs | 6 | ||||
| -rw-r--r-- | mingling_macros/src/func/gen_program.rs | 2 |
3 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d9198b..5fe8be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,10 @@ None 4. **[`pathf:patterns`]** Added `CommandPattern` to the `pathf` pattern analyzer, matching functions annotated with `#[command]`. The pattern tracks the generated hidden module (`__command_{fn}_module`) and marks it as a local module item via `AnalyzeItem::local_module()`. The build system generates a glob re-export `use path::__command_{fn}_module::*;` to bring all generated types (`Entry*`, `CMD*`, chain struct, dispatcher static) into scope. +5. **[`macros:dispatcher`]** Added a `From<pack_Type> for crate::Entry` implementation inside the `dispatcher!()` macro expansion. When the `dispatcher!()` macro generates the entry pack type (via `pack!(#pack = Vec<String>)`), it now also generates `impl From<#pack> for crate::Entry { fn from(value: #pack) -> Self { crate::Entry::new(value.inner) } }`. This allows pack types generated by `dispatcher!()` to be directly converted into `crate::Entry`, enabling ergonomic integration with program-level entry handling. + +6. **[`macros:gen_program`]** Added a `pack!(Entry = Vec<String>)` invocation inside the `__this_program_impl` module generated by `gen_program!()`. This creates a `Entry` pack type (aliasing a `Vec<String>` container) directly in the generated module, providing a default entry point type for the program that can be used by `dispatcher!()`-generated types and other chain infrastructure without requiring the user to define a separate entry pack type manually. + #### **BREAKING CHANGES** (API CHANGES): None diff --git a/mingling_macros/src/func/dispatcher.rs b/mingling_macros/src/func/dispatcher.rs index 45ac4c8..ef02618 100644 --- a/mingling_macros/src/func/dispatcher.rs +++ b/mingling_macros/src/func/dispatcher.rs @@ -121,6 +121,12 @@ pub(crate) fn dispatcher(input: TokenStream) -> TokenStream { ::mingling::macros::pack!(#(#entry_attrs)* #pack = Vec<String>); + impl From<#pack> for crate::Entry { + fn from(value: #pack) -> Self { + crate::Entry::new(value.inner) + } + } + #comp_entry #dispatch_tree_entry diff --git a/mingling_macros/src/func/gen_program.rs b/mingling_macros/src/func/gen_program.rs index 0c35318..d50041e 100644 --- a/mingling_macros/src/func/gen_program.rs +++ b/mingling_macros/src/func/gen_program.rs @@ -56,6 +56,8 @@ pub(crate) fn gen_program_impl(_input: TokenStream) -> TokenStream { /// Alias for the current program type `ThisProgram` pub type Next = ::mingling::ChainProcess<ThisProgram>; + ::mingling::macros::pack!(Entry = Vec<String>); + impl ::mingling::Routable<ThisProgram> for ::mingling::ChainProcess<ThisProgram> { fn to_chain(self) -> ::mingling::ChainProcess<ThisProgram> { |
