aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/insertion-source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-04-02 12:22:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-04-02 12:22:38 +0200
commit8336dd4c16d4885989a6d8f0c83a4b401f5cb63b (patch)
tree26ca613e7f3a3fe9fb75bf5bb3b65503661e0ebf /xsde/cxx/hybrid/insertion-source.cxx
parente4c22d3686da0e973e21eae0561c1169c0eeff36 (diff)
Add support for attributes with default and fixed values.
tests/cxx/hybrid/default: new test tests/cxx/hybrid/binary: update to test default and fixed values
Diffstat (limited to 'xsde/cxx/hybrid/insertion-source.cxx')
-rw-r--r--xsde/cxx/hybrid/insertion-source.cxx38
1 files changed, 30 insertions, 8 deletions
diff --git a/xsde/cxx/hybrid/insertion-source.cxx b/xsde/cxx/hybrid/insertion-source.cxx
index b0b89c9..7dc6fcb 100644
--- a/xsde/cxx/hybrid/insertion-source.cxx
+++ b/xsde/cxx/hybrid/insertion-source.cxx
@@ -100,19 +100,41 @@ namespace CXX
virtual Void
traverse (SemanticGraph::Attribute& a)
{
+ // Don't waste space on fixed attributes.
+ //
+ if (a.fixed ())
+ return;
+
if (a.optional ())
{
- String const& present (epresent (a));
+ if (!a.default_ ())
+ {
+ String const& present (epresent (a));
- if (exceptions)
- os << "s << x." << present << " ();";
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+ }
else
- os << "if (!(s << x." << present << " ()))" << endl
- << "return false;";
+ {
+ String const& default_ (edefault (a));
- os << endl
- << "if (x." << present << " ())"
- << "{";
+ if (exceptions)
+ os << "s << x." << default_ << " ();";
+ else
+ os << "if (!(s << x." << default_ << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (!x." << default_ << " ())"
+ << "{";
+ }
}
String const& name (ename (a));