summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-11-22 16:58:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-11-22 16:58:56 +0200
commita376ccf37122f0768fce8e3c5a16561e01ee2351 (patch)
tree31878d0b10bf15989f2b08976a5de0fabebcac42 /cli
parent0e56fe29a9afeee00e02e722496678df89d37d50 (diff)
Implement option value modifiers generation
Diffstat (limited to 'cli')
-rw-r--r--cli/context.cxx2
-rw-r--r--cli/context.hxx1
-rw-r--r--cli/header.cxx7
-rw-r--r--cli/inline.cxx9
-rw-r--r--cli/options.cli5
-rw-r--r--cli/options.cxx9
-rw-r--r--cli/options.hxx4
-rw-r--r--cli/options.ixx60
8 files changed, 68 insertions, 29 deletions
diff --git a/cli/context.cxx b/cli/context.cxx
index 05e15cc..76a97a4 100644
--- a/cli/context.cxx
+++ b/cli/context.cxx
@@ -99,6 +99,7 @@ context (ostream& os_,
os (os_),
unit (unit_),
options (ops),
+ modifier (options.generate_modifier ()),
usage (!options.suppress_usage ()),
inl (data_->inl_),
opt_prefix (options.option_prefix ()),
@@ -119,6 +120,7 @@ context (context& c)
os (c.os),
unit (c.unit),
options (c.options),
+ modifier (c.modifier),
usage (c.usage),
inl (c.inl),
opt_prefix (c.opt_prefix),
diff --git a/cli/context.hxx b/cli/context.hxx
index 30539af..2b0c128 100644
--- a/cli/context.hxx
+++ b/cli/context.hxx
@@ -38,6 +38,7 @@ public:
semantics::cli_unit& unit;
options_type const& options;
+ bool modifier;
bool usage;
string const& inl;
diff --git a/cli/header.cxx b/cli/header.cxx
index b06c2bf..2749b6d 100644
--- a/cli/header.cxx
+++ b/cli/header.cxx
@@ -22,6 +22,11 @@ namespace
os << "const " << type << "&" << endl
<< name << " () const;"
<< endl;
+
+ if (modifier)
+ os << "void" << endl
+ << name << " (const " << type << "&);"
+ << endl;
}
};
@@ -98,7 +103,7 @@ namespace
//
//
- os << "// Option accessors." << endl
+ os << "// Option accessors" << (modifier ? " and modifiers." : ".") << endl
<< "//" << endl
<< endl;
diff --git a/cli/inline.cxx b/cli/inline.cxx
index 23a87ff..a4db1da 100644
--- a/cli/inline.cxx
+++ b/cli/inline.cxx
@@ -23,8 +23,15 @@ namespace
os << inl << "const " << type << "& " << scope << "::" << endl
<< name << " () const"
<< "{"
- << "return " << emember (o) << ";"
+ << "return this->" << emember (o) << ";"
<< "}";
+
+ if (modifier)
+ os << inl << "void " << scope << "::" << endl
+ << name << "(const " << type << "& x)"
+ << "{"
+ << "this->" << emember (o) << " = x;"
+ << "}";
}
};
diff --git a/cli/options.cli b/cli/options.cli
index 085a26a..b9df64f 100644
--- a/cli/options.cli
+++ b/cli/options.cli
@@ -23,6 +23,11 @@ class options
"Write the generated files to <dir> instead of the current directory."
};
+ bool --generate-modifier
+ {
+ "Generate option value modifiers in addition to accessors."
+ };
+
bool --suppress-inline
{
"Generate all functions non-inline. By default simple functions are
diff --git a/cli/options.cxx b/cli/options.cxx
index 38ed14d..78b3f5f 100644
--- a/cli/options.cxx
+++ b/cli/options.cxx
@@ -241,6 +241,7 @@ options (int argc,
: help_ (),
version_ (),
output_dir_ (),
+ generate_modifier_ (),
suppress_inline_ (),
suppress_usage_ (),
long_usage_ (),
@@ -278,6 +279,7 @@ options (int start,
: help_ (),
version_ (),
output_dir_ (),
+ generate_modifier_ (),
suppress_inline_ (),
suppress_usage_ (),
long_usage_ (),
@@ -315,6 +317,7 @@ options (int argc,
: help_ (),
version_ (),
output_dir_ (),
+ generate_modifier_ (),
suppress_inline_ (),
suppress_usage_ (),
long_usage_ (),
@@ -353,6 +356,7 @@ options (int start,
: help_ (),
version_ (),
output_dir_ (),
+ generate_modifier_ (),
suppress_inline_ (),
suppress_usage_ (),
long_usage_ (),
@@ -391,6 +395,9 @@ print_usage (::std::ostream& os)
os << "--output-dir|-o <dir> Write the generated files to <dir> instead of the" << ::std::endl
<< " current directory." << ::std::endl;
+ os << "--generate-modifier Generate option value modifiers in addition to" << ::std::endl
+ << " accessors." << ::std::endl;
+
os << "--suppress-inline Generate all functions non-inline." << ::std::endl;
os << "--suppress-usage Suppress the generation of the usage printing code." << ::std::endl;
@@ -477,6 +484,8 @@ struct _cli_options_map_init
&::cli::thunk< options, std::string, &options::output_dir_ >;
_cli_options_map_["-o"] =
&::cli::thunk< options, std::string, &options::output_dir_ >;
+ _cli_options_map_["--generate-modifier"] =
+ &::cli::thunk< options, bool, &options::generate_modifier_ >;
_cli_options_map_["--suppress-inline"] =
&::cli::thunk< options, bool, &options::suppress_inline_ >;
_cli_options_map_["--suppress-usage"] =
diff --git a/cli/options.hxx b/cli/options.hxx
index fdf7627..d5712d1 100644
--- a/cli/options.hxx
+++ b/cli/options.hxx
@@ -184,6 +184,9 @@ class options
output_dir () const;
const bool&
+ generate_modifier () const;
+
+ const bool&
suppress_inline () const;
const bool&
@@ -272,6 +275,7 @@ class options
bool help_;
bool version_;
std::string output_dir_;
+ bool generate_modifier_;
bool suppress_inline_;
bool suppress_usage_;
bool long_usage_;
diff --git a/cli/options.ixx b/cli/options.ixx
index 1745d4a..60afbda 100644
--- a/cli/options.ixx
+++ b/cli/options.ixx
@@ -91,162 +91,168 @@ namespace cli
inline const bool& options::
help () const
{
- return help_;
+ return this->help_;
}
inline const bool& options::
version () const
{
- return version_;
+ return this->version_;
}
inline const std::string& options::
output_dir () const
{
- return output_dir_;
+ return this->output_dir_;
+}
+
+inline const bool& options::
+generate_modifier () const
+{
+ return this->generate_modifier_;
}
inline const bool& options::
suppress_inline () const
{
- return suppress_inline_;
+ return this->suppress_inline_;
}
inline const bool& options::
suppress_usage () const
{
- return suppress_usage_;
+ return this->suppress_usage_;
}
inline const bool& options::
long_usage () const
{
- return long_usage_;
+ return this->long_usage_;
}
inline const std::size_t& options::
option_length () const
{
- return option_length_;
+ return this->option_length_;
}
inline const bool& options::
generate_cxx () const
{
- return generate_cxx_;
+ return this->generate_cxx_;
}
inline const bool& options::
generate_man () const
{
- return generate_man_;
+ return this->generate_man_;
}
inline const bool& options::
generate_html () const
{
- return generate_html_;
+ return this->generate_html_;
}
inline const std::string& options::
man_prologue () const
{
- return man_prologue_;
+ return this->man_prologue_;
}
inline const std::string& options::
man_epilogue () const
{
- return man_epilogue_;
+ return this->man_epilogue_;
}
inline const std::string& options::
html_prologue () const
{
- return html_prologue_;
+ return this->html_prologue_;
}
inline const std::string& options::
html_epilogue () const
{
- return html_epilogue_;
+ return this->html_epilogue_;
}
inline const std::string& options::
class_ () const
{
- return class__;
+ return this->class__;
}
inline const bool& options::
stdout () const
{
- return stdout_;
+ return this->stdout_;
}
inline const std::string& options::
hxx_suffix () const
{
- return hxx_suffix_;
+ return this->hxx_suffix_;
}
inline const std::string& options::
ixx_suffix () const
{
- return ixx_suffix_;
+ return this->ixx_suffix_;
}
inline const std::string& options::
cxx_suffix () const
{
- return cxx_suffix_;
+ return this->cxx_suffix_;
}
inline const std::string& options::
man_suffix () const
{
- return man_suffix_;
+ return this->man_suffix_;
}
inline const std::string& options::
html_suffix () const
{
- return html_suffix_;
+ return this->html_suffix_;
}
inline const std::string& options::
option_prefix () const
{
- return option_prefix_;
+ return this->option_prefix_;
}
inline const std::string& options::
option_separator () const
{
- return option_separator_;
+ return this->option_separator_;
}
inline const bool& options::
include_with_brackets () const
{
- return include_with_brackets_;
+ return this->include_with_brackets_;
}
inline const std::string& options::
include_prefix () const
{
- return include_prefix_;
+ return this->include_prefix_;
}
inline const std::string& options::
guard_prefix () const
{
- return guard_prefix_;
+ return this->guard_prefix_;
}
inline const std::map<std::string, std::string>& options::
reserved_name () const
{
- return reserved_name_;
+ return this->reserved_name_;
}