From cc5cdb07e40f30e614bd15d81a5091faf717f4f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Jul 2014 10:19:30 +0200 Subject: Add support for abstract complex types in C++/Tree --- xsd/cxx/tree/serialization-source.cxx | 5 ++++- xsd/cxx/tree/stream-extraction-source.cxx | 1 + xsd/cxx/tree/stream-insertion-source.cxx | 1 + xsd/cxx/tree/stream-source.cxx | 1 + xsd/cxx/tree/tree-header.cxx | 3 ++- xsd/cxx/tree/tree-source.cxx | 27 ++++++++++++++++++--------- 6 files changed, 27 insertions(+), 11 deletions(-) (limited to 'xsd/cxx/tree') diff --git a/xsd/cxx/tree/serialization-source.cxx b/xsd/cxx/tree/serialization-source.cxx index 559a3cf..8a94c74 100644 --- a/xsd/cxx/tree/serialization-source.cxx +++ b/xsd/cxx/tree/serialization-source.cxx @@ -956,7 +956,10 @@ namespace CXX // but substitutes, then it will be registered as part of the // substitution registration. // - if (polymorphic && polymorphic_p (c) && !anonymous_p (c)) + if (polymorphic && + polymorphic_p (c) && + !c.abstract_p () && + !anonymous_p (c)) { // Note that we are using the original type name. // diff --git a/xsd/cxx/tree/stream-extraction-source.cxx b/xsd/cxx/tree/stream-extraction-source.cxx index ceb56c1..7c1382e 100644 --- a/xsd/cxx/tree/stream-extraction-source.cxx +++ b/xsd/cxx/tree/stream-extraction-source.cxx @@ -673,6 +673,7 @@ namespace CXX // if (polymorphic && polymorphic_p (c) && + !c.abstract_p () && (!anonymous_p (c) || anonymous_substitutes_p (c))) { // Note that we are using the original type name. diff --git a/xsd/cxx/tree/stream-insertion-source.cxx b/xsd/cxx/tree/stream-insertion-source.cxx index 2c82cfd..f2e47a8 100644 --- a/xsd/cxx/tree/stream-insertion-source.cxx +++ b/xsd/cxx/tree/stream-insertion-source.cxx @@ -448,6 +448,7 @@ namespace CXX // if (polymorphic && polymorphic_p (c) && + !c.abstract_p () && (!anonymous_p (c) || anonymous_substitutes_p (c))) { // Note that we are using the original type name. diff --git a/xsd/cxx/tree/stream-source.cxx b/xsd/cxx/tree/stream-source.cxx index 935ad40..656f0ed 100644 --- a/xsd/cxx/tree/stream-source.cxx +++ b/xsd/cxx/tree/stream-source.cxx @@ -385,6 +385,7 @@ namespace CXX // if (polymorphic && polymorphic_p (c) && + !c.abstract_p () && (!anonymous_p (c) || anonymous_substitutes_p (c))) { // Note that we are using the original type name. diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx index f0c3560..320e0c6 100644 --- a/xsd/cxx/tree/tree-header.cxx +++ b/xsd/cxx/tree/tree-header.cxx @@ -3296,7 +3296,8 @@ namespace CXX os << "virtual " << name << "*" << endl << "_clone (" << flags_type << " f = 0," << endl - << container << "* c = 0) const;" + << container << "* c = 0) const" << + (c.abstract_p () ? " = 0" : "") << ";" << endl; // operator= diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx index 8a01c5a..5720dbd 100644 --- a/xsd/cxx/tree/tree-source.cxx +++ b/xsd/cxx/tree/tree-source.cxx @@ -729,8 +729,16 @@ namespace CXX << strlit (e.name ()) << "," << endl << (e.qualified_p () ? strlit (e.namespace_ ().name ()) - : L + String ("\"\"")) << "," << endl - << "&::xsd::cxx::tree::factory_impl< " << type << " >," << endl + : L + String ("\"\"")) << "," << endl; + + SemanticGraph::Complex* tc; + if ((tc = dynamic_cast (&t)) != 0 && + tc->abstract_p ()) + os << "0,"; + else + os << "&::xsd::cxx::tree::factory_impl< " << type << " >,"; + + os << endl << (e.global_p () ? "true" : "false") << ", " << (e.qualified_p () ? "true" : "false") << ", " << "i, n, f, this));" @@ -3309,12 +3317,13 @@ namespace CXX // _clone // - os << name << "* " << name << "::" << endl - << "_clone (" << flags_type << " f," << endl - << container << "* c) const" - << "{" - << "return new class " << name << " (*this, f, c);" - << "}"; + if (!c.abstract_p ()) + os << name << "* " << name << "::" << endl + << "_clone (" << flags_type << " f," << endl + << container << "* c) const" + << "{" + << "return new class " << name << " (*this, f, c);" + << "}"; // operator= // @@ -3364,7 +3373,7 @@ namespace CXX // Register with type factory map. // - if (polymorphic && polymorphic_p (c)) + if (polymorphic && polymorphic_p (c) && !c.abstract_p ()) { // Note that we are using the original type name. // -- cgit v1.1