summaryrefslogtreecommitdiff
path: root/cli/cli/inline.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cli/inline.cxx')
-rw-r--r--cli/cli/inline.cxx108
1 files changed, 108 insertions, 0 deletions
diff --git a/cli/cli/inline.cxx b/cli/cli/inline.cxx
new file mode 100644
index 0000000..05b83db
--- /dev/null
+++ b/cli/cli/inline.cxx
@@ -0,0 +1,108 @@
+// file : cli/inline.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// license : MIT; see accompanying LICENSE file
+
+#include <cli/inline.hxx>
+
+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 << "const " << type << "& " << scope << "::" << endl
+ << name << " () const"
+ << "{"
+ << "return this->" << emember (o) << ";"
+ << "}";
+
+ if (gen_modifier)
+ {
+ os << inl << type << "& " << scope << "::" << endl
+ << name << " ()"
+ << "{"
+ << "return this->" << emember (o) << ";"
+ << "}";
+
+ os << inl << "void " << scope << "::" << endl
+ << name << "(const " << type << "& x)"
+ << "{"
+ << "this->" << emember (o) << " = x;"
+ << "}";
+ }
+
+ if (gen_specifier && type != "bool")
+ {
+ string spec (especifier (o));
+
+ os << inl << "bool " << scope << "::" << endl
+ << spec << " () const"
+ << "{"
+ << "return this->" << especifier_member (o) << ";"
+ << "}";
+
+ if (gen_modifier)
+ os << inl << "void " << scope << "::" << endl
+ << spec << "(bool x)"
+ << "{"
+ << "this->" << especifier_member (o) << " = x;"
+ << "}";
+ }
+ }
+ };
+
+ //
+ //
+ 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
+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;
+
+ ns >> ns_names >> ns;
+ ns_names >> cl;
+
+ unit.dispatch (ctx.unit);
+}