Skip to content

Commit

Permalink
Implement derive macros (#1258)
Browse files Browse the repository at this point in the history
commit-id:38af599e

---

**Stack**:
- #1264
- #1258⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do
not merge manually using the UI - doing so may have unexpected results.*
  • Loading branch information
maciektr authored Apr 15, 2024
1 parent 45e7e22 commit 7d4f625
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 7d4f625

Please sign in to comment.