diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-03-09 11:44:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 11:44:57 -0800 |
commit | fdea868dbfdee4b0e04852ce59065c8b2ff71662 (patch) | |
tree | 7d142cc58af557088719c4cac67b0e03ef74498d /bindgen-integration/cpp/Test.h | |
parent | 2afecece53a82fdf18e53a98d1b8ed0077500995 (diff) | |
parent | 50ee7372b4bb67097cc40fc9578b880efebb2680 (diff) |
Auto merge of #567 - fitzgen:bitfield-accessors, r=emilio
Reintroduce bitfield accessors
This commit reintroduces accessor methods for bitfields in the generated
bindings.
Fixes #519
r? @emilio
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 |