diff options
-rw-r--r-- | NEWS | 13 | ||||
-rw-r--r-- | xsde/cxx/hybrid/elements.cxx | 1 | ||||
-rw-r--r-- | xsde/cxx/hybrid/elements.hxx | 3 | ||||
-rw-r--r-- | xsde/cxx/hybrid/parser-aggregate-header.cxx | 36 | ||||
-rw-r--r-- | xsde/cxx/hybrid/serializer-aggregate-header.cxx | 36 |
5 files changed, 87 insertions, 2 deletions
@@ -8,8 +8,17 @@ Version 3.2.0 * New configuration parameter, XSDE_STL_ITERATOR, makes iterators provided by the mapping conform to the STL requirements. This - feature requires working <iterator> header and allows you to use - the standard algorithms such as find_if, etc. + feature requires working <iterator> header and allows you to use the + standard algorithms such as find_if, etc. + + * When the code is generated with the --generate-polymorphic or + --runtime-polymorphic option, the resulting parser and serializer + aggregate classes provide the static polymorphic() function which + returns true if the object model corresponding to the root element + or root type is polymorphic and false otherwise. This can be used + together with the XSDE_POLYMORPHIC macro to implement generic parsing + and serialization code that works with both polymorphic and non- + polymorphic object models. Version 3.1.0 diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index 2c31646..6db57ff 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -34,6 +34,7 @@ namespace CXX exceptions (!ops.value<CLI::no_exceptions> ()), stl (!ops.value<CLI::no_stl> ()), poly_code (ops.value<CLI::generate_polymorphic> ()), + poly_runtime (poly_code || ops.value<CLI::runtime_polymorphic> ()), reset (!ops.value<CLI::suppress_reset> ()), detach (ops.value<CLI::generate_detach> ()), mixin (ops.value<CLI::reuse_style_mixin> ()), diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx index 63d7995..5a94dda 100644 --- a/xsde/cxx/hybrid/elements.hxx +++ b/xsde/cxx/hybrid/elements.hxx @@ -42,6 +42,7 @@ namespace CXX exceptions (c.exceptions), stl (c.stl), poly_code (c.poly_code), + poly_runtime (c.poly_runtime), reset (c.reset), detach (c.detach), typeinfo (c.typeinfo), @@ -71,6 +72,7 @@ namespace CXX exceptions (c.exceptions), stl (c.stl), poly_code (c.poly_code), + poly_runtime (c.poly_runtime), reset (c.reset), detach (c.detach), typeinfo (c.typeinfo), @@ -580,6 +582,7 @@ namespace CXX Boolean exceptions; Boolean stl; Boolean poly_code; + Boolean poly_runtime; Boolean reset; Boolean detach; Boolean typeinfo; diff --git a/xsde/cxx/hybrid/parser-aggregate-header.cxx b/xsde/cxx/hybrid/parser-aggregate-header.cxx index ce9a786..370cf07 100644 --- a/xsde/cxx/hybrid/parser-aggregate-header.cxx +++ b/xsde/cxx/hybrid/parser-aggregate-header.cxx @@ -580,6 +580,7 @@ namespace CXX String root_parser (unclash (name, "root_parser")); String root_map; String error, reset; + String poly_name; String parser_map, parser_map_entries; InstanceSet set; @@ -606,6 +607,12 @@ namespace CXX set.insert (reset); } + if (poly_runtime) + { + poly_name = unclash (name, "polymorphic"); + set.insert (poly_name); + } + if (poly_code) { parser_map = unclash (name, "parser_map_"); @@ -712,6 +719,17 @@ namespace CXX os << "}"; } + // polymorphic () + // + if (poly_runtime) + { + os << "static bool" << endl + << poly_name << " ()" + << "{" + << "return " << (tid_map.size () > 0 ? "true" : "false") << ";" + << "}"; + } + os << "public:" << endl; for (TypeInstanceMap::Iterator i (map.begin ()), end (map.end ()); @@ -755,6 +773,7 @@ namespace CXX String root_name (unclash (name, "root_name")); String root_namespace (unclash (name, "root_namespace")); String error, reset; + String poly_name; String parser_map, parser_map_entries; InstanceSet set; @@ -784,6 +803,12 @@ namespace CXX set.insert (reset); } + if (poly_runtime) + { + poly_name = unclash (name, "polymorphic"); + set.insert (poly_name); + } + if (poly_code) { parser_map = unclash (name, "parser_map_"); @@ -902,6 +927,17 @@ namespace CXX os << "}"; } + // polymorphic () + // + if (poly_runtime) + { + os << "static bool" << endl + << poly_name << " ()" + << "{" + << "return " << (tid_map.size () > 0 ? "true" : "false") << ";" + << "}"; + } + os << "public:" << endl; for (TypeInstanceMap::Iterator i (map.begin ()), end (map.end ()); diff --git a/xsde/cxx/hybrid/serializer-aggregate-header.cxx b/xsde/cxx/hybrid/serializer-aggregate-header.cxx index 97eb60b..3e7708c 100644 --- a/xsde/cxx/hybrid/serializer-aggregate-header.cxx +++ b/xsde/cxx/hybrid/serializer-aggregate-header.cxx @@ -580,6 +580,7 @@ namespace CXX String root_serializer (unclash (name, "root_serializer")); String root_map; String error, reset; + String poly_name; String serializer_map, serializer_map_entries; InstanceSet set; @@ -606,6 +607,12 @@ namespace CXX set.insert (reset); } + if (poly_runtime) + { + poly_name = unclash (name, "polymorphic"); + set.insert (poly_name); + } + if (poly_code) { serializer_map = unclash (name, "serializer_map_"); @@ -717,6 +724,17 @@ namespace CXX os << "}"; } + // polymorphic () + // + if (poly_runtime) + { + os << "static bool" << endl + << poly_name << " ()" + << "{" + << "return " << (tid_map.size () > 0 ? "true" : "false") << ";" + << "}"; + } + os << "public:" << endl; for (TypeInstanceMap::Iterator i (map.begin ()), end (map.end ()); @@ -762,6 +780,7 @@ namespace CXX String root_name (unclash (name, "root_name")); String root_namespace (unclash (name, "root_namespace")); String error, reset; + String poly_name; String serializer_map, serializer_map_entries; InstanceSet set; @@ -791,6 +810,12 @@ namespace CXX set.insert (reset); } + if (poly_runtime) + { + poly_name = unclash (name, "polymorphic"); + set.insert (poly_name); + } + if (poly_code) { serializer_map = unclash (name, "serializer_map_"); @@ -914,6 +939,17 @@ namespace CXX os << "}"; } + // polymorphic () + // + if (poly_runtime) + { + os << "static bool" << endl + << poly_name << " ()" + << "{" + << "return " << (tid_map.size () > 0 ? "true" : "false") << ";" + << "}"; + } + os << "public:" << endl; for (TypeInstanceMap::Iterator i (map.begin ()), end (map.end ()); |