1#![allow(dead_code, clippy::upper_case_acronyms, clippy::enum_variant_names)]
2
3#[derive(Clone, Debug, Hash, PartialEq, Eq)]
4pub struct TypeName {
5 pub namespace: String,
6 pub name: String,
7 pub generics: Vec<Type>,
8}
9
10#[derive(Clone, Debug, Hash, PartialEq, Eq)]
11pub enum Type {
12 Void,
13 Bool,
14 Char,
15 I8,
16 U8,
17 I16,
18 U16,
19 I32,
20 U32,
21 I64,
22 U64,
23 F32,
24 F64,
25 ISize,
26 USize,
27 String,
28 GUID,
29 IUnknown,
30 IInspectable,
31 HRESULT,
32 PSTR,
33 PWSTR,
34 PCSTR,
35 PCWSTR,
36 BSTR,
37 Type,
38 TypeRef(TypeName),
39 GenericParam(u16),
40 MutPtr(Box<Self>, usize),
41 ConstPtr(Box<Self>, usize),
42 Win32Array(Box<Self>, usize),
43 WinrtArray(Box<Self>),
44 WinrtArrayRef(Box<Self>),
45 ConstRef(Box<Self>),
46}
47
48impl Type {
49 pub fn into_mut_ptr(self) -> Self {
50 match self {
51 Self::MutPtr(ty: Box, count: usize) => Self::MutPtr(ty, count + 1),
52 Self::ConstPtr(ty: Box, count: usize) => Self::MutPtr(ty, count + 1),
53 _ => Self::MutPtr(Box::new(self), 1),
54 }
55 }
56
57 pub fn into_const_ptr(self) -> Self {
58 match self {
59 Self::MutPtr(ty: Box, count: usize) => Self::ConstPtr(ty, count + 1),
60 Self::ConstPtr(ty: Box, count: usize) => Self::ConstPtr(ty, count + 1),
61 _ => Self::ConstPtr(Box::new(self), 1),
62 }
63 }
64
65 pub fn into_array(self, len: usize) -> Self {
66 Self::Win32Array(Box::new(self), len)
67 }
68}
69
70pub struct Signature {
71 pub params: Vec<SignatureParam>,
72 pub return_type: Type,
73 pub call_flags: u8,
74}
75
76// TODO: just Param?
77pub struct SignatureParam {
78 pub name: String,
79 pub ty: Type,
80}
81