-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register macro expansion capabilities
commit-id:3dc2a19c
- Loading branch information
Showing
10 changed files
with
184 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use cairo_lang_macro_stable::StableExpansionKind; | ||
use std::num::NonZeroU8; | ||
|
||
#[derive(Clone)] | ||
pub enum ExpansionKind { | ||
Attr = 1, | ||
Derive = 2, | ||
Inline = 3, | ||
} | ||
|
||
impl ExpansionKind { | ||
/// Convert to FFI-safe representation. | ||
/// # Safety | ||
#[doc(hidden)] | ||
pub fn into_stable(self) -> StableExpansionKind { | ||
NonZeroU8::try_from(self as u8).unwrap() | ||
} | ||
|
||
/// Convert to native Rust representation. | ||
/// | ||
/// # Safety | ||
#[doc(hidden)] | ||
pub unsafe fn from_stable(kind: &StableExpansionKind) -> Self { | ||
if *kind == Self::Attr.into_stable() { | ||
Self::Attr | ||
} else if *kind == Self::Derive.into_stable() { | ||
Self::Derive | ||
} else { | ||
// Note that it defaults to inline for unknown values. | ||
Self::Inline | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters