aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-02-19 12:25:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-02-19 12:25:46 +0200
commit9bd9b2a74362ae6755ac63fbe3990565edd5cff3 (patch)
treed30e32a5624044c51ff6c9d1e8ce503b010401e7 /xsde/cxx
parent17106842a129b349759e829f4ce3493c7d698799 (diff)
Add support for translating schema paths in fpt mode
New options: --schema-file-regex, --schema-file-regex-trace.
Diffstat (limited to 'xsde/cxx')
-rw-r--r--xsde/cxx/hybrid/elements.cxx8
-rw-r--r--xsde/cxx/hybrid/generator.cxx88
-rw-r--r--xsde/cxx/hybrid/generator.hxx3
-rw-r--r--xsde/cxx/parser/elements.cxx8
-rw-r--r--xsde/cxx/parser/generator.cxx45
-rw-r--r--xsde/cxx/parser/generator.hxx1
-rw-r--r--xsde/cxx/serializer/elements.cxx8
-rw-r--r--xsde/cxx/serializer/generator.cxx45
-rw-r--r--xsde/cxx/serializer/generator.hxx1
9 files changed, 156 insertions, 51 deletions
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<SemanticGraph::Path> ("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<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
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<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
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<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
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&);
diff --git a/xsde/cxx/parser/elements.cxx b/xsde/cxx/parser/elements.cxx
index 2261abd..fafcd52 100644
--- a/xsde/cxx/parser/elements.cxx
+++ b/xsde/cxx/parser/elements.cxx
@@ -206,6 +206,7 @@ namespace CXX
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
+ SemanticGraph::Schema& s (u.schema ());
Boolean weak (u.context ().count ("weak"));
if (weak && (type_ == header || type_ == impl_header))
@@ -214,7 +215,7 @@ namespace CXX
// in the impl files.
//
if (type_ == header)
- schema_.dispatch (u.schema ());
+ schema_.dispatch (s);
return;
}
@@ -222,7 +223,10 @@ namespace CXX
if (type_ == source && !weak)
return;
- SemanticGraph::Path path (u.path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("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/parser/generator.cxx b/xsde/cxx/parser/generator.cxx
index 1645525..c8a9f68 100644
--- a/xsde/cxx/parser/generator.cxx
+++ b/xsde/cxx/parser/generator.cxx
@@ -613,6 +613,7 @@ namespace CXX
generate (Parser::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
@@ -949,23 +950,13 @@ namespace CXX
cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native);
}
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- ixx_path = path / ixx_path;
- cxx_path = path / cxx_path;
-
- if (impl || driver)
- {
- hxx_impl_path = path / hxx_impl_path;
- cxx_impl_path = path / cxx_impl_path;
- cxx_driver_path = path /cxx_driver_path;
- }
-
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -974,6 +965,32 @@ 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;
+
+ if (impl || driver)
+ {
+ hxx_impl_path = out_dir / hxx_impl_path;
+ cxx_impl_path = out_dir / cxx_impl_path;
+ cxx_driver_path = out_dir /cxx_driver_path;
+ }
+ }
+
// Open the impl files first so that if open fails, the skel files
// are not deleted.
//
diff --git a/xsde/cxx/parser/generator.hxx b/xsde/cxx/parser/generator.hxx
index 10b3dd3..9c8f680 100644
--- a/xsde/cxx/parser/generator.hxx
+++ b/xsde/cxx/parser/generator.hxx
@@ -50,6 +50,7 @@ namespace CXX
generate (CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
diff --git a/xsde/cxx/serializer/elements.cxx b/xsde/cxx/serializer/elements.cxx
index 0192faf..ba59a82 100644
--- a/xsde/cxx/serializer/elements.cxx
+++ b/xsde/cxx/serializer/elements.cxx
@@ -226,6 +226,7 @@ namespace CXX
// Support for weak (forward) inclusion used in the file-per-type
// compilation model.
//
+ SemanticGraph::Schema& s (u.schema ());
Boolean weak (u.context ().count ("weak"));
if (weak && (type_ == header || type_ == impl_header))
@@ -234,7 +235,7 @@ namespace CXX
// in the impl files.
//
if (type_ == header)
- schema_.dispatch (u.schema ());
+ schema_.dispatch (s);
return;
}
@@ -242,7 +243,10 @@ namespace CXX
if (type_ == source && !weak)
return;
- SemanticGraph::Path path (u.path ());
+ SemanticGraph::Path path (
+ s.context ().count ("renamed")
+ ? s.context ().get<SemanticGraph::Path> ("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/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 9d519b9..92e5197 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -606,6 +606,7 @@ namespace CXX
generate (Serializer::CLI::Options const& ops,
Schema& schema,
Path const& file_path,
+ Boolean fpt,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,
@@ -935,23 +936,13 @@ namespace CXX
cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native);
}
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ Path out_dir;
+
+ if (NarrowString dir = ops.value<CLI::output_dir> ())
{
try
{
- Path path (dir, boost::filesystem::native);
-
- hxx_path = path / hxx_path;
- ixx_path = path / ixx_path;
- cxx_path = path / cxx_path;
-
- if (impl || driver)
- {
- hxx_impl_path = path / hxx_impl_path;
- cxx_impl_path = path / cxx_impl_path;
- cxx_driver_path = path /cxx_driver_path;
- }
-
+ out_dir = Path (dir, boost::filesystem::native);
}
catch (InvalidPath const&)
{
@@ -960,6 +951,32 @@ 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;
+
+ if (impl || driver)
+ {
+ hxx_impl_path = out_dir / hxx_impl_path;
+ cxx_impl_path = out_dir / cxx_impl_path;
+ cxx_driver_path = out_dir /cxx_driver_path;
+ }
+ }
+
// Open the impl files first so that if open fails, the skel files
// are not deleted.
//
diff --git a/xsde/cxx/serializer/generator.hxx b/xsde/cxx/serializer/generator.hxx
index dd3c0c5..8c2465c 100644
--- a/xsde/cxx/serializer/generator.hxx
+++ b/xsde/cxx/serializer/generator.hxx
@@ -50,6 +50,7 @@ namespace CXX
generate (CLI::Options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const&,
+ Boolean file_per_type,
TypeMap::Namespaces& type_map,
Boolean gen_driver,
const WarningSet& disabled_warnings,