1#![allow(non_upper_case_globals)]
2
3#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd)]
4pub struct TypeName {
5 pub namespace: &'static str,
6 pub name: &'static str,
7}
8
9impl TypeName {
10 pub const Enum: Self = Self::from_const("System", "Enum");
11 pub const Delegate: Self = Self::from_const("System", "MulticastDelegate");
12 pub const Struct: Self = Self::from_const("System", "ValueType");
13 pub const Object: Self = Self::from_const("System", "Object");
14 pub const GUID: Self = Self::from_const("System", "Guid");
15 pub const Type: Self = Self::from_const("System", "Type");
16 pub const Attribute: Self = Self::from_const("System", "Attribute");
17 pub const IsConst: Self = Self::from_const("System.Runtime.CompilerServices", "IsConst");
18
19 pub const HResult: Self = Self::from_const("Windows.Foundation", "HResult");
20 pub const IAsyncAction: Self = Self::from_const("Windows.Foundation", "IAsyncAction");
21 pub const IAsyncActionWithProgress: Self = Self::from_const("Windows.Foundation", "IAsyncActionWithProgress");
22 pub const IAsyncOperation: Self = Self::from_const("Windows.Foundation", "IAsyncOperation");
23 pub const IAsyncOperationWithProgress: Self = Self::from_const("Windows.Foundation", "IAsyncOperationWithProgress");
24
25 pub const Matrix3x2: Self = Self::from_const("Windows.Foundation.Numerics", "Matrix3x2");
26 pub const Matrix4x4: Self = Self::from_const("Windows.Foundation.Numerics", "Matrix4x4");
27
28 pub const IIterable: Self = Self::from_const("Windows.Foundation.Collections", "IIterable");
29 pub const IIterator: Self = Self::from_const("Windows.Foundation.Collections", "IIterator");
30 pub const IVectorView: Self = Self::from_const("Windows.Foundation.Collections", "IVectorView");
31 pub const IVector: Self = Self::from_const("Windows.Foundation.Collections", "IVector");
32
33 pub const PWSTR: Self = Self::from_const("Windows.Win32.Foundation", "PWSTR");
34 pub const PSTR: Self = Self::from_const("Windows.Win32.Foundation", "PSTR");
35 pub const BSTR: Self = Self::from_const("Windows.Win32.Foundation", "BSTR");
36 pub const HANDLE: Self = Self::from_const("Windows.Win32.Foundation", "HANDLE");
37 pub const HRESULT: Self = Self::from_const("Windows.Win32.Foundation", "HRESULT");
38 pub const CHAR: Self = Self::from_const("Windows.Win32.Foundation", "CHAR");
39 pub const BOOL: Self = Self::from_const("Windows.Win32.Foundation", "BOOL");
40 pub const WIN32_ERROR: Self = Self::from_const("Windows.Win32.Foundation", "WIN32_ERROR");
41
42 pub const D2D_MATRIX_3X2_F: Self = Self::from_const("Windows.Win32.Graphics.Direct2D.Common", "D2D_MATRIX_3X2_F");
43 pub const D3DMATRIX: Self = Self::from_const("Windows.Win32.Graphics.Direct3D", "D3DMATRIX");
44 pub const IUnknown: Self = Self::from_const("Windows.Win32.System.Com", "IUnknown");
45 pub const HSTRING: Self = Self::from_const("Windows.Win32.System.WinRT", "HSTRING");
46 pub const IInspectable: Self = Self::from_const("Windows.Win32.System.WinRT", "IInspectable");
47 pub const IRestrictedErrorInfo: Self = Self::from_const("Windows.Win32.System.WinRT", "IRestrictedErrorInfo");
48 pub const IDispatch: Self = Self::from_const("Windows.Win32.System.Com", "IDispatch");
49
50 const fn from_const(namespace: &'static str, name: &'static str) -> Self {
51 Self { namespace, name }
52 }
53
54 pub fn new(namespace: &'static str, name: &'static str) -> Self {
55 Self { namespace, name }
56 }
57
58 pub fn parse(full_name: &'static str) -> Self {
59 let index = full_name.rfind('.').expect("Expected full name separated with `.`");
60 Self::new(&full_name[0..index], &full_name[index + 1..])
61 }
62}
63
64impl std::fmt::Display for TypeName {
65 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
66 write!(fmt, "{}.{}", self.namespace, self.name)
67 }
68}
69