From 713324411804114f2699c6c127c659345d7359d5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 May 2012 11:52:59 +0200 Subject: Port to use regex from libcutl instead of libbackend-elements --- build/import/libboost/regex/rules.make | 50 -------------------- build/import/libboost/regex/stub.make | 36 --------------- xsde/cxx/elements.cxx | 22 ++++----- xsde/cxx/elements.hxx | 8 ++-- xsde/cxx/hybrid/aggregate-include.hxx | 2 +- xsde/cxx/hybrid/elements.cxx | 8 ++-- xsde/cxx/hybrid/elements.hxx | 6 +-- xsde/cxx/hybrid/generator.cxx | 77 ++++++++++++++++--------------- xsde/cxx/hybrid/tree-forward.cxx | 2 +- xsde/cxx/parser/elements.cxx | 4 +- xsde/cxx/parser/elements.hxx | 4 +- xsde/cxx/parser/generator.cxx | 41 ++++++++-------- xsde/cxx/parser/parser-header.cxx | 2 +- xsde/cxx/parser/type-processor.cxx | 12 ++--- xsde/cxx/serializer/elements.cxx | 4 +- xsde/cxx/serializer/elements.hxx | 4 +- xsde/cxx/serializer/generator.cxx | 41 ++++++++-------- xsde/cxx/serializer/serializer-header.cxx | 2 +- xsde/cxx/serializer/type-processor.cxx | 17 +++---- xsde/makefile | 9 +--- xsde/type-map/parser.cxx | 8 ++-- xsde/type-map/type-map.hxx | 29 ++++++++++-- xsde/xsde.cxx | 48 ++++++++++--------- 23 files changed, 182 insertions(+), 254 deletions(-) delete mode 100644 build/import/libboost/regex/rules.make delete mode 100644 build/import/libboost/regex/stub.make diff --git a/build/import/libboost/regex/rules.make b/build/import/libboost/regex/rules.make deleted file mode 100644 index 3c85243..0000000 --- a/build/import/libboost/regex/rules.make +++ /dev/null @@ -1,50 +0,0 @@ -# file : build/import/libboost/regex/rules.make -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2011 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libboost/%: root := $(libboost_root) - -$(dcf_root)/import/libboost/regex/regex.l: \ - | $(dcf_root)/import/libboost/regex/. - -ifeq ($(libboost_type),archive) - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/regex/regex.l: \ - $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).a \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).a -else -$(dcf_root)/import/libboost/regex/regex.l: \ - $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).a -endif - @echo $^ >$@ - -else - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/regex/regex.l: \ - $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).so \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).so -else -$(dcf_root)/import/libboost/regex/regex.l: \ - $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).so -endif - @echo $^ >$@ - @echo rpath:$(root)/stage/lib >>$@ - -endif - - -$(dcf_root)/import/libboost/regex/regex.l.cpp-options: \ - | $(dcf_root)/import/libboost/regex/. - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libboost/regex/regex.l,\ -rm -f $(dcf_root)/import/libboost/regex/regex.l) - $(call message,,rm -f $(dcf_root)/import/libboost/regex/regex.l.cpp-options) - -endif diff --git a/build/import/libboost/regex/stub.make b/build/import/libboost/regex/stub.make deleted file mode 100644 index 9c02508..0000000 --- a/build/import/libboost/regex/stub.make +++ /dev/null @@ -1,36 +0,0 @@ -# file : build/import/libboost/regex/stub.make -# author : Boris Kolpackov -# copyright : Copyright (c) 2005-2011 Boris Kolpackov -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libboost/configuration-rules.make,$(dcf_root)) - -libboost_installed := - -$(call -include,$(dcf_root)/import/libboost/configuration-dynamic.make) - -ifdef libboost_installed - -ifeq ($(libboost_installed),y) - -ifeq ($(libboost_system),y) -$(call export,l: -lboost_regex$(libboost_suffix) -lboost_system$(libboost_suffix),cpp_options: ) -else -$(call export,l: -lboost_regex$(libboost_suffix),cpp_options: ) -endif - -else - -$(call include-once,$(scf_root)/import/libboost/regex/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libboost/regex/regex.l,\ - cpp-options: $(dcf_root)/import/libboost/regex/regex.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx index ba93854..cc41e08 100644 --- a/xsde/cxx/elements.cxx +++ b/xsde/cxx/elements.cxx @@ -5,8 +5,6 @@ #include -#include - #include // std::toupper #include #include @@ -211,7 +209,7 @@ namespace CXX for (Containers::Vector::ConstIterator i (nsr.begin ()), e (nsr.end ()); i != e; ++i) { - nsr_mapping_.push_back (Regex (*i)); + nsr_mapping_.push_back (Regex (String (*i))); } // Custom direct mapping. @@ -244,7 +242,7 @@ namespace CXX for (Containers::Vector::ConstIterator i (ir.begin ()), e (ir.end ()); i != e; ++i) { - include_mapping_.push_back (Regex (*i)); + include_mapping_.push_back (Regex (String (*i))); } // Reserved names. @@ -345,12 +343,12 @@ namespace CXX e != nsr_mapping.rend (); ++e) { if (trace_namespace_regex) - wcerr << "try: '" << e->pattern () << "' : "; + wcerr << "try: '" << e->regex () << "' : "; if (e->match (pair)) { - tmp = e->merge (pair); - tmp = colon.merge (tmp); // replace `/' with `::' + tmp = e->replace (pair); + tmp = colon.replace (tmp); // replace `/' with `::' // Check the result. // @@ -381,7 +379,7 @@ namespace CXX } else { - tmp = colon.merge (n); // replace `/' with `::' + tmp = colon.replace (n); // replace `/' with `::' if (!cxx_id_expr.match (tmp)) { @@ -390,8 +388,8 @@ namespace CXX if (urn_mapping.match (n)) { Regex filter (L"#[.:-]#_#"); - tmp = urn_mapping.merge (n); - tmp = filter.merge (tmp); + tmp = urn_mapping.replace (n); + tmp = filter.replace (tmp); if (!cxx_id_expr.match (tmp)) throw NoNamespaceMapping ( @@ -1120,11 +1118,11 @@ namespace CXX e != include_mapping.rend (); ++e) { if (trace_include_regex) - wcerr << "try: '" << e->pattern () << "' : "; + wcerr << "try: '" << e->regex () << "' : "; if (e->match (path)) { - r = e->merge (path); + r = e->replace (path); found = true; if (trace_include_regex) diff --git a/xsde/cxx/elements.hxx b/xsde/cxx/elements.hxx index 2816fea..02b72eb 100644 --- a/xsde/cxx/elements.hxx +++ b/xsde/cxx/elements.hxx @@ -6,13 +6,13 @@ #ifndef CXX_ELEMENTS_HXX #define CXX_ELEMENTS_HXX +#include + #include #include #include #include -#include - #include #include @@ -135,8 +135,8 @@ namespace CXX class Context { public: - typedef BackendElements::Regex::Pattern RegexPat; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::wregex RegexPat; + typedef cutl::re::wregexsub Regex; typedef Cult::Containers::Vector RegexMapping; typedef Cult::Containers::Map MapMapping; typedef Cult::Containers::Map MappingCache; diff --git a/xsde/cxx/hybrid/aggregate-include.hxx b/xsde/cxx/hybrid/aggregate-include.hxx index 5567244..03a5198 100644 --- a/xsde/cxx/hybrid/aggregate-include.hxx +++ b/xsde/cxx/hybrid/aggregate-include.hxx @@ -166,7 +166,7 @@ namespace CXX path_str = path.native_file_string (); } - String inc_path (hxx_expr->merge (path_str)); + String inc_path (hxx_expr->replace (path_str)); os << "#include " << process_include_path (inc_path) << endl << endl; } diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index e94d10f..337e15f 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -630,26 +630,26 @@ namespace CXX { case forward: { - inc_path = (regex_ ? regex_ : ctx_.fwd_expr)->merge (path_str); + inc_path = (regex_ ? regex_ : ctx_.fwd_expr)->replace (path_str); break; } case header: case impl_header: case source: { - inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->merge (path_str); + inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->replace (path_str); break; } case inline_: { if (weak) { - inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->merge (path_str); + inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->replace (path_str); ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl; } - inc_path = (regex_ ? regex_ : ctx_.ixx_expr)->merge (path_str); + inc_path = (regex_ ? regex_ : ctx_.ixx_expr)->replace (path_str); break; } } diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx index 804d178..45fe671 100644 --- a/xsde/cxx/hybrid/elements.hxx +++ b/xsde/cxx/hybrid/elements.hxx @@ -8,9 +8,9 @@ #include -#include +#include -#include +#include #include @@ -20,7 +20,7 @@ namespace CXX { namespace Hybrid { - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; // // diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx index e71d36a..4db77ea 100644 --- a/xsde/cxx/hybrid/generator.cxx +++ b/xsde/cxx/hybrid/generator.cxx @@ -8,6 +8,8 @@ #include +#include + #include #include @@ -15,7 +17,6 @@ #include #include -#include #include #include @@ -1356,7 +1357,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 (); } @@ -1364,7 +1365,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 (); } @@ -1372,7 +1373,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 (); } @@ -1380,15 +1381,15 @@ namespace CXX if (forward && !fwd_expr.match (name)) { wcerr << "error: forward expression '" << - fwd_expr.pattern () << "' does not match '" << + fwd_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 fwd_name (forward ? fwd_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 fwd_name (forward ? fwd_expr.replace (name) : NarrowString ()); Path hxx_path (hxx_name, boost::filesystem::native); Path ixx_path (ixx_name, boost::filesystem::native); @@ -1557,7 +1558,7 @@ namespace CXX sloc_filter sloc (fwd); - String guard (guard_expr.merge (guard_prefix + fwd_name)); + String guard (guard_expr.replace (guard_prefix + fwd_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1641,7 +1642,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); @@ -1854,7 +1855,7 @@ namespace CXX // Guard // - String guard (guard_expr.merge (guard_prefix + ixx_name)); + String guard (guard_expr.replace (guard_prefix + ixx_name)); guard = ctx.escape (guard); // make a c++ id std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -2037,18 +2038,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 (); } @@ -2064,7 +2065,7 @@ namespace CXX AutoUnlinks& unlinks) { using std::ios_base; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { @@ -2145,7 +2146,7 @@ namespace CXX if (!hxx_expr.match (name)) { wcerr << "error: parser implementation header expression '" << - hxx_expr.pattern () << "' does not match '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -2153,14 +2154,14 @@ namespace CXX if (!cxx_expr.match (name)) { wcerr << "error: parser implementation source expression '" << - cxx_expr.pattern () << "' does not match '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } - NarrowString hxx_skel_name (hxx_skel_expr.merge (name)); - NarrowString hxx_name (hxx_expr.merge (name)); - NarrowString cxx_name (cxx_expr.merge (name)); + NarrowString hxx_skel_name (hxx_skel_expr.replace (name)); + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString cxx_name (cxx_expr.replace (name)); Path hxx_path (hxx_name, boost::filesystem::native); Path cxx_path (cxx_name, boost::filesystem::native); @@ -2277,7 +2278,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); @@ -2452,18 +2453,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 (); } @@ -2479,7 +2480,7 @@ namespace CXX AutoUnlinks& unlinks) { using std::ios_base; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { @@ -2559,7 +2560,7 @@ namespace CXX if (!hxx_expr.match (name)) { wcerr << "error: serializer implementation header expression '" << - hxx_expr.pattern () << "' does not match '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -2567,14 +2568,14 @@ namespace CXX if (!cxx_expr.match (name)) { wcerr << "error: serializer implementation source expression '" << - cxx_expr.pattern () << "' does not match '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } - NarrowString hxx_skel_name (hxx_skel_expr.merge (name)); - NarrowString hxx_name (hxx_expr.merge (name)); - NarrowString cxx_name (cxx_expr.merge (name)); + NarrowString hxx_skel_name (hxx_skel_expr.replace (name)); + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString cxx_name (cxx_expr.replace (name)); Path hxx_path (hxx_name, boost::filesystem::native); Path cxx_path (cxx_name, boost::filesystem::native); @@ -2691,7 +2692,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); @@ -2874,18 +2875,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/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx index 08d7fac..b220847 100644 --- a/xsde/cxx/hybrid/tree-forward.cxx +++ b/xsde/cxx/hybrid/tree-forward.cxx @@ -730,7 +730,7 @@ namespace CXX // if (!generate_xml_schema && xml_schema) { - String name (ctx.hxx_expr->merge (xml_schema)); + String name (ctx.hxx_expr->replace (xml_schema)); ctx.os << "#include " << ctx.process_include_path (name) << endl << endl; diff --git a/xsde/cxx/parser/elements.cxx b/xsde/cxx/parser/elements.cxx index 1e58262..bd5b09a 100644 --- a/xsde/cxx/parser/elements.cxx +++ b/xsde/cxx/parser/elements.cxx @@ -305,12 +305,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/xsde/cxx/parser/elements.hxx b/xsde/cxx/parser/elements.hxx index 020e51b..6ce5593 100644 --- a/xsde/cxx/parser/elements.hxx +++ b/xsde/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/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx index 22e1669..6c8f8c7 100644 --- a/xsde/cxx/parser/generator.cxx +++ b/xsde/cxx/parser/generator.cxx @@ -7,6 +7,8 @@ #include +#include + #include #include @@ -14,7 +16,6 @@ #include #include -#include #include #include @@ -632,7 +633,7 @@ namespace CXX using std::ios_base; namespace Indentation = BackendElements::Indentation; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { @@ -885,7 +886,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 (); } @@ -893,7 +894,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 (); } @@ -901,7 +902,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 (); } @@ -911,7 +912,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 (); } @@ -919,7 +920,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 (); } @@ -927,15 +928,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; @@ -943,9 +944,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); @@ -1215,7 +1216,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); @@ -1595,7 +1596,7 @@ namespace CXX Context ctx (hxx_impl, schema, file_path, ops, &hxx_expr, &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); @@ -1675,18 +1676,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/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx index 238b5e6..2cdc297 100644 --- a/xsde/cxx/parser/parser-header.cxx +++ b/xsde/cxx/parser/parser-header.cxx @@ -1750,7 +1750,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/xsde/cxx/parser/type-processor.cxx b/xsde/cxx/parser/type-processor.cxx index 8605241..3e0abbe 100644 --- a/xsde/cxx/parser/type-processor.cxx +++ b/xsde/cxx/parser/type-processor.cxx @@ -105,8 +105,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 (); @@ -118,16 +118,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 { diff --git a/xsde/cxx/serializer/elements.cxx b/xsde/cxx/serializer/elements.cxx index 76947ea..7802e5d 100644 --- a/xsde/cxx/serializer/elements.cxx +++ b/xsde/cxx/serializer/elements.cxx @@ -328,12 +328,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/xsde/cxx/serializer/elements.hxx b/xsde/cxx/serializer/elements.hxx index b61aa83..ada9371 100644 --- a/xsde/cxx/serializer/elements.hxx +++ b/xsde/cxx/serializer/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/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx index 4b31497..167dae5 100644 --- a/xsde/cxx/serializer/generator.cxx +++ b/xsde/cxx/serializer/generator.cxx @@ -7,6 +7,8 @@ #include +#include + #include #include @@ -14,7 +16,6 @@ #include #include -#include #include #include @@ -625,7 +626,7 @@ namespace CXX using std::ios_base; namespace Indentation = BackendElements::Indentation; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { @@ -871,7 +872,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 (); } @@ -879,7 +880,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 (); } @@ -887,7 +888,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 (); } @@ -897,7 +898,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 (); } @@ -905,7 +906,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 (); } @@ -913,15 +914,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; @@ -929,9 +930,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); @@ -1202,7 +1203,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); @@ -1582,7 +1583,7 @@ namespace CXX Context ctx (hxx_impl, schema, file_path, ops, &hxx_expr, &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); @@ -1662,18 +1663,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/xsde/cxx/serializer/serializer-header.cxx b/xsde/cxx/serializer/serializer-header.cxx index ea07ca5..939a052 100644 --- a/xsde/cxx/serializer/serializer-header.cxx +++ b/xsde/cxx/serializer/serializer-header.cxx @@ -1906,7 +1906,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/xsde/cxx/serializer/type-processor.cxx b/xsde/cxx/serializer/type-processor.cxx index a07ff31..3c3a025 100644 --- a/xsde/cxx/serializer/type-processor.cxx +++ b/xsde/cxx/serializer/type-processor.cxx @@ -74,11 +74,6 @@ namespace CXX { // Check if the namespace matches. // - //@@ Should probably store precompiled regex somewhere - // instead of doing it every time. - // - boost::basic_regex ns_expr; - Boolean ns_match; if (!n->xsd_name ().empty ()) @@ -110,8 +105,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 (); @@ -123,16 +118,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 { diff --git a/xsde/makefile b/xsde/makefile index eaa97ff..e4ab12b 100644 --- a/xsde/makefile +++ b/xsde/makefile @@ -112,10 +112,6 @@ $(call import,\ l: be.l,cpp-options: be.l.cpp-options) $(call import,\ - $(scf_root)/import/libboost/regex/stub.make,\ - l: re.l,cpp-options: re.l.cpp-options) - -$(call import,\ $(scf_root)/import/libboost/filesystem/stub.make,\ l: fs.l,cpp-options: fs.l.cpp-options) @@ -125,7 +121,7 @@ $(call import,\ # Build. # -$(xsde): $(cxx_obj) $(xsd_fe.l) $(be.l) $(cult.l) $(cutl.l) $(fs.l) $(re.l) +$(xsde): $(cxx_obj) $(xsd_fe.l) $(be.l) $(cult.l) $(cutl.l) $(fs.l) $(cxx_obj) $(cxx_od): cpp_options := -I$(src_base) $(cxx_obj) $(cxx_od): \ @@ -133,8 +129,7 @@ $(cxx_obj) $(cxx_od): \ $(be.l.cpp-options) \ $(cult.l.cpp-options) \ $(cutl.l.cpp-options) \ - $(fs.l.cpp-options) \ - $(re.l.cpp-options) + $(fs.l.cpp-options) $(call include-dep,$(cxx_od)) diff --git a/xsde/type-map/parser.cxx b/xsde/type-map/parser.cxx index 929c3d3..16bb7ec 100644 --- a/xsde/type-map/parser.cxx +++ b/xsde/type-map/parser.cxx @@ -5,7 +5,7 @@ #include -#include +#include #include @@ -14,7 +14,7 @@ using std::endl; namespace TypeMap { typedef Lexer::Token Token; - typedef BackendElements::Regex::Format Format; + typedef cutl::re::wformat Format; Parser::Parser (Lexer& lex, String const& path) : lex_ (lex), path_ (path), e (std::wcerr) @@ -99,7 +99,7 @@ namespace TypeMap catch (Format const& ex) { e << path_ << ":" << t.line () << ": invalid namespace pattern: " - << ex.description () << endl; + << ex.description ().c_str () << endl; return false; } @@ -234,7 +234,7 @@ namespace TypeMap catch (Format const& ex) { e << path_ << ":" << t.line () << ": invalid namespace pattern: " - << ex.description () << endl; + << ex.description ().c_str () << endl; return false; } diff --git a/xsde/type-map/type-map.hxx b/xsde/type-map/type-map.hxx index 459b64a..3218c5e 100644 --- a/xsde/type-map/type-map.hxx +++ b/xsde/type-map/type-map.hxx @@ -6,20 +6,29 @@ #ifndef XSDE_TYPE_MAP_TYPE_MAP_HXX #define XSDE_TYPE_MAP_TYPE_MAP_HXX +#include + #include #include -#include - namespace TypeMap { using namespace Cult::Types; typedef WideString String; - typedef BackendElements::Regex::Pattern Pattern; + typedef cutl::re::wregex Pattern; class Type { public: + Type (String const& xsd_name, + String const& cxx_ret_name, + String const& cxx_arg_name) + : xsd_name_ (xsd_name), + cxx_ret_name_ (cxx_ret_name), + cxx_arg_name_ (cxx_arg_name) + { + } + Type (Pattern const& xsd_name, String const& cxx_ret_name, String const& cxx_arg_name) @@ -56,6 +65,11 @@ namespace TypeMap class Namespace { public: + Namespace (String const& xsd_name) + : xsd_name_ (xsd_name), has_cxx_name_ (false) + { + } + Namespace (Pattern const& xsd_name) : xsd_name_ (xsd_name), has_cxx_name_ (false) { @@ -116,6 +130,14 @@ namespace TypeMap } Void + types_push_back (String const& xsd_type, + String const& cxx_ret_type, + String const& cxx_arg_type = L"") + { + types_.push_back (Type (xsd_type, cxx_ret_type, cxx_arg_type)); + } + + Void types_push_back (Pattern const& xsd_type, String const& cxx_ret_type, String const& cxx_arg_type = L"") @@ -157,4 +179,3 @@ namespace TypeMap } #endif // XSDE_TYPE_MAP_TYPE_MAP_HXX - diff --git a/xsde/xsde.cxx b/xsde/xsde.cxx index 134d6d9..1220da9 100644 --- a/xsde/xsde.cxx +++ b/xsde/xsde.cxx @@ -4,8 +4,11 @@ // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include + #include +#include + #include #include @@ -30,7 +33,6 @@ #include #include -#include #include #include @@ -138,8 +140,8 @@ struct LocationTranslator: XSDFrontend::LocationTranslator private: typedef Cult::Containers::Map Map; - typedef BackendElements::Regex::Expression Regex; - typedef BackendElements::Regex::Format RegexFormat; + typedef cutl::re::regexsub Regex; + typedef cutl::re::format RegexFormat; typedef Cult::Containers::Vector RegexVector; typedef Cult::Containers::Map Cache; @@ -165,8 +167,8 @@ struct AnonymousNameTranslator: Transformations::AnonymousNameTranslator WideString const& xpath); private: - typedef BackendElements::Regex::Expression Regex; - typedef BackendElements::Regex::Format RegexFormat; + typedef cutl::re::wregexsub Regex; + typedef cutl::re::wformat RegexFormat; typedef Cult::Containers::Vector RegexVector; RegexVector regex_; @@ -192,15 +194,15 @@ struct SchemaPerTypeTranslator: Transformations::SchemaPerTypeTranslator translate_schema (NarrowString const& file); private: - typedef BackendElements::Regex::Expression TypeRegex; - typedef BackendElements::Regex::Format TypeRegexFormat; + typedef cutl::re::wregexsub TypeRegex; + typedef cutl::re::wformat TypeRegexFormat; typedef Cult::Containers::Vector TypeRegexVector; TypeRegexVector type_regex_; Boolean type_trace_; - typedef BackendElements::Regex::Expression SchemaRegex; - typedef BackendElements::Regex::Format SchemaRegexFormat; + typedef cutl::re::regexsub SchemaRegex; + typedef cutl::re::format SchemaRegexFormat; typedef Cult::Containers::Vector SchemaRegexVector; SchemaRegexVector schema_regex_; @@ -1487,7 +1489,7 @@ LocationTranslator (NarrowStrings const& map, catch (RegexFormat const& e) { wcerr << "error: invalid location regex: '" << - e.expression ().c_str () << "': " << + e.regex ().c_str () << "': " << e.description ().c_str () << endl; throw Failed (); @@ -1524,11 +1526,11 @@ translate (NarrowString const& l) i != regex_.rend (); ++i) { if (trace_) - wcerr << "try: '" << i->pattern () << "' : "; + wcerr << "try: '" << i->regex ().str ().c_str () << "' : "; if (i->match (l)) { - NarrowString r (i->merge (l)); + NarrowString r (i->replace (l)); if (trace_) wcerr << "'" << r.c_str () << "' : +" << endl; @@ -1558,12 +1560,12 @@ AnonymousNameTranslator (NarrowStrings const& regex, Boolean trace) { try { - regex_.push_back (Regex (*i)); + regex_.push_back (Regex (WideString (*i))); } catch (RegexFormat const& e) { wcerr << "error: invalid anonymous type regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description () << endl; throw Failed (); } @@ -1585,11 +1587,11 @@ translate (WideString const& file, i != regex_.rend (); ++i) { if (trace_) - wcerr << "try: '" << i->pattern () << "' : "; + wcerr << "try: '" << i->regex () << "' : "; if (i->match (s)) { - WideString r (i->merge (s)); + WideString r (i->replace (s)); if (trace_) wcerr << "'" << r << "' : +" << endl; @@ -1621,12 +1623,12 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex, { try { - type_regex_.push_back (TypeRegex (*i)); + type_regex_.push_back (TypeRegex (WideString (*i))); } catch (TypeRegexFormat const& e) { wcerr << "error: invalid type file regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description () << endl; throw Failed (); } @@ -1642,7 +1644,7 @@ SchemaPerTypeTranslator (NarrowStrings const& type_regex, catch (SchemaRegexFormat const& e) { wcerr << "error: invalid type file regex: '" << - e.expression ().c_str () << "': " << e.description ().c_str () << endl; + e.regex ().c_str () << "': " << e.description ().c_str () << endl; throw Failed (); } @@ -1661,11 +1663,11 @@ translate_type (WideString const& ns, WideString const& name) i != type_regex_.rend (); ++i) { if (type_trace_) - wcerr << "try: '" << i->pattern () << "' : "; + wcerr << "try: '" << i->regex () << "' : "; if (i->match (s)) { - WideString r (i->merge (s)); + WideString r (i->replace (s)); if (type_trace_) wcerr << "'" << r << "' : +" << endl; @@ -1692,11 +1694,11 @@ translate_schema (NarrowString const& file) i != schema_regex_.rend (); ++i) { if (schema_trace_) - wcerr << "try: '" << i->pattern () << "' : "; + wcerr << "try: '" << i->regex ().str ().c_str () << "' : "; if (i->match (file)) { - NarrowString r (i->merge (file)); + NarrowString r (i->replace (file)); if (schema_trace_) wcerr << "'" << r.c_str () << "' : +" << endl; -- cgit v1.1