From beab8baab8a7f727f5ba65ecbd7e11decea18112 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 4 Oct 2009 09:00:19 +0200 Subject: Add --suppress-inline option --- cli/context.cxx | 9 ++++----- cli/context.hxx | 6 ++++-- cli/generator.cxx | 10 +++++----- cli/options.cli | 1 + cli/options.cxx | 35 ++++++++++------------------------- cli/options.hxx | 6 ++++++ cli/options.ixx | 31 +++++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 cli/options.ixx (limited to 'cli') diff --git a/cli/context.cxx b/cli/context.cxx index bc7ff0f..1af10e8 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -10,17 +10,15 @@ using namespace std; context:: -context (std::ostream& os_, - semantics::cli_unit& unit_) +context (ostream& os_, semantics::cli_unit& unit_, options_type const& ops) : data_ (new (shared) data), os (os_), unit (unit_), + options (ops), inl (data_->inl_), reserved_name_map (data_->reserved_name_map_) { - //@@ --generate-inline - // - if (false) + if (!options.suppress_inline ()) inl = "inline "; } @@ -29,6 +27,7 @@ context (context& c) : data_ (c.data_), os (c.os), unit (c.unit), + options (c.options), inl (c.inl), reserved_name_map (c.reserved_name_map) { diff --git a/cli/context.hxx b/cli/context.hxx index ae490c9..8063f59 100644 --- a/cli/context.hxx +++ b/cli/context.hxx @@ -13,6 +13,7 @@ #include +#include "options.hxx" #include "semantics.hxx" #include "traversal.hxx" @@ -23,6 +24,7 @@ class context public: typedef std::size_t size_t; typedef std::string string; + typedef ::options options_type; private: struct data; @@ -31,6 +33,7 @@ private: public: std::ostream& os; semantics::cli_unit& unit; + options_type const& options; string& inl; @@ -65,8 +68,7 @@ public: } public: - context (std::ostream&, - semantics::cli_unit&); + context (std::ostream&, semantics::cli_unit&, options_type const&); context (context&); diff --git a/cli/generator.cxx b/cli/generator.cxx index 0142201..6c766e4 100644 --- a/cli/generator.cxx +++ b/cli/generator.cxx @@ -75,7 +75,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) { try { - bool inl (false); + bool inl (!ops.suppress_inline ()); string hxx_suffix (".hxx"); string ixx_suffix (".ixx"); @@ -104,7 +104,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) // Process names. // { - context ctx (cerr, unit); + context ctx (cerr, unit, ops); process_names (ctx); } @@ -167,7 +167,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) // { cxx_filter filt (hxx); - context ctx (hxx, unit); + context ctx (hxx, unit, ops); string guard (make_guard (hxx_name, "", ctx)); @@ -193,7 +193,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) if (inl) { cxx_filter filt (ixx); - context ctx (ixx, unit); + context ctx (ixx, unit, ops); generate_inline (ctx); } @@ -201,7 +201,7 @@ generate (options const& ops, semantics::cli_unit& unit, path const& p) // { cxx_filter filt (cxx); - context ctx (cxx, unit); + context ctx (cxx, unit, ops); cxx << "#include \"" << hxx_name << "\"" << endl << endl; diff --git a/cli/options.cli b/cli/options.cli index e7024fb..3b78646 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -15,4 +15,5 @@ class options bool --help; bool --version; std::string --output-dir; + bool --suppress-inline; }; diff --git a/cli/options.cxx b/cli/options.cxx index 6aba013..c2ad4fd 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -4,27 +4,6 @@ #include "options.hxx" -// options -// - -bool const& options:: -help () const -{ - return help_; -} - -bool const& options:: -version () const -{ - return version_; -} - -std::string const& options:: -output_dir () const -{ - return output_dir_; -} - #include #include #include @@ -188,7 +167,8 @@ options (int argc, ::cli::unknown_mode arg) : help_ (), version_ (), - output_dir_ () + output_dir_ (), + suppress_inline_ () { _parse (1, argc, argv, opt, arg); } @@ -201,7 +181,8 @@ options (int start, ::cli::unknown_mode arg) : help_ (), version_ (), - output_dir_ () + output_dir_ (), + suppress_inline_ () { _parse (start, argc, argv, opt, arg); } @@ -214,7 +195,8 @@ options (int argc, ::cli::unknown_mode arg) : help_ (), version_ (), - output_dir_ () + output_dir_ (), + suppress_inline_ () { end = _parse (1, argc, argv, opt, arg); } @@ -228,7 +210,8 @@ options (int start, ::cli::unknown_mode arg) : help_ (), version_ (), - output_dir_ () + output_dir_ (), + suppress_inline_ () { end = _parse (start, argc, argv, opt, arg); } @@ -249,6 +232,8 @@ struct _cli_options_map_init &::cli::thunk; _cli_options_map_["--output-dir"] = &::cli::thunk; + _cli_options_map_["--suppress-inline"] = + &::cli::thunk; } } _cli_options_map_init_; diff --git a/cli/options.hxx b/cli/options.hxx index 37ec251..cf92229 100644 --- a/cli/options.hxx +++ b/cli/options.hxx @@ -213,6 +213,9 @@ class options std::string const& output_dir () const; + bool const& + suppress_inline () const; + private: int _parse (int start, @@ -225,6 +228,9 @@ class options bool help_; bool version_; std::string output_dir_; + bool suppress_inline_; }; +#include "options.ixx" + #endif // OPTIONS_HXX diff --git a/cli/options.ixx b/cli/options.ixx new file mode 100644 index 0000000..ac93219 --- /dev/null +++ b/cli/options.ixx @@ -0,0 +1,31 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// options +// + +inline bool const& options:: +help () const +{ + return help_; +} + +inline bool const& options:: +version () const +{ + return version_; +} + +inline std::string const& options:: +output_dir () const +{ + return output_dir_; +} + +inline bool const& options:: +suppress_inline () const +{ + return suppress_inline_; +} + -- cgit v1.1