diff options
Diffstat (limited to 'bindgen-integration/cpp/Test.h')
-rw-r--r-- | bindgen-integration/cpp/Test.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h index db90f4d7..c060984d 100644 --- a/bindgen-integration/cpp/Test.h +++ b/bindgen-integration/cpp/Test.h @@ -20,3 +20,45 @@ typedef Test TypeAlias; } // namespace testing typedef testing::TypeAlias TypeAlias; + +namespace bitfields { + +struct First { + unsigned char three_bits_byte_one : 3; + // This starts a new byte, leaving 5 bits unused. + unsigned char :0; + + unsigned char six_bits_byte_two : 6; + unsigned char two_bits_byte_two : 2; + + /// Returns true if the bitfields match the arguments, false otherwise. + bool assert(unsigned char first, + unsigned char second, + unsigned char third); +}; + +struct Second { + int thirty_one_bits : 31; + bool one_bit : 1; + + /// Returns true if the bitfields match the arguments, false otherwise. + bool assert(int first, + bool second); +}; + +enum ItemKind { + ITEM_KIND_UNO, + ITEM_KIND_DOS, + ITEM_KIND_TRES, +}; + +struct Third { + int flags : 28; + bool is_whatever : 1; + ItemKind kind : 3; + + /// Returns true if the bitfields match the arguments, false otherwise. + bool assert(int first, bool second, ItemKind third); +}; + +} // namespace bitfields |