orchestra_proc_macro/
orchestra.rs1use proc_macro2::TokenStream;
17use syn::{parse2, Result};
18
19use super::{parse::*, *};
20
21pub(crate) fn impl_orchestra_gen(
22 attr: TokenStream,
23 orig: TokenStream,
24) -> Result<proc_macro2::TokenStream> {
25 let args: OrchestraAttrArgs = parse2(attr)?;
26 let message_wrapper = args.message_wrapper;
27
28 let of: OrchestraGuts = parse2(orig)?;
29
30 let support_crate = support_crate().expect("The crate this macro is run for, includes the proc-macro support as dependency, otherwise it could not be run in the first place. qed");
31 let info = OrchestraInfo {
32 support_crate,
33 subsystems: of.subsystems,
34 baggage: of.baggage,
35 orchestra_name: of.name,
36 message_wrapper,
37 message_channel_capacity: args.message_channel_capacity,
38 signal_channel_capacity: args.signal_channel_capacity,
39 extern_event_ty: args.extern_event_ty,
40 extern_signal_ty: args.extern_signal_ty,
41 extern_error_ty: args.extern_error_ty,
42 outgoing_ty: args.outgoing_ty,
43 boxed_messages: args.boxed_messages,
44 };
45
46 let mut additive = impl_orchestra_struct(&info);
47 additive.extend(impl_builder(&info));
48
49 additive.extend(impl_orchestrated_subsystem(&info));
50 additive.extend(impl_channels_out_struct(&info));
51 additive.extend(impl_subsystem_types_all(&info)?);
52
53 additive.extend(impl_message_wrapper_enum(&info)?);
54
55 let ts = expander::Expander::new("orchestra-expansion")
56 .add_comment("Generated orchestra code by `#[orchestra(..)]`".to_owned())
57 .dry(!cfg!(feature = "expand"))
58 .verbose(true)
59 .write_to_out_dir(additive)
64 .expect("Expander does not fail due to IO in OUT_DIR. qed");
65
66 Ok(ts)
67}