summaryrefslogtreecommitdiffstats
path: root/vendor/windows-metadata/src/writer/mod.rs
blob: 8dcf332b8d1c8ee338692e4a5816439485c80cc6 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
mod imp;
use super::*;

// Generates an in-memory .winmd file.
pub fn write(name: &str, winrt: bool, items: &[Item], assemblies: &[&str]) -> Vec<u8> {
    imp::write(name, winrt, items, assemblies)
}

pub enum Item {
    Struct(Struct),
    Enum(Enum),
    Interface(Interface),
}

pub struct Struct {
    pub namespace: String,
    pub name: String,
    pub fields: Vec<Field>,
}

pub struct Enum {
    pub namespace: String,
    pub name: String,
    pub constants: Vec<Constant>,
}

pub struct Interface {
    pub namespace: String,
    pub name: String,
    pub methods: Vec<Method>,
}

pub struct Field {
    pub name: String,
    pub ty: Type,
}

pub struct Constant {
    pub name: String,
    pub value: Value,
}

pub struct Method {
    pub name: String,
    pub return_type: Type,
    pub params: Vec<Param>,
}

pub struct Param {
    pub name: String,
    pub ty: Type,
    pub flags: ParamFlags,
}

flags!(ParamFlags, u32);
impl ParamFlags {
    pub const INPUT: Self = Self(0x1);
    pub const OUTPUT: Self = Self(0x2);
    pub const OPTIONAL: Self = Self(0x10);
}

pub enum Type {
    Void,
    Bool,
    Char,
    I8,
    U8,
    I16,
    U16,
    I32,
    U32,
    I64,
    U64,
    F32,
    F64,
    ISize,
    USize,
    String,
    Named((String, String)),
}

pub enum Value {
    Bool(bool),
    U8(u8),
    I8(i8),
    U16(u16),
    I16(i16),
    U32(u32),
    I32(i32),
    U64(u64),
    I64(i64),
    F32(f32),
    F64(f64),
    String(String),
}