Skip to content

Commit

Permalink
Implement derive macros
Browse files Browse the repository at this point in the history
commit-id:38af599e
  • Loading branch information
maciektr committed Apr 15, 2024
1 parent f627ac3 commit e7f11ca
Show file tree
Hide file tree
Showing 3 changed files with 471 additions and 95 deletions.
10 changes: 10 additions & 0 deletions plugins/cairo-lang-macro-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ pub fn inline_macro(_args: TokenStream, input: TokenStream) -> TokenStream {
macro_helper(input, quote!(::cairo_lang_macro::ExpansionKind::Inline))
}

/// Constructs the derive macro implementation.
///
/// This macro hides the conversion to stable ABI structs from the user.
///
/// Note, that this macro can be used multiple times, to define multiple independent attribute macros.
#[proc_macro_attribute]
pub fn derive_macro(_args: TokenStream, input: TokenStream) -> TokenStream {
macro_helper(input, quote!(::cairo_lang_macro::ExpansionKind::Derive))
}

fn macro_helper(input: TokenStream, kind: impl ToTokens) -> TokenStream {
let item: ItemFn = parse_macro_input!(input as ItemFn);
let original_item_name = item.sig.ident.to_string();
Expand Down
Loading

0 comments on commit e7f11ca

Please sign in to comment.