|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58763 - trunk/tools/bcp
From: john_at_[hidden]
Date: 2010-01-06 08:06:21
Author: johnmaddock
Date: 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
New Revision: 58763
URL: http://svn.boost.org/trac/boost/changeset/58763
Log:
Add support for top level namespaces other than "boost".
Text files modified:
trunk/tools/bcp/add_path.cpp | 19 +++++++++++++++++++
trunk/tools/bcp/bcp.hpp | 1 +
trunk/tools/bcp/bcp_imp.cpp | 35 ++++++++++++++++++++++++++++++++++-
trunk/tools/bcp/bcp_imp.hpp | 4 ++++
trunk/tools/bcp/copy_path.cpp | 16 ++++++++++++----
trunk/tools/bcp/main.cpp | 5 +++++
6 files changed, 75 insertions(+), 5 deletions(-)
Modified: trunk/tools/bcp/add_path.cpp
==============================================================================
--- trunk/tools/bcp/add_path.cpp (original)
+++ trunk/tools/bcp/add_path.cpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -496,4 +496,23 @@
add_dependent_lib(swhat.str(1), p, view);
}
}
+ if(m_list_namespaces)
+ {
+ //
+ // scan for top level namespaces and add to our list:
+ //
+ static const boost::regex namespace_scanner(
+ "^(?<!\\\\\\n)[[:blank:]]*+namespace\\s++(\\w++)\\s++(\\{[^{}]*(?:(?2)[^{}]*)*\\})"
+ );
+ i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), namespace_scanner, 1);
+ while(i != j)
+ {
+ if(m_top_namespaces.count(*i) == 0)
+ {
+ //std::cout << *i << " (Found in " << p << ")" << std::endl;
+ m_top_namespaces[*i] = p;
+ }
+ ++i;
+ }
+ }
}
Modified: trunk/tools/bcp/bcp.hpp
==============================================================================
--- trunk/tools/bcp/bcp.hpp (original)
+++ trunk/tools/bcp/bcp.hpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -31,6 +31,7 @@
virtual void add_module(const char* p) = 0;
virtual void set_namespace(const char* name) = 0;
virtual void set_namespace_alias(bool) = 0;
+ virtual void set_namespace_list(bool) = 0;
virtual int run() = 0;
Modified: trunk/tools/bcp/bcp_imp.cpp
==============================================================================
--- trunk/tools/bcp/bcp_imp.cpp (original)
+++ trunk/tools/bcp/bcp_imp.cpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -20,7 +20,7 @@
bcp_implementation::bcp_implementation()
: m_list_mode(false), m_list_summary_mode(false), m_license_mode(false), m_cvs_mode(false),
m_svn_mode(false), m_unix_lines(false), m_scan_mode(false), m_bsl_convert_mode(false),
- m_bsl_summary_mode(false), m_namespace_alias(false)
+ m_bsl_summary_mode(false), m_namespace_alias(false), m_list_namespaces(false)
{
}
@@ -112,6 +112,12 @@
m_namespace_alias = b;
}
+void bcp_implementation::set_namespace_list(bool b)
+{
+ m_list_namespaces = b;
+ m_list_mode = b;
+}
+
fs::path get_short_path(const fs::path& p)
{
// truncate path no more than "x/y":
@@ -233,6 +239,33 @@
//
// now perform output:
//
+ if(m_list_namespaces)
+ {
+ // List the namespaces, in two lists, headers and source files
+ // first, then everything else afterwards:
+ //
+ boost::regex important_file("boost/.*|libs/[^/]*/(?:[^/]*/)?/src/.*");
+ std::map<std::string, fs::path>::const_iterator i, j;
+ i = m_top_namespaces.begin();
+ j = m_top_namespaces.end();
+ std::cout << "\n\nThe top level namespaces found for header and source files were:\n";
+ while(i != j)
+ {
+ if(regex_match(i->second.string(), important_file))
+ std::cout << i->first << " (from " << i->second << ")" << std::endl;
+ ++i;
+ }
+
+ i = m_top_namespaces.begin();
+ std::cout << "\n\nThe top level namespaces found for all other source files were:\n";
+ while(i != j)
+ {
+ if(!regex_match(i->second.string(), important_file))
+ std::cout << i->first << " (from " << i->second << ")" << std::endl;
+ ++i;
+ }
+ return 0;
+ }
std::set<fs::path, path_less>::iterator m, n;
std::set<fs::path, path_less> short_paths;
m = m_copy_paths.begin();
Modified: trunk/tools/bcp/bcp_imp.hpp
==============================================================================
--- trunk/tools/bcp/bcp_imp.hpp (original)
+++ trunk/tools/bcp/bcp_imp.hpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -65,6 +65,7 @@
void add_module(const char* p);
void set_namespace(const char* name);
void set_namespace_alias(bool);
+ void set_namespace_list(bool);
virtual int run();
@@ -94,6 +95,7 @@
bool m_bsl_convert_mode; // try to convert to the BSL
bool m_bsl_summary_mode; // summarise BSL issues only
bool m_namespace_alias; // make "boost" a namespace alias when doing a namespace rename.
+ bool m_list_namespaces; // list all the top level namespaces found.
fs::path m_boost_path; // the path to the boost root
fs::path m_dest_path; // the path to copy to
std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control
@@ -111,4 +113,6 @@
std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information
std::string m_namespace_name; // namespace rename.
std::set<std::string> m_lib_names; // List of library binary names
+ std::map<std::string, fs::path> m_top_namespaces; // List of top level namespace names
};
+
Modified: trunk/tools/bcp/copy_path.cpp
==============================================================================
--- trunk/tools/bcp/copy_path.cpp (original)
+++ trunk/tools/bcp/copy_path.cpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -106,13 +106,21 @@
static const boost::regex namespace_matcher(
"(?|"
- "(namespace\\s+)boost\\>()"
+ "(namespace\\s+)boost(_\\w+)?"
"|"
- "()boost(\\s*(?:::|,|\\)))"
+ "(namespace\\s+)(adstl|phoenix|rapidxml)\\>"
"|"
- "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)boost\\>()"
+ "()boost((?:_\\w+)?\\s*(?:::|,|\\)))"
"|"
- "(^\\s*#\\s*define[^\\n]+)boost(\\s*)$"
+ "()((?:adstl|phoenix|rapidxml)\\s*(?:::|,|\\)))"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)boost(_\\w+)?"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)(adstl|phoenix|rapidxml)\\>"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)boost((?:_\\w+)?\\s*)$"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)((?:adstl|phoenix|rapidxml)\\s*)$"
")"
);
Modified: trunk/tools/bcp/main.cpp
==============================================================================
--- trunk/tools/bcp/main.cpp (original)
+++ trunk/tools/bcp/main.cpp 2010-01-06 08:06:20 EST (Wed, 06 Jan 2010)
@@ -145,6 +145,11 @@
{
papp->set_namespace_alias(true);
}
+ else if(0 == std::strncmp("--list-namespaces", argv[i], 17))
+ {
+ list_mode = true;
+ papp->set_namespace_list(true);
+ }
else if(argv[i][0] == '-')
{
std::cout << "Error: Unknown argument " << argv[i] << std::endl;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk