diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-04-03 22:32:14 +0100 |
---|---|---|
committer | Gerrit Rockbox <gerrit@rockbox.org> | 2016-04-08 18:06:27 +0200 |
commit | 56dc54d38ac6c1d47ea6dbae88b1e5f7fee9f3ec (patch) | |
tree | 7f44562caba6a6152b0137489db3888a7f1f4bca | |
parent | 45a02dcf818ca2f7513863cda2a56a8929c6d20e (diff) | |
download | rockbox-56dc54d.tar.gz rockbox-56dc54d.zip |
soc_desc: add default constructors to most structures
After being caught by several bugs of the type "let's forgot to initialize
a field to default value", I'm finally fixing this.
Change-Id: I01c33e0611d4f697f767db66465e4fb30858cdab
-rw-r--r-- | utils/regtools/include/soc_desc.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/regtools/include/soc_desc.hpp b/utils/regtools/include/soc_desc.hpp index f6c5cca28f..66562f80d9 100644 --- a/utils/regtools/include/soc_desc.hpp +++ b/utils/regtools/include/soc_desc.hpp @@ -39,6 +39,9 @@ typedef uint32_t soc_addr_t; typedef uint32_t soc_word_t; typedef int soc_id_t; +/** Default value for IDs */ +const soc_id_t DEFAULT_ID = 0xcafebabe; + /** Error class */ class error_t { @@ -81,6 +84,9 @@ struct enum_t std::string name; /** Name (must be unique among field enums) */ std::string desc; /** Optional description of the meaning of this value */ soc_word_t value; /** Value of the field */ + + /** Default constructor: default ID and value is 0 */ + enum_t():id(DEFAULT_ID), value(0) {} }; /** Register field information */ @@ -93,6 +99,9 @@ struct field_t size_t width; /** Width of the field in bits */ std::vector< enum_t > enum_; /** List of special values */ + /** Default constructor: default ID, position is 0, width is 1 */ + field_t():id(DEFAULT_ID), pos(0), width(1) {} + /** Returns the bit mask of the field within the register */ soc_word_t bitmask() const { @@ -140,6 +149,9 @@ struct variant_t soc_id_t id; /** ID (must be unique among register variants) */ std::string type; /** type of the variant */ soc_addr_t offset; /** offset of the variant */ + + /** Default constructor: default ID, offset is 0 */ + variant_t():id(DEFAULT_ID), offset(0) {} }; /** Register information */ @@ -149,6 +161,9 @@ struct register_t std::string desc; /** Optional description of the register */ std::vector< field_t > field; /** List of fields */ std::vector< variant_t > variant; /** List of variants */ + + /** Default constructor: width is 32 */ + register_t():width(32) {} }; /** Node address range information */ @@ -170,6 +185,9 @@ struct range_t std::string variable; /** Formula variable name (for FORMULA) */ std::vector< soc_word_t > list; /** Address list (for LIST) */ + /** Default constructor: empty stride */ + range_t():type(STRIDE), first(0), count(0), base(0), stride(0) {} + /** Return the number of indexes (based on count or list) */ size_t size() { @@ -193,6 +211,9 @@ struct instance_t type_t type; /** Instance type */ soc_word_t addr; /** Address (for SINGLE) */ range_t range; /** Range (for RANGE) */ + + /** Default constructor: single instance at 0 */ + instance_t():id(DEFAULT_ID), type(SINGLE), addr(0) {} }; /** Node information */ @@ -205,6 +226,9 @@ struct node_t std::vector< register_t> register_; /** Optional register */ std::vector< instance_t> instance; /** List of instances */ std::vector< node_t > node; /** List of sub-nodes */ + + /** Default constructor: default ID */ + node_t():id(DEFAULT_ID) {} }; /** System-on-chip information */ |