summaryrefslogtreecommitdiff
path: root/xsd/xsd/cxx/tree/stream-source.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/xsd/cxx/tree/stream-source.cxx')
-rw-r--r--xsd/xsd/cxx/tree/stream-source.cxx89
1 files changed, 48 insertions, 41 deletions
diff --git a/xsd/xsd/cxx/tree/stream-source.cxx b/xsd/xsd/cxx/tree/stream-source.cxx
index e8a7fc4..935ad40 100644
--- a/xsd/xsd/cxx/tree/stream-source.cxx
+++ b/xsd/xsd/cxx/tree/stream-source.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/stream-source.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <cxx/tree/stream-source.hxx>
@@ -21,7 +20,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& l)
{
String name (ename (l));
@@ -52,15 +51,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (l) && !anonymous_p (l))
+ if (polymorphic &&
+ polymorphic_p (l) &&
+ (!anonymous_p (l) || anonymous_substitutes_p (l)))
{
// Note that we are using the original type name.
//
String const& name (ename (l));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -87,7 +88,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& u)
{
String name (ename (u));
@@ -107,15 +108,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (u) && !anonymous_p (u))
+ if (polymorphic &&
+ polymorphic_p (u) &&
+ (!anonymous_p (u) || anonymous_substitutes_p (u)))
{
// Note that we are using the original type name.
//
String const& name (ename (u));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -131,7 +134,7 @@ namespace CXX
inherits_base_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& e)
{
String name (ename (e));
@@ -142,13 +145,13 @@ namespace CXX
if (renamed_type (e, name) && !name)
return;
- Boolean string_based (false);
+ bool string_based (false);
{
IsStringBasedType t (string_based);
t.dispatch (e);
}
- Boolean enum_based (false);
+ bool enum_based (false);
if (string_based)
{
SemanticGraph::Enumeration* be (0);
@@ -185,15 +188,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (e) && !anonymous_p (e))
+ if (polymorphic &&
+ polymorphic_p (e) &&
+ (!anonymous_p (e) || anonymous_substitutes_p (e)))
{
// Note that we are using the original type name.
//
String const& name (ename (e));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -211,7 +216,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& e)
{
if (skip (e))
@@ -226,17 +231,15 @@ namespace CXX
// dynamically-type with xsi:type.
//
SemanticGraph::Type& t (e.type ());
- Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
- // aCC cannot handle an inline call to std_ostream_map_instance.
- //
if (poly)
{
os << "{"
<< "::xsd::cxx::tree::std_ostream_map< " << char_type
<< " >& om (" << endl
- << "::xsd::cxx::tree::std_ostream_map_instance< 0, " <<
- char_type << " > ());"
+ << "::xsd::cxx::tree::std_ostream_map_instance< " <<
+ poly_plate << ", " << char_type << " > ());"
<< endl;
}
@@ -304,7 +307,7 @@ namespace CXX
{
}
- virtual Void
+ virtual void
traverse (Type& a)
{
String const& aname (eaname (a));
@@ -334,7 +337,7 @@ namespace CXX
inherits_ >> base_;
}
- virtual Void
+ virtual void
traverse (Type& c)
{
String name (ename (c));
@@ -347,7 +350,7 @@ namespace CXX
//
//
- Boolean has_body (has<Traversal::Member> (c) || c.inherits_p ());
+ bool has_body (has<Traversal::Member> (c) || c.inherits_p ());
os << std_ostream_type << "&" << endl
<< "operator<< (" << std_ostream_type << "& o, " <<
@@ -380,15 +383,17 @@ namespace CXX
// Register with ostream map.
//
- if (polymorphic && polymorphic_p (c) && !anonymous_p (c))
+ if (polymorphic &&
+ polymorphic_p (c) &&
+ (!anonymous_p (c) || anonymous_substitutes_p (c)))
{
// Note that we are using the original type name.
//
String const& name (ename (c));
os << "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_initializer< 0, " <<
- char_type << ", " << name << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_initializer< " <<
+ poly_plate << ", " << char_type << ", " << name << " >" << endl
<< "_xsd_" << name << "_std_ostream_init;"
<< endl;
}
@@ -400,10 +405,8 @@ namespace CXX
};
}
- Void
- generate_stream_source (Context& ctx,
- UnsignedLong first,
- UnsignedLong last)
+ void
+ generate_stream_source (Context& ctx, size_t first, size_t last)
{
String c (ctx.char_type);
@@ -415,8 +418,8 @@ namespace CXX
ctx.os << "#include <xsd/cxx/tree/std-ostream-map.hxx>" << endl
<< endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ bool import_maps (ctx.options.import_maps ());
+ bool export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -432,19 +435,23 @@ namespace CXX
if (export_maps)
ctx.os << "template struct __declspec (dllexport) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
if (import_maps)
ctx.os << "template struct __declspec (dllimport) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " <<
+ ctx.char_type << " >;";
ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl
<< "template struct __attribute__ ((visibility(\"default\"))) " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " << ctx.char_type <<
+ " >;";
ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl
<< "template struct XSD_MAP_VISIBILITY " <<
- "std_ostream_plate< 0, " << ctx.char_type << " >;";
+ "std_ostream_plate< " << ctx.poly_plate << ", " << ctx.char_type <<
+ " >;";
ctx.os << "#endif" << endl
<< "}" // tree
@@ -457,15 +464,15 @@ namespace CXX
ctx.os << "namespace _xsd"
<< "{"
<< "static" << endl
- << "const ::xsd::cxx::tree::std_ostream_plate< 0, " <<
- ctx.char_type << " >" << endl
+ << "const ::xsd::cxx::tree::std_ostream_plate< " <<
+ ctx.poly_plate << ", " << ctx.char_type << " >" << endl
<< "std_ostream_plate_init;"
<< "}";
}
Traversal::Schema schema;
- Traversal::Sources sources;
+ Sources sources;
Traversal::Names names_ns, names;
Namespace ns (ctx, first, last);