aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/parser/parser-inline.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-25 14:54:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-25 14:54:24 +0200
commitc5e3c6ee3e291a5dfc6670160677f4962d526dc4 (patch)
tree2b3440a35d7174719d096ddb868ec4529a94af43 /xsde/cxx/parser/parser-inline.cxx
parentb7c3f32ea4e68a0865761f65d68a011ab9606363 (diff)
Add the {parser,serializer}_maps functions to set polymorphic maps
Use that in the generated aggregate classes in C++/Hybrid instead of the individual setters since their names are unknown for included and imported schemas.
Diffstat (limited to 'xsde/cxx/parser/parser-inline.cxx')
-rw-r--r--xsde/cxx/parser/parser-inline.cxx79
1 files changed, 71 insertions, 8 deletions
diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx
index f0d9e7b..2d02b3e 100644
--- a/xsde/cxx/parser/parser-inline.cxx
+++ b/xsde/cxx/parser/parser-inline.cxx
@@ -376,16 +376,22 @@ namespace CXX
//
struct ParticleMemberSet: Traversal::Element, Context
{
- ParticleMemberSet (Context& c)
- : Context (c)
+ ParticleMemberSet (Context& c, Boolean poly)
+ : Context (c), poly_ (poly)
{
}
virtual Void
traverse (SemanticGraph::Element& e)
{
- os << "this->" << emember (e) << " = &" << ename (e) << ";";
+ if (poly_)
+ os << "this->" << emember_map (e) << " = &" << ename (e) << ";";
+ else
+ os << "this->" << emember (e) << " = &" << ename (e) << ";";
}
+
+ private:
+ Boolean poly_;
};
struct AttributeMemberSet: Traversal::Attribute, Context
@@ -406,8 +412,8 @@ namespace CXX
Traversal::List,
Context
{
- BaseMemberSet (Context& c)
- : Context (c)
+ BaseMemberSet (Context& c, Boolean poly)
+ : Context (c), poly_ (poly)
{
inherits_ >> *this;
}
@@ -427,6 +433,9 @@ namespace CXX
virtual Void
traverse (SemanticGraph::List& l)
{
+ if (poly_)
+ return;
+
String const& name (ename (l));
String item (unclash (name, "item"));
@@ -435,6 +444,7 @@ namespace CXX
private:
Traversal::Inherits inherits_;
+ Boolean poly_;
};
//
@@ -533,9 +543,11 @@ namespace CXX
: Context (c),
particle_accessor_ (c),
attribute_accessor_ (c),
- base_set_ (c),
- particle_set_ (c),
+ base_set_ (c, false),
+ particle_set_ (c, false),
attribute_set_ (c),
+ base_set_poly_ (c, true),
+ particle_set_poly_ (c, true),
particle_ (c)
{
// Accessor.
@@ -559,6 +571,16 @@ namespace CXX
contains_particle_set_ >> particle_set_;
names_attribute_set_ >> attribute_set_;
+
+ // Member set polymorphic.
+ //
+ inherits_base_set_poly_ >> base_set_poly_;
+ base_set_poly_ >> contains_compositor_set_poly_;
+
+ contains_compositor_set_poly_ >> compositor_set_poly_;
+ compositor_set_poly_ >> contains_particle_set_poly_;
+ contains_particle_set_poly_ >> compositor_set_poly_;
+ contains_particle_set_poly_ >> particle_set_poly_;
}
virtual Void
@@ -611,7 +633,7 @@ namespace CXX
<< "parsers (";
{
- ParserParamDecl decl (*this, true);
+ ParserParamDecl decl (*this, true, false);
decl.traverse (c);
}
@@ -627,6 +649,37 @@ namespace CXX
contains_compositor (c, contains_compositor_set_);
os << "}";
+
+ // parser_maps ()
+ //
+ if (poly_code && he)
+ {
+ Boolean r (false);
+ ParserParamTest test (*this, r, true);
+ test.traverse (c);
+
+ // Have potentially polymorphic elements.
+ //
+ if (r)
+ {
+ os << inl
+ << "void " << name << "::" << endl
+ << "parser_maps (";
+
+ {
+ ParserParamDecl decl (*this, true, true);
+ decl.traverse (c);
+ }
+
+ os << ")"
+ << "{";
+
+ inherits (c, inherits_base_set_poly_);
+ contains_compositor (c, contains_compositor_set_poly_);
+
+ os << "}";
+ }
+ }
}
String fq_base;
@@ -832,6 +885,16 @@ namespace CXX
//
//
+ BaseMemberSet base_set_poly_;
+ Traversal::Inherits inherits_base_set_poly_;
+
+ Traversal::Compositor compositor_set_poly_;
+ ParticleMemberSet particle_set_poly_;
+ Traversal::ContainsCompositor contains_compositor_set_poly_;
+ Traversal::ContainsParticle contains_particle_set_poly_;
+
+ //
+ //
Particle particle_;
};
}