diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
commit | bada6666c70977a058755ccf232e7d67b24adeed (patch) | |
tree | 1e92d50cebce96abaf9bce19e36026c47f77b9ba /xsd/xsd/cxx/parser/type-processor.cxx | |
parent | eaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff) |
New upstream release
Diffstat (limited to 'xsd/xsd/cxx/parser/type-processor.cxx')
-rw-r--r-- | xsd/xsd/cxx/parser/type-processor.cxx | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/xsd/xsd/cxx/parser/type-processor.cxx b/xsd/xsd/cxx/parser/type-processor.cxx index 4744c0a..2f1132c 100644 --- a/xsd/xsd/cxx/parser/type-processor.cxx +++ b/xsd/xsd/cxx/parser/type-processor.cxx @@ -1,9 +1,8 @@ // file : xsd/cxx/parser/type-processor.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <cult/containers/set.hxx> +#include <set> #include <cxx/parser/elements.hxx> #include <cxx/parser/type-processor.hxx> @@ -11,16 +10,12 @@ #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> +using namespace std; + namespace CXX { namespace Parser { - TypeProcessor:: - TypeProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // @@ -29,14 +24,14 @@ namespace CXX { Type (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : schema_ (schema), type_map_ (type_map), add_includes_ (add_includes) { } - virtual Void + virtual void traverse (SemanticGraph::Type& type) { using TypeMap::Namespace; @@ -54,7 +49,7 @@ namespace CXX // match the type in order to add include directives to the // new root schema. // - Boolean set (true); + bool set (true); if (tc.count ("ret-type")) { @@ -73,14 +68,14 @@ namespace CXX String ns_name (ns.name ()); String t_name (type.name ()); - // std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; + //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; - for (Namespaces::ConstIterator n (type_map_.begin ()); + for (Namespaces::const_iterator n (type_map_.begin ()); n != type_map_.end (); ++n) { // Check if the namespace matches. // - Boolean ns_match; + bool ns_match; if (!n->xsd_name ().empty ()) { @@ -89,7 +84,9 @@ namespace CXX else ns_match = ns_name.empty (); - // std::wcerr << "considering ns expr: " << n->xsd_name () << endl; + //std::wcerr << "considering ns expr: " << n->xsd_name () + // << " for " << ns_name + // << ": " << (ns_match ? "+" : "-") << endl; if (ns_match) { @@ -111,8 +108,8 @@ namespace CXX { if (!n->xsd_name ().empty ()) { - cxx_ns = n->xsd_name ().merge ( - n->cxx_name (), ns_name, true); + cxx_ns = n->xsd_name ().replace ( + ns_name, n->cxx_name (), true); } else cxx_ns = n->cxx_name (); @@ -124,16 +121,16 @@ namespace CXX // String ret_type (cxx_ns); - ret_type += t->xsd_name ().merge ( - t->cxx_ret_name (), t_name, true); + ret_type += t->xsd_name ().replace ( + t_name, t->cxx_ret_name (), true); String arg_type; if (t->cxx_arg_name ()) { arg_type = cxx_ns; - arg_type += t->xsd_name ().merge ( - t->cxx_arg_name (), t_name, true); + arg_type += t->xsd_name ().replace ( + t_name, t->cxx_arg_name (), true); } else { @@ -141,7 +138,7 @@ namespace CXX arg_type = ret_type; else { - WideChar last (ret_type[ret_type.size () - 1]); + wchar_t last (ret_type[ret_type.size () - 1]); // If it is already a pointer or reference then use // it as is. @@ -155,12 +152,12 @@ namespace CXX tc.set ("ret-type", ret_type); tc.set ("arg-type", arg_type); + + //std::wcerr << t_name << " -> " << ret_type << endl; } tc.set ("root-schema", &schema_); - //std::wcerr << t_name << " -> " << ret_type << endl; - // See of we need to add any includes to the translations // unit. // @@ -168,7 +165,7 @@ namespace CXX { if (n->includes_begin () != n->includes_end ()) { - typedef Cult::Containers::Set<String> Includes; + typedef std::set<String> Includes; if (!schema_.context ().count ("includes")) schema_.context ().set ("includes", Includes ()); @@ -194,7 +191,7 @@ namespace CXX private: SemanticGraph::Schema& schema_; TypeMap::Namespaces& type_map_; - Boolean add_includes_; + bool add_includes_; }; @@ -207,7 +204,7 @@ namespace CXX { GlobalType (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : type_ (schema, type_map, add_includes) { inherits_ >> type_; @@ -215,20 +212,20 @@ namespace CXX argumented_ >> type_; } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { type_.traverse (t); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { type_.traverse (l); Traversal::List::argumented (l, argumented_); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { type_.traverse (c); @@ -236,7 +233,7 @@ namespace CXX Complex::names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::Enumeration& e) { type_.traverse (e); @@ -252,10 +249,10 @@ namespace CXX Traversal::Argumented argumented_; }; - Void - process_impl (CLI::Options const& options, + void + process_impl (options const& ops, XSDFrontend::SemanticGraph::Schema& tu, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& type_map) { if (tu.names_begin ()->named ().name () == @@ -279,14 +276,13 @@ namespace CXX // If --extern-xml-schema is specified, then we don't want // includes from the XML Schema type map. // - Boolean extern_xml_schema ( - options.value<CLI::extern_xml_schema> ()); + bool extern_xml_schema (ops.extern_xml_schema ()); // // Traversal::Schema schema; Traversal::Schema xs_schema; - Traversal::Sources sources; + Sources sources; Traversal::Implies implies; schema >> sources >> schema; @@ -312,7 +308,7 @@ namespace CXX // If we are generating the test driver, make sure the root // element type is processed. // - if (gen_driver && options.value<CLI::generate_test_driver> ()) + if (gen_driver && ops.generate_test_driver ()) { // Figure out the root element. Validator should have made sure // it is unique. @@ -320,14 +316,14 @@ namespace CXX SemanticGraph::Element* root (0); { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; Traversal::Names schema_names; Traversal::Namespace ns; Traversal::Names ns_names; - RootElement root_element (options, root); + RootElement root_element (ops, root); schema >> schema_names >> ns >> ns_names >> root_element; @@ -340,13 +336,13 @@ namespace CXX } } - Void TypeProcessor:: - process (CLI::Options const& options, + void TypeProcessor:: + process (options const& ops, XSDFrontend::SemanticGraph::Schema& s, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& tm) { - process_impl (options, s, gen_driver, tm); + process_impl (ops, s, gen_driver, tm); } } } |