aboutsummaryrefslogtreecommitdiff
path: root/macro/src/clang.rs
blob: 09efc1ec16edb9717eb1d6c78c94588b5b40bba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use serde_derive::{Deserialize, Serialize};

pub(crate) type Node = clang_ast::Node<Clang>;

#[derive(Deserialize, Serialize)]
pub(crate) enum Clang {
    NamespaceDecl(NamespaceDecl),
    EnumDecl(EnumDecl),
    EnumConstantDecl(EnumConstantDecl),
    ImplicitCastExpr,
    ConstantExpr(ConstantExpr),
    Unknown,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct NamespaceDecl {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<Box<str>>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct EnumDecl {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<Box<str>>,
    #[serde(
        rename = "fixedUnderlyingType",
        skip_serializing_if = "Option::is_none"
    )]
    pub fixed_underlying_type: Option<Type>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct EnumConstantDecl {
    pub name: Box<str>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct ConstantExpr {
    pub value: Box<str>,
}

#[derive(Deserialize, Serialize)]
pub(crate) struct Type {
    #[serde(rename = "qualType")]
    pub qual_type: Box<str>,
    #[serde(rename = "desugaredQualType", skip_serializing_if = "Option::is_none")]
    pub desugared_qual_type: Option<Box<str>>,
}

#[cfg(all(test, target_pointer_width = "64"))]
const _: [(); core::mem::size_of::<Node>()] = [(); 88];