diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-09-09 13:09:46 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2016-09-21 00:31:12 +0100 |
commit | 7b1bcae879305da138bb3e08d04735b54266c537 (patch) | |
tree | 1ca365c8b49b0696a61729bccf43fb1b1c58df3b | |
parent | 84ff8a4df9eac157ea9df22054b996fef5b34d8f (diff) | |
download | rockbox-7b1bcae879305da138bb3e08d04735b54266c537.tar.gz rockbox-7b1bcae879305da138bb3e08d04735b54266c537.zip |
regtools: rename error_t to err_t to avoid name clash
Change-Id: Ib8d34e4f58f3225b1dafc533ce7e1b7867ad053b
-rw-r--r-- | utils/regtools/headergen_v2.cpp | 8 | ||||
-rw-r--r-- | utils/regtools/include/soc_desc.hpp | 10 | ||||
-rw-r--r-- | utils/regtools/lib/formula.cpp | 2 | ||||
-rw-r--r-- | utils/regtools/lib/soc_desc.cpp | 13 | ||||
-rw-r--r-- | utils/regtools/swiss_knife.cpp | 44 |
5 files changed, 38 insertions, 39 deletions
diff --git a/utils/regtools/headergen_v2.cpp b/utils/regtools/headergen_v2.cpp index bc056aaeb5..22a99b7df4 100644 --- a/utils/regtools/headergen_v2.cpp +++ b/utils/regtools/headergen_v2.cpp | |||
@@ -87,12 +87,12 @@ void print_context(const error_context_t& ctx) | |||
87 | { | 87 | { |
88 | for(size_t j = 0; j < ctx.count(); j++) | 88 | for(size_t j = 0; j < ctx.count(); j++) |
89 | { | 89 | { |
90 | error_t e = ctx.get(j); | 90 | err_t e = ctx.get(j); |
91 | switch(e.level()) | 91 | switch(e.level()) |
92 | { | 92 | { |
93 | case error_t::INFO: printf("[INFO]"); break; | 93 | case err_t::INFO: printf("[INFO]"); break; |
94 | case error_t::WARNING: printf("[WARN]"); break; | 94 | case err_t::WARNING: printf("[WARN]"); break; |
95 | case error_t::FATAL: printf("[FATAL]"); break; | 95 | case err_t::FATAL: printf("[FATAL]"); break; |
96 | default: printf("[UNK]"); break; | 96 | default: printf("[UNK]"); break; |
97 | } | 97 | } |
98 | if(e.location().size() != 0) | 98 | if(e.location().size() != 0) |
diff --git a/utils/regtools/include/soc_desc.hpp b/utils/regtools/include/soc_desc.hpp index b8d16b423e..3d8481f963 100644 --- a/utils/regtools/include/soc_desc.hpp +++ b/utils/regtools/include/soc_desc.hpp | |||
@@ -43,7 +43,7 @@ typedef int soc_id_t; | |||
43 | const soc_id_t DEFAULT_ID = 0xcafebabe; | 43 | const soc_id_t DEFAULT_ID = 0xcafebabe; |
44 | 44 | ||
45 | /** Error class */ | 45 | /** Error class */ |
46 | class error_t | 46 | class err_t |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | enum level_t | 49 | enum level_t |
@@ -52,7 +52,7 @@ public: | |||
52 | WARNING, | 52 | WARNING, |
53 | FATAL | 53 | FATAL |
54 | }; | 54 | }; |
55 | error_t(level_t lvl, const std::string& loc, const std::string& msg) | 55 | err_t(level_t lvl, const std::string& loc, const std::string& msg) |
56 | :m_level(lvl), m_loc(loc), m_msg(msg) {} | 56 | :m_level(lvl), m_loc(loc), m_msg(msg) {} |
57 | level_t level() const { return m_level; } | 57 | level_t level() const { return m_level; } |
58 | std::string location() const { return m_loc; } | 58 | std::string location() const { return m_loc; } |
@@ -66,11 +66,11 @@ protected: | |||
66 | class error_context_t | 66 | class error_context_t |
67 | { | 67 | { |
68 | public: | 68 | public: |
69 | void add(const error_t& err) { m_list.push_back(err); } | 69 | void add(const err_t& err) { m_list.push_back(err); } |
70 | size_t count() const { return m_list.size(); } | 70 | size_t count() const { return m_list.size(); } |
71 | error_t get(size_t i) const { return m_list[i]; } | 71 | err_t get(size_t i) const { return m_list[i]; } |
72 | protected: | 72 | protected: |
73 | std::vector< error_t > m_list; | 73 | std::vector< err_t > m_list; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | /** | 76 | /** |
diff --git a/utils/regtools/lib/formula.cpp b/utils/regtools/lib/formula.cpp index 1a6b16c773..dbde20a321 100644 --- a/utils/regtools/lib/formula.cpp +++ b/utils/regtools/lib/formula.cpp | |||
@@ -24,7 +24,7 @@ struct formula_evaluator | |||
24 | va_start(args, fmt); | 24 | va_start(args, fmt); |
25 | vsnprintf(buffer,sizeof(buffer), fmt, args); | 25 | vsnprintf(buffer,sizeof(buffer), fmt, args); |
26 | va_end(args); | 26 | va_end(args); |
27 | ctx.add(error_t(error_t::FATAL, m_loc, buffer)); | 27 | ctx.add(err_t(err_t::FATAL, m_loc, buffer)); |
28 | return false; | 28 | return false; |
29 | } | 29 | } |
30 | 30 | ||
diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp index b52201672f..3238c4de73 100644 --- a/utils/regtools/lib/soc_desc.cpp +++ b/utils/regtools/lib/soc_desc.cpp | |||
@@ -149,23 +149,23 @@ std::string xml_loc(xmlAttr *attr) | |||
149 | } | 149 | } |
150 | 150 | ||
151 | template<typename T> | 151 | template<typename T> |
152 | bool add_error(error_context_t& ctx, error_t::level_t lvl, T *node, | 152 | bool add_error(error_context_t& ctx, err_t::level_t lvl, T *node, |
153 | const std::string& msg) | 153 | const std::string& msg) |
154 | { | 154 | { |
155 | ctx.add(error_t(lvl, xml_loc(node), msg)); | 155 | ctx.add(err_t(lvl, xml_loc(node), msg)); |
156 | return false; | 156 | return false; |
157 | } | 157 | } |
158 | 158 | ||
159 | template<typename T> | 159 | template<typename T> |
160 | bool add_fatal(error_context_t& ctx, T *node, const std::string& msg) | 160 | bool add_fatal(error_context_t& ctx, T *node, const std::string& msg) |
161 | { | 161 | { |
162 | return add_error(ctx, error_t::FATAL, node, msg); | 162 | return add_error(ctx, err_t::FATAL, node, msg); |
163 | } | 163 | } |
164 | 164 | ||
165 | template<typename T> | 165 | template<typename T> |
166 | bool add_warning(error_context_t& ctx, T *node, const std::string& msg) | 166 | bool add_warning(error_context_t& ctx, T *node, const std::string& msg) |
167 | { | 167 | { |
168 | return add_error(ctx, error_t::WARNING, node, msg); | 168 | return add_error(ctx, err_t::WARNING, node, msg); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool parse_wrong_version_error(xmlNode *node, error_context_t& ctx) | 171 | bool parse_wrong_version_error(xmlNode *node, error_context_t& ctx) |
@@ -529,7 +529,7 @@ bool parse_root_elem(xmlNode *node, soc_t& soc, error_context_t& ctx) | |||
529 | END_ATTR_MATCH() | 529 | END_ATTR_MATCH() |
530 | if(!has_version) | 530 | if(!has_version) |
531 | { | 531 | { |
532 | ctx.add(error_t(error_t::FATAL, xml_loc(node), "no version attribute, is this a v1 file ?")); | 532 | ctx.add(err_t(err_t::FATAL, xml_loc(node), "no version attribute, is this a v1 file ?")); |
533 | return false; | 533 | return false; |
534 | } | 534 | } |
535 | if(ver != MAJOR_VERSION) | 535 | if(ver != MAJOR_VERSION) |
@@ -660,7 +660,7 @@ namespace | |||
660 | if((x) < 0) { \ | 660 | if((x) < 0) { \ |
661 | std::ostringstream oss; \ | 661 | std::ostringstream oss; \ |
662 | oss << __FILE__ << ":" << __LINE__; \ | 662 | oss << __FILE__ << ":" << __LINE__; \ |
663 | ctx.add(error_t(error_t::FATAL, oss.str(), "write error")); \ | 663 | ctx.add(err_t(err_t::FATAL, oss.str(), "write error")); \ |
664 | return -1; \ | 664 | return -1; \ |
665 | } \ | 665 | } \ |
666 | }while(0) | 666 | }while(0) |
@@ -1576,7 +1576,6 @@ node_inst_t node_inst_t::child(const std::string& name) const | |||
1576 | return child(name, INST_NO_INDEX); | 1576 | return child(name, INST_NO_INDEX); |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | |||
1580 | node_inst_t node_inst_t::child(const std::string& name, size_t index) const | 1579 | node_inst_t node_inst_t::child(const std::string& name, size_t index) const |
1581 | { | 1580 | { |
1582 | std::vector< node_t > *nodes = get_children(m_node); | 1581 | std::vector< node_t > *nodes = get_children(m_node); |
diff --git a/utils/regtools/swiss_knife.cpp b/utils/regtools/swiss_knife.cpp index fb65b5ca24..2ea1fc4ad3 100644 --- a/utils/regtools/swiss_knife.cpp +++ b/utils/regtools/swiss_knife.cpp | |||
@@ -35,12 +35,12 @@ void print_context(const error_context_t& ctx) | |||
35 | { | 35 | { |
36 | for(size_t j = 0; j < ctx.count(); j++) | 36 | for(size_t j = 0; j < ctx.count(); j++) |
37 | { | 37 | { |
38 | error_t e = ctx.get(j); | 38 | err_t e = ctx.get(j); |
39 | switch(e.level()) | 39 | switch(e.level()) |
40 | { | 40 | { |
41 | case error_t::INFO: printf("[INFO]"); break; | 41 | case err_t::INFO: printf("[INFO]"); break; |
42 | case error_t::WARNING: printf("[WARN]"); break; | 42 | case err_t::WARNING: printf("[WARN]"); break; |
43 | case error_t::FATAL: printf("[FATAL]"); break; | 43 | case err_t::FATAL: printf("[FATAL]"); break; |
44 | default: printf("[UNK]"); break; | 44 | default: printf("[UNK]"); break; |
45 | } | 45 | } |
46 | if(e.location().size() != 0) | 46 | if(e.location().size() != 0) |
@@ -110,7 +110,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte | |||
110 | soc_word_t base = 0, stride = 0; | 110 | soc_word_t base = 0, stride = 0; |
111 | if(in.addr.size() <= 1) | 111 | if(in.addr.size() <= 1) |
112 | { | 112 | { |
113 | ctx.add(error_t(error_t::WARNING, loc, | 113 | ctx.add(err_t(err_t::WARNING, loc, |
114 | "register uses a formula but has only one instance")); | 114 | "register uses a formula but has only one instance")); |
115 | is_stride = false; | 115 | is_stride = false; |
116 | } | 116 | } |
@@ -125,7 +125,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte | |||
125 | 125 | ||
126 | if(is_stride) | 126 | if(is_stride) |
127 | { | 127 | { |
128 | ctx.add(error_t(error_t::INFO, loc, "promoted formula to base/stride")); | 128 | ctx.add(err_t(err_t::INFO, loc, "promoted formula to base/stride")); |
129 | out.instance[0].range.type = range_t::STRIDE; | 129 | out.instance[0].range.type = range_t::STRIDE; |
130 | out.instance[0].range.base = base; | 130 | out.instance[0].range.base = base; |
131 | out.instance[0].range.stride = stride; | 131 | out.instance[0].range.stride = stride; |
@@ -167,7 +167,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_dev_t& in, node_t& out, error_conte | |||
167 | { | 167 | { |
168 | std::string loc = _loc + "." + in.name; | 168 | std::string loc = _loc + "." + in.name; |
169 | if(!in.version.empty()) | 169 | if(!in.version.empty()) |
170 | ctx.add(error_t(error_t::INFO, loc, "dropped version")); | 170 | ctx.add(err_t(err_t::INFO, loc, "dropped version")); |
171 | out.name = in.name; | 171 | out.name = in.name; |
172 | out.title = in.long_name; | 172 | out.title = in.long_name; |
173 | out.desc = in.desc; | 173 | out.desc = in.desc; |
@@ -330,10 +330,10 @@ int do_write(int argc, char **argv) | |||
330 | void check_name(const std::string& path, const std::string& name, error_context_t& ctx) | 330 | void check_name(const std::string& path, const std::string& name, error_context_t& ctx) |
331 | { | 331 | { |
332 | if(name.empty()) | 332 | if(name.empty()) |
333 | ctx.add(error_t(error_t::FATAL, path, "name is empty")); | 333 | ctx.add(err_t(err_t::FATAL, path, "name is empty")); |
334 | for(size_t i = 0; i < name.size(); i++) | 334 | for(size_t i = 0; i < name.size(); i++) |
335 | if(!isalnum(name[i]) && name[i] != '_') | 335 | if(!isalnum(name[i]) && name[i] != '_') |
336 | ctx.add(error_t(error_t::FATAL, path, "name '" + name + | 336 | ctx.add(err_t(err_t::FATAL, path, "name '" + name + |
337 | "' must only contain alphanumeric characters or '_'")); | 337 | "' must only contain alphanumeric characters or '_'")); |
338 | } | 338 | } |
339 | 339 | ||
@@ -351,7 +351,7 @@ void check_instance(const std::string& _path, const instance_t& inst, error_cont | |||
351 | var[inst.range.variable] = inst.range.first; | 351 | var[inst.range.variable] = inst.range.first; |
352 | soc_word_t res; | 352 | soc_word_t res; |
353 | if(!evaluate_formula(inst.range.formula, var, res, path + ".<formula>", ctx)) | 353 | if(!evaluate_formula(inst.range.formula, var, res, path + ".<formula>", ctx)) |
354 | ctx.add(error_t(error_t::FATAL, path + ".<formula>", | 354 | ctx.add(err_t(err_t::FATAL, path + ".<formula>", |
355 | "cannot evaluate formula")); | 355 | "cannot evaluate formula")); |
356 | } | 356 | } |
357 | } | 357 | } |
@@ -362,7 +362,7 @@ void check_field(const std::string& _path, const field_t& field, error_context_t | |||
362 | std::string path = _path + "." + field.name; | 362 | std::string path = _path + "." + field.name; |
363 | check_name(path, field.name, ctx); | 363 | check_name(path, field.name, ctx); |
364 | if(field.width == 0) | 364 | if(field.width == 0) |
365 | ctx.add(error_t(error_t::WARNING, path, "field has width 0")); | 365 | ctx.add(err_t(err_t::WARNING, path, "field has width 0")); |
366 | soc_word_t max = field.bitmask() >> field.pos; | 366 | soc_word_t max = field.bitmask() >> field.pos; |
367 | std::set< std::string > names; | 367 | std::set< std::string > names; |
368 | std::map< soc_word_t, std::string > map; | 368 | std::map< soc_word_t, std::string > map; |
@@ -373,12 +373,12 @@ void check_field(const std::string& _path, const field_t& field, error_context_t | |||
373 | std::string path_ = path + "." + n; | 373 | std::string path_ = path + "." + n; |
374 | check_name(path_, n, ctx); | 374 | check_name(path_, n, ctx); |
375 | if(v > max) | 375 | if(v > max) |
376 | ctx.add(error_t(error_t::FATAL, path_, "value does not fit into the field")); | 376 | ctx.add(err_t(err_t::FATAL, path_, "value does not fit into the field")); |
377 | if(names.find(n) != names.end()) | 377 | if(names.find(n) != names.end()) |
378 | ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in enums")); | 378 | ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in enums")); |
379 | names.insert(n); | 379 | names.insert(n); |
380 | if(map.find(v) != map.end()) | 380 | if(map.find(v) != map.end()) |
381 | ctx.add(error_t(error_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); | 381 | ctx.add(err_t(err_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); |
382 | map[v] = n; | 382 | map[v] = n; |
383 | } | 383 | } |
384 | } | 384 | } |
@@ -387,7 +387,7 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e | |||
387 | { | 387 | { |
388 | std::string path = _path + ".<register>"; | 388 | std::string path = _path + ".<register>"; |
389 | if(reg.width != 8 && reg.width != 16 && reg.width != 32) | 389 | if(reg.width != 8 && reg.width != 16 && reg.width != 32) |
390 | ctx.add(error_t(error_t::WARNING, path, "width is not 8, 16 or 32")); | 390 | ctx.add(err_t(err_t::WARNING, path, "width is not 8, 16 or 32")); |
391 | for(size_t i = 0; i < reg.field.size(); i++) | 391 | for(size_t i = 0; i < reg.field.size(); i++) |
392 | check_field(path, reg.field[i], ctx); | 392 | check_field(path, reg.field[i], ctx); |
393 | std::set< std::string > names; | 393 | std::set< std::string > names; |
@@ -396,16 +396,16 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e | |||
396 | { | 396 | { |
397 | std::string n = reg.field[i].name; | 397 | std::string n = reg.field[i].name; |
398 | if(names.find(n) != names.end()) | 398 | if(names.find(n) != names.end()) |
399 | ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in fields")); | 399 | ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in fields")); |
400 | if(reg.field[i].pos + reg.field[i].width > reg.width) | 400 | if(reg.field[i].pos + reg.field[i].width > reg.width) |
401 | ctx.add(error_t(error_t::FATAL, path, "field '" + n + "' does not fit into the register")); | 401 | ctx.add(err_t(err_t::FATAL, path, "field '" + n + "' does not fit into the register")); |
402 | names.insert(n); | 402 | names.insert(n); |
403 | if(bitmap & reg.field[i].bitmask()) | 403 | if(bitmap & reg.field[i].bitmask()) |
404 | { | 404 | { |
405 | /* find the duplicate to ease debugging */ | 405 | /* find the duplicate to ease debugging */ |
406 | for(size_t j = 0; j < i; j++) | 406 | for(size_t j = 0; j < i; j++) |
407 | if(reg.field[j].bitmask() & reg.field[i].bitmask()) | 407 | if(reg.field[j].bitmask() & reg.field[i].bitmask()) |
408 | ctx.add(error_t(error_t::FATAL, path, "overlap between fields '" + | 408 | ctx.add(err_t(err_t::FATAL, path, "overlap between fields '" + |
409 | reg.field[j].name + "' and '" + n + "'")); | 409 | reg.field[j].name + "' and '" + n + "'")); |
410 | } | 410 | } |
411 | bitmap |= reg.field[i].bitmask(); | 411 | bitmap |= reg.field[i].bitmask(); |
@@ -420,7 +420,7 @@ void check_node(const std::string& _path, const node_t& node, error_context_t& c | |||
420 | std::string path = _path + "." + node.name; | 420 | std::string path = _path + "." + node.name; |
421 | check_name(_path, node.name, ctx); | 421 | check_name(_path, node.name, ctx); |
422 | if(node.instance.empty()) | 422 | if(node.instance.empty()) |
423 | ctx.add(error_t(error_t::WARNING, path, "subnode with no instances")); | 423 | ctx.add(err_t(err_t::WARNING, path, "subnode with no instances")); |
424 | for(size_t j = 0; j < node.instance.size(); j++) | 424 | for(size_t j = 0; j < node.instance.size(); j++) |
425 | check_instance(path, node.instance[j], ctx); | 425 | check_instance(path, node.instance[j], ctx); |
426 | for(size_t i = 0; i < node.register_.size(); i++) | 426 | for(size_t i = 0; i < node.register_.size(); i++) |
@@ -440,7 +440,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, | |||
440 | { | 440 | { |
441 | std::string n = nodes[i].instance[j].name; | 441 | std::string n = nodes[i].instance[j].name; |
442 | if(names.find(n) != names.end()) | 442 | if(names.find(n) != names.end()) |
443 | ctx.add(error_t(error_t::FATAL, path, "duplicate instance name '" + | 443 | ctx.add(err_t(err_t::FATAL, path, "duplicate instance name '" + |
444 | n + "' in subnodes")); | 444 | n + "' in subnodes")); |
445 | names.insert(n); | 445 | names.insert(n); |
446 | } | 446 | } |
@@ -450,7 +450,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, | |||
450 | { | 450 | { |
451 | std::string n = nodes[i].name; | 451 | std::string n = nodes[i].name; |
452 | if(names.find(n) != names.end()) | 452 | if(names.find(n) != names.end()) |
453 | ctx.add(error_t(error_t::FATAL, path, "duplicate node name '" + n + | 453 | ctx.add(err_t(err_t::FATAL, path, "duplicate node name '" + n + |
454 | "' in subnodes")); | 454 | "' in subnodes")); |
455 | names.insert(n); | 455 | names.insert(n); |
456 | } | 456 | } |
@@ -832,4 +832,4 @@ int main(int argc, char **argv) | |||
832 | else | 832 | else |
833 | usage(); | 833 | usage(); |
834 | return 0; | 834 | return 0; |
835 | } \ No newline at end of file | 835 | } |