summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/context.hxx14
-rw-r--r--cli/source.cxx3
2 files changed, 16 insertions, 1 deletions
diff --git a/cli/context.hxx b/cli/context.hxx
index 2b0c128..8f9b659 100644
--- a/cli/context.hxx
+++ b/cli/context.hxx
@@ -113,6 +113,20 @@ private:
operator= (context const&);
};
+// Checks if scope Y names any of X.
+//
+template <typename X, typename Y>
+bool
+has (Y& y)
+{
+ for (semantics::scope::names_iterator i (y.names_begin ()),
+ e (y.names_end ()); i != e; ++i)
+ if (i->named ().is_a<X> ())
+ return true;
+
+ return false;
+}
+
// Standard namespace traverser.
//
struct namespace_: traversal::namespace_, context
diff --git a/cli/source.cxx b/cli/source.cxx
index 1c0b890..61cc1c0 100644
--- a/cli/source.cxx
+++ b/cli/source.cxx
@@ -350,6 +350,7 @@ namespace
traverse (type& c)
{
string name (escape (c.name ()));
+ bool ho (has<semantics::option> (c));
os << "// " << name << endl
<< "//" << endl
@@ -447,7 +448,7 @@ namespace
if (usage)
{
os << "void " << name << "::" << endl
- << "print_usage (::std::ostream& os)"
+ << "print_usage (::std::ostream&" << (ho ? " os" : "") << ")"
<< "{";
// Calculate option length.