windows_metadata/
attributes.rs1macro_rules! flags {
2 ($name:ident, $size:ty) => {
3 #[derive(Default, Copy, Clone, PartialEq, Eq, Debug, Ord, PartialOrd)]
4 pub struct $name(pub $size);
5 impl $name {
6 pub fn contains(&self, contains: Self) -> bool {
7 *self & contains == contains
8 }
9 }
10 impl std::ops::BitOr for $name {
11 type Output = Self;
12 fn bitor(self, other: Self) -> Self {
13 Self(self.0 | other.0)
14 }
15 }
16 impl std::ops::BitAnd for $name {
17 type Output = Self;
18 fn bitand(self, other: Self) -> Self {
19 Self(self.0 & other.0)
20 }
21 }
22 impl std::ops::BitOrAssign for $name {
23 fn bitor_assign(&mut self, other: Self) {
24 self.0.bitor_assign(other.0);
25 }
26 }
27 impl std::ops::BitAndAssign for $name {
28 fn bitand_assign(&mut self, other: Self) {
29 self.0.bitand_assign(other.0);
30 }
31 }
32 impl std::ops::Not for $name {
33 type Output = Self;
34 fn not(self) -> Self {
35 Self(self.0.not())
36 }
37 }
38 };
39}
40
41flags!(AssemblyFlags, u32);
42impl AssemblyFlags {
43 pub const WindowsRuntime: Self = Self(0x200);
44}
45
46flags!(FieldAttributes, u16);
47impl FieldAttributes {
48 pub const Private: Self = Self(0x1);
49 pub const Public: Self = Self(0x6);
50 pub const Literal: Self = Self(0x40);
51 pub const Static: Self = Self(0x10);
52 pub const SpecialName: Self = Self(0x200);
53 pub const RTSpecialName: Self = Self(0x400);
54 pub const HasDefault: Self = Self(0x8000);
55}
56
57flags!(MethodAttributes, u16);
58impl MethodAttributes {
59 pub const Abstract: Self = Self(0x400);
60 pub const HideBySig: Self = Self(0x80);
61 pub const NewSlot: Self = Self(0x100);
62 pub const Public: Self = Self(0x6);
63 pub const Static: Self = Self(0x10);
64 pub const SpecialName: Self = Self(0x800);
65 pub const Virtual: Self = Self(0x40);
66 pub const PInvokeImpl: Self = Self(0x2000);
67 pub const RTSpecialName: Self = Self(0x1000);
68}
69
70flags!(MethodImplAttributes, u16);
71impl MethodImplAttributes {
72 pub const Runtime: Self = Self(0x3);
73 pub const PreserveSig: Self = Self(0x80);
74}
75
76flags!(MethodCallAttributes, u8);
78impl MethodCallAttributes {
79 pub const HASTHIS: Self = Self(0x20);
80 pub const VARARG: Self = Self(0x05);
81}
82
83flags!(ParamAttributes, u16);
84impl ParamAttributes {
85 pub const In: Self = Self(0x1);
86 pub const Out: Self = Self(0x2);
87 pub const Optional: Self = Self(0x10);
88}
89
90flags!(PInvokeAttributes, u16);
91impl PInvokeAttributes {
92 pub const NoMangle: Self = Self(0x01);
93 pub const SupportsLastError: Self = Self(0x40);
94 pub const CallConvPlatformapi: Self = Self(0x100);
95 pub const CallConvCdecl: Self = Self(0x200);
96 pub const CallConvFastcall: Self = Self(0x500);
97}
98
99flags!(TypeAttributes, u32);
100impl TypeAttributes {
101 pub const Public: Self = Self(0x1);
102 pub const NestedPublic: Self = Self(0x2);
103 pub const ExplicitLayout: Self = Self(0x10);
104 pub const Abstract: Self = Self(0x80);
105 pub const Sealed: Self = Self(0x100);
106 pub const WindowsRuntime: Self = Self(0x4000);
107 pub const Interface: Self = Self(0x20);
108 pub const SequentialLayout: Self = Self(0x8);
109 pub const Import: Self = Self(0x1000);
110
111 pub fn is_nested(&self) -> bool {
112 (self.0 & 0x00000006) != 0
113 }
114}
115
116flags!(GenericParamAttributes, u16);
117impl GenericParamAttributes {
118 pub const None: Self = Self(0);
119}