diff options
author | Chris Johns <chrisj@rtems.org> | 2014-08-04 09:50:56 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2014-08-04 09:50:56 +1000 |
commit | 81534626cc87c4c6b050f9166c0c75fd61d3d53e (patch) | |
tree | eb23b7bd32e291e9365fb78c3f2d4639b4485a20 | |
parent | 28884db485eba2b580d8da526e190f903b2e6174 (diff) |
rtems-tld: Add recursive parsing of headers and defines.
-rw-r--r-- | rld.h | 2 | ||||
-rw-r--r-- | rtems-tld.cpp | 43 | ||||
-rw-r--r-- | rtems.ini | 6 | ||||
-rw-r--r-- | test-trace.ini | 8 |
4 files changed, 51 insertions, 8 deletions
@@ -175,7 +175,7 @@ namespace rld { if (e.front () != e.back ()) throw rld::error ("invalid quoting", "string: " + s); - e = e.substr (1, e.length () - 1); + e = e.substr (1, e.length () - (1 + 1)); } } if (empty || !e.empty ()) diff --git a/rtems-tld.cpp b/rtems-tld.cpp index 4f17fba..ede5d10 100644 --- a/rtems-tld.cpp +++ b/rtems-tld.cpp @@ -121,6 +121,16 @@ namespace rld rld::config::config& config); /** + * Recursive parser for strings. + */ + void parse (rld::config::config& config, + const rld::config::section& section, + const std::string& sec_name, + const std::string& rec_name, + rld::strings& items, + int depth = 0); + + /** * Dump the wrapper. */ void dump (std::ostream& out) const; @@ -261,11 +271,12 @@ namespace rld */ const rld::config::section& section = config.get_section (name); + parse (config, section, "headers", "header", headers); + parse (config, section, "defines", "define", defines); + rld::strings sig_list; - rld::config::parse_items (section, "header", headers); - rld::config::parse_items (section, "define", defines); - rld::config::parse_items (section, "signature", sig_list); + rld::config::parse_items (section, "signatures", sig_list); for (rld::strings::const_iterator sli = sig_list.begin (); sli != sig_list.end (); @@ -283,6 +294,32 @@ namespace rld } void + wrapper::parse (rld::config::config& config, + const rld::config::section& section, + const std::string& sec_name, + const std::string& rec_name, + rld::strings& items, + int depth) + { + if (depth > 32) + throw rld::error ("too deep", "parsing: " + sec_name + '/' + rec_name); + + rld::config::parse_items (section, rec_name, items); + + rld::strings sl; + + rld::config::parse_items (section, sec_name, sl); + + for (rld::strings::const_iterator sli = sl.begin (); + sli != sl.end (); + ++sli) + { + const rld::config::section& sec = config.get_section (*sli); + parse (config, sec, sec_name, rec_name, items, depth + 1); + } + } + + void wrapper::dump (std::ostream& out) const { out << " Wrapper: " << name << std::endl @@ -2,9 +2,9 @@ ; RTEMS API Trace Configurations ; [rtems-api] -header = rtems-api-headers -define = rtems-api-defines -signature = rtems-api-signatures +headers = rtems-api-headers +defines = rtems-api-defines +signatures = rtems-api-signatures [rtems-api-headers] header = "#include <rtems.h>" diff --git a/test-trace.ini b/test-trace.ini index 2901952..b4e2306 100644 --- a/test-trace.ini +++ b/test-trace.ini @@ -35,7 +35,13 @@ trace = test_trace_1, test_trace_2 trace = test_trace_3 header = '#include "test-trace.h"' define = "#define TEST_TRACE 1" -signature = test-signatures +signatures = test-signatures + +[test-headers] +header = '#include "test-trace.h"' + +[test-defines] +define = "#define TEST_TRACE 1" [test-signatures] test_trace_1 = void, int |