use crate::ffi::{StableOption, StableSlice};
use std::ffi::CStr;
use std::num::NonZeroU8;
use std::os::raw::c_char;
use std::ptr::NonNull;
pub mod ffi;
#[repr(C)]
#[derive(Debug)]
pub struct StableExpansion {
pub name: *mut c_char,
pub kind: StableExpansionKind,
}
pub type StableExpansionKind = NonZeroU8;
pub type StableExpansionsList = StableSlice<StableExpansion>;
#[repr(C)]
#[derive(Debug)]
pub struct StableTokenStream {
pub value: *mut c_char,
pub metadata: StableTokenStreamMetadata,
}
#[repr(C)]
#[derive(Debug)]
pub struct StableTokenStreamMetadata {
pub original_file_path: Option<NonNull<c_char>>,
pub file_id: Option<NonNull<c_char>>,
}
pub type StableAuxData = StableOption<StableSlice<u8>>;
#[repr(C)]
#[derive(Debug)]
pub struct StableDiagnostic {
pub message: *mut c_char,
pub severity: StableSeverity,
}
pub type StableSeverity = NonZeroU8;
#[repr(C)]
#[derive(Debug)]
pub struct StableProcMacroResult {
pub token_stream: StableTokenStream,
pub diagnostics: StableSlice<StableDiagnostic>,
pub aux_data: StableAuxData,
pub full_path_markers: StableSlice<*mut c_char>,
}
#[repr(C)]
pub struct StableResultWrapper {
pub input: StableTokenStream,
pub input_attr: StableTokenStream,
pub output: StableProcMacroResult,
}
impl StableTokenStream {
pub unsafe fn to_string(&self) -> String {
CStr::from_ptr(self.value).to_string_lossy().to_string()
}
}
#[repr(C)]
pub struct StablePostProcessContext {
pub aux_data: StableSlice<StableAuxData>,
pub full_path_markers: StableSlice<StableFullPathMarker>,
}
#[repr(C)]
pub struct StableFullPathMarker {
pub key: *mut c_char,
pub full_path: *mut c_char,
}