aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/tree-header.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/tree-header.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/tree-header.cxx')
-rw-r--r--xsde/cxx/hybrid/tree-header.cxx115
1 files changed, 85 insertions, 30 deletions
diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx
index 3003e4c..77a1c71 100644
--- a/xsde/cxx/hybrid/tree-header.cxx
+++ b/xsde/cxx/hybrid/tree-header.cxx
@@ -369,6 +369,7 @@ namespace CXX
Traversal::Fundamental::Token,
Traversal::Fundamental::Name,
Traversal::Fundamental::NameToken,
+ Traversal::Fundamental::NameTokens,
Traversal::Fundamental::NCName,
Traversal::Fundamental::Language,
@@ -376,6 +377,7 @@ namespace CXX
Traversal::Fundamental::Id,
Traversal::Fundamental::IdRef,
+ Traversal::Fundamental::IdRefs,
Traversal::Fundamental::AnyURI,
@@ -390,6 +392,7 @@ namespace CXX
Traversal::Fundamental::Time,
Traversal::Fundamental::Entity,
+ Traversal::Fundamental::Entities,
Context
{
@@ -636,6 +639,12 @@ namespace CXX
}
virtual Void
+ traverse (SemanticGraph::Fundamental::NameTokens&)
+ {
+ align_type ("size_t");
+ }
+
+ virtual Void
traverse (SemanticGraph::Fundamental::Name&)
{
align_type ("size_t"); // std::string
@@ -676,6 +685,12 @@ namespace CXX
align_type ("size_t"); // std::string
}
+ virtual Void
+ traverse (SemanticGraph::Fundamental::IdRefs&)
+ {
+ align_type ("size_t");
+ }
+
// URI.
//
virtual Void
@@ -749,6 +764,12 @@ namespace CXX
align_type ("size_t"); // std::string
}
+ virtual Void
+ traverse (SemanticGraph::Fundamental::Entities&)
+ {
+ align_type ("size_t");
+ }
+
private:
Void
align_type (Char const* t)
@@ -767,7 +788,17 @@ namespace CXX
private:
Traversal::Inherits inherits_;
- Traversal::Attribute attribute_;
+ struct Attribute: Traversal::Attribute
+ {
+ virtual Void
+ traverse (Type& a)
+ {
+ if (!a.fixed ())
+ Traversal::Attribute::traverse (a);
+ }
+ };
+
+ Attribute attribute_;
Traversal::Names attribute_names_;
Traversal::Element particle_;
@@ -787,13 +818,16 @@ namespace CXX
virtual Void
traverse (SemanticGraph::Attribute& a)
{
- SemanticGraph::Type& t (a.type ());
+ if (!a.fixed ())
+ {
+ SemanticGraph::Type& t (a.type ());
- var_.dispatch (t);
- os << " " << emember (a) << ";";
+ var_.dispatch (t);
+ os << " " << emember (a) << ";";
- if (a.optional () && fixed_length (t))
- os << "bool " << epresent_member (a) << ";";
+ if (a.optional () && !a.default_ () && fixed_length (t))
+ os << "bool " << epresent_member (a) << ";";
+ }
}
private:
@@ -1105,19 +1139,23 @@ namespace CXX
os << "// " << comment (a.name ()) << endl
<< "// " << endl;
+ Boolean def (a.default_ ());
+ Boolean fix (a.fixed ());
+
String const& name (ename (a));
SemanticGraph::Type& t (a.type ());
- if (a.optional ())
+
+ if (a.optional () && !fix)
{
- String const& present (epresent (a));
+ String const& name (def ? edefault (a) : epresent (a));
os << "bool" << endl
- << present << " () const;"
+ << name << " () const;"
<< endl;
os << "void" << endl
- << present << " (bool);"
+ << name << " (bool);"
<< endl;
}
@@ -1129,32 +1167,49 @@ namespace CXX
<< name << " () const;"
<< endl;
- // type&
- // name ()
+ // Do not generate modifiers for fixed attributes.
//
- ret_.dispatch (t);
- os << endl
- << name << " ();"
- << endl;
+ if (!fix)
+ {
+ // type&
+ // name ()
+ //
+ ret_.dispatch (t);
+ os << endl
+ << name << " ();"
+ << endl;
- // void
- // name (const type& | type*)
- //
- os << "void" << endl
- << name << " (";
- arg_.dispatch (t);
- os << ");"
- << endl;
+ // void
+ // name (const type& | type*)
+ //
+ os << "void" << endl
+ << name << " (";
+ arg_.dispatch (t);
+ os << ");"
+ << endl;
- // type*
- // detach ()
- //
- if (detach && !fixed_length (t))
+ // type*
+ // detach ()
+ //
+ if (detach && !fixed_length (t))
+ {
+ arg_.dispatch (t);
+ os << endl
+ << edetach (a) << " ();"
+ << endl;
+ }
+ }
+
+ if (def)
{
- arg_.dispatch (t);
+ // static const type&
+ // name_{default|fixed}_value ()
+ //
+ os << "static ";
+ ro_ret_.dispatch (t);
os << endl
- << edetach (a) << " ();"
+ << edefault_value (a) << " ();"
<< endl;
}
}