From f15dcbcb90c92e0ce4c9ff575349b60713fe1f83 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 20 Sep 2009 07:04:17 +0200 Subject: Add definition unit to context --- cli/context.cxx | 5 ++++- cli/context.hxx | 12 ++++++------ cli/generator.cxx | 17 ++++++++++++++--- cli/makefile | 5 ++++- 4 files changed, 28 insertions(+), 11 deletions(-) (limited to 'cli') diff --git a/cli/context.cxx b/cli/context.cxx index 96eec1c..cd03386 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -10,9 +10,11 @@ using namespace std; context:: -context (std::ostream& os_) +context (std::ostream& os_, + semantics::cli_unit& unit_) : data_ (new (shared) data), os (os_), + unit (unit_), reserved_name_map (data_->reserved_name_map_) { } @@ -21,6 +23,7 @@ context:: context (context& c) : data_ (c.data_), os (c.os), + unit (c.unit), reserved_name_map (c.reserved_name_map) { } diff --git a/cli/context.hxx b/cli/context.hxx index c3caa73..4d88fe9 100644 --- a/cli/context.hxx +++ b/cli/context.hxx @@ -28,6 +28,7 @@ private: public: std::ostream& os; + semantics::cli_unit& unit; typedef std::map reserved_name_map_type; reserved_name_map_type& reserved_name_map; @@ -45,8 +46,10 @@ public: escape (string const&) const; public: - context (std::ostream& os_); - context (context& c); + context (std::ostream&, + semantics::cli_unit&); + + context (context&); private: context& @@ -57,10 +60,7 @@ private: // struct namespace_: traversal::namespace_, context { - namespace_ (context& c) - : context (c) - { - } + namespace_ (context& c) : context (c) {} virtual void pre (type&); diff --git a/cli/generator.cxx b/cli/generator.cxx index cf9de69..c23f382 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -13,6 +13,10 @@ #include #include +#include "header.hxx" +#include "source.hxx" +#include "inline.hxx" + #include "context.hxx" #include "generator.hxx" @@ -154,7 +158,7 @@ generate (semantics::cli_unit& unit, path const& p) // { cxx_filter filt (hxx); - context ctx (hxx); + context ctx (hxx, unit); string guard (make_guard (hxx_name, "", ctx)); @@ -162,6 +166,7 @@ generate (semantics::cli_unit& unit, path const& p) << "#define " << guard << endl << endl; + generate_header (ctx); if (inl) { @@ -177,17 +182,23 @@ generate (semantics::cli_unit& unit, path const& p) if (inl) { cxx_filter filt (ixx); - context ctx (ixx); + context ctx (ixx, unit); + generate_inline (ctx); } // CXX // { cxx_filter filt (cxx); - context ctx (cxx); + context ctx (cxx, unit); cxx << "#include \"" << hxx_name << "\"" << endl << endl; + + if (!inl) + generate_inline (ctx); + + generate_source (ctx); } auto_rm.cancel (); diff --git a/cli/makefile b/cli/makefile index 10899be..a6026a6 100644 --- a/cli/makefile +++ b/cli/makefile @@ -9,7 +9,10 @@ cxx_tun := cli.cxx lexer.cxx parser.cxx cxx_tun += \ context.cxx \ -generator.cxx +generator.cxx \ +header.cxx \ +inline.cxx \ +source.cxx cxx_tun += \ semantics/class.cxx \ -- cgit v1.1