aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-23 00:23:00 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-23 00:23:00 +0800
commitd94103fd7e76dd86cd64c23f00c818165fb7dc22 (patch)
treea435e61fdaa4c273d221d9bbbba640172cb20f6a /mingling_core/src/program.rs
parent443ffe86485519a218997955335cde142733f88f (diff)
Replace macro_rules dispatch with proc-macro generation
Generate `render()` and `do_chain()` match dispatch directly in `program_final_gen`, using a compile-time `ASYNC_ENABLED` constant to select the correct sync/async signature. Removes the `__dispatch_program_renderers!` and `__dispatch_program_chains!` macros from `mingling_core`.
Diffstat (limited to 'mingling_core/src/program.rs')
-rw-r--r--mingling_core/src/program.rs73
1 files changed, 0 insertions, 73 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index 12dc9cc..a1b803e 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -169,79 +169,6 @@ where
}
}
-#[macro_export]
-#[doc(hidden)]
-macro_rules! __dispatch_program_renderers {
- (
- $( $render_ty:ty => $prev_ty:ident, )*
- ) => {
- fn render(any: mingling::AnyOutput<Self::Enum>, __renderer_inner_result: &mut mingling::RenderResult) {
- match any.member_id {
- $(
- Self::$prev_ty => {
- // SAFETY: The `type_id` check ensures that `any` contains a value of type `$prev_ty`,
- // so downcasting to `$prev_ty` is safe.
- let value = unsafe { any.downcast::<$prev_ty>().unwrap_unchecked() };
- <$render_ty as mingling::Renderer>::render(value, __renderer_inner_result);
- }
- )*
- _ => (),
- }
- }
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-#[cfg(feature = "async")]
-macro_rules! __dispatch_program_chains {
- (
- $( $chain_ty:ty => $chain_prev:ident, )*
- ) => {
- fn do_chain(
- any: mingling::AnyOutput<Self::Enum>,
- ) -> std::pin::Pin<Box<dyn Future<Output = mingling::ChainProcess<Self::Enum>> + Send>> {
- match any.member_id {
- $(
- Self::$chain_prev => {
- // SAFETY: The `type_id` check ensures that `any` contains a value of type `$chain_prev`,
- // so downcasting to `$chain_prev` is safe.
- let value = unsafe { any.downcast::<$chain_prev>().unwrap_unchecked() };
- let fut = async { <$chain_ty as mingling::Chain<Self::Enum>>::proc(value).await };
- Box::pin(fut)
- }
- )*
- _ => panic!("No chain found for type id: {:?}", any.type_id),
- }
- }
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-#[cfg(not(feature = "async"))]
-macro_rules! __dispatch_program_chains {
- (
- $( $chain_ty:ty => $chain_prev:ident, )*
- ) => {
- fn do_chain(
- any: mingling::AnyOutput<Self::Enum>,
- ) -> mingling::ChainProcess<Self::Enum> {
- match any.member_id {
- $(
- Self::$chain_prev => {
- // SAFETY: The `type_id` check ensures that `any` contains a value of type `$chain_prev`,
- // so downcasting to `$chain_prev` is safe.
- let value = unsafe { any.downcast::<$chain_prev>().unwrap_unchecked() };
- <$chain_ty as mingling::Chain<Self::Enum>>::proc(value)
- }
- )*
- _ => panic!("No chain found for type id: {:?}", any.type_id),
- }
- }
- };
-}
-
/// Get all registered dispatcher names from the program
#[allow(unused_variables)]
#[must_use]