#[derive(Debug, Clone, Default, PartialEq)]
pub struct Header {
pub items: Vec<Item>,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum Item {
Function(Function),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Function {
pub name: String,
pub params: Vec<Param>,
pub ret: Type,
pub variadic: bool,
pub doc: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Param {
pub name: Option<String>,
pub ty: Type,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum Type {
Void,
Bool,
Char,
SChar,
UChar,
Short,
UShort,
Int,
UInt,
Long,
ULong,
LongLong,
ULongLong,
SizeT,
SSizeT,
Float,
Double,
Pointer {
pointee: Box<Type>,
is_const: bool,
},
Named(String),
}
impl Type {
pub fn ptr(pointee: Type) -> Self {
Type::Pointer {
pointee: Box::new(pointee),
is_const: false,
}
}
pub fn const_ptr(pointee: Type) -> Self {
Type::Pointer {
pointee: Box::new(pointee),
is_const: true,
}
}
}