tract_pulse/
macros.rs

1#[macro_export]
2macro_rules! pulsed_op_to_typed_op {
3    () => {
4        fn to_typed(&self) -> Box<dyn TypedOp> {
5            tract_core::dyn_clone::clone_box(self)
6        }
7    };
8}
9
10#[macro_export]
11macro_rules! register_all_mod {
12    ($($m: ident),*) => {
13        pub fn register_all(inventory: &mut HashMap<TypeId, OpPulsifier>) {
14            $( $m::register_all(inventory); )*
15        }
16    }
17}
18
19#[macro_export]
20macro_rules! register_all {
21    ($($op: ty: $func: expr),*) => {
22        pub fn register_all(inventory: &mut HashMap<TypeId, OpPulsifier>) {
23            $(
24            inventory.insert(
25                std::any::TypeId::of::<$op>(),
26                OpPulsifier {
27                    type_id: std::any::TypeId::of::<$op>(),
28                    func: |source: &TypedModel,
29                           node: &TypedNode,
30                           target: &mut PulsedModel,
31                           mapping: &HashMap<OutletId, OutletId>,
32                           symbol: &Symbol,
33                           pulse: &TDim|
34                     -> TractResult<Option<TVec<OutletId>>> {
35                        let op = node.op_as::<$op>().unwrap();
36                        ($func)(op, source, node, target, mapping, symbol, pulse)
37                    },
38                    name: stringify!($op)
39                }
40            );)*
41        }
42    };
43}