diff options
-rw-r--r-- | xsde/cxx/hybrid/elements.cxx | 18 | ||||
-rw-r--r-- | xsde/cxx/hybrid/elements.hxx | 7 | ||||
-rw-r--r-- | xsde/cxx/hybrid/parser-source.cxx | 6 | ||||
-rw-r--r-- | xsde/cxx/hybrid/serializer-header.cxx | 17 | ||||
-rw-r--r-- | xsde/cxx/hybrid/serializer-source.cxx | 28 |
5 files changed, 51 insertions, 25 deletions
diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index 679a63d..2c31646 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -435,6 +435,24 @@ namespace CXX : ename_custom (t); } + Boolean Context:: + recursive_base (SemanticGraph::Complex& c) + { + using namespace SemanticGraph; + + for (Complex* p (&c); p && p->inherits_p ();) + { + Type& t (p->inherits ().base ()); + + if (recursive (t)) + return true; + + p = dynamic_cast<Complex*> (&t); + } + + return false; + } + Void Context:: close_ns () { diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx index 9faeb8d..63d7995 100644 --- a/xsde/cxx/hybrid/elements.hxx +++ b/xsde/cxx/hybrid/elements.hxx @@ -540,18 +540,21 @@ namespace CXX return c.context ().get<Boolean> ("fixed"); } - Boolean + static Boolean recursive (SemanticGraph::Type& t) { return t.context ().count ("recursive"); } - Boolean + static Boolean polymorphic (SemanticGraph::Type& t) { return t.context ().count ("polymorphic"); } + static Boolean + recursive_base (SemanticGraph::Complex& c); + public: String istream (NarrowString const& is) const; diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx index bfeb129..c877e1d 100644 --- a/xsde/cxx/hybrid/parser-source.cxx +++ b/xsde/cxx/hybrid/parser-source.cxx @@ -1100,11 +1100,9 @@ namespace CXX << "{"; if (mixin && hb) - os << epimpl (c); //@@ fq-name - else - os << epskel (c); //@@ fq-name + os << epimpl (c.inherits ().base ()) << "::_reset ();"; - os << "::_reset ();" + os << epskel (c) << "::_reset ();" << endl; if (!rec) diff --git a/xsde/cxx/hybrid/serializer-header.cxx b/xsde/cxx/hybrid/serializer-header.cxx index db0578f..153da8d 100644 --- a/xsde/cxx/hybrid/serializer-header.cxx +++ b/xsde/cxx/hybrid/serializer-header.cxx @@ -494,15 +494,22 @@ namespace CXX os << "virtual void" << endl << "post ();" << endl; + } - // reset + // reset + // + if (reset && (rec || (mixin && recursive_base (c)))) + { + // If we are using mixin and this type has a base with _reset(), + // then we need to provide _reset() in the whole hierarchy to + // resolve an ambiguity. // - if (reset) - os << "virtual void" << endl - << "_reset ();" - << endl; + os << "virtual void" << endl + << "_reset ();" + << endl; } + if (tiein && hb) os << (tiein ? "public:" : "protected:") << endl << fq_name (c.inherits ().base (), "s:impl") << " base_impl_;" diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx index b035246..0aeaf89 100644 --- a/xsde/cxx/hybrid/serializer-source.cxx +++ b/xsde/cxx/hybrid/serializer-source.cxx @@ -1222,28 +1222,28 @@ namespace CXX } os << "}"; + } - // reset - // - if (reset) - { - os << "void " << name << "::" << endl - << "_reset ()" - << "{"; + // reset + // + if (reset && (rec || (mixin && recursive_base (c)))) + { + os << "void " << name << "::" << endl + << "_reset ()" + << "{"; - if (mixin && hb) - os << esimpl (c); - else - os << esskel (c); + if (mixin && hb) + os << esimpl (c.inherits ().base ()) << "::_reset ();"; - os << "::_reset ();"; + os << esskel (c) << "::_reset ();"; + if (rec) os << "for (; !this->" << state << ".empty (); " << "this->" << state << ".pop ()) ;"; // Space is for g++-4.3. - os << "}"; - } + os << "}"; } + } private: |