codama_macros/
lib.rs

1use proc_macro::TokenStream;
2#[cfg(not(target_os = "solana"))]
3mod attributes;
4#[cfg(not(target_os = "solana"))]
5mod derives;
6
7fn codama_derive(input: TokenStream) -> TokenStream {
8    #[cfg(not(target_os = "solana"))]
9    {
10        derives::codama_derive(input)
11    }
12    #[cfg(target_os = "solana")]
13    {
14        input
15    }
16}
17
18fn codama_attribute(attr: TokenStream, input: TokenStream) -> TokenStream {
19    #[cfg(not(target_os = "solana"))]
20    {
21        attributes::codama_attribute(attr, input)
22    }
23    #[cfg(target_os = "solana")]
24    {
25        let _ = attr;
26        input
27    }
28}
29
30#[proc_macro_derive(CodamaAccount, attributes(codama))]
31pub fn codama_account_derive(input: TokenStream) -> TokenStream {
32    codama_derive(input)
33}
34
35#[proc_macro_derive(CodamaAccounts, attributes(codama))]
36pub fn codama_accounts_derive(input: TokenStream) -> TokenStream {
37    codama_derive(input)
38}
39
40#[proc_macro_derive(CodamaErrors, attributes(codama))]
41pub fn codama_errors_derive(input: TokenStream) -> TokenStream {
42    codama_derive(input)
43}
44
45#[proc_macro_derive(CodamaInstruction, attributes(codama))]
46pub fn codama_instruction_derive(input: TokenStream) -> TokenStream {
47    codama_derive(input)
48}
49
50#[proc_macro_derive(CodamaInstructions, attributes(codama))]
51pub fn codama_instructions_derive(input: TokenStream) -> TokenStream {
52    codama_derive(input)
53}
54
55#[proc_macro_derive(CodamaPda, attributes(codama))]
56pub fn codama_pda_derive(input: TokenStream) -> TokenStream {
57    codama_derive(input)
58}
59
60#[proc_macro_derive(CodamaType, attributes(codama))]
61pub fn codama_type_derive(input: TokenStream) -> TokenStream {
62    codama_derive(input)
63}
64
65#[proc_macro_attribute]
66pub fn codama(attr: TokenStream, input: TokenStream) -> TokenStream {
67    codama_attribute(attr, input)
68}