aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/tree-forward.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-03-16 08:16:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-03-16 08:16:43 +0200
commitbce9d5a76072ec697ef69021818aa68709036da5 (patch)
tree9ec56eff60abacaea121d1602a1e48388ca34216 /xsde/cxx/hybrid/tree-forward.cxx
parentbe19f3aae4e16b4dc9c980cb9b53e807616662ef (diff)
Add support for type customization in C++/Hybrid
examples/cxx/hybrid/custom/wildcard/: new example
Diffstat (limited to 'xsde/cxx/hybrid/tree-forward.cxx')
-rw-r--r--xsde/cxx/hybrid/tree-forward.cxx60
1 files changed, 57 insertions, 3 deletions
diff --git a/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx
index 32f1180..451f129 100644
--- a/xsde/cxx/hybrid/tree-forward.cxx
+++ b/xsde/cxx/hybrid/tree-forward.cxx
@@ -24,7 +24,25 @@ namespace CXX
virtual Void
traverse (Type& l)
{
- os << "class " << ename (l) << ";";
+ SemanticGraph::Context& ctx (l.context ());
+
+ // Forward-declare the base.
+ //
+ if (ctx.count ("name-base"))
+ {
+ if (String base = ctx.get<String> ("name-base"))
+ os << "class " << base << ";";
+ }
+
+ // Typedef or forward-declare the type.
+ //
+ if (ctx.count ("name-typedef"))
+ {
+ os << "typedef " << ctx.get<String> ("name-typedef") << " " <<
+ ename (l) << ";";
+ }
+ else
+ os << "class " << ename (l) << ";";
}
};
@@ -38,7 +56,25 @@ namespace CXX
virtual Void
traverse (Type& u)
{
- os << "class " << ename (u) << ";";
+ SemanticGraph::Context& ctx (u.context ());
+
+ // Forward-declare the base.
+ //
+ if (ctx.count ("name-base"))
+ {
+ if (String base = ctx.get<String> ("name-base"))
+ os << "class " << base << ";";
+ }
+
+ // Typedef or forward-declare the type.
+ //
+ if (ctx.count ("name-typedef"))
+ {
+ os << "typedef " << ctx.get<String> ("name-typedef") << " " <<
+ ename (u) << ";";
+ }
+ else
+ os << "class " << ename (u) << ";";
}
};
@@ -52,7 +88,25 @@ namespace CXX
virtual Void
traverse (Type& c)
{
- os << "class " << ename (c) << ";";
+ SemanticGraph::Context& ctx (c.context ());
+
+ // Forward-declare the base.
+ //
+ if (ctx.count ("name-base"))
+ {
+ if (String base = ctx.get<String> ("name-base"))
+ os << "class " << base << ";";
+ }
+
+ // Typedef or forward-declare the type.
+ //
+ if (ctx.count ("name-typedef"))
+ {
+ os << "typedef " << ctx.get<String> ("name-typedef") << " " <<
+ ename (c) << ";";
+ }
+ else
+ os << "class " << ename (c) << ";";
}
};