aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-08-05 12:49:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-08-05 12:49:12 +0200
commitf36d0a664debcd8697d5debca9d912512cac2480 (patch)
tree865d29baba0a9d7004d4b1e0d965c160d41737fc
parent674364d49216b6e7f3eaf9f0e21deabd6a26ec5a (diff)
Make _clone() for polymorphic custom type base pure virtual
-rw-r--r--xsd/cxx/tree/tree-header.cxx17
-rw-r--r--xsd/cxx/tree/tree-source.cxx6
2 files changed, 18 insertions, 5 deletions
diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx
index 320e0c6..f576645 100644
--- a/xsd/cxx/tree/tree-header.cxx
+++ b/xsd/cxx/tree/tree-header.cxx
@@ -2342,7 +2342,8 @@ namespace CXX
// If renamed name is empty then we do not need to generate
// anything for this type.
//
- if (renamed_type (c, name) && !name)
+ bool renamed (renamed_type (c, name));
+ if (renamed && !name)
return;
SemanticGraph::Context& ctx (c.context ());
@@ -3296,8 +3297,18 @@ namespace CXX
os << "virtual " << name << "*" << endl
<< "_clone (" << flags_type << " f = 0," << endl
- << container << "* c = 0) const" <<
- (c.abstract_p () ? " = 0" : "") << ";"
+ << container << "* c = 0) const";
+
+ // Make the _clone() function pure virtual if the type is
+ // abstract or we are generating a polymorphic base for a
+ // custom implementation (in which case the base must be
+ // inherited from and _clone() overridden).
+ //
+ if (c.abstract_p () ||
+ (renamed && polymorphic && polymorphic_p (c)))
+ os << " = 0";
+
+ os << ";"
<< endl;
// operator=
diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx
index 5720dbd..96a0286 100644
--- a/xsd/cxx/tree/tree-source.cxx
+++ b/xsd/cxx/tree/tree-source.cxx
@@ -2296,7 +2296,8 @@ namespace CXX
// If renamed name is empty then we do not need to generate
// anything for this type.
//
- if (renamed_type (c, name) && !name)
+ bool renamed (renamed_type (c, name));
+ if (renamed && !name)
return;
SemanticGraph::Context& ctx (c.context ());
@@ -3317,7 +3318,8 @@ namespace CXX
// _clone
//
- if (!c.abstract_p ())
+ if (!(c.abstract_p () ||
+ (renamed && polymorphic && polymorphic_p (c))))
os << name << "* " << name << "::" << endl
<< "_clone (" << flags_type << " f," << endl
<< container << "* c) const"