aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-14 12:21:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-14 12:21:35 +0200
commitb7197929af1cca15e490703ba3632ae52a348b60 (patch)
treee4ed9dc7cf2021d6ad398fade7fc8148ff982b16
parent6f395f9f769866a04f6949cb7ed14f93d90cf728 (diff)
New mapping for anyType with support for polymorphism
-rw-r--r--NEWS4
-rw-r--r--dist/libxsde/xsde/makefile8
-rw-r--r--dist/libxsde/xsde/nmakefile8
-rw-r--r--dist/tests/cxx/hybrid/makefile2
-rw-r--r--dist/tests/cxx/hybrid/nmakefile2
-rw-r--r--documentation/cxx/hybrid/guide/index.xhtml87
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-pimpl.cxx102
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-pimpl.hxx48
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-pskel.cxx104
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-pskel.hxx84
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-pskel.ixx29
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-simpl.cxx20
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-simpl.hxx32
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-sskel.cxx29
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-sskel.hxx66
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type-sskel.ixx27
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type.cxx151
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type.hxx56
-rw-r--r--libxsde/xsde/makefile8
-rw-r--r--tests/cxx/hybrid/polymorphism/any-type/driver.cxx2
-rw-r--r--tests/cxx/hybrid/polymorphism/any-type/test-000.std15
-rw-r--r--tests/cxx/hybrid/polymorphism/any-type/test-000.xml27
-rw-r--r--tests/cxx/hybrid/polymorphism/any-type/test.xsd2
-rw-r--r--tests/cxx/hybrid/polymorphism/makefile4
-rw-r--r--xsde/cxx/elements.cxx1
-rw-r--r--xsde/cxx/hybrid/generator.cxx440
-rw-r--r--xsde/cxx/hybrid/generator.hxx8
-rw-r--r--xsde/cxx/hybrid/parser-aggregate-header.cxx13
-rw-r--r--xsde/cxx/hybrid/parser-source.cxx124
-rw-r--r--xsde/cxx/hybrid/serializer-aggregate-header.cxx13
-rw-r--r--xsde/cxx/hybrid/serializer-source.cxx32
-rw-r--r--xsde/cxx/hybrid/tree-header.cxx9
-rw-r--r--xsde/cxx/hybrid/tree-size-processor.cxx23
-rw-r--r--xsde/cxx/parser/generator.cxx392
-rw-r--r--xsde/cxx/parser/parser-header.cxx14
-rw-r--r--xsde/cxx/parser/parser-inline.cxx19
-rw-r--r--xsde/cxx/serializer/generator.cxx392
-rw-r--r--xsde/cxx/serializer/serializer-header.cxx14
-rw-r--r--xsde/cxx/serializer/serializer-inline.cxx19
-rw-r--r--xsde/xsde.cxx42
40 files changed, 1747 insertions, 725 deletions
diff --git a/NEWS b/NEWS
index 0ce961e..b76baec 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,10 @@ Version 3.2.0
* The anySimpleType build-in type is now mapped to std::string or a C-string,
depending on whether STL is enabled or not.
+ * New mapping for anyType with support for polymorphism. For more
+ information, see Section 5.14, "Mapping for anyType" in the Embedded
+ C++/Hybrid Mapping Getting Started Guide.
+
* 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
diff --git a/dist/libxsde/xsde/makefile b/dist/libxsde/xsde/makefile
index af6cfe9..99cddc1 100644
--- a/dist/libxsde/xsde/makefile
+++ b/dist/libxsde/xsde/makefile
@@ -69,7 +69,13 @@ endif
## C++/Hybrid
##
-src += cxx/hybrid/sequence.cxx
+src += \
+cxx/hybrid/any-type.cxx \
+cxx/hybrid/any-type-pimpl.cxx \
+cxx/hybrid/any-type-pskel.cxx \
+cxx/hybrid/any-type-simpl.cxx \
+cxx/hybrid/any-type-sskel.cxx \
+cxx/hybrid/sequence.cxx
ifeq ($(XSDE_POLYMORPHIC),y)
src += \
diff --git a/dist/libxsde/xsde/nmakefile b/dist/libxsde/xsde/nmakefile
index aaffe74..bbf8797 100644
--- a/dist/libxsde/xsde/nmakefile
+++ b/dist/libxsde/xsde/nmakefile
@@ -75,7 +75,13 @@ src = $(src) cxx\xml\char-table.cxx cxx\xml\ncname.cxx
## C++/Hybrid
##
-src = $(src) cxx\hybrid\sequence.cxx
+src = $(src) \
+cxx\hybrid\any-type.cxx \
+cxx\hybrid\any-type-pimpl.cxx \
+cxx\hybrid\any-type-pskel.cxx \
+cxx\hybrid\any-type-simpl.cxx \
+cxx\hybrid\any-type-sskel.cxx \
+cxx\hybrid\sequence.cxx
!if "$(XSDE_POLYMORPHIC)" == "y"
src = $(src) \
diff --git a/dist/tests/cxx/hybrid/makefile b/dist/tests/cxx/hybrid/makefile
index 2117324..828d663 100644
--- a/dist/tests/cxx/hybrid/makefile
+++ b/dist/tests/cxx/hybrid/makefile
@@ -5,7 +5,7 @@ include $(root)/build/config.make
dirs := sequences
ifeq ($(XSDE_POLYMORPHIC),y)
-dirs += polymorphism/enumeration polymorphism/multischema
+dirs += polymorphism/any-type polymorphism/enumeration polymorphism/multischema
endif
ifeq ($(XSDE_STL),y)
diff --git a/dist/tests/cxx/hybrid/nmakefile b/dist/tests/cxx/hybrid/nmakefile
index 57d2324..3f94ad0 100644
--- a/dist/tests/cxx/hybrid/nmakefile
+++ b/dist/tests/cxx/hybrid/nmakefile
@@ -5,7 +5,7 @@ root = ..\..\..
dirs = sequences
!if "$(XSDE_POLYMORPHIC)" == "y"
-dirs = $(dirs) polymorphism\enumeration polymorphism\multischema
+dirs = $(dirs) polymorphism\any-type polymorphism\enumeration polymorphism\multischema
!endif
!if "$(XSDE_STL)" == "y"
diff --git a/documentation/cxx/hybrid/guide/index.xhtml b/documentation/cxx/hybrid/guide/index.xhtml
index 7d33a4e..b3edc1d 100644
--- a/documentation/cxx/hybrid/guide/index.xhtml
+++ b/documentation/cxx/hybrid/guide/index.xhtml
@@ -270,6 +270,7 @@
<tr><th>5.11</th><td><a href="#5.11">Mapping for <code>gYear</code></a></td></tr>
<tr><th>5.12</th><td><a href="#5.12">Mapping for <code>gYearMonth</code></a></td></tr>
<tr><th>5.13</th><td><a href="#5.13">Mapping for <code>time</code></a></td></tr>
+ <tr><th>5.14</th><td><a href="#5.14">Mapping for <code>anyType</code></a></td></tr>
</table>
</td>
</tr>
@@ -4599,6 +4600,21 @@ for (supermen::person_iterator i = sm->person ().begin ();
<td><code>time</code></td>
<td><a href="#5.13">Section 5.13, "Mapping for <code>time</code>"</a></td>
</tr>
+
+ <tr>
+ <th colspan="3">anyType and anySimpleType</th>
+ </tr>
+ <tr>
+ <td><code>anyType</code></td>
+ <td><code>any_type</code></td>
+ <td><a href="#5.14">Section 5.14, "Mapping for <code>anyType</code>"</a></td>
+ </tr>
+ <tr>
+ <td><code>anySimpleType</code></td>
+ <td><code>any_simple_type</code></td>
+ <td><code>std::string</code> or <code>char*</code><br/>
+ <a href="#3.1">Section 3.1, "Standard Template Library"</a></td>
+ </tr>
</table>
<p>As you can see from the table above a number of built-in
@@ -5644,6 +5660,77 @@ namespace xml_schema
}
</pre>
+ <h2><a name="5.14">5.14 Mapping for <code>anyType</code></a></h2>
+
+ <p>The <code>anyType</code> built-in XML Schema type is mapped to
+ the <code>any_type</code> class in the <code>xml_schema</code>
+ namespace. With C++ exceptions enabled (<a href="#3.3">Section 3.3,
+ "C++ Exceptions"</a>), it has the following interface:</p>
+
+ <pre class="c++">
+namespace xml_schema
+{
+ class any_type
+ {
+ public:
+ // Custom data.
+ //
+ typedef xml_schema::data_sequence custom_data_sequence;
+ typedef custom_data_sequence::iterator custom_data_iterator;
+ typedef custom_data_sequence::const_iterator custom_data_const_iterator;
+
+ void
+ allocate_custom_data ();
+
+ const custom_data_sequence&amp;
+ custom_data () const;
+
+ custom_data_sequence&amp;
+ custom_data ();
+ };
+}
+ </pre>
+
+ <p>If C++ exceptions are disabled, the <code>any_type</code> class has
+ the following interface:</p>
+
+ <pre class="c++">
+namespace xml_schema
+{
+ class any_type
+ {
+ public:
+ // Custom data.
+ //
+ typedef xml_schema::data_sequence custom_data_sequence;
+ typedef custom_data_sequence::iterator custom_data_iterator;
+ typedef custom_data_sequence::const_iterator custom_data_const_iterator;
+
+ bool
+ allocate_custom_data ();
+
+ const custom_data_sequence&amp;
+ custom_data () const;
+
+ custom_data_sequence&amp;
+ custom_data ();
+ };
+}
+ </pre>
+
+ <p>The <code>allocate_custom_data()</code> function allocates the
+ custom data sequence. With C++ exceptions disabled, it returns
+ <code>false</code> if memory allocation has failed and <code>true</code>
+ otherwise. For more information on custom data, refer to
+ <a href="#4.9">Section 4.9, "Customizing the Object Model"</a>.</p>
+
+ <p>The default parser and serializer implementations for the
+ <code>anyType</code> built-in type ignore all its content and
+ return an empty <code>any_type</code> instance. If your application
+ needs to access this content, then you will need to provide your
+ own implementations of these parser and serializer and use the
+ custom data sequence to store the extracted data.</p>
+
<!-- Parsing and Serialization -->
<h1><a name="6">6 Parsing and Serialization</a></h1>
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pimpl.cxx b/libxsde/xsde/cxx/hybrid/any-type-pimpl.cxx
new file mode 100644
index 0000000..30ec8f6
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-pimpl.cxx
@@ -0,0 +1,102 @@
+// file : xsde/cxx/hybrid/any-type-pimpl.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/config.hxx>
+
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type-pimpl.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ any_type_pimpl::
+ ~any_type_pimpl ()
+ {
+ if (!base_ && val_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ delete val_;
+#else
+ val_->~any_type ();
+ cxx::free (val_);
+#endif
+ }
+ }
+
+ void any_type_pimpl::
+ _reset ()
+ {
+ any_type_pskel::_reset ();
+
+ if (!base_ && val_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ delete val_;
+#else
+ val_->~any_type ();
+ cxx::free (val_);
+#endif
+ val_ = 0;
+ }
+ }
+
+ any_type_pimpl::
+ any_type_pimpl (bool base)
+ : base_ (base), val_ (0)
+ {
+ }
+
+ void any_type_pimpl::
+ pre_impl (any_type* qn)
+ {
+ val_ = qn;
+ }
+
+ void any_type_pimpl::
+ _pre ()
+ {
+ if (val_ == 0)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ val_ = new any_type ();
+#else
+ val_ = static_cast<any_type*> (alloc (sizeof (any_type)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (val_);
+ new (val_) any_type ();
+ ag.release ();
+#else
+ if (val_)
+ new (val_) any_type ();
+#endif
+#endif
+
+#ifndef XSDE_EXCEPTIONS
+ if (val_ == 0)
+ {
+ _sys_error (sys_error::no_memory);
+ return;
+ }
+#endif
+ }
+ }
+
+ any_type* any_type_pimpl::
+ post_any_type ()
+ {
+ any_type* r = val_;
+ val_ = 0;
+ return r;
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pimpl.hxx b/libxsde/xsde/cxx/hybrid/any-type-pimpl.hxx
new file mode 100644
index 0000000..4e799a6
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-pimpl.hxx
@@ -0,0 +1,48 @@
+// file : xsde/cxx/hybrid/any-type-pimpl.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_ANY_TYPE_PIMPL_HXX
+#define XSDE_CXX_HYBRID_ANY_TYPE_PIMPL_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <xsde/cxx/hybrid/any-type-pskel.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_REUSE_STYLE_MIXIN
+ struct any_type_pimpl: virtual any_type_pskel
+#else
+ struct any_type_pimpl: any_type_pskel
+#endif
+ {
+ ~any_type_pimpl ();
+ any_type_pimpl (bool base = false);
+
+ void
+ pre_impl (any_type*);
+
+ virtual void
+ _pre ();
+
+ virtual any_type*
+ post_any_type ();
+
+ virtual void
+ _reset ();
+
+ protected:
+ bool base_;
+ any_type* val_;
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_ANY_TYPE_PIMPL_HXX
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx b/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx
new file mode 100644
index 0000000..d8434b2
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-pskel.cxx
@@ -0,0 +1,104 @@
+// file : xsde/cxx/hybrid/any-type-pskel.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/any-type-pskel.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_POLYMORPHIC
+ bool any_type_pskel::
+ _start_element_impl (const ro_string& ns,
+ const ro_string& name,
+ const char* type)
+ {
+#ifdef XSDE_PARSER_VALIDATION
+ parser::context& ctx = _context ();
+ ctx.current_.any_ = true;
+ ctx.current_.depth_++;
+
+ _start_any_element (ns, name, type);
+ return true;
+#else
+ return false;
+#endif
+ }
+#else
+ bool any_type_pskel::
+ _start_element_impl (const ro_string& ns, const ro_string& name)
+ {
+#ifdef XSDE_PARSER_VALIDATION
+ parser::context& ctx = _context ();
+ ctx.current_.any_ = true;
+ ctx.current_.depth_++;
+
+ _start_any_element (ns, name);
+ return true;
+#else
+ return false;
+#endif
+ }
+#endif
+
+ bool any_type_pskel::
+ _end_element_impl (const ro_string& ns, const ro_string& name)
+ {
+#ifdef XSDE_PARSER_VALIDATION
+ _end_any_element (ns, name);
+ return true;
+#else
+ return false;
+#endif
+ }
+
+#ifdef XSDE_PARSER_VALIDATION
+ bool any_type_pskel::
+ _attribute_impl_phase_two (const ro_string& ns,
+ const ro_string& name,
+ const ro_string& value)
+ {
+ _any_attribute (ns, name, value);
+ return true;
+ }
+#else
+ bool any_type_pskel::
+ _attribute_impl (const ro_string&,
+ const ro_string&,
+ const ro_string&)
+ {
+ return false;
+ }
+#endif
+
+ bool any_type_pskel::
+ _characters_impl (const ro_string& s)
+ {
+#ifdef XSDE_PARSER_VALIDATION
+ _any_characters (s);
+ return true;
+#else
+ return false;
+#endif
+ }
+
+#ifdef XSDE_POLYMORPHIC
+ const char* any_type_pskel::
+ _static_type ()
+ {
+ return "anyType http://www.w3.org/2001/XMLSchema";
+ }
+
+ const char* any_type_pskel::
+ _dynamic_type () const
+ {
+ return _static_type ();
+ }
+#endif
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pskel.hxx b/libxsde/xsde/cxx/hybrid/any-type-pskel.hxx
new file mode 100644
index 0000000..6751120
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-pskel.hxx
@@ -0,0 +1,84 @@
+// file : xsde/cxx/hybrid/any-type-pskel.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_ANY_TYPE_PSKEL_HXX
+#define XSDE_CXX_HYBRID_ANY_TYPE_PSKEL_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#ifdef XSDE_PARSER_VALIDATION
+# include <xsde/cxx/parser/validating/parser.hxx>
+#else
+# include <xsde/cxx/parser/non-validating/parser.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_PARSER_VALIDATION
+ struct any_type_pskel: parser::validating::complex_content
+#else
+ struct any_type_pskel: parser::non_validating::complex_content
+#endif
+ {
+#ifdef XSDE_POLYMORPHIC
+ virtual bool
+ _start_element_impl (const ro_string&,
+ const ro_string&,
+ const char*);
+#else
+ virtual bool
+ _start_element_impl (const ro_string&, const ro_string&);
+#endif
+
+ virtual bool
+ _end_element_impl (const ro_string&, const ro_string&);
+
+#ifdef XSDE_PARSER_VALIDATION
+ virtual bool
+ _attribute_impl_phase_two (const ro_string&,
+ const ro_string&,
+ const ro_string&);
+#else
+ virtual bool
+ _attribute_impl (const ro_string&,
+ const ro_string&,
+ const ro_string&);
+#endif
+
+ virtual bool
+ _characters_impl (const ro_string&);
+
+ virtual any_type*
+ post_any_type () = 0;
+
+#ifdef XSDE_POLYMORPHIC
+ static const char*
+ _static_type ();
+
+ virtual const char*
+ _dynamic_type () const;
+#endif
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ any_type_pskel ();
+ any_type_pskel (any_type_pskel* impl, void*);
+
+ protected:
+ any_type_pskel* any_type_impl_;
+#endif
+ };
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/any-type-pskel.ixx>
+
+#endif // XSDE_CXX_HYBRID_ANY_TYPE_PSKEL_HXX
diff --git a/libxsde/xsde/cxx/hybrid/any-type-pskel.ixx b/libxsde/xsde/cxx/hybrid/any-type-pskel.ixx
new file mode 100644
index 0000000..b63ec72
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-pskel.ixx
@@ -0,0 +1,29 @@
+// file : xsde/cxx/hybrid/any-type-pskel.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ // any_type_pskel
+ //
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ inline any_type_pskel::
+ any_type_pskel ()
+ : any_type_impl_ (0)
+ {
+ }
+
+ inline any_type_pskel::
+ any_type_pskel (any_type_pskel* impl, void*)
+ : complex_content (impl, 0), any_type_impl_ (impl)
+ {
+ }
+#endif
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type-simpl.cxx b/libxsde/xsde/cxx/hybrid/any-type-simpl.cxx
new file mode 100644
index 0000000..fd65e92
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-simpl.cxx
@@ -0,0 +1,20 @@
+// file : xsde/cxx/hybrid/any-type-simpl.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/any-type-simpl.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ void any_type_simpl::
+ pre (const any_type&)
+ {
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type-simpl.hxx b/libxsde/xsde/cxx/hybrid/any-type-simpl.hxx
new file mode 100644
index 0000000..a6ef220
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-simpl.hxx
@@ -0,0 +1,32 @@
+// file : xsde/cxx/hybrid/any-type-simpl.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_ANY_TYPE_SIMPL_HXX
+#define XSDE_CXX_HYBRID_ANY_TYPE_SIMPL_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <xsde/cxx/hybrid/any-type-sskel.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_REUSE_STYLE_MIXIN
+ struct any_type_simpl: virtual any_type_sskel
+#else
+ struct any_type_simpl: any_type_sskel
+#endif
+ {
+ virtual void
+ pre (const any_type&);
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_ANY_TYPE_SIMPL_HXX
diff --git a/libxsde/xsde/cxx/hybrid/any-type-sskel.cxx b/libxsde/xsde/cxx/hybrid/any-type-sskel.cxx
new file mode 100644
index 0000000..7c6c1c1
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-sskel.cxx
@@ -0,0 +1,29 @@
+// file : xsde/cxx/hybrid/any-type-sskel.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/any-type-sskel.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_POLYMORPHIC
+ const char* any_type_sskel::
+ _static_type ()
+ {
+ return "anyType http://www.w3.org/2001/XMLSchema";
+ }
+
+ const char* any_type_sskel::
+ _dynamic_type () const
+ {
+ return _static_type ();
+ }
+#endif
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type-sskel.hxx b/libxsde/xsde/cxx/hybrid/any-type-sskel.hxx
new file mode 100644
index 0000000..29663be
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-sskel.hxx
@@ -0,0 +1,66 @@
+// file : xsde/cxx/hybrid/any-type-sskel.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_ANY_TYPE_SSKEL_HXX
+#define XSDE_CXX_HYBRID_ANY_TYPE_SSKEL_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#ifdef XSDE_SERIALIZER_VALIDATION
+# include <xsde/cxx/serializer/validating/serializer.hxx>
+#else
+# include <xsde/cxx/serializer/non-validating/serializer.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_SERIALIZER_VALIDATION
+ struct any_type_sskel: serializer::validating::complex_content
+#else
+ struct any_type_sskel: serializer::non_validating::complex_content
+#endif
+ {
+ virtual void
+ pre (const any_type&) = 0;
+
+ // Override the following two functions to implement
+ // your logic.
+ //
+
+ // virtual void
+ // _serialize_attributes ();
+
+ // virtual void
+ // _serialize_content ();
+
+#ifdef XSDE_POLYMORPHIC
+ static const char*
+ _static_type ();
+
+ virtual const char*
+ _dynamic_type () const;
+#endif
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ any_type_sskel ();
+ any_type_sskel (any_type_sskel* impl, void*);
+
+ protected:
+ any_type_sskel* any_type_impl_;
+#endif
+ };
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/any-type-sskel.ixx>
+
+#endif // XSDE_CXX_HYBRID_ANY_TYPE_SSKEL_HXX
diff --git a/libxsde/xsde/cxx/hybrid/any-type-sskel.ixx b/libxsde/xsde/cxx/hybrid/any-type-sskel.ixx
new file mode 100644
index 0000000..341a340
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type-sskel.ixx
@@ -0,0 +1,27 @@
+// file : xsde/cxx/hybrid/any-type-sskel.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ inline any_type_sskel::
+ any_type_sskel ()
+ : any_type_impl_ (0)
+ {
+ }
+
+ inline any_type_sskel::
+ any_type_sskel (any_type_sskel* impl, void*)
+ : complex_content (impl, 0), any_type_impl_ (impl)
+ {
+ }
+#endif
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type.cxx b/libxsde/xsde/cxx/hybrid/any-type.cxx
index d4f257d..544e11b 100644
--- a/libxsde/xsde/cxx/hybrid/any-type.cxx
+++ b/libxsde/xsde/cxx/hybrid/any-type.cxx
@@ -3,6 +3,12 @@
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <xsde/cxx/config.hxx>
+
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/hybrid/any-type.hxx>
namespace xsde
@@ -13,12 +19,155 @@ namespace xsde
{
// any_type
//
-#ifdef XSDE_POLYMORPHIC
any_type::
~any_type ()
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ delete data_;
+#else
+ if (data_ != 0)
+ {
+ data_->~data_sequence ();
+ cxx::free (data_);
+ }
+#endif
+ }
+
+#ifdef XSDE_EXCEPTIONS
+ void any_type::
+ allocate_custom_data ()
+ {
+ if (data_ != 0)
+ return;
+
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ data_ = new data_sequence;
+#else
+ // Default data_sequence c-tor cannot throw so we don't need a guard.
+ //
+ data_ = static_cast<data_sequence*> (
+ cxx::alloc (sizeof (data_sequence)));
+ new (data_) data_sequence;
+#endif
}
+ void any_type::
+ _copy (any_type& c) const
+ {
+ if (data_ != 0)
+ {
+ c.allocate_custom_data ();
+ data_->copy (c.custom_data ());
+ }
+ }
+
+ struct any_type_guard
+ {
+ any_type_guard (any_type* p) : p_ (p) {}
+
+ ~any_type_guard ()
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ delete p_;
+#else
+ if (p_ != 0)
+ {
+ p_->~any_type ();
+ cxx::free (p_);
+ }
+#endif
+ }
+
+ void
+ release () { p_ = 0; }
+
+ private:
+ any_type* p_;
+ };
+
+ any_type* any_type::
+ _clone () const
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ any_type* c = new any_type;
+#else
+ // Default any_type c-tor cannot throw so we don't need alloc_guard.
+ //
+ any_type* c = static_cast<any_type*> (cxx::alloc (sizeof (any_type)));
+ new (c) any_type;
+#endif
+ any_type_guard g (c);
+ _copy (*c);
+ g.release ();
+ return c;
+ }
+#else
+ bool any_type::
+ allocate_custom_data ()
+ {
+ if (data_ != 0)
+ return true;
+
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ data_ = new data_sequence;
+#else
+ data_ = static_cast<data_sequence*> (
+ cxx::alloc (sizeof (data_sequence)));
+#endif
+ if (data_ == 0)
+ return false;
+
+#ifdef XSDE_CUSTOM_ALLOCATOR
+ new (data_) data_sequence;
+#endif
+ return true;
+ }
+
+ bool
+ _copy (any_type&) const
+ {
+ if (data_ != 0)
+ {
+ if (!c.allocate_custom_data () ||
+ !data_.copy (c.custom_data ()))
+ return false;
+ }
+
+ return true;
+ }
+
+ any_type* any_type::
+ _clone () const
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ any_type* c = new any_type;
+#else
+ any_type* c = static_cast<any_type*> (cxx::alloc (sizeof (any_type)));
+#endif
+
+ if (c == 0)
+ return 0;
+
+#ifdef XSDE_CUSTOM_ALLOCATOR
+ new (c) any_type;
+#endif
+
+ if (!_copy (*c))
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
+ delete c;
+#else
+ c->~any_type ();
+ cxx::free (c);
+#endif
+ return 0;
+ }
+
+ return c;
+ }
+#endif
+
+#ifdef XSDE_POLYMORPHIC
#ifdef XSDE_STL
const std::string& any_type::
_dynamic_type () const
diff --git a/libxsde/xsde/cxx/hybrid/any-type.hxx b/libxsde/xsde/cxx/hybrid/any-type.hxx
index a356564..48b0e22 100644
--- a/libxsde/xsde/cxx/hybrid/any-type.hxx
+++ b/libxsde/xsde/cxx/hybrid/any-type.hxx
@@ -8,11 +8,11 @@
#include <xsde/cxx/config.hxx>
-/*
#ifdef XSDE_STL
# include <string>
#endif
-*/
+
+#include <xsde/cxx/hybrid/sequence.hxx>
namespace xsde
{
@@ -22,11 +22,55 @@ namespace xsde
{
struct any_type
{
- /*
-#ifdef XSDE_POLYMORPHIC
+ any_type ()
+ : data_ (0)
+ {
+ }
+
+ // Custom data.
+ //
+ typedef data_sequence custom_data_sequence;
+ typedef custom_data_sequence::iterator custom_data_iterator;
+ typedef custom_data_sequence::const_iterator custom_data_const_iterator;
+
+#ifndef XSDE_EXCEPTIONS
+ bool
+#else
+ void
+#endif
+ allocate_custom_data ();
+
+ const custom_data_sequence&
+ custom_data () const
+ {
+ return *data_;
+ }
+
+ custom_data_sequence&
+ custom_data ()
+ {
+ return *data_;
+ }
+
+#ifndef XSDE_EXCEPTIONS
+ bool
+#else
+ void
+#endif
+ _copy (any_type&) const;
+
+#ifndef XSDE_POLYMORPHIC
+ ~any_type ();
+
+ any_type*
+ _clone () const;
+#else
virtual
~any_type ();
+ virtual any_type*
+ _clone () const;
+
#ifdef XSDE_STL
virtual const std::string&
_dynamic_type () const;
@@ -41,7 +85,9 @@ namespace xsde
_static_type ();
#endif
#endif
- */
+
+ private:
+ data_sequence* data_;
};
}
}
diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile
index ce95980..0741d13 100644
--- a/libxsde/xsde/makefile
+++ b/libxsde/xsde/makefile
@@ -77,7 +77,13 @@ endif
## C++/Hybrid
##
-cxx_tun += cxx/hybrid/sequence.cxx
+cxx_tun += \
+cxx/hybrid/any-type.cxx \
+cxx/hybrid/any-type-pimpl.cxx \
+cxx/hybrid/any-type-pskel.cxx \
+cxx/hybrid/any-type-simpl.cxx \
+cxx/hybrid/any-type-sskel.cxx \
+cxx/hybrid/sequence.cxx
ifeq ($(xsde_polymorphic),y)
cxx_tun += \
diff --git a/tests/cxx/hybrid/polymorphism/any-type/driver.cxx b/tests/cxx/hybrid/polymorphism/any-type/driver.cxx
index bfea16f..cf39e15 100644
--- a/tests/cxx/hybrid/polymorphism/any-type/driver.cxx
+++ b/tests/cxx/hybrid/polymorphism/any-type/driver.cxx
@@ -52,7 +52,7 @@ main (int argc, char* argv[])
doc_s.add_prefix ("xsi", "http://www.w3.org/2001/XMLSchema-instance");
root_s.pre (*r);
- doc_s.serialize (cout);
+ doc_s.serialize (cout, xml_schema::document_simpl::pretty_print);
root_s.post ();
delete r;
diff --git a/tests/cxx/hybrid/polymorphism/any-type/test-000.std b/tests/cxx/hybrid/polymorphism/any-type/test-000.std
new file mode 100644
index 0000000..0c40a51
--- /dev/null
+++ b/tests/cxx/hybrid/polymorphism/any-type/test-000.std
@@ -0,0 +1,15 @@
+<t:root xmlns:t="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <t:any></t:any>
+ <t:any></t:any>
+ <t:base x="abc">
+ <a>123</a>
+ <b>abc</b>
+ </t:base>
+ <t:any x="xyz" xsi:type="t:derived">
+ <a>123</a>
+ <b>abc</b>
+ <c>9</c>
+ <c>8</c>
+ <c>7</c>
+ </t:any>
+</t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/polymorphism/any-type/test-000.xml b/tests/cxx/hybrid/polymorphism/any-type/test-000.xml
index f0a8bcb..7a6563c 100644
--- a/tests/cxx/hybrid/polymorphism/any-type/test-000.xml
+++ b/tests/cxx/hybrid/polymorphism/any-type/test-000.xml
@@ -1,7 +1,28 @@
<t:root xmlns:t="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <t:any><x>abc</x>junk<y>123</y></t:any>
- <t:base ><a>123</a><b>abc</b></t:base>
- <t:any xsi:type="t:derived"><a>123</a><b>abc</b><c>9</c><c>8</c><c>7</c></t:any>
+ <t:any>
+ <x>abc</x>
+ junk
+ <y>123</y>
+ </t:any>
+
+ <t:any1>
+ <x>abc</x>
+ junk
+ <y>123</y>
+ </t:any1>
+
+ <t:base x="abc">
+ <a>123</a>
+ <b>abc</b>
+ </t:base>
+
+ <t:any x="xyz" xsi:type="t:derived">
+ <a>123</a>
+ <b>abc</b>
+ <c>9</c>
+ <c>8</c>
+ <c>7</c>
+ </t:any>
</t:root>
diff --git a/tests/cxx/hybrid/polymorphism/any-type/test.xsd b/tests/cxx/hybrid/polymorphism/any-type/test.xsd
index 33b5251..ab35171 100644
--- a/tests/cxx/hybrid/polymorphism/any-type/test.xsd
+++ b/tests/cxx/hybrid/polymorphism/any-type/test.xsd
@@ -2,6 +2,7 @@
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
<element name="any" type="anyType"/>
+ <element name="any1" type="anyType" substitutionGroup="t:any"/>
<complexType name="base">
<complexContent>
@@ -10,6 +11,7 @@
<element name="a" type="int"/>
<element name="b" type="string"/>
</sequence>
+ <attribute name="x" type="string"/>
</restriction>
</complexContent>
</complexType>
diff --git a/tests/cxx/hybrid/polymorphism/makefile b/tests/cxx/hybrid/polymorphism/makefile
index 7523bb2..c418d34 100644
--- a/tests/cxx/hybrid/polymorphism/makefile
+++ b/tests/cxx/hybrid/polymorphism/makefile
@@ -8,12 +8,12 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
# NOTE: remember to update dist/tests/cxx/hybrid/polymorphis/{makefile,
# nmakefile} if you change anything here.
#
-all_tests := enumeration multischema
+all_tests := any-type enumeration multischema
build_tests :=
ifeq ($(xsde_iostream),y)
-build_tests += enumeration multischema
+build_tests += any-type enumeration multischema
endif
default := $(out_base)/
diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx
index 2289e32..be77456 100644
--- a/xsde/cxx/elements.cxx
+++ b/xsde/cxx/elements.cxx
@@ -105,7 +105,6 @@ namespace CXX
};
}
-
// Context
//
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index ee39079..8e3d8d1 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -46,6 +46,7 @@
#include <boost/filesystem/fstream.hpp>
+#include <sstream>
#include <iostream>
#include <usage.hxx>
@@ -56,6 +57,7 @@ using std::endl;
using std::wcerr;
using namespace XSDFrontend::SemanticGraph;
+namespace Indentation = BackendElements::Indentation;
//
//
@@ -825,10 +827,67 @@ namespace CXX
*i, p == NarrowString::npos ? 0 : p + 1, NarrowString::npos));
}
}
+
+ struct FundNamespace: Namespace, Hybrid::Context
+ {
+ FundNamespace (Hybrid::Context& c, Char type)
+ : Namespace (c), Hybrid::Context (c), type_ (type)
+ {
+ }
+
+ void
+ traverse (Type& ns)
+ {
+ namespace CLI = Hybrid::CLI;
+
+ pre (ns);
+
+ os << "using ::xsde::cxx::hybrid::any_type;"
+ << endl;
+
+ Boolean us, ui;
+ String skel, impl;
+
+ if (type_ == 'p')
+ {
+ skel = options.value<CLI::pskel_type_suffix> ();
+ impl = options.value<CLI::pimpl_type_suffix> ();
+
+ us = skel == L"_pskel";
+ ui = impl == L"_pimpl";
+ }
+ else
+ {
+ skel = options.value<CLI::sskel_type_suffix> ();
+ impl = options.value<CLI::simpl_type_suffix> ();
+
+ us = skel == L"_sskel";
+ ui = impl == L"_simpl";
+ }
+
+ if (us)
+ os << "using ::xsde::cxx::hybrid::any_type_" << type_ << "skel;";
+ else
+ os << "using ::xsde::cxx::hybrid::any_type_" << type_ << "skel " <<
+ "any_type" << skel << ";";
+
+ if (ui)
+ os << "using ::xsde::cxx::hybrid::any_type_" << type_ << "impl;";
+ else
+ os << "using ::xsde::cxx::hybrid::any_type_" << type_ << "impl " <<
+ "any_type" << impl << ";";
+
+ post (ns);
+ }
+
+ private:
+ Char type_;
+ };
}
+
Parser::CLI::Options* Hybrid::Generator::
- parser_options (CLI::Options const& h)
+ parser_options (CLI::Options const& h, Schema& schema, Path const& path)
{
namespace H = CLI;
namespace P = Parser::CLI;
@@ -907,11 +966,33 @@ namespace CXX
r->value<P::show_sloc> () = h.value<H::show_sloc> ();
r->value<P::proprietary_license> () = h.value<H::proprietary_license> ();
+ // Add the anyType parser.
+ //
+ {
+ std::wostringstream os;
+ Context ctx (os, schema, path, h, 0, 0, 0);
+
+ os << endl
+ << "#include <xsde/cxx/hybrid/any-type.hxx>" << endl
+ << "#include <xsde/cxx/hybrid/any-type-pskel.hxx>" << endl
+ << "#include <xsde/cxx/hybrid/any-type-pimpl.hxx>" << endl
+ << endl;
+
+ {
+ Indentation::Clip<Indentation::CXX, WideChar> clip (os);
+
+ FundNamespace ns (ctx, 'p');
+ ns.dispatch (ctx.xs_ns ());
+ }
+
+ r->value<P::hxx_prologue> ().push_back (String (os.str ()).to_narrow ());
+ }
+
return r.release ();
}
Serializer::CLI::Options* Hybrid::Generator::
- serializer_options (CLI::Options const& h)
+ serializer_options (CLI::Options const& h, Schema& schema, Path const& path)
{
namespace H = CLI;
namespace S = Serializer::CLI;
@@ -990,6 +1071,28 @@ namespace CXX
r->value<S::show_sloc> () = h.value<H::show_sloc> ();
r->value<S::proprietary_license> () = h.value<H::proprietary_license> ();
+ // Add the anyType parser.
+ //
+ {
+ std::wostringstream os;
+ Context ctx (os, schema, path, h, 0, 0, 0);
+
+ os << endl
+ << "#include <xsde/cxx/hybrid/any-type.hxx>" << endl
+ << "#include <xsde/cxx/hybrid/any-type-sskel.hxx>" << endl
+ << "#include <xsde/cxx/hybrid/any-type-simpl.hxx>" << endl
+ << endl;
+
+ {
+ Indentation::Clip<Indentation::CXX, WideChar> clip (os);
+
+ FundNamespace ns (ctx, 's');
+ ns.dispatch (ctx.xs_ns ());
+ }
+
+ r->value<S::hxx_prologue> ().push_back (String (os.str ()).to_narrow ());
+ }
+
return r.release ();
}
@@ -1162,8 +1265,6 @@ namespace CXX
AutoUnlinks& unlinks)
{
using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
-
typedef Context::Regex Regex;
try
@@ -1454,6 +1555,18 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ // Version check.
+ //
+ fwd << "#include <xsde/cxx/version.hxx>" << endl
+ << endl
+ << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
+ << "#error XSD/e runtime version mismatch" << endl
+ << "#endif" << endl
+ << endl;
+
+ fwd << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
+
// Copy prologue.
//
fwd << "// Begin prologue." << endl
@@ -1471,18 +1584,6 @@ namespace CXX
<< endl;
{
- // Version check.
- //
- fwd << "#include <xsde/cxx/version.hxx>" << endl
- << endl
- << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
- << "#error XSD/e runtime version mismatch" << endl
- << "#endif" << endl
- << endl;
-
- fwd << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
-
// Set auto-indentation.
//
Indentation::Clip<Indentation::CXX, WideChar> fwd_clip (fwd);
@@ -1490,9 +1591,6 @@ namespace CXX
// Generate.
//
generate_tree_forward (ctx, false);
-
- fwd << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -1511,6 +1609,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ fwd << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
fwd << "#endif // " << guard << endl;
if (show_sloc)
@@ -1522,6 +1623,9 @@ namespace CXX
}
}
+ // C++ namespace mapping for the XML Schema namespace.
+ //
+ String xs_ns;
// HXX
//
@@ -1529,6 +1633,8 @@ namespace CXX
Context ctx (
hxx, schema, file_path, ops, &fwd_expr, &hxx_expr, &ixx_expr);
+ xs_ns = ctx.xs_ns_name ();
+
Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx);
String guard (guard_expr.merge (guard_prefix + hxx_name));
@@ -1539,140 +1645,140 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
- // Copy prologue.
+ // Version check.
//
- hxx << "// Begin prologue." << endl
- << "//" << endl;
+ hxx << "#include <xsde/cxx/version.hxx>" << endl
+ << endl
+ << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
+ << "#error XSD/e runtime version mismatch" << endl
+ << "#endif" << endl
+ << endl;
- append (hxx,
- ops.value<CLI::hxx_prologue> (),
- ops.value<CLI::prologue> (),
- "");
- append (hxx,
- find_value (ops.value<CLI::hxx_prologue_file> (), ""),
- prologue);
+ // Runtime/generated code compatibility checks.
+ //
- hxx << "//" << endl
- << "// End prologue." << endl
+ hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
{
- // Version check.
- //
- hxx << "#include <xsde/cxx/version.hxx>" << endl
- << endl
- << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
- << "#error XSD/e runtime version mismatch" << endl
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
<< "#endif" << endl
<< endl;
+ }
- // Runtime/generated code compatibility checks.
- //
+ if (ops.value<CLI::no_stl> ())
+ {
+ hxx << "#ifdef XSDE_STL" << endl
+ << "#error the XSD/e runtime uses STL while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_STL" << endl
+ << "#error the generated code uses STL while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- hxx << "#include <xsde/cxx/config.hxx>" << endl
+ if (ops.value<CLI::no_exceptions> ())
+ {
+ hxx << "#ifdef XSDE_EXCEPTIONS" << endl
+ << "#error the XSD/e runtime uses exceptions while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-exceptions)" << endl
+ << "#endif" << endl
<< endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_EXCEPTIONS" << endl
+ << "#error the generated code uses exceptions while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-exceptions)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::char_encoding> () == "iso8859-1")
- {
- hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
- << "#error the generated code uses the ISO-8859-1 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
- << "#error the generated code uses the UTF-8 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::no_long_long> ())
+ {
+ hxx << "#ifdef XSDE_LONGLONG" << endl
+ << "#error the XSD/e runtime uses long long while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_LONGLONG" << endl
+ << "#error the generated code uses long long while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_stl> ())
- {
- hxx << "#ifdef XSDE_STL" << endl
- << "#error the XSD/e runtime uses STL while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_STL" << endl
- << "#error the generated code uses STL while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::custom_allocator> ())
+ {
+ hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the generated code uses custom allocator while " <<
+ "the XSD/e runtime does not (reconfigure the runtime or " <<
+ "remove --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the XSD/e runtime uses custom allocator while " <<
+ "the generated code does not (reconfigure the runtime or " <<
+ "add --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_exceptions> ())
- {
- hxx << "#ifdef XSDE_EXCEPTIONS" << endl
- << "#error the XSD/e runtime uses exceptions while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_EXCEPTIONS" << endl
- << "#error the generated code uses exceptions while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
+ //
+ //
- if (ops.value<CLI::no_long_long> ())
- {
- hxx << "#ifdef XSDE_LONGLONG" << endl
- << "#error the XSD/e runtime uses long long while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_LONGLONG" << endl
- << "#error the generated code uses long long while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
+ hxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
- if (ops.value<CLI::custom_allocator> ())
- {
- hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the generated code uses custom allocator while " <<
- "the XSD/e runtime does not (reconfigure the runtime or " <<
- "remove --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the XSD/e runtime uses custom allocator while " <<
- "the generated code does not (reconfigure the runtime or " <<
- "add --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
+ // Copy prologue.
+ //
+ hxx << "// Begin prologue." << endl
+ << "//" << endl;
- //
- //
+ append (hxx,
+ ops.value<CLI::hxx_prologue> (),
+ ops.value<CLI::prologue> (),
+ "");
+ append (hxx,
+ find_value (ops.value<CLI::hxx_prologue_file> (), ""),
+ prologue);
- hxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
+ hxx << "//" << endl
+ << "// End prologue." << endl
+ << endl;
+ {
// Set auto-indentation.
//
Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx);
@@ -1705,9 +1811,6 @@ namespace CXX
<< "#endif // XSDE_DONT_INCLUDE_INLINE" << endl
<< endl;
}
-
- hxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -1727,6 +1830,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ hxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
hxx << "#endif // " << guard << endl;
if (show_sloc)
@@ -1822,6 +1928,9 @@ namespace CXX
Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (cxx);
+ cxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
+
// Copy prologue.
//
cxx << "// Begin prologue." << endl
@@ -1840,9 +1949,6 @@ namespace CXX
<< endl;
{
- cxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
-
// Set auto-indentation.
//
Indentation::Clip<Indentation::CXX, WideChar> cxx_clip (cxx);
@@ -1860,9 +1966,6 @@ namespace CXX
if (!ops.value<CLI::generate_extraction> ().empty ())
generate_extraction_source (ctx);
-
- cxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -1882,6 +1985,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ cxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
if (show_sloc)
{
wcerr << cxx_path << ": "
@@ -1899,6 +2005,26 @@ namespace CXX
{
generate_tree_type_map (ops, schema, file_path, hxx_name,
parser_type_map, serializer_type_map);
+
+ // Re-map anyType.
+ //
+ if (ops.value<CLI::generate_parser> ())
+ {
+ parser_type_map.push_back (
+ TypeMap::Namespace ("http://www.w3.org/2001/XMLSchema"));
+
+ TypeMap::Namespace& xs (parser_type_map.back ());
+ xs.types_push_back ("anyType", xs_ns + L"::any_type*");
+ }
+
+ if (ops.value<CLI::generate_serializer> ())
+ {
+ serializer_type_map.push_back (
+ TypeMap::Namespace ("http://www.w3.org/2001/XMLSchema"));
+
+ TypeMap::Namespace& xs (serializer_type_map.back ());
+ xs.types_push_back ("anyType", L"const " + xs_ns + L"::any_type&");
+ }
}
return sloc;
@@ -1949,8 +2075,6 @@ namespace CXX
AutoUnlinks& unlinks)
{
using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
-
typedef BackendElements::Regex::Expression<Char> Regex;
try
@@ -2171,6 +2295,9 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ hxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
+
// Copy prologue.
//
hxx << "// Begin prologue." << endl
@@ -2189,9 +2316,6 @@ namespace CXX
<< endl;
{
- hxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
-
// Define omit aggregate macro.
//
hxx << "#ifndef XSDE_OMIT_PAGGR" << endl
@@ -2226,9 +2350,6 @@ namespace CXX
hxx << "#endif // XSDE_OMIT_PAGGR" << endl
<< endl;
}
-
- hxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -2248,6 +2369,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ hxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
hxx << "#endif // " << guard << endl;
if (show_sloc)
@@ -2371,8 +2495,6 @@ namespace CXX
AutoUnlinks& unlinks)
{
using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
-
typedef BackendElements::Regex::Expression<Char> Regex;
try
@@ -2580,6 +2702,9 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
+ hxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
+
// Copy prologue.
//
hxx << "// Begin prologue." << endl
@@ -2598,9 +2723,6 @@ namespace CXX
<< endl;
{
- hxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
-
// Define omit aggregate macro.
//
hxx << "#ifndef XSDE_OMIT_SAGGR" << endl
@@ -2635,9 +2757,6 @@ namespace CXX
hxx << "#endif // XSDE_OMIT_SAGGR" << endl
<< endl;
}
-
- hxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -2657,6 +2776,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ hxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
hxx << "#endif // " << guard << endl;
if (show_sloc)
diff --git a/xsde/cxx/hybrid/generator.hxx b/xsde/cxx/hybrid/generator.hxx
index e812801..805e282 100644
--- a/xsde/cxx/hybrid/generator.hxx
+++ b/xsde/cxx/hybrid/generator.hxx
@@ -39,10 +39,14 @@ namespace CXX
options_spec ();
static Parser::CLI::Options*
- parser_options (CLI::Options const&);
+ parser_options (CLI::Options const&,
+ XSDFrontend::SemanticGraph::Schema&,
+ XSDFrontend::SemanticGraph::Path const&);
static Serializer::CLI::Options*
- serializer_options (CLI::Options const&);
+ serializer_options (CLI::Options const&,
+ XSDFrontend::SemanticGraph::Schema&,
+ XSDFrontend::SemanticGraph::Path const&);
// Calculate type sizes.
//
diff --git a/xsde/cxx/hybrid/parser-aggregate-header.cxx b/xsde/cxx/hybrid/parser-aggregate-header.cxx
index a769e6d..de76640 100644
--- a/xsde/cxx/hybrid/parser-aggregate-header.cxx
+++ b/xsde/cxx/hybrid/parser-aggregate-header.cxx
@@ -219,7 +219,11 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnyType& t)
{
- fund_type (t, "any_type");
+ if (fund_type (t, "any_type"))
+ {
+ if (polymorphic (t))
+ collect (t);
+ }
}
virtual Void
@@ -510,11 +514,16 @@ namespace CXX
}
private:
- virtual Void
+ virtual Boolean
fund_type (SemanticGraph::Type& t, String const& name)
{
if (map_.find (&t) == map_.end ())
+ {
map_[&t] = find_instance_name (name);
+ return true;
+ }
+
+ return false;
}
String
diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx
index c610101..3bfac39 100644
--- a/xsde/cxx/hybrid/parser-source.cxx
+++ b/xsde/cxx/hybrid/parser-source.cxx
@@ -1836,30 +1836,25 @@ namespace CXX
// The following code is similar to what we have in post().
//
- // Default parser implementation for anyType returns void.
+ // If our base is a fixed-length type then copy the data
+ // over. Note that it cannot be a C-string.
//
- if (!b.is_a<SemanticGraph::AnyType> ())
+ if (fixed_length (b))
{
- // If our base is a fixed-length type then copy the data
- // over. Note that it cannot be a C-string.
- //
- if (fixed_length (b))
- {
- os << "static_cast< ";
+ os << "static_cast< ";
- base_name_.dispatch (b);
+ base_name_.dispatch (b);
- os << "& > (" << endl
- << "*" << top_member << ") = " << endl;
- }
+ os << "& > (" << endl
+ << "*" << top_member << ") = " << endl;
+ }
- if (tiein)
- os << "this->base_impl_.";
- else
- os << epimpl (b) << "::"; //@@ fq-name.
+ if (tiein)
+ os << "this->base_impl_.";
+ else
+ os << epimpl (b) << "::"; //@@ fq-name.
- os << post_name (b) << " ();";
- }
+ os << post_name (b) << " ();";
os << "}"
<< "else" << endl
@@ -1997,72 +1992,67 @@ namespace CXX
{
SemanticGraph::Type& b (c.inherits ().base ());
- // Default parser implementation for anyType returns void.
+ // If we are recursive but our base is not, we only call
+ // base post() if it is the first post call.
//
- if (!b.is_a<SemanticGraph::AnyType> ())
+ if (rec && !recursive (b))
{
- // If we are recursive but our base is not, we only call
- // base post() if it is the first post call.
- //
- if (rec && !recursive (b))
- {
- os << "if (this->" << epstate_top (c) << ")"
- << "{"
- << "this->" << epstate_top (c) << " = false;";
- }
+ os << "if (this->" << epstate_top (c) << ")"
+ << "{"
+ << "this->" << epstate_top (c) << " = false;";
+ }
- // If our base is a fixed-length type or C-string-base, then
- // copy the data over.
- //
- if (fixed_length (b))
- {
- os << "static_cast< ";
+ // If our base is a fixed-length type or C-string-base, then
+ // copy the data over.
+ //
+ if (fixed_length (b))
+ {
+ os << "static_cast< ";
- base_name_.dispatch (b);
+ base_name_.dispatch (b);
- os << "& > (";
+ os << "& > (";
- if (!rec)
- os << (fixed ? "" : "*") << "this->" << state << "." <<
- member;
- else
- os << endl
- << "*" << top_member;
+ if (!rec)
+ os << (fixed ? "" : "*") << "this->" << state << "." <<
+ member;
+ else
+ os << endl
+ << "*" << top_member;
- os << ") = " << endl;
- }
+ os << ") = " << endl;
+ }
- if (c_string_base)
- {
- os << "static_cast< ";
+ if (c_string_base)
+ {
+ os << "static_cast< ";
- base_name_.dispatch (b);
+ base_name_.dispatch (b);
- os << "* > (";
+ os << "* > (";
- if (!rec)
- os << "this->" << state << "." << member;
- else
- os << top_member;
+ if (!rec)
+ os << "this->" << state << "." << member;
+ else
+ os << top_member;
- os << ")->base_value (" << endl;
- }
+ os << ")->base_value (" << endl;
+ }
- if (tiein)
- os << "this->base_impl_.";
- else
- os << epimpl (b) << "::"; //@@ fq-name.
+ if (tiein)
+ os << "this->base_impl_.";
+ else
+ os << epimpl (b) << "::"; //@@ fq-name.
- os << post_name (b) << " ()";
+ os << post_name (b) << " ()";
- if (c_string_base)
- os << ")";
+ if (c_string_base)
+ os << ")";
- os << ";";
+ os << ";";
- if (rec && !recursive (b))
- os << "}";
- }
+ if (rec && !recursive (b))
+ os << "}";
}
if (fixed)
diff --git a/xsde/cxx/hybrid/serializer-aggregate-header.cxx b/xsde/cxx/hybrid/serializer-aggregate-header.cxx
index 1b4a03d..bacf474 100644
--- a/xsde/cxx/hybrid/serializer-aggregate-header.cxx
+++ b/xsde/cxx/hybrid/serializer-aggregate-header.cxx
@@ -219,7 +219,11 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnyType& t)
{
- fund_type (t, "any_type");
+ if (fund_type (t, "any_type"))
+ {
+ if (polymorphic (t))
+ collect (t);
+ }
}
virtual Void
@@ -510,11 +514,16 @@ namespace CXX
}
private:
- virtual Void
+ virtual Boolean
fund_type (SemanticGraph::Type& t, String const& name)
{
if (map_.find (&t) == map_.end ())
+ {
map_[&t] = find_instance_name (name);
+ return true;
+ }
+
+ return false;
}
String
diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx
index ef9eae9..fa613d4 100644
--- a/xsde/cxx/hybrid/serializer-source.cxx
+++ b/xsde/cxx/hybrid/serializer-source.cxx
@@ -947,11 +947,13 @@ namespace CXX
if (polymorphic (t))
{
+ String skel (fq_name (t, "s:impl"));
+
if (stl)
{
os << "const ::std::string& dt = " << access << iter <<
"->_dynamic_type ();"
- << "if (dt != " << esskel (t) << "::_static_type ())" << endl
+ << "if (dt != " << skel << "::_static_type ())" << endl
<< "this->_context ().type_id (dt.c_str ());"
<< endl;
}
@@ -959,7 +961,7 @@ namespace CXX
{
os << "const char* dt = " << access << iter <<
"->_dynamic_type ();"
- << "if (strcmp (dt, " << esskel (t) <<
+ << "if (strcmp (dt, " << skel <<
"::_static_type ()) != 0)" << endl
<< "this->_context ().type_id (dt);"
<< endl;
@@ -994,11 +996,13 @@ namespace CXX
if (polymorphic (t))
{
+ String skel (fq_name (t, "s:impl"));
+
if (stl)
{
os << "const ::std::string& dt = " << access << ename (e) <<
" ()._dynamic_type ();"
- << "if (dt != " << esskel (t) << "::_static_type ())" << endl
+ << "if (dt != " << skel << "::_static_type ())" << endl
<< "this->_context ().type_id (dt.c_str ());"
<< endl;
}
@@ -1006,7 +1010,7 @@ namespace CXX
{
os << "const char* dt = " << access << ename (e) <<
" ()._dynamic_type ();"
- << "if (strcmp (dt, " << esskel (t) <<
+ << "if (strcmp (dt, " << skel <<
"::_static_type ()) != 0)" << endl
<< "this->_context ().type_id (dt);"
<< endl;
@@ -1163,7 +1167,7 @@ namespace CXX
if (rec || (tiein && hb))
{
os << name << "::" << endl
- << name << " ()" << endl;
+ << name << " ()";
String d ("\n: ");
@@ -1234,20 +1238,16 @@ namespace CXX
<< endl;
}
- // Call base pre(). Default serializer implementation for
- // anyType takes void.
+ // Call base pre().
//
- if (!b.is_a<SemanticGraph::AnyType> ())
- {
- if (tiein)
- os << "this->base_impl_.pre (";
- else
- os << esimpl (b) << "::pre (";
+ if (tiein)
+ os << "this->base_impl_.pre (";
+ else
+ os << esimpl (b) << "::pre (";
- type_pass_.dispatch (b);
+ type_pass_.dispatch (b);
- os << "x);";
- }
+ os << "x);";
}
if (!restriction)
diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx
index b82cb7b..90bdd24 100644
--- a/xsde/cxx/hybrid/tree-header.cxx
+++ b/xsde/cxx/hybrid/tree-header.cxx
@@ -608,7 +608,6 @@ namespace CXX
Traversal::Union,
Traversal::Complex,
- Traversal::AnyType,
Traversal::AnySimpleType,
Traversal::Fundamental::Byte,
@@ -729,15 +728,9 @@ namespace CXX
Complex::contains_compositor (c, contains_compositor_);
}
- // anyType & anySimpleType.
+ // anySimpleType
//
virtual Void
- traverse (SemanticGraph::AnyType&)
- {
- align_type ("char", 1);
- }
-
- virtual Void
traverse (SemanticGraph::AnySimpleType&)
{
align_type ("size_t", 5); // std::string
diff --git a/xsde/cxx/hybrid/tree-size-processor.cxx b/xsde/cxx/hybrid/tree-size-processor.cxx
index e56b828..4aad4a2 100644
--- a/xsde/cxx/hybrid/tree-size-processor.cxx
+++ b/xsde/cxx/hybrid/tree-size-processor.cxx
@@ -542,18 +542,12 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnyType& t)
{
- /*
- @@ disabled
+ set (t, false);
+
// Check if this type is marked polymorphic.
//
if (poly_types_.find (t.name ()) != poly_types_.end ())
- {
t.context ().set ("polymorphic", true);
- set (t, false);
- }
- else
- */
- set (t, true);
}
virtual Void
@@ -880,14 +874,8 @@ namespace CXX
// Only user-defined and anyType can be declared polymorphic.
//
- /*
- @@ disabled
if (rt.is_a<SemanticGraph::Fundamental::Type> () ||
rt.is_a<SemanticGraph::AnySimpleType> ())
- */
- if (rt.is_a<SemanticGraph::Fundamental::Type> () ||
- rt.is_a<SemanticGraph::AnySimpleType> () ||
- rt.is_a<SemanticGraph::AnyType> ())
{
wcerr << r.file () << ":" << r.line () << ":" << r.column ()
<< ": error: built-in type '" << rt.name () << "' "
@@ -897,16 +885,9 @@ namespace CXX
<< ": info: because type '" << rt.name () << "' is "
<< "used in a substitution group declared here" << endl;
- /*
- @@ disabled
wcerr << r.file () << ":" << r.line () << ":" << r.column ()
<< ": info: only user-defined types and anyType can "
<< "be polymorphic in this mapping" << endl;
- */
-
- wcerr << r.file () << ":" << r.line () << ":" << r.column ()
- << ": info: only user-defined types can "
- << "be polymorphic in this mapping" << endl;
valid_ = false;
return;
diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx
index b6f91ee..859a7dc 100644
--- a/xsde/cxx/parser/generator.cxx
+++ b/xsde/cxx/parser/generator.cxx
@@ -1215,222 +1215,222 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
- // Copy prologue.
+ // Version check.
//
- hxx << "// Begin prologue." << endl
- << "//" << endl;
+ hxx << "#include <xsde/cxx/version.hxx>" << endl
+ << endl
+ << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
+ << "#error XSD/e runtime version mismatch" << endl
+ << "#endif" << endl
+ << endl;
- append (
- hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
- append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
+ // Runtime/generated code compatibility checks.
+ //
- hxx << "//" << endl
- << "// End prologue." << endl
+ hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
{
- // Version check.
- //
- hxx << "#include <xsde/cxx/version.hxx>" << endl
- << endl
- << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
- << "#error XSD/e runtime version mismatch" << endl
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
<< "#endif" << endl
<< endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- // Runtime/generated code compatibility checks.
- //
+ if (ops.value<CLI::no_stl> ())
+ {
+ hxx << "#ifdef XSDE_STL" << endl
+ << "#error the XSD/e runtime uses STL while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_STL" << endl
+ << "#error the generated code uses STL while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- hxx << "#include <xsde/cxx/config.hxx>" << endl
+ if (ops.value<CLI::no_iostream> ())
+ {
+ hxx << "#ifdef XSDE_IOSTREAM" << endl
+ << "#error the XSD/e runtime uses iostream while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-iostream)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_IOSTREAM" << endl
+ << "#error the generated code uses iostream while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-iostream)" << endl
+ << "#endif" << endl
<< endl;
+ }
- if (ops.value<CLI::char_encoding> () == "iso8859-1")
- {
- hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
- << "#error the generated code uses the ISO-8859-1 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
- << "#error the generated code uses the UTF-8 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::no_exceptions> ())
+ {
+ hxx << "#ifdef XSDE_EXCEPTIONS" << endl
+ << "#error the XSD/e runtime uses exceptions while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-exceptions)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_EXCEPTIONS" << endl
+ << "#error the generated code uses exceptions while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-exceptions)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_stl> ())
- {
- hxx << "#ifdef XSDE_STL" << endl
- << "#error the XSD/e runtime uses STL while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_STL" << endl
- << "#error the generated code uses STL while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::no_long_long> ())
+ {
+ hxx << "#ifdef XSDE_LONGLONG" << endl
+ << "#error the XSD/e runtime uses long long while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_LONGLONG" << endl
+ << "#error the generated code uses long long while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_iostream> ())
- {
- hxx << "#ifdef XSDE_IOSTREAM" << endl
- << "#error the XSD/e runtime uses iostream while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-iostream)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_IOSTREAM" << endl
- << "#error the generated code uses iostream while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-iostream)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::suppress_validation> ())
+ {
+ hxx << "#ifdef XSDE_PARSER_VALIDATION" << endl
+ << "#error the XSD/e runtime uses validation while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --suppress-validation)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_PARSER_VALIDATION" << endl
+ << "#error the generated code uses validation while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --suppress-validation)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_exceptions> ())
- {
- hxx << "#ifdef XSDE_EXCEPTIONS" << endl
- << "#error the XSD/e runtime uses exceptions while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_EXCEPTIONS" << endl
- << "#error the generated code uses exceptions while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::generate_polymorphic> () ||
+ ops.value<CLI::runtime_polymorphic> ())
+ {
+ hxx << "#ifndef XSDE_POLYMORPHIC" << endl
+ << "#error the generated code expects XSD/e runtime with " <<
+ "polymorphism support (reconfigure the runtime or remove " <<
+ "--generate-polymorphic/--runtime-polymorphic)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifdef XSDE_POLYMORPHIC" << endl
+ << "#error the generated code expects XSD/e runtime " <<
+ "without polymorphism support (reconfigure the runtime or " <<
+ "add --generate-polymorphic/--runtime-polymorphic)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_long_long> ())
- {
- hxx << "#ifdef XSDE_LONGLONG" << endl
- << "#error the XSD/e runtime uses long long while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_LONGLONG" << endl
- << "#error the generated code uses long long while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::reuse_style_mixin> ())
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_MIXIN" << endl
+ << "#error the generated code uses the mixin reuse style " <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or remove --reuse-style-mixin)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else if (ops.value<CLI::reuse_style_none> ())
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_NONE" << endl
+ << "#error the generated code does not provide support " <<
+ "for parser reuse while the XSD/e runtime does (reconfigure " <<
+ "the runtime or remove --reuse-style-none)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_TIEIN" << endl
+ << "#error the generated code uses the tiein reuse style " <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or add --reuse-style-mixin or --reuse-style-none)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::suppress_validation> ())
- {
- hxx << "#ifdef XSDE_PARSER_VALIDATION" << endl
- << "#error the XSD/e runtime uses validation while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --suppress-validation)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_PARSER_VALIDATION" << endl
- << "#error the generated code uses validation while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --suppress-validation)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::custom_allocator> ())
+ {
+ hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the generated code uses custom allocator while " <<
+ "the XSD/e runtime does not (reconfigure the runtime or " <<
+ "remove --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the XSD/e runtime uses custom allocator while " <<
+ "the generated code does not (reconfigure the runtime or " <<
+ "add --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::generate_polymorphic> () ||
- ops.value<CLI::runtime_polymorphic> ())
- {
- hxx << "#ifndef XSDE_POLYMORPHIC" << endl
- << "#error the generated code expects XSD/e runtime with " <<
- "polymorphism support (reconfigure the runtime or remove " <<
- "--generate-polymorphic/--runtime-polymorphic)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifdef XSDE_POLYMORPHIC" << endl
- << "#error the generated code expects XSD/e runtime " <<
- "without polymorphism support (reconfigure the runtime or " <<
- "add --generate-polymorphic/--runtime-polymorphic)" << endl
- << "#endif" << endl
- << endl;
- }
+ //
+ //
- if (ops.value<CLI::reuse_style_mixin> ())
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_MIXIN" << endl
- << "#error the generated code uses the mixin reuse style " <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or remove --reuse-style-mixin)" << endl
- << "#endif" << endl
- << endl;
- }
- else if (ops.value<CLI::reuse_style_none> ())
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_NONE" << endl
- << "#error the generated code does not provide support " <<
- "for parser reuse while the XSD/e runtime does (reconfigure " <<
- "the runtime or remove --reuse-style-none)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_TIEIN" << endl
- << "#error the generated code uses the tiein reuse style " <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or add --reuse-style-mixin or --reuse-style-none)" << endl
- << "#endif" << endl
- << endl;
- }
+ hxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
- if (ops.value<CLI::custom_allocator> ())
- {
- hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the generated code uses custom allocator while " <<
- "the XSD/e runtime does not (reconfigure the runtime or " <<
- "remove --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the XSD/e runtime uses custom allocator while " <<
- "the generated code does not (reconfigure the runtime or " <<
- "add --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
+ // Copy prologue.
+ //
+ hxx << "// Begin prologue." << endl
+ << "//" << endl;
- //
- //
+ append (
+ hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
+ append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
- hxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
+ hxx << "//" << endl
+ << "// End prologue." << endl
+ << endl;
+ {
// Set auto-indentation.
//
Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx);
@@ -1445,9 +1445,6 @@ namespace CXX
if (inline_)
hxx << "#include " << ctx.process_include_path (ixx_name) << endl
<< endl;
-
- hxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -1463,6 +1460,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ hxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
hxx << "#endif // " << guard << endl;
if (show_sloc)
diff --git a/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx
index fe6d67b..2498768 100644
--- a/xsde/cxx/parser/parser-header.cxx
+++ b/xsde/cxx/parser/parser-header.cxx
@@ -1523,14 +1523,20 @@ namespace CXX
String const& real_name (c.get<String> ("p:real-name"));
String const& name (c.get<String> ("p:name"));
- os << "typedef " << real_name << " " << name << ";";
-
String const& real_impl (c.get<String> ("p:real-impl"));
String const& impl (c.get<String> ("p:impl"));
- os << "typedef " << real_impl << " " << impl << ";"
- << endl;
+ if (options.value<CLI::skel_type_suffix> () == "_pskel")
+ os << "using " << real_name << ";";
+ else
+ os << "typedef " << real_name << " " << name << ";";
+ if (options.value<CLI::impl_type_suffix> () == "_pimpl")
+ os << "using " << real_impl << ";";
+ else
+ os << "typedef " << real_impl << " " << impl << ";";
+
+ os << endl;
return true;
}
diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx
index 5ebf014..f0d9e7b 100644
--- a/xsde/cxx/parser/parser-inline.cxx
+++ b/xsde/cxx/parser/parser-inline.cxx
@@ -169,12 +169,11 @@ namespace CXX
//
SemanticGraph::Type& base (e.inherits ().base ());
String fq_base (fq_name (base));
- String real_fq_base (real_fq_name (base));
os << inl
<< name << "::" << endl
<< name << " (" << fq_base << "* tiein)" << endl
- << ": " << real_fq_base << " (tiein, 0)," << endl
+ << ": " << fq_base << " (tiein, 0)," << endl
<< " " << impl << " (0)"
<< "{";
@@ -186,7 +185,7 @@ namespace CXX
os << inl
<< name << "::" << endl
<< name << " (" << name << "* impl, void*)" << endl
- << ": " << real_fq_base << " (impl, 0)," << endl
+ << ": " << fq_base << " (impl, 0)," << endl
<< " " << impl << " (impl)"
<< "{";
@@ -630,13 +629,10 @@ namespace CXX
os << "}";
}
- // We have to use "real" (non-typedef) base name in base
- // initializer because of some broken compilers (EVC 4.0).
- //
- String real_fq_base;
+ String fq_base;
if (hb && tiein)
- real_fq_base = real_fq_name (c.inherits ().base ());
+ fq_base = fq_name (c.inherits ().base ());
// Default c-tor.
//
@@ -644,8 +640,7 @@ namespace CXX
<< name << "::" << endl;
if (hb && tiein)
- os << name << " (" << fq_name (c.inherits ().base ()) <<
- "* tiein)" << endl;
+ os << name << " (" << fq_base << "* tiein)" << endl;
else
os << name << " ()" << endl;
@@ -658,7 +653,7 @@ namespace CXX
if (hb && tiein)
{
- os << real_fq_base << " (tiein, 0)";
+ os << fq_base << " (tiein, 0)";
comma = true;
}
@@ -741,7 +736,7 @@ namespace CXX
<< ": ";
if (hb)
- os << real_fq_base << " (impl, 0)," << endl;
+ os << fq_base << " (impl, 0)," << endl;
else
os << complex_base << " (impl, 0)," << endl;
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 36539f4..3366ff4 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -1201,222 +1201,222 @@ namespace CXX
<< "#define " << guard << endl
<< endl;
- // Copy prologue.
+ // Version check.
//
- hxx << "// Begin prologue." << endl
- << "//" << endl;
+ hxx << "#include <xsde/cxx/version.hxx>" << endl
+ << endl
+ << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
+ << "#error XSD/e runtime version mismatch" << endl
+ << "#endif" << endl
+ << endl;
- append (
- hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
- append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
+ // Runtime/generated code compatibility checks.
+ //
- hxx << "//" << endl
- << "// End prologue." << endl
+ hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
{
- // Version check.
- //
- hxx << "#include <xsde/cxx/version.hxx>" << endl
- << endl
- << "#if (XSDE_INT_VERSION != " << XSDE_INT_VERSION << "L)" << endl
- << "#error XSD/e runtime version mismatch" << endl
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
<< "#endif" << endl
<< endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- // Runtime/generated code compatibility checks.
- //
+ if (ops.value<CLI::no_stl> ())
+ {
+ hxx << "#ifdef XSDE_STL" << endl
+ << "#error the XSD/e runtime uses STL while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_STL" << endl
+ << "#error the generated code uses STL while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-stl)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- hxx << "#include <xsde/cxx/config.hxx>" << endl
+ if (ops.value<CLI::no_iostream> ())
+ {
+ hxx << "#ifdef XSDE_IOSTREAM" << endl
+ << "#error the XSD/e runtime uses iostream while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-iostream)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_IOSTREAM" << endl
+ << "#error the generated code uses iostream while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-iostream)" << endl
+ << "#endif" << endl
<< endl;
+ }
- if (ops.value<CLI::char_encoding> () == "iso8859-1")
- {
- hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
- << "#error the generated code uses the ISO-8859-1 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
- << "#error the generated code uses the UTF-8 encoding" <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or change the --char-encoding value)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::no_exceptions> ())
+ {
+ hxx << "#ifdef XSDE_EXCEPTIONS" << endl
+ << "#error the XSD/e runtime uses exceptions while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-exceptions)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_EXCEPTIONS" << endl
+ << "#error the generated code uses exceptions while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-exceptions)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_stl> ())
- {
- hxx << "#ifdef XSDE_STL" << endl
- << "#error the XSD/e runtime uses STL while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_STL" << endl
- << "#error the generated code uses STL while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-stl)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::no_long_long> ())
+ {
+ hxx << "#ifdef XSDE_LONGLONG" << endl
+ << "#error the XSD/e runtime uses long long while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_LONGLONG" << endl
+ << "#error the generated code uses long long while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --no-long-long)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_iostream> ())
- {
- hxx << "#ifdef XSDE_IOSTREAM" << endl
- << "#error the XSD/e runtime uses iostream while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-iostream)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_IOSTREAM" << endl
- << "#error the generated code uses iostream while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-iostream)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::suppress_validation> ())
+ {
+ hxx << "#ifdef XSDE_SERIALIZER_VALIDATION" << endl
+ << "#error the XSD/e runtime uses validation while the " <<
+ "generated code does not (reconfigure the runtime or " <<
+ "remove --suppress-validation)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_SERIALIZER_VALIDATION" << endl
+ << "#error the generated code uses validation while the " <<
+ "XSD/e runtime does not (reconfigure the runtime or " <<
+ "add --suppress-validation)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_exceptions> ())
- {
- hxx << "#ifdef XSDE_EXCEPTIONS" << endl
- << "#error the XSD/e runtime uses exceptions while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_EXCEPTIONS" << endl
- << "#error the generated code uses exceptions while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-exceptions)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::generate_polymorphic> () ||
+ ops.value<CLI::runtime_polymorphic> ())
+ {
+ hxx << "#ifndef XSDE_POLYMORPHIC" << endl
+ << "#error the generated code expects XSD/e runtime with " <<
+ "polymorphism support (reconfigure the runtime or remove " <<
+ "--generate-polymorphic/--runtime-polymorphic)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifdef XSDE_POLYMORPHIC" << endl
+ << "#error the generated code expects XSD/e runtime " <<
+ "without polymorphism support (reconfigure the runtime or " <<
+ "add --generate-polymorphic/--runtime-polymorphic)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::no_long_long> ())
- {
- hxx << "#ifdef XSDE_LONGLONG" << endl
- << "#error the XSD/e runtime uses long long while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_LONGLONG" << endl
- << "#error the generated code uses long long while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --no-long-long)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::reuse_style_mixin> ())
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_MIXIN" << endl
+ << "#error the generated code uses the mixin reuse style " <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or remove --reuse-style-mixin)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else if (ops.value<CLI::reuse_style_none> ())
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_NONE" << endl
+ << "#error the generated code does not provide support " <<
+ "for serializer reuse while the XSD/e runtime does (" <<
+ "reconfigure the runtime or remove --reuse-style-none)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_REUSE_STYLE_TIEIN" << endl
+ << "#error the generated code uses the tiein reuse style " <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or add --reuse-style-mixin or --reuse-style-none)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::suppress_validation> ())
- {
- hxx << "#ifdef XSDE_SERIALIZER_VALIDATION" << endl
- << "#error the XSD/e runtime uses validation while the " <<
- "generated code does not (reconfigure the runtime or " <<
- "remove --suppress-validation)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_SERIALIZER_VALIDATION" << endl
- << "#error the generated code uses validation while the " <<
- "XSD/e runtime does not (reconfigure the runtime or " <<
- "add --suppress-validation)" << endl
- << "#endif" << endl
- << endl;
- }
+ if (ops.value<CLI::custom_allocator> ())
+ {
+ hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the generated code uses custom allocator while " <<
+ "the XSD/e runtime does not (reconfigure the runtime or " <<
+ "remove --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
+ << "#error the XSD/e runtime uses custom allocator while " <<
+ "the generated code does not (reconfigure the runtime or " <<
+ "add --custom-allocator)" << endl
+ << "#endif" << endl
+ << endl;
+ }
- if (ops.value<CLI::generate_polymorphic> () ||
- ops.value<CLI::runtime_polymorphic> ())
- {
- hxx << "#ifndef XSDE_POLYMORPHIC" << endl
- << "#error the generated code expects XSD/e runtime with " <<
- "polymorphism support (reconfigure the runtime or remove " <<
- "--generate-polymorphic/--runtime-polymorphic)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifdef XSDE_POLYMORPHIC" << endl
- << "#error the generated code expects XSD/e runtime " <<
- "without polymorphism support (reconfigure the runtime or " <<
- "add --generate-polymorphic/--runtime-polymorphic)" << endl
- << "#endif" << endl
- << endl;
- }
+ //
+ //
- if (ops.value<CLI::reuse_style_mixin> ())
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_MIXIN" << endl
- << "#error the generated code uses the mixin reuse style " <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or remove --reuse-style-mixin)" << endl
- << "#endif" << endl
- << endl;
- }
- else if (ops.value<CLI::reuse_style_none> ())
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_NONE" << endl
- << "#error the generated code does not provide support " <<
- "for serializer reuse while the XSD/e runtime does (" <<
- "reconfigure the runtime or remove --reuse-style-none)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifndef XSDE_REUSE_STYLE_TIEIN" << endl
- << "#error the generated code uses the tiein reuse style " <<
- "while the XSD/e runtime does not (reconfigure the runtime " <<
- "or add --reuse-style-mixin or --reuse-style-none)" << endl
- << "#endif" << endl
- << endl;
- }
+ hxx << "#include <xsde/cxx/pre.hxx>" << endl
+ << endl;
- if (ops.value<CLI::custom_allocator> ())
- {
- hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the generated code uses custom allocator while " <<
- "the XSD/e runtime does not (reconfigure the runtime or " <<
- "remove --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
- else
- {
- hxx << "#ifdef XSDE_CUSTOM_ALLOCATOR" << endl
- << "#error the XSD/e runtime uses custom allocator while " <<
- "the generated code does not (reconfigure the runtime or " <<
- "add --custom-allocator)" << endl
- << "#endif" << endl
- << endl;
- }
+ // Copy prologue.
+ //
+ hxx << "// Begin prologue." << endl
+ << "//" << endl;
- //
- //
+ append (
+ hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
+ append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
- hxx << "#include <xsde/cxx/pre.hxx>" << endl
- << endl;
+ hxx << "//" << endl
+ << "// End prologue." << endl
+ << endl;
+ {
// Set auto-indentation.
//
Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx);
@@ -1432,9 +1432,6 @@ namespace CXX
if (inline_)
hxx << "#include " << ctx.process_include_path (ixx_name) << endl
<< endl;
-
- hxx << "#include <xsde/cxx/post.hxx>" << endl
- << endl;
}
// Copy epilogue.
@@ -1450,6 +1447,9 @@ namespace CXX
<< "// End epilogue." << endl
<< endl;
+ hxx << "#include <xsde/cxx/post.hxx>" << endl
+ << endl;
+
hxx << "#endif // " << guard << endl;
if (show_sloc)
diff --git a/xsde/cxx/serializer/serializer-header.cxx b/xsde/cxx/serializer/serializer-header.cxx
index e8fd2f5..bf2c724 100644
--- a/xsde/cxx/serializer/serializer-header.cxx
+++ b/xsde/cxx/serializer/serializer-header.cxx
@@ -1686,14 +1686,20 @@ namespace CXX
String const& real_name (c.get<String> ("s:real-name"));
String const& name (c.get<String> ("s:name"));
- os << "typedef " << real_name << " " << name << ";";
-
String const& real_impl (c.get<String> ("s:real-impl"));
String const& impl (c.get<String> ("s:impl"));
- os << "typedef " << real_impl << " " << impl << ";"
- << endl;
+ if (options.value<CLI::skel_type_suffix> () == "_sskel")
+ os << "using " << real_name << ";";
+ else
+ os << "typedef " << real_name << " " << name << ";";
+ if (options.value<CLI::impl_type_suffix> () == "_simpl")
+ os << "using " << real_impl << ";";
+ else
+ os << "typedef " << real_impl << " " << impl << ";";
+
+ os << endl;
return true;
}
diff --git a/xsde/cxx/serializer/serializer-inline.cxx b/xsde/cxx/serializer/serializer-inline.cxx
index 998f0f1..621f8b2 100644
--- a/xsde/cxx/serializer/serializer-inline.cxx
+++ b/xsde/cxx/serializer/serializer-inline.cxx
@@ -154,12 +154,11 @@ namespace CXX
//
SemanticGraph::Type& base (e.inherits ().base ());
String fq_base (fq_name (base));
- String real_fq_base (real_fq_name (base));
os << inl
<< name << "::" << endl
<< name << " (" << fq_base << "* tiein)" << endl
- << ": " << real_fq_base << " (tiein, 0)," << endl
+ << ": " << fq_base << " (tiein, 0)," << endl
<< " " << impl << " (0)"
<< "{";
@@ -171,7 +170,7 @@ namespace CXX
os << inl
<< name << "::" << endl
<< name << " (" << name << "* impl, void*)" << endl
- << ": " << real_fq_base << " (impl, 0)," << endl
+ << ": " << fq_base << " (impl, 0)," << endl
<< " " << impl << " (impl)"
<< "{";
@@ -575,13 +574,10 @@ namespace CXX
os << "}";
}
- // We have to use "real" (non-typedef) base name in base
- // initializer because of some broken compilers (EVC 4.0).
- //
- String real_fq_base;
+ String fq_base;
if (hb && tiein)
- real_fq_base = real_fq_name (c.inherits ().base ());
+ fq_base = fq_name (c.inherits ().base ());
// Default c-tor.
//
@@ -589,8 +585,7 @@ namespace CXX
<< name << "::" << endl;
if (hb && tiein)
- os << name << " (" << fq_name (c.inherits ().base ()) <<
- "* tiein)" << endl;
+ os << name << " (" << fq_base << "* tiein)" << endl;
else
os << name << " ()" << endl;
@@ -601,7 +596,7 @@ namespace CXX
if (hb && tiein)
{
- os << real_fq_base << " (tiein, 0)";
+ os << fq_base << " (tiein, 0)";
comma = true;
}
@@ -661,7 +656,7 @@ namespace CXX
<< ": ";
if (hb)
- os << real_fq_base << " (impl, 0)," << endl;
+ os << fq_base << " (impl, 0)," << endl;
else
os << complex_base << " (impl, 0)," << endl;
diff --git a/xsde/xsde.cxx b/xsde/xsde.cxx
index 2281ae9..476869e 100644
--- a/xsde/xsde.cxx
+++ b/xsde/xsde.cxx
@@ -499,12 +499,6 @@ main (Int argc, Char* argv[])
h_ops = new CXX::Hybrid::CLI::Options (
CLI::parse (CXX::Hybrid::Generator::options_spec (), args));
- if (h_ops->value<CXX::Hybrid::CLI::generate_parser> ())
- p_ops = CXX::Hybrid::Generator::parser_options (*h_ops);
-
- if (h_ops->value<CXX::Hybrid::CLI::generate_serializer> ())
- s_ops = CXX::Hybrid::Generator::serializer_options (*h_ops);
-
show_sloc = h_ops->value<CXX::Hybrid::CLI::show_sloc> ();
}
@@ -885,6 +879,18 @@ main (Int argc, Char* argv[])
// The first schema. Will be handled later.
//
root = &b->schema ();
+
+ // Create parser/serializer options (we need a schema, any
+ // schema to do this).
+ //
+ if (gen_parser && !p_ops)
+ p_ops = CXX::Hybrid::Generator::parser_options (
+ *h_ops, *root, b->path ());
+
+ if (gen_serializer && !s_ops)
+ s_ops = CXX::Hybrid::Generator::serializer_options (
+ *h_ops, *root, b->path ());
+
++b;
for (Schema::UsesIterator e (schema->uses_end ()); b != e; ++b)
@@ -909,8 +915,21 @@ main (Int argc, Char* argv[])
}
}
else
+ {
root = schema.get ();
+ // Create parser/serializer options (we need a schema, any
+ // schema to do this).
+ //
+ if (gen_parser && !p_ops)
+ p_ops = CXX::Hybrid::Generator::parser_options (
+ *h_ops, *root, tu);
+
+ if (gen_serializer && !s_ops)
+ s_ops = CXX::Hybrid::Generator::serializer_options (
+ *h_ops, *root, tu);
+ }
+
// Generate mapping.
//
TypeMap::Namespaces parser_type_map, serializer_type_map;
@@ -1157,6 +1176,17 @@ main (Int argc, Char* argv[])
? s.context ().get<SemanticGraph::Path> ("renamed")
: s.used_begin ()->path ());
+ // Create parser/serializer options (we need a schema, any
+ // schema to do this).
+ //
+ if (gen_parser && !p_ops)
+ p_ops = CXX::Hybrid::Generator::parser_options (
+ *h_ops, s, path);
+
+ if (gen_serializer && !s_ops)
+ s_ops = CXX::Hybrid::Generator::serializer_options (
+ *h_ops, s, path);
+
TypeMap::Namespaces parser_type_map, serializer_type_map;
if (gen_hybrid)