From 6bf1e46ccc93777ca9f62746ada0e18c72fcf138 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 May 2012 11:50:57 +0200 Subject: Port to use regex from libcutl instead of libbackend-elements --- xsd/cxx/parser/elements.cxx | 4 ++-- xsd/cxx/parser/elements.hxx | 4 ++-- xsd/cxx/parser/generator.cxx | 43 ++++++++++++++++++++------------------- xsd/cxx/parser/parser-header.cxx | 2 +- xsd/cxx/parser/type-processor.cxx | 22 +++++++++++--------- 5 files changed, 39 insertions(+), 36 deletions(-) (limited to 'xsd/cxx/parser') diff --git a/xsd/cxx/parser/elements.cxx b/xsd/cxx/parser/elements.cxx index 585d42c..94baa28 100644 --- a/xsd/cxx/parser/elements.cxx +++ b/xsd/cxx/parser/elements.cxx @@ -248,12 +248,12 @@ namespace CXX case header: case source: { - inc_path = ctx_.hxx_expr->merge (path_str); + inc_path = ctx_.hxx_expr->replace (path_str); break; } case impl_header: { - inc_path = ctx_.hxx_impl_expr->merge (path_str); + inc_path = ctx_.hxx_impl_expr->replace (path_str); break; } } diff --git a/xsd/cxx/parser/elements.hxx b/xsd/cxx/parser/elements.hxx index edcd9f2..d8cedd8 100644 --- a/xsd/cxx/parser/elements.hxx +++ b/xsd/cxx/parser/elements.hxx @@ -8,7 +8,7 @@ #include -#include +#include #include @@ -33,7 +33,7 @@ namespace CXX class Context: public CXX::Context { public: - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; public: Context (std::wostream&, diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx index 1a121cd..998c480 100644 --- a/xsd/cxx/parser/generator.cxx +++ b/xsd/cxx/parser/generator.cxx @@ -7,6 +7,8 @@ #include +#include + #include #include @@ -14,7 +16,6 @@ #include #include -#include #include #include @@ -626,7 +627,7 @@ namespace CXX using std::ios_base; namespace Indentation = BackendElements::Indentation; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { @@ -795,7 +796,7 @@ namespace CXX type_map.push_back (xsd); - // Everyhting else maps to void. + // Everything else maps to void. // TypeMap::Namespace rest (".*"); rest.types_push_back (".*", "void", "void"); @@ -861,7 +862,7 @@ namespace CXX if (!hxx_expr.match (name)) { wcerr << "error: header expression '" << - hxx_expr.pattern () << "' does not match '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -869,7 +870,7 @@ namespace CXX if (inline_ && !ixx_expr.match (name)) { wcerr << "error: inline expression '" << - ixx_expr.pattern () << "' does not match '" << + ixx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -877,7 +878,7 @@ namespace CXX if (source && !cxx_expr.match (name)) { wcerr << "error: source expression '" << - cxx_expr.pattern () << "' does not match '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -887,7 +888,7 @@ namespace CXX if (!hxx_impl_expr.match (name)) { wcerr << "error: implementation header expression '" << - hxx_impl_expr.pattern () << "' does not match '" << + hxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -895,7 +896,7 @@ namespace CXX if (!cxx_impl_expr.match (name)) { wcerr << "error: implementation source expression '" << - cxx_impl_expr.pattern () << "' does not match '" << + cxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -903,15 +904,15 @@ namespace CXX if (!cxx_driver_expr.match (name)) { wcerr << "error: driver source expression '" << - cxx_driver_expr.pattern () << "' does not match '" << + cxx_driver_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } } - NarrowString hxx_name (hxx_expr.merge (name)); - NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ()); - NarrowString cxx_name (source ? cxx_expr.merge (name) : NarrowString ()); + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); + NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ()); NarrowString hxx_impl_name; NarrowString cxx_impl_name; @@ -919,9 +920,9 @@ namespace CXX if (impl || driver) { - hxx_impl_name = hxx_impl_expr.merge (name); - cxx_impl_name = cxx_impl_expr.merge (name); - cxx_driver_name = cxx_driver_expr.merge (name); + hxx_impl_name = hxx_impl_expr.replace (name); + cxx_impl_name = cxx_impl_expr.replace (name); + cxx_driver_name = cxx_driver_expr.replace (name); } Path hxx_path (hxx_name, boost::filesystem::native); @@ -1198,7 +1199,7 @@ namespace CXX sloc_filter sloc (hxx); - String guard (guard_expr.merge (guard_prefix + hxx_name)); + String guard (guard_expr.replace (guard_prefix + hxx_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1406,7 +1407,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - String guard (guard_expr.merge (guard_prefix + hxx_impl_name)); + String guard (guard_expr.replace (guard_prefix + hxx_impl_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1501,18 +1502,18 @@ namespace CXX throw Failed (); } - catch (BackendElements::Regex::Format const& e) + catch (cutl::re::format const& e) { wcerr << "error: invalid regex: '" << - e.expression ().c_str () << "': " << + e.regex ().c_str () << "': " << e.description ().c_str () << endl; throw Failed (); } - catch (BackendElements::Regex::Format const& e) + catch (cutl::re::wformat const& e) { wcerr << "error: invalid regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } diff --git a/xsd/cxx/parser/parser-header.cxx b/xsd/cxx/parser/parser-header.cxx index 1dd01b2..2490a26 100644 --- a/xsd/cxx/parser/parser-header.cxx +++ b/xsd/cxx/parser/parser-header.cxx @@ -1298,7 +1298,7 @@ namespace CXX if (extern_xml_schema) { - String name (ctx.hxx_expr->merge (extern_xml_schema)); + String name (ctx.hxx_expr->replace (extern_xml_schema)); ctx.os << "#include " << ctx.process_include_path (name) << endl << endl; diff --git a/xsd/cxx/parser/type-processor.cxx b/xsd/cxx/parser/type-processor.cxx index 2207a10..db3e45b 100644 --- a/xsd/cxx/parser/type-processor.cxx +++ b/xsd/cxx/parser/type-processor.cxx @@ -73,7 +73,7 @@ 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 ()); n != type_map_.end (); ++n) @@ -89,7 +89,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 +113,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 +126,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 { @@ -155,12 +157,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. // -- cgit v1.1