diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-06-18 00:57:41 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-06-18 02:09:28 +0200 |
commit | 700a3ea249f1f82abe7ed4be98359aff615d13e1 (patch) | |
tree | b678320e07aa6dede425507b4e76226afa532ee6 /bindgen-integration/cpp/Test.h | |
parent | 02ac99221a4d418c1d7dd3eef1fcda160f3696b1 (diff) |
codegen: Fix bitfield getter/setters so they work with NPOT sizes.
Diffstat (limited to 'bindgen-integration/cpp/Test.h')
-rw-r--r-- | bindgen-integration/cpp/Test.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h index 4b8c1690..e23a32e6 100644 --- a/bindgen-integration/cpp/Test.h +++ b/bindgen-integration/cpp/Test.h @@ -92,6 +92,36 @@ struct Date2 { unsigned short byte); }; + +struct Fifth { + unsigned short nWeekDay : 3; // 0..7 (3 bits) + unsigned short nMonthDay : 6; // 0..31 (6 bits) + unsigned short nMonth : 5; // 0..12 (5 bits) + unsigned short nYear : 8; // 0..100 (8 bits) + unsigned char byte; + + /// Returns true if the bitfields match the arguments, false otherwise. + bool assert(unsigned short nWeekDay, + unsigned short nMonthDay, + unsigned short nMonth, + unsigned short nYear, + unsigned char byte); +}; + +struct Sixth { + unsigned char byte; + unsigned char nWeekDay : 3; + unsigned char nMonth : 5; + unsigned char nMonthDay : 6; + + /// Returns true if the bitfields match the arguments, false otherwise. + bool assert(unsigned char byte, + unsigned char nWeekDay, + unsigned char nMonth, + unsigned char nMonthDay); +}; + + } // namespace bitfields struct AutoRestoreBool { |