diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-10 11:09:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-10 11:09:13 +0200 |
commit | 4f9022f24c4591391637121c7274d9855b37bd93 (patch) | |
tree | 55d15cf4c092e28c588c31daf118cac7b4b5910a /cli/generator.cxx | |
parent | 963eaef32dc1b35bd065de8b62d4c73a932208b2 (diff) |
Add support for options file inclusion
New include-path prefixes, c++: and cli:, are now recognized (e.g.,
include <cli:foo>;). Without a prefix, the include declarations is
considered to be c++-include unless the path ends with the .cli
extension.
The cli-included files are loaded and parsed. Currently, only inclusion
relative to the current file is supported. Duplicate inclusions are
detected and ignored based on the absolute filesystem path.
If a file cli-includes another file, then the runtime code is assumed
to come from the included file and is not generated.
Diffstat (limited to 'cli/generator.cxx')
-rw-r--r-- | cli/generator.cxx | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/cli/generator.cxx b/cli/generator.cxx index 842fc54..8b4b244 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -158,6 +158,19 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) process_names (ctx); } + // Check if we need to generate the runtime code. If we include + // another options file, then we assume the runtime is generated + // there. + // + bool runtime (true); + for (semantics::cli_unit::includes_iterator i (unit.includes_begin ()); + runtime && i != unit.includes_end (); + ++i) + { + if (i->is_a<semantics::cli_includes> ()) + runtime = false; + } + // // ofstream hxx (hxx_path.string ().c_str ()); @@ -237,7 +250,9 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) << "#define " << guard << endl << endl; - generate_runtime_header (ctx); + if (runtime) + generate_runtime_header (ctx); + generate_header (ctx); if (inl) @@ -256,7 +271,10 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) { cxx_filter filt (ixx); context ctx (ixx, unit, ops); - generate_runtime_inline (ctx); + + if (runtime) + generate_runtime_inline (ctx); + generate_inline (ctx); } @@ -270,10 +288,13 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) (br ? '>' : '"') << endl << endl; - if (!inl) - generate_runtime_inline (ctx); + if (runtime) + { + if (!inl) + generate_runtime_inline (ctx); - generate_runtime_source (ctx); + generate_runtime_source (ctx); + } if (!inl) generate_inline (ctx); |