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