From 9bd9b2a74362ae6755ac63fbe3990565edd5cff3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Feb 2010 12:25:46 +0200 Subject: Add support for translating schema paths in fpt mode New options: --schema-file-regex, --schema-file-regex-trace. --- xsde/cxx/hybrid/elements.cxx | 8 +++- xsde/cxx/hybrid/generator.cxx | 88 ++++++++++++++++++++++++++++++++++--------- xsde/cxx/hybrid/generator.hxx | 3 ++ 3 files changed, 80 insertions(+), 19 deletions(-) (limited to 'xsde/cxx/hybrid') diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index e3bd02b..3607c37 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -580,6 +580,7 @@ namespace CXX // compilation model. // Type t (type_); + SemanticGraph::Schema& s (u.schema ()); Boolean weak (u.context ().count ("weak")); if (weak && (t == header || t == impl_header)) @@ -594,7 +595,7 @@ namespace CXX t = forward; else { - schema_.dispatch (u.schema ()); + schema_.dispatch (s); return; } } @@ -602,7 +603,10 @@ namespace CXX if (t == source && !weak) return; - SemanticGraph::Path path (u.path ()); + SemanticGraph::Path path ( + s.context ().count ("renamed") + ? s.context ().get ("renamed") + : u.path ()); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx index c39b062..34cfa2d 100644 --- a/xsde/cxx/hybrid/generator.cxx +++ b/xsde/cxx/hybrid/generator.cxx @@ -1140,6 +1140,7 @@ namespace CXX generate_tree (Hybrid::CLI::Options const& ops, Schema& schema, Path const& file_path, + Boolean fpt, const WarningSet& disabled_warnings, TypeMap::Namespaces& parser_type_map, TypeMap::Namespaces& serializer_type_map, @@ -1267,16 +1268,13 @@ namespace CXX Path cxx_path (cxx_name, boost::filesystem::native); Path fwd_path (fwd_name, boost::filesystem::native); - if (NarrowString dir = ops.value ()) + Path out_dir; + + if (NarrowString dir = ops.value ()) { try { - Path path (dir, boost::filesystem::native); - - hxx_path = path / hxx_path; - ixx_path = path / ixx_path; - cxx_path = path / cxx_path; - fwd_path = path / fwd_path; + out_dir = Path (dir, boost::filesystem::native); } catch (InvalidPath const&) { @@ -1285,6 +1283,26 @@ namespace CXX } } + if (fpt && !generate_xml_schema) + { + // In the file-per-type mode the schema files are always local + // unless the user added the directory so that we propagate this + // to the output files. + // + Path fpt_dir (file_path.branch_path ()); + + if (!fpt_dir.empty ()) + out_dir /= fpt_dir; + } + + if (!out_dir.empty ()) + { + hxx_path = out_dir / hxx_path; + ixx_path = out_dir / ixx_path; + cxx_path = out_dir / cxx_path; + fwd_path = out_dir / fwd_path; + } + // Open the tree files. // WideOutputFileStream hxx (hxx_path, ios_base::out); @@ -1892,6 +1910,7 @@ namespace CXX generate_parser (Hybrid::CLI::Options const& ops, Schema& schema, Path const& file_path, + Boolean fpt, const WarningSet&, FileList& file_list, AutoUnlinks& unlinks) @@ -1998,14 +2017,13 @@ namespace CXX Path hxx_path (hxx_name, boost::filesystem::native); Path cxx_path (cxx_name, boost::filesystem::native); - if (NarrowString dir = ops.value ()) + Path out_dir; + + if (NarrowString dir = ops.value ()) { try { - Path path (dir, boost::filesystem::native); - - hxx_path = path / hxx_path; - cxx_path = path / cxx_path; + out_dir = Path (dir, boost::filesystem::native); } catch (InvalidPath const&) { @@ -2014,6 +2032,24 @@ namespace CXX } } + if (fpt) + { + // In the file-per-type mode the schema files are always local + // unless the user added the directory so that we propagate this + // to the output files. + // + Path fpt_dir (file_path.branch_path ()); + + if (!fpt_dir.empty ()) + out_dir /= fpt_dir; + } + + if (!out_dir.empty ()) + { + hxx_path = out_dir / hxx_path; + cxx_path = out_dir / cxx_path; + } + WideOutputFileStream hxx (hxx_path, ios_base::out); WideOutputFileStream cxx (cxx_path, ios_base::out); @@ -2296,6 +2332,7 @@ namespace CXX generate_serializer (Hybrid::CLI::Options const& ops, Schema& schema, Path const& file_path, + Boolean fpt, const WarningSet&, FileList& file_list, AutoUnlinks& unlinks) @@ -2390,14 +2427,13 @@ namespace CXX Path hxx_path (hxx_name, boost::filesystem::native); Path cxx_path (cxx_name, boost::filesystem::native); - if (NarrowString dir = ops.value ()) + Path out_dir; + + if (NarrowString dir = ops.value ()) { try { - Path path (dir, boost::filesystem::native); - - hxx_path = path / hxx_path; - cxx_path = path / cxx_path; + out_dir = Path (dir, boost::filesystem::native); } catch (InvalidPath const&) { @@ -2406,6 +2442,24 @@ namespace CXX } } + if (fpt) + { + // In the file-per-type mode the schema files are always local + // unless the user added the directory so that we propagate this + // to the output files. + // + Path fpt_dir (file_path.branch_path ()); + + if (!fpt_dir.empty ()) + out_dir /= fpt_dir; + } + + if (!out_dir.empty ()) + { + hxx_path = out_dir / hxx_path; + cxx_path = out_dir / cxx_path; + } + WideOutputFileStream hxx (hxx_path, ios_base::out); WideOutputFileStream cxx (cxx_path, ios_base::out); diff --git a/xsde/cxx/hybrid/generator.hxx b/xsde/cxx/hybrid/generator.hxx index 5d1afa0..e812801 100644 --- a/xsde/cxx/hybrid/generator.hxx +++ b/xsde/cxx/hybrid/generator.hxx @@ -82,6 +82,7 @@ namespace CXX CLI::Options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, + Boolean file_per_type, WarningSet const& disabled_warnings, TypeMap::Namespaces& parser_type_map, TypeMap::Namespaces& serializer_type_map, @@ -93,6 +94,7 @@ namespace CXX CLI::Options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, + Boolean file_per_type, WarningSet const& disabled_warnings, FileList&, AutoUnlinks&); @@ -102,6 +104,7 @@ namespace CXX CLI::Options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, + Boolean file_per_type, WarningSet const& disabled_warnings, FileList&, AutoUnlinks&); -- cgit v1.1