summaryrefslogtreecommitdiffstats
path: root/tests/rust/bitflags.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:39:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:39:07 +0000
commitaf6b8ed095f88f1df2116cdc7a9d44872cfa6074 (patch)
tree1f2df671c1f8033d5ed83f056167a0911f8d2a57 /tests/rust/bitflags.rs
parentInitial commit. (diff)
downloadrust-cbindgen-af6b8ed095f88f1df2116cdc7a9d44872cfa6074.tar.xz
rust-cbindgen-af6b8ed095f88f1df2116cdc7a9d44872cfa6074.zip
Adding upstream version 0.26.0.upstream/0.26.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rust/bitflags.rs')
-rw-r--r--tests/rust/bitflags.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/rust/bitflags.rs b/tests/rust/bitflags.rs
new file mode 100644
index 0000000..cba8377
--- /dev/null
+++ b/tests/rust/bitflags.rs
@@ -0,0 +1,61 @@
+bitflags! {
+ /// Constants shared by multiple CSS Box Alignment properties
+ ///
+ /// These constants match Gecko's `NS_STYLE_ALIGN_*` constants.
+ #[derive(MallocSizeOf)]
+ #[repr(C)]
+ pub struct AlignFlags: u8 {
+ /// 'auto'
+ const AUTO = 0;
+ /// 'normal'
+ const NORMAL = 1;
+ /// 'start'
+ const START = 1 << 1;
+ /// 'end'
+ const END = 1 << 2;
+ const ALIAS = Self::END.bits();
+ /// 'flex-start'
+ const FLEX_START = 1 << 3;
+ const MIXED = 1 << 4 | AlignFlags::FLEX_START.bits() | AlignFlags::END.bits();
+ const MIXED_SELF = 1 << 5 | AlignFlags::FLEX_START.bits() | AlignFlags::END.bits();
+ }
+}
+
+bitflags! {
+ #[repr(C)]
+ pub struct DebugFlags: u32 {
+ /// Flag with the topmost bit set of the u32
+ const BIGGEST_ALLOWED = 1 << 31;
+ }
+}
+
+bitflags! {
+ #[repr(C)]
+ pub struct LargeFlags: u64 {
+ /// Flag with a very large shift that usually would be narrowed.
+ const LARGE_SHIFT = 1u64 << 44;
+ const INVERTED = !Self::LARGE_SHIFT.bits();
+ }
+}
+
+// bitflags 2 allows to define types out-of-line for custom derives
+// #[derive(SomeTrait)]
+#[repr(C)]
+pub struct OutOfLine(u32);
+
+bitflags! {
+ impl OutOfLine: u32 {
+ const A = 1;
+ const B = 2;
+ const AB = Self::A.bits() | Self::B.bits();
+ }
+}
+
+#[no_mangle]
+pub extern "C" fn root(
+ flags: AlignFlags,
+ bigger_flags: DebugFlags,
+ largest_flags: LargeFlags,
+ out_of_line: OutOfLine,
+) {
+}