From 4f9022f24c4591391637121c7274d9855b37bd93 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 May 2012 11:09:13 +0200 Subject: Add support for options file inclusion New include-path prefixes, c++: and cli:, are now recognized (e.g., include ;). 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. --- cli/header.cxx | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'cli/header.cxx') diff --git a/cli/header.cxx b/cli/header.cxx index 3a47c4d..fb714ed 100644 --- a/cli/header.cxx +++ b/cli/header.cxx @@ -185,14 +185,38 @@ namespace // // - struct includes: traversal::cxx_includes, context + struct includes: traversal::cxx_includes, + traversal::cli_includes, + context { includes (context& c) : context (c) {} virtual void traverse (semantics::cxx_includes& i) { - os << "#include " << i.file () << endl + generate (i.kind (), i.file ().string ()); + } + + virtual void + traverse (semantics::cli_includes& i) + { + generate (i.kind (), + i.file ().base ().string () + options.hxx_suffix ()); + } + + void + generate (semantics::includes::kind_type k, string const& f) + { + char b, e; + if (k == semantics::includes::quote) + b = e = '"'; + else + { + b = '<'; + e = '>'; + } + + os << "#include " << b << f << e << endl << endl; } }; -- cgit v1.1