odra_codegen/
lib.rs

1macro_rules! as_ref_for_contract_impl_generator {
2    ($struct_ident:ident) => {
3        impl ::core::convert::AsRef<odra_ir::module::ModuleImpl> for $struct_ident<'_> {
4            fn as_ref(&self) -> &odra_ir::module::ModuleImpl {
5                self.contract
6            }
7        }
8    };
9}
10
11macro_rules! as_ref_for_contract_struct_generator {
12    ($struct_ident:ident) => {
13        impl ::core::convert::AsRef<odra_ir::module::ModuleStruct> for $struct_ident<'_> {
14            fn as_ref(&self) -> &odra_ir::module::ModuleStruct {
15                self.module
16            }
17        }
18    };
19}
20
21use generator::GenerateCode;
22mod generator;
23mod poet;
24pub use poet::OdraPoet;
25
26/// Generates the code for the given Odra module.
27pub fn generate_code<T>(entity: T) -> proc_macro2::TokenStream
28where
29    T: OdraPoet
30{
31    <T as OdraPoet>::Poet::from(entity).generate_code()
32}