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(crate) $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 SpecialName: Self = Self(0x800);
64 pub const Virtual: Self = Self(0x40);
65}
66
67flags!(MethodImplAttributes, u16);
68impl MethodImplAttributes {
69 pub const PreserveSig: Self = Self(0x80);
70}
71
72flags!(MethodCallAttributes, u8);
74impl MethodCallAttributes {
75 pub const HASTHIS: Self = Self(0x20);
76 pub const VARARG: Self = Self(0x05);
77}
78
79flags!(ParamAttributes, u16);
80impl ParamAttributes {
81 pub const In: Self = Self(0x1);
82 pub const Out: Self = Self(0x2);
83 pub const Optional: Self = Self(0x10);
84}
85
86flags!(PInvokeAttributes, u16);
87impl PInvokeAttributes {
88 pub const SupportsLastError: Self = Self(0x40);
89 pub const CallConvPlatformapi: Self = Self(0x100);
90 pub const CallConvCdecl: Self = Self(0x200);
91}
92
93flags!(TypeAttributes, u32);
94impl TypeAttributes {
95 pub const Public: Self = Self(0x1);
96 pub const ExplicitLayout: Self = Self(0x10);
97 pub const Abstract: Self = Self(0x80);
98 pub const Sealed: Self = Self(0x100);
99 pub const WindowsRuntime: Self = Self(0x4000);
100 pub const Interface: Self = Self(0x20);
101 pub const SequentialLayout: Self = Self(0x8);
102 pub const Import: Self = Self(0x1000);
103
104 pub fn is_nested(&self) -> bool {
105 (self.0 & 0x00000006) != 0
106 }
107}
108
109flags!(GenericParamAttributes, u16);
110impl GenericParamAttributes {}