summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-27 18:19:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-27 18:19:49 +0200
commitb5e7ac58b0e44a7903808d622f5af97c07171281 (patch)
tree7b68154dfce0b000ec3c03e1fd56d75a7e9c9d78 /cli
parentbf3b6fe73a414edb5fbb1da29baa7e882dd982a8 (diff)
Generate accessor implementations
Diffstat (limited to 'cli')
-rw-r--r--cli/inline.cxx54
1 files changed, 53 insertions, 1 deletions
diff --git a/cli/inline.cxx b/cli/inline.cxx
index e376d76..86c0ddb 100644
--- a/cli/inline.cxx
+++ b/cli/inline.cxx
@@ -7,7 +7,53 @@
namespace
{
+ //
+ //
+ struct option: traversal::option, context
+ {
+ option (context& c) : context (c) {}
+ virtual void
+ traverse (type& o)
+ {
+ string name (ename (o));
+ string type (o.type ().name ());
+ string scope (escape (o.scope ().name ()));
+
+ os << inl << type << " const& " << scope << "::" << endl
+ << name << " () const"
+ << "{"
+ << "return " << emember (o) << ";"
+ << "}";
+ }
+ };
+
+ //
+ //
+ struct class_: traversal::class_, context
+ {
+ class_ (context& c)
+ : context (c), option_ (c)
+ {
+ names_option_ >> option_;
+ }
+
+ virtual void
+ traverse (type& c)
+ {
+ string name (escape (c.name ()));
+
+ os << "// " << name << endl
+ << "//" << endl
+ << endl;
+
+ names (c, names_option_);
+ }
+
+ private:
+ option option_;
+ traversal::names names_option_;
+ };
}
void
@@ -16,9 +62,15 @@ generate_inline (context& ctx)
traversal::cli_unit unit;
traversal::names unit_names;
namespace_ ns (ctx);
+ class_ cl (ctx);
+
+ unit >> unit_names >> ns;
+ unit_names >> cl;
+
traversal::names ns_names;
- unit >> unit_names >> ns >> ns_names >> ns;
+ ns >> ns_names >> ns;
+ ns_names >> cl;
unit.dispatch (ctx.unit);
}