Debian Codegraph @

.cargo/vendor/cbindgen/tests/expectations/bitflags.cpp

raw
1 #include <cstdarg>
2 #include <cstdint>
3 #include <cstdlib>
4 #include <ostream>
5 #include <new>
6
7 /// Constants shared by multiple CSS Box Alignment properties
8 ///
9 /// These constants match Gecko's `NS_STYLE_ALIGN_*` constants.
10 struct AlignFlags {
11 uint8_t bits;
12
13 constexpr explicit operator bool() const {
14 return !!bits;
15 }
16 constexpr AlignFlags operator~() const {
17 return AlignFlags { static_cast<decltype(bits)>(~bits) };
18 }
19 constexpr AlignFlags operator|(const AlignFlags& other) const {
20 return AlignFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
21 }
22 AlignFlags& operator|=(const AlignFlags& other) {
23 *this = (*this | other);
24 return *this;
25 }
26 constexpr AlignFlags operator&(const AlignFlags& other) const {
27 return AlignFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
28 }
29 AlignFlags& operator&=(const AlignFlags& other) {
30 *this = (*this & other);
31 return *this;
32 }
33 constexpr AlignFlags operator^(const AlignFlags& other) const {
34 return AlignFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
35 }
36 AlignFlags& operator^=(const AlignFlags& other) {
37 *this = (*this ^ other);
38 return *this;
39 }
40 };
41 /// 'auto'
42 constexpr static const AlignFlags AlignFlags_AUTO = AlignFlags{ /* .bits = */ (uint8_t)0 };
43 /// 'normal'
44 constexpr static const AlignFlags AlignFlags_NORMAL = AlignFlags{ /* .bits = */ (uint8_t)1 };
45 /// 'start'
46 constexpr static const AlignFlags AlignFlags_START = AlignFlags{ /* .bits = */ (uint8_t)(1 << 1) };
47 /// 'end'
48 constexpr static const AlignFlags AlignFlags_END = AlignFlags{ /* .bits = */ (uint8_t)(1 << 2) };
49 constexpr static const AlignFlags AlignFlags_ALIAS = AlignFlags{ /* .bits = */ (uint8_t)(AlignFlags_END).bits };
50 /// 'flex-start'
51 constexpr static const AlignFlags AlignFlags_FLEX_START = AlignFlags{ /* .bits = */ (uint8_t)(1 << 3) };
52 constexpr static const AlignFlags AlignFlags_MIXED = AlignFlags{ /* .bits = */ (uint8_t)(((1 << 4) | (AlignFlags_FLEX_START).bits) | (AlignFlags_END).bits) };
53 constexpr static const AlignFlags AlignFlags_MIXED_SELF = AlignFlags{ /* .bits = */ (uint8_t)(((1 << 5) | (AlignFlags_FLEX_START).bits) | (AlignFlags_END).bits) };
54
55 struct DebugFlags {
56 uint32_t bits;
57
58 constexpr explicit operator bool() const {
59 return !!bits;
60 }
61 constexpr DebugFlags operator~() const {
62 return DebugFlags { static_cast<decltype(bits)>(~bits) };
63 }
64 constexpr DebugFlags operator|(const DebugFlags& other) const {
65 return DebugFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
66 }
67 DebugFlags& operator|=(const DebugFlags& other) {
68 *this = (*this | other);
69 return *this;
70 }
71 constexpr DebugFlags operator&(const DebugFlags& other) const {
72 return DebugFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
73 }
74 DebugFlags& operator&=(const DebugFlags& other) {
75 *this = (*this & other);
76 return *this;
77 }
78 constexpr DebugFlags operator^(const DebugFlags& other) const {
79 return DebugFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
80 }
81 DebugFlags& operator^=(const DebugFlags& other) {
82 *this = (*this ^ other);
83 return *this;
84 }
85 };
86 /// Flag with the topmost bit set of the u32
87 constexpr static const DebugFlags DebugFlags_BIGGEST_ALLOWED = DebugFlags{ /* .bits = */ (uint32_t)(1 << 31) };
88
89 struct LargeFlags {
90 uint64_t bits;
91
92 constexpr explicit operator bool() const {
93 return !!bits;
94 }
95 constexpr LargeFlags operator~() const {
96 return LargeFlags { static_cast<decltype(bits)>(~bits) };
97 }
98 constexpr LargeFlags operator|(const LargeFlags& other) const {
99 return LargeFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
100 }
101 LargeFlags& operator|=(const LargeFlags& other) {
102 *this = (*this | other);
103 return *this;
104 }
105 constexpr LargeFlags operator&(const LargeFlags& other) const {
106 return LargeFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
107 }
108 LargeFlags& operator&=(const LargeFlags& other) {
109 *this = (*this & other);
110 return *this;
111 }
112 constexpr LargeFlags operator^(const LargeFlags& other) const {
113 return LargeFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
114 }
115 LargeFlags& operator^=(const LargeFlags& other) {
116 *this = (*this ^ other);
117 return *this;
118 }
119 };
120 /// Flag with a very large shift that usually would be narrowed.
121 constexpr static const LargeFlags LargeFlags_LARGE_SHIFT = LargeFlags{ /* .bits = */ (uint64_t)(1ull << 44) };
122 constexpr static const LargeFlags LargeFlags_INVERTED = LargeFlags{ /* .bits = */ (uint64_t)~(LargeFlags_LARGE_SHIFT).bits };
123
124 extern "C" {
125
126 void root(AlignFlags flags, DebugFlags bigger_flags, LargeFlags largest_flags);
127
128 } // extern "C"