cairo_lang_macro_stable/
lib.rs1use crate::ffi::{StableOption, StableSlice};
2use std::num::NonZeroU8;
3use std::os::raw::c_char;
4use std::ptr::NonNull;
5
6pub mod ffi;
7
8#[repr(C)]
9#[derive(Debug)]
10pub struct StableToken {
11 pub span: StableTextSpan,
12 pub ptr: *const u8,
13 pub len: usize,
14}
15
16#[repr(C)]
17#[derive(Debug)]
18pub struct StableTextSpan {
19 pub start: u32,
20 pub end: u32,
21}
22
23#[repr(C)]
24#[derive(Debug)]
25pub enum StableTokenTree {
26 Ident(StableToken),
27}
28
29#[repr(C)]
30#[derive(Debug)]
31pub struct StableExpansion {
32 pub name: *mut c_char,
33 pub kind: StableExpansionKind,
34}
35
36pub type StableExpansionKind = NonZeroU8;
37
38pub type StableExpansionsList = StableSlice<StableExpansion>;
39
40#[repr(C)]
44#[derive(Debug)]
45pub struct StableTokenStream {
46 pub tokens: StableSlice<StableTokenTree>,
47 pub metadata: StableTokenStreamMetadata,
48 pub size_hint: usize,
49}
50
51#[repr(C)]
55#[derive(Debug)]
56pub struct StableTokenStreamMetadata {
57 pub original_file_path: Option<NonNull<c_char>>,
58 pub file_id: Option<NonNull<c_char>>,
59 pub edition: Option<NonNull<c_char>>,
60}
61
62pub type StableAuxData = StableOption<StableSlice<u8>>;
66
67#[repr(C)]
71#[derive(Debug)]
72pub struct StableDiagnostic {
73 pub message: *mut c_char,
74 pub severity: StableSeverity,
75 pub spans: StableSlice<StableTextSpan>,
76}
77
78pub type StableSeverity = NonZeroU8;
82
83#[repr(C)]
87#[derive(Debug)]
88pub struct StableProcMacroResult {
89 pub token_stream: StableTokenStream,
90 pub diagnostics: StableSlice<StableDiagnostic>,
91 pub aux_data: StableAuxData,
92 pub full_path_markers: StableSlice<*mut c_char>,
93}
94
95#[repr(C)]
96pub struct StableResultWrapper {
97 pub input: StableTokenStream,
98 pub input_attr: StableTokenStream,
99 pub output: StableProcMacroResult,
100}
101
102#[repr(C)]
103pub struct StablePostProcessContext {
104 pub aux_data: StableSlice<StableAuxData>,
105 pub full_path_markers: StableSlice<StableFullPathMarker>,
106}
107
108#[repr(C)]
109pub struct StableFullPathMarker {
110 pub key: *mut c_char,
111 pub full_path: *mut c_char,
112}