summaryrefslogtreecommitdiff
path: root/xsd/xsd/cxx/tree/elements.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/xsd/cxx/tree/elements.cxx')
-rw-r--r--xsd/xsd/cxx/tree/elements.cxx428
1 files changed, 226 insertions, 202 deletions
diff --git a/xsd/xsd/cxx/tree/elements.cxx b/xsd/xsd/cxx/tree/elements.cxx
index cad5a33..202ab62 100644
--- a/xsd/xsd/cxx/tree/elements.cxx
+++ b/xsd/xsd/cxx/tree/elements.cxx
@@ -1,6 +1,5 @@
// file : xsd/cxx/tree/elements.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/elements.hxx>
@@ -11,55 +10,18 @@ namespace CXX
{
// Context
//
- Void Context::
- update_ns_scope () // Keeping this function first helps HP-UX
- { // (long symbols).
- ns_scope.clear ();
-
- Boolean first (true);
-
- for (NamespaceStack::Iterator i (ns_scope_stack.begin ());
- i != ns_scope_stack.end ();
- ++i)
- {
- // We only qualify names until the namespace level.
- //
- if (first)
- first = false;
- else
- ns_scope += L"::";
-
- ns_scope += *i;
- }
- }
-
Context::
Context (std::wostream& o,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
- CLI::Options const& ops,
+ options_type const& ops,
Counts const& counts_,
- Boolean generate_xml_schema__,
+ bool generate_xml_schema__,
StringLiteralMap const* map,
Regex const* fe,
Regex const* he,
Regex const* ie)
- : CXX::Context (o,
- root,
- path,
- map,
- ops.value<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
+ : CXX::Context (o, root, path, ops, map),
options (ops),
counts (counts_),
any_type (any_type_),
@@ -84,9 +46,10 @@ namespace CXX
as_decimal_type (as_decimal_type_),
generate_xml_schema (generate_xml_schema_),
doxygen (doxygen_),
- polymorphic (ops.value<CLI::generate_polymorphic> ()),
- polymorphic_all (ops.value<CLI::polymorphic_type_all> ()),
- detach (ops.value<CLI::generate_detach> ()),
+ polymorphic (ops.generate_polymorphic ()),
+ polymorphic_all (ops.polymorphic_type_all ()),
+ poly_plate (ops.polymorphic_plate ()),
+ detach (ops.generate_detach ()),
fwd_expr (fe),
hxx_expr (he),
ixx_expr (ie),
@@ -96,7 +59,7 @@ namespace CXX
qname_type_ (L"::xsd::cxx::xml::qualified_name< " + char_type + L" >"),
parser_type_ (L"::xsd::cxx::xml::dom::parser< " + char_type + L" >"),
generate_xml_schema_ (generate_xml_schema__),
- doxygen_ (ops.value<CLI::generate_doxygen> ()),
+ doxygen_ (ops.generate_doxygen ()),
ns_scope_stack (ns_scope_stack_),
cxx_uq_id_expr_ (L"^[a-zA-Z_]\\w*$"),
cxx_uq_id_expr (cxx_uq_id_expr_)
@@ -118,23 +81,25 @@ namespace CXX
container = xs_name + L"::" + xsc.get<String> ("container");
flags_type = xs_name + L"::" + xsc.get<String> ("flags");
- if (ops.value<CLI::generate_element_type> ())
+ if (ops.generate_element_type ())
element_type = xs_name + L"::" + xsc.get<String> ("element-type");
properties_type = xs_name + L"::" + xsc.get<String> ("properties");
- if (!ops.value<CLI::suppress_parsing> () ||
- ops.value<CLI::generate_serialization> ())
+ if (!ops.suppress_parsing () || ops.generate_serialization ())
{
error_handler_type = xs_name + L"::" +
xsc.get<String> ("error-handler");
}
- dom_auto_ptr_ = xs_name + L"::dom::auto_ptr";
+ dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11
+ ? L"::dom::unique_ptr"
+ : L"::dom::auto_ptr");
+
dom_node_key_ = xs_name + L"::dom::" +
xsc.get<String> ("tree-node-key");
- if (ops.value<CLI::generate_serialization> ())
+ if (ops.generate_serialization ())
{
as_double_type_ = xs_name + L"::" +
xsc.get<String> ("as-double");
@@ -152,17 +117,17 @@ namespace CXX
// istream and ostream are templates and for now use the same
// names regardless of the naming convention.
//
- if (!ops.value<CLI::generate_extraction> ().empty ())
+ if (!ops.generate_extraction ().empty ())
istream_type = xs_name + L"::istream";
- if (!ops.value<CLI::generate_insertion> ().empty ())
+ if (!ops.generate_insertion ().empty ())
ostream_type = xs_name + L"::ostream";
}
// Xerces-C++ namespace. IntelliSense for some reason does not like
// it fully-qualified (maybe because it's a namespace alias).
//
- if (ops.value<CLI::generate_intellisense> ())
+ if (ops.generate_intellisense ())
xerces_ns = "xercesc";
else
xerces_ns = "::xercesc";
@@ -178,14 +143,14 @@ namespace CXX
// Custom type mapping.
//
- typedef Containers::Vector<NarrowString> Vector;
// Direct custom type mapping.
//
{
- Vector const& v (ops.value<CLI::custom_type> ());
+ NarrowStrings const& v (ops.custom_type ());
- for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()),
+ e (v.end ()); i != e; ++i)
{
String s (*i);
@@ -194,7 +159,7 @@ namespace CXX
// Split the string in two parts at the last '='.
//
- Size pos (s.rfind ('='));
+ size_t pos (s.rfind ('='));
// If no delimiter found then both type and base are empty.
//
@@ -237,20 +202,21 @@ namespace CXX
// Regex custom type mapping.
//
{
- Vector const& v (ops.value<CLI::custom_type_regex> ());
+ NarrowStrings const& v (ops.custom_type_regex ());
- for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i)
+ for (NarrowStrings::const_iterator i (v.begin ()),
+ e (v.end ()); i != e; ++i)
{
String s (*i);
if (s.empty ())
throw InvalidCustomTypeMapping (s, "mapping string is empty");
- WideChar delimiter (s[0]);
+ wchar_t delimiter (s[0]);
// First get pattern.
//
- Size pos (s.find (delimiter, 1));
+ size_t pos (s.find (delimiter, 1));
if (pos == String::npos)
throw InvalidCustomTypeMapping (
@@ -291,7 +257,7 @@ namespace CXX
}
regex_custom_type_map.push_back (
- RegexCustomTypeMapInfo (pat, type, base));
+ RegexCustomTypeMapInfo (WideRegexPat (pat), type, base));
}
}
}
@@ -325,6 +291,7 @@ namespace CXX
doxygen (c.doxygen),
polymorphic (c.polymorphic),
polymorphic_all (c.polymorphic_all),
+ poly_plate (c.poly_plate),
detach (c.detach),
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
@@ -366,6 +333,7 @@ namespace CXX
doxygen (c.doxygen),
polymorphic (c.polymorphic),
polymorphic_all (c.polymorphic_all),
+ poly_plate (c.poly_plate),
detach (c.detach),
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
@@ -378,7 +346,29 @@ namespace CXX
{
}
- Boolean Context::
+ void Context::
+ update_ns_scope ()
+ {
+ ns_scope.clear ();
+
+ bool first (true);
+
+ for (NamespaceStack::iterator i (ns_scope_stack.begin ());
+ i != ns_scope_stack.end ();
+ ++i)
+ {
+ // We only qualify names until the namespace level.
+ //
+ if (first)
+ first = false;
+ else
+ ns_scope += L"::";
+
+ ns_scope += *i;
+ }
+ }
+
+ bool Context::
custom_type (SemanticGraph::Type const& t, String& r) const
{
String const& name (t.name ());
@@ -386,7 +376,7 @@ namespace CXX
// First search the direct mapping.
//
{
- DirectCustomTypeMap::ConstIterator i (
+ DirectCustomTypeMap::const_iterator i (
direct_custom_type_map.find (name));
if (i != direct_custom_type_map.end ())
@@ -399,7 +389,7 @@ namespace CXX
// Second search the regex mapping.
//
- for (RegexCustomTypeMap::ConstIterator
+ for (RegexCustomTypeMap::const_iterator
i (regex_custom_type_map.begin ()),
e (regex_custom_type_map.end ());
i != e; ++i)
@@ -414,7 +404,7 @@ namespace CXX
return true;
}
- r = i->pat.merge (i->type_sub, name);
+ r = i->pat.replace (name, i->type_sub);
return true;
}
}
@@ -437,7 +427,7 @@ namespace CXX
return r;
}
- Boolean Context::
+ bool Context::
renamed_type (SemanticGraph::Type const& t, String& r) const
{
String const& name (t.name ());
@@ -445,7 +435,7 @@ namespace CXX
// First search the direct mapping.
//
{
- DirectCustomTypeMap::ConstIterator i (
+ DirectCustomTypeMap::const_iterator i (
direct_custom_type_map.find (name));
if (i != direct_custom_type_map.end ())
@@ -458,7 +448,7 @@ namespace CXX
// Second search the regex mapping.
//
- for (RegexCustomTypeMap::ConstIterator
+ for (RegexCustomTypeMap::const_iterator
i (regex_custom_type_map.begin ()),
e (regex_custom_type_map.end ());
i != e; ++i)
@@ -467,7 +457,7 @@ namespace CXX
{
if (!i->base_sub.empty ())
{
- r = i->pat.merge (i->base_sub, name);
+ r = i->pat.replace (name, i->base_sub);
}
else
r.clear ();
@@ -479,17 +469,17 @@ namespace CXX
return false;
}
- Void Context::
+ void Context::
write_annotation (SemanticGraph::Annotation& a)
{
String const& doc (a.documentation ());
- WideChar const* s (doc.c_str ());
- Size size (doc.size ());
+ wchar_t const* s (doc.c_str ());
+ size_t size (doc.size ());
// Remove leading and trailing whitespaces.
//
- while (*s == WideChar (0x20) || *s == WideChar (0x0A) ||
- *s == WideChar (0x0D) || *s == WideChar (0x09))
+ while (*s == wchar_t (0x20) || *s == wchar_t (0x0A) ||
+ *s == wchar_t (0x0D) || *s == wchar_t (0x09))
{
s++;
size--;
@@ -497,11 +487,11 @@ namespace CXX
if (size != 0)
{
- WideChar const* e (s + size - 1);
+ wchar_t const* e (s + size - 1);
while (e > s &&
- (*e == WideChar (0x20) || *e == WideChar (0x0A) ||
- *e == WideChar (0x0D) || *e == WideChar (0x09)))
+ (*e == wchar_t (0x20) || *e == wchar_t (0x0A) ||
+ *e == wchar_t (0x0D) || *e == wchar_t (0x09)))
--e;
size = s <= e ? e - s + 1 : 0;
@@ -514,15 +504,15 @@ namespace CXX
// Go over the data, forcing newline after 80 chars and adding
// ' * ' after each new line.
//
- WideChar const* last_space (0);
- WideChar const* b (s);
- WideChar const* e (s);
- Boolean after_newline (false);
- Boolean rogue (false);
+ wchar_t const* last_space (0);
+ wchar_t const* b (s);
+ wchar_t const* e (s);
+ bool after_newline (false);
+ bool rogue (false);
for (; e < s + size; ++e)
{
- UnsignedLong u (unicode_char (e)); // May advance e.
+ unsigned int u (unicode_char (e)); // May advance e.
// We are going to treat \v and \f as rogue here even though
// they can be present in C++ source code.
@@ -579,16 +569,16 @@ namespace CXX
}
}
- Void Context::
- write_rogue_text (WideChar const* s, Size size, Boolean rogue)
+ void Context::
+ write_rogue_text (wchar_t const* s, size_t size, bool rogue)
{
if (!rogue)
os.write (s, size);
else
{
- for (WideChar const* p (s); p < s + size; ++p)
+ for (wchar_t const* p (s); p < s + size; ++p)
{
- UnsignedLong u (unicode_char (p)); // May advance p.
+ unsigned int u (unicode_char (p)); // May advance p.
// We are going to treat \v and \f as rogue here even though
// they can be present in C++ source code.
@@ -596,36 +586,69 @@ namespace CXX
if (u > 127 || (u < 32 && u != '\t' && u != '\n'))
os.put ('?');
else
- os.put (static_cast<WideChar> (u));
+ os.put (static_cast<wchar_t> (u));
}
}
}
- Boolean Context::
+ bool Context::
polymorphic_p (SemanticGraph::Type& t)
{
+ // IDREF templates cannot be polymorphic.
+ //
+ if (!t.named_p () &&
+ (t.is_a<SemanticGraph::Fundamental::IdRef> () ||
+ t.is_a<SemanticGraph::Fundamental::IdRefs> ()))
+ return false;
+
if (polymorphic_all)
{
- Boolean fund (false);
+ bool fund (false);
IsFundamentalType test (fund);
test.dispatch (t);
return !fund;
}
else
- return t.context ().get<Boolean> ("polymorphic");
+ return t.context ().get<bool> ("polymorphic");
+ }
+
+ bool Context::
+ anonymous_substitutes_p (SemanticGraph::Type& t)
+ {
+ // IDREF templates cannot match.
+ //
+ if (!t.named_p () &&
+ (t.is_a<SemanticGraph::Fundamental::IdRef> () ||
+ t.is_a<SemanticGraph::Fundamental::IdRefs> ()))
+ return false;
+
+ // See which elements this type classifies.
+ //
+ for (SemanticGraph::Type::ClassifiesIterator i (t.classifies_begin ()),
+ e (t.classifies_end ()); i != e; ++i)
+ {
+ if (SemanticGraph::Element* e =
+ dynamic_cast<SemanticGraph::Element*> (&i->instance ()))
+ {
+ if (e->substitutes_p ())
+ return true;
+ }
+ }
+
+ return false;
}
// GenerateDefautCtor
//
GenerateDefaultCtor::
- GenerateDefaultCtor (Context& c, Boolean& generate, Boolean no_base)
+ GenerateDefaultCtor (Context& c, bool& generate, bool no_base)
: Context (c), generate_ (generate), no_base_ (no_base)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Complex& c)
{
// Make sure we figure out if we have any required members before
@@ -637,38 +660,38 @@ namespace CXX
Complex::inherits (c, inherits_);
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Type&)
{
if (!no_base_)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Enumeration&)
{
if (!no_base_)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Attribute& a)
{
if (min (a) == 1 && !a.fixed_p ())
generate_ = true;
}
- Void GenerateDefaultCtor::
+ void GenerateDefaultCtor::
traverse (SemanticGraph::Any& a)
{
- if (options.value<CLI::generate_wildcard> () &&
+ if (options.generate_wildcard () &&
min (a) == 1 && max (a) == 1)
generate_ = true;
}
@@ -677,7 +700,7 @@ namespace CXX
// GenerateFromBaseCtor
//
GenerateFromBaseCtor::
- GenerateFromBaseCtor (Context& c, Boolean& generate)
+ GenerateFromBaseCtor (Context& c, bool& generate)
: generate_ (generate),
custom_ (false),
traverser_ (c, generate, custom_)
@@ -685,7 +708,7 @@ namespace CXX
inherits_ >> traverser_;
}
- Void GenerateFromBaseCtor::
+ void GenerateFromBaseCtor::
traverse (SemanticGraph::Complex& c)
{
inherits (c, inherits_);
@@ -703,14 +726,14 @@ namespace CXX
}
GenerateFromBaseCtor::Traverser::
- Traverser (Context& c, Boolean& generate, Boolean& custom)
+ Traverser (Context& c, bool& generate, bool& custom)
: Context (c), generate_ (generate), custom_ (custom)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Type& t)
{
if (!custom_)
@@ -720,7 +743,7 @@ namespace CXX
}
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Complex& c)
{
names (c, names_);
@@ -732,24 +755,24 @@ namespace CXX
traverse (static_cast<SemanticGraph::Type&> (c));
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
generate_ = true;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Attribute& a)
{
if (min (a) == 1 && !a.fixed_p ())
generate_ = true;
}
- Void GenerateFromBaseCtor::Traverser::
+ void GenerateFromBaseCtor::Traverser::
traverse (SemanticGraph::Any& a)
{
- if (options.value<CLI::generate_wildcard> () &&
+ if (options.generate_wildcard () &&
min (a) == 1 && max (a) == 1)
generate_ = true;
}
@@ -758,10 +781,10 @@ namespace CXX
//
HasComplexPolyNonOptArgs::
HasComplexPolyNonOptArgs (Context& c,
- Boolean base,
- Boolean& complex,
- Boolean& poly,
- Boolean& clash)
+ bool base,
+ bool& complex,
+ bool& poly,
+ bool& clash)
: Context (c),
complex_ (complex),
poly_ (poly),
@@ -773,7 +796,7 @@ namespace CXX
*this >> names_ >> *this;
}
- Void HasComplexPolyNonOptArgs::
+ void HasComplexPolyNonOptArgs::
traverse (SemanticGraph::Complex& c)
{
// No optimizations: need to check every arg for clashes.
@@ -782,14 +805,14 @@ namespace CXX
names (c, names_);
}
- Void HasComplexPolyNonOptArgs::
+ void HasComplexPolyNonOptArgs::
traverse (SemanticGraph::Element& e)
{
if (!skip (e) && min (e) == 1 && max (e) == 1)
{
- Boolean poly (polymorphic && polymorphic_p (e.type ()));
+ bool poly (polymorphic && polymorphic_p (e.type ()));
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
@@ -807,15 +830,15 @@ namespace CXX
// FromBaseCtorArg
//
FromBaseCtorArg::
- FromBaseCtorArg (Context& c, ArgType at, Boolean arg)
+ FromBaseCtorArg (Context& c, CtorArgType at, bool arg)
: Context (c), arg_type_ (at), arg_ (arg)
{
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -830,7 +853,7 @@ namespace CXX
}
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -842,29 +865,29 @@ namespace CXX
os << "," << endl;
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << auto_ptr << "< " << etype (e) << " >";
else
os << "const " << etype (e) << "&";
@@ -873,7 +896,7 @@ namespace CXX
}
}
- Void FromBaseCtorArg::
+ void FromBaseCtorArg::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -895,7 +918,7 @@ namespace CXX
// CtorArgs
//
CtorArgs::
- CtorArgs (Context& c, ArgType at)
+ CtorArgs (Context& c, CtorArgType at)
: Context (c),
arg_type_ (at),
base_arg_ (0),
@@ -907,7 +930,7 @@ namespace CXX
}
CtorArgs::
- CtorArgs (Context& c, ArgType at, String& base_arg)
+ CtorArgs (Context& c, CtorArgType at, String& base_arg)
: Context (c),
arg_type_ (at),
base_arg_ (&base_arg),
@@ -918,7 +941,7 @@ namespace CXX
*this >> names_ >> *this;
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Type& t)
{
os << comma () << "const ";
@@ -929,13 +952,17 @@ namespace CXX
if (base_arg_ != 0)
{
- *base_arg_ = L"_xsd_" + ename (t) + L"_base";
+ // IDREF templates don't have a name.
+ //
+ *base_arg_ = t.named_p ()
+ ? (L"_xsd_" + ename (t) + L"_base")
+ : L"_xsd_base";
os << " " << *base_arg_;
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Enumeration& e)
{
os << comma () << "const ";
@@ -952,10 +979,10 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -967,7 +994,7 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -975,29 +1002,29 @@ namespace CXX
if (min (e) == 1 && max (e) == 1)
{
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << comma () << auto_ptr << "< " << etype (e) << " >";
else
os << comma () << "const " << etype (e) << "&";
@@ -1006,7 +1033,7 @@ namespace CXX
}
}
- Void CtorArgs::
+ void CtorArgs::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -1025,7 +1052,7 @@ namespace CXX
String CtorArgs::
comma ()
{
- Boolean tmp (first_);
+ bool tmp (first_);
first_ = false;
return tmp ? "" : ",\n";
}
@@ -1034,17 +1061,17 @@ namespace CXX
// CtorArgsWithoutBase
//
CtorArgsWithoutBase::
- CtorArgsWithoutBase (Context& c, ArgType at, Boolean arg, Boolean first)
+ CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first)
: Context (c), arg_type_ (at), arg_ (arg), first_ (first)
{
*this >> inherits_ >> *this;
*this >> names_ >> *this;
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Any& a)
{
- if (!options.value<CLI::generate_wildcard> ())
+ if (!options.generate_wildcard ())
return;
if (min (a) == 1 && max (a) == 1)
@@ -1056,7 +1083,7 @@ namespace CXX
}
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Element& e)
{
if (skip (e))
@@ -1064,29 +1091,29 @@ namespace CXX
if (min (e) == 1 && max (e) == 1)
{
- Boolean auto_ptr (false);
+ bool ptr (false);
switch (arg_type_)
{
- case arg_complex_auto_ptr:
+ case CtorArgType::complex_auto_ptr:
{
- Boolean simple (true);
+ bool simple (true);
IsSimpleType t (simple);
t.dispatch (e.type ());
- auto_ptr = !simple;
+ ptr = !simple;
break;
}
- case arg_poly_auto_ptr:
+ case CtorArgType::poly_auto_ptr:
{
- auto_ptr = polymorphic && polymorphic_p (e.type ());
+ ptr = polymorphic && polymorphic_p (e.type ());
break;
}
- case arg_type:
+ case CtorArgType::type:
break;
}
- if (auto_ptr)
- os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+ if (ptr)
+ os << comma () << auto_ptr << "< " << etype (e) << " >";
else
os << comma () << "const " << etype (e) << "&";
@@ -1095,7 +1122,7 @@ namespace CXX
}
}
- Void CtorArgsWithoutBase::
+ void CtorArgsWithoutBase::
traverse (SemanticGraph::Attribute& a)
{
// Note that we are not going to include attributes with
@@ -1114,14 +1141,14 @@ namespace CXX
String CtorArgsWithoutBase::
comma ()
{
- Boolean tmp (first_);
+ bool tmp (first_);
first_ = false;
return tmp ? "" : ",\n";
}
// GlobalElementBase
//
- Boolean GlobalElementBase::
+ bool GlobalElementBase::
generate_p (SemanticGraph::Element& e)
{
if (e.substitutes_p () && ctx_.polymorphic)
@@ -1133,44 +1160,44 @@ namespace CXX
// If we are not generating element types nor parsing/serialization
// code then we won't generate anything from it.
//
- if (!ctx_.options.value<CLI::generate_element_type> () &&
- ctx_.options.value<CLI::suppress_parsing> () &&
- !ctx_.options.value<CLI::generate_serialization> ())
+ if (!ctx_.options.generate_element_type () &&
+ ctx_.options.suppress_parsing () &&
+ !ctx_.options.generate_serialization ())
return false;
return true;
}
- Boolean GlobalElementBase::
+ bool GlobalElementBase::
doc_root_p (SemanticGraph::Element& e)
{
- if (!ctx_.options.value<CLI::root_element_first> () &&
- !ctx_.options.value<CLI::root_element_last> () &&
- !ctx_.options.value<CLI::root_element_all> () &&
- !ctx_.options.value<CLI::root_element_none> () &&
- ctx_.options.value<CLI::root_element> ().empty ())
+ if (!ctx_.options.root_element_first () &&
+ !ctx_.options.root_element_last () &&
+ !ctx_.options.root_element_all () &&
+ !ctx_.options.root_element_none () &&
+ ctx_.options.root_element ().empty ())
return true; // By default treat them all.
- if (ctx_.options.value<CLI::root_element_none> ())
+ if (ctx_.options.root_element_none ())
return false;
- if (ctx_.options.value<CLI::root_element_all> ())
+ if (ctx_.options.root_element_all ())
return true;
- if (ctx_.options.value<CLI::root_element_first> () &&
+ if (ctx_.options.root_element_first () &&
e.context ().count ("first") != 0)
return true;
- if (ctx_.options.value<CLI::root_element_last> () &&
+ if (ctx_.options.root_element_last () &&
e.context ().count ("last") != 0)
return true;
- typedef Cult::Containers::Vector<NarrowString> Names;
- Names const& names (ctx_.options.value<CLI::root_element> ());
+ NarrowStrings const& names (ctx_.options.root_element ());
// Hopefully nobody will specify more than a handful of names ;-).
//
- for (Names::ConstIterator i (names.begin ()); i != names.end (); ++i)
+ for (NarrowStrings::const_iterator i (names.begin ());
+ i != names.end (); ++i)
{
String name (*i);
@@ -1185,8 +1212,8 @@ namespace CXX
//
Namespace::
Namespace (Context& c,
- UnsignedLong first,
- UnsignedLong last)
+ size_t first,
+ size_t last)
: CXX::Namespace (c, *this),
GlobalElementBase (c),
ctx_ (c),
@@ -1196,7 +1223,7 @@ namespace CXX
{
}
- Void Namespace::
+ void Namespace::
traverse (Type& ns)
{
using SemanticGraph::Element;
@@ -1205,7 +1232,7 @@ namespace CXX
CXX::Namespace::traverse (ns);
else
{
- Boolean opened (false);
+ bool opened (false);
for (Type::NamesIterator i (ns.names_begin ());
i != ns.names_end (); ++i)
@@ -1235,13 +1262,13 @@ namespace CXX
}
}
- Void Namespace::
- enter (Type&, String const& name, Boolean)
+ void Namespace::
+ enter (Type&, String const& name, bool)
{
ctx_.enter_ns_scope (name);
}
- Void Namespace::
+ void Namespace::
leave ()
{
ctx_.leave_ns_scope ();
@@ -1249,7 +1276,7 @@ namespace CXX
// Includes
//
- Void TypeForward::
+ void TypeForward::
traverse (SemanticGraph::Type& t)
{
String const& name (ename (t));
@@ -1271,14 +1298,14 @@ namespace CXX
os << "class " << name << ";";
}
- Void Includes::
+ void Includes::
traverse_ (SemanticGraph::Uses& u)
{
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
Type t (type_);
- Boolean weak (u.context ().count ("weak"));
+ bool weak (u.context ().count ("weak"));
SemanticGraph::Schema& s (u.schema ());
if (weak && t == header)
@@ -1301,6 +1328,7 @@ namespace CXX
s.context ().count ("renamed")
? s.context ().get<SemanticGraph::Path> ("renamed")
: u.path ());
+ path.normalize ();
// Try to use the portable representation of the path. If that
// fails, fall back to the native representation.
@@ -1308,15 +1336,11 @@ namespace CXX
NarrowString path_str;
try
{
- path_str = path.string ();
+ path_str = path.posix_string ();
}
catch (SemanticGraph::InvalidPath const&)
{
-#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
- path_str = path.native_file_string ();
-#else
path_str = path.string ();
-#endif
}
String inc_path;
@@ -1325,25 +1349,25 @@ namespace CXX
{
case forward:
{
- inc_path = ctx_.fwd_expr->merge (path_str);
+ inc_path = ctx_.fwd_expr->replace (path_str);
break;
}
case header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
break;
}
case inline_:
{
if (weak)
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = ctx_.hxx_expr->replace (path_str);
ctx_.os << "#include " << ctx_.process_include_path (inc_path)
<< endl;
}
- inc_path = ctx_.ixx_expr->merge (path_str);
+ inc_path = ctx_.ixx_expr->replace (path_str);
break;
}
}