From b535f3bbfbe1835925515abb454232bc4fca1ce1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 23 Oct 2015 15:39:26 +0200 Subject: Handle abstract elements in more places --- xsd/cxx/tree/parser-source.cxx | 37 ++++++++++++++++++++++++------------- xsd/cxx/tree/tree-source.cxx | 15 ++++++++++++--- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/xsd/cxx/tree/parser-source.cxx b/xsd/cxx/tree/parser-source.cxx index cf4d6cc..9668d9d 100644 --- a/xsd/cxx/tree/parser-source.cxx +++ b/xsd/cxx/tree/parser-source.cxx @@ -28,8 +28,29 @@ namespace CXX if (!doc_root_p (e)) return; - String const& name (eparser (e)); SemanticGraph::Type& t (e.type ()); + + // Check if we need to handle xsi:type and substitution groups. + // If this element's type is anonymous then we don't need to do + // anything. + // + bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); + + // Check if this element is abstract. + // + bool abst; + { + SemanticGraph::Complex* tc; + abst = (tc = dynamic_cast (&t)) != 0 && + tc->abstract_p (); + } + + // Nothing to do if we are abstract and not polymorphic. + // + if (abst && !polymorphic) + return; + + String const& name (eparser (e)); String type (type_name (e)); String const& error_handler (error_handler_type); @@ -289,12 +310,6 @@ namespace CXX test.dispatch (t); } - // Check if we need to handle xsi:type and substitution groups. - // If this element's type is anonymous then we don't need to do - // anything. - // - bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); - // const DOMDocument& // os << auto_ptr << "< " << type << " >" << endl @@ -326,9 +341,7 @@ namespace CXX << strlit (e.name ()) << "," << endl << strlit (e.namespace_().name ()) << "," << endl; - SemanticGraph::Complex* tc; - if ((tc = dynamic_cast (&t)) != 0 && - tc->abstract_p ()) + if (abst) os << "0,"; else os << "&::xsd::cxx::tree::factory_impl< " << type << " >,"; @@ -426,9 +439,7 @@ namespace CXX << strlit (e.name ()) << "," << endl << strlit (e.namespace_().name ()) << "," << endl; - SemanticGraph::Complex* tc; - if ((tc = dynamic_cast (&t)) != 0 && - tc->abstract_p ()) + if (abst) os << "0,"; else os << "&::xsd::cxx::tree::factory_impl< " << type << " >,"; diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx index 0a936bc..fbbd1b4 100644 --- a/xsd/cxx/tree/tree-source.cxx +++ b/xsd/cxx/tree/tree-source.cxx @@ -3532,10 +3532,19 @@ namespace CXX virtual void traverse (Type& e) { - if (element_type_ && doc_root_p (e)) + SemanticGraph::Type& t (e.type ()); + + // Check if this element is abstract. + // + bool abst; { - SemanticGraph::Type& t (e.type ()); + SemanticGraph::Complex* tc; + abst = (tc = dynamic_cast (&t)) != 0 && + tc->abstract_p (); + } + if (!abst && element_type_ && doc_root_p (e)) + { bool fund (false); { IsFundamentalType test (fund); @@ -3719,7 +3728,7 @@ namespace CXX } } - if (polymorphic && e.substitutes_p () && + if (!abst && polymorphic && e.substitutes_p () && !options.suppress_parsing ()) { String const& name (ename (e)); -- cgit v1.1