Utils/Console: Fix classic spirit include warnings
g0dil [Mon, 3 May 2010 10:52:49 +0000 (10:52 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1614 270642c3-0616-0410-b53a-bc976706d245

senf/.gitignore
senf/Utils/Console/Parse.cc
senf/Utils/Console/Parse.ih
senf/Utils/Console/Parse.test.cc
senf/Utils/Phoenix.hh
senf/config.hh
site_scons/senfutil.py

index e75ff76..a4de1b0 100644 (file)
@@ -1 +1,2 @@
 /local_config.hh
+/autoconf.hh
index f9b2d21..a2ace99 100644 (file)
 #include <cerrno>
 #include <sys/stat.h>
 #include <boost/iterator/transform_iterator.hpp>
-#include <boost/spirit/iterator/file_iterator.hpp>
-#include <boost/spirit/iterator/position_iterator.hpp>
+#include <senf/config.hh>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+#  include <boost/spirit/include/classic_file_iterator.hpp>
+#  include <boost/spirit/include/classic_position_iterator.hpp>
+#else
+#  include <boost/spirit/iterator/file_iterator.hpp>
+#  include <boost/spirit/iterator/position_iterator.hpp>
+#endif
+
 #include <senf/Utils/Exception.hh>
 #include <senf/Utils/senfassert.hh>
 
@@ -279,6 +287,9 @@ namespace {
 
 namespace boost {
 namespace spirit {
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+namespace classic {
+#endif
 
     template <>
     struct position_policy<senf::console::detail::FilePositionWithIndex>
@@ -305,6 +316,9 @@ namespace spirit {
             }
     };
 
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+}
+#endif
 }}
 
 prefix_ senf::console::CommandParser::CommandParser()
@@ -321,27 +335,27 @@ template <class Iterator>
 prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator npe,
                                                          std::string const & source, Callback cb)
 {
-    typedef boost::spirit::position_iterator<
+    typedef detail::boost_spirit::position_iterator<
         Iterator, detail::FilePositionWithIndex> PositionIterator;
     PositionIterator b (npb, npe, source);
     PositionIterator e (npe, npe, source);
     ParseCommandInfo info;
     detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
-    boost::spirit::parse_info<PositionIterator> result;
+    detail::boost_spirit::parse_info<PositionIterator> result;
 
     for(;;) {
-        result = boost::spirit::parse(
+        result = detail::boost_spirit::parse(
             b, e, * impl().grammar.use_parser<Impl::Grammar::SkipParser>());
         b = result.stop;
         if (b == e)
             return e.base();
         info.clear();
         try {
-            result = boost::spirit::parse(b, e,
+            result = detail::boost_spirit::parse(b, e,
                                           impl().grammar.use_parser<Impl::Grammar::CommandParser>(),
                                           impl().grammar.use_parser<Impl::Grammar::SkipParser>());
         }
-        catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
+        catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
             if (impl().grammar.incremental && ex.where == e)
                 return b.base();
             else
@@ -375,7 +389,7 @@ prefix_ void senf::console::CommandParser::parseFile(std::string const & filenam
     if (stat( filename.c_str(), &statBuf) != 0)
         throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
     if (statBuf.st_size == 0) return;
-    boost::spirit::file_iterator<> i (filename);
+    detail::boost_spirit::file_iterator<> i (filename);
     if (!i) {
         if (errno == 0)
             // hmm.. errno==0 but the file_iterator is false; something is wrong but we
@@ -384,25 +398,25 @@ prefix_ void senf::console::CommandParser::parseFile(std::string const & filenam
         else
             throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
     }
-    boost::spirit::file_iterator<> const i_end (i.make_end());
+    detail::boost_spirit::file_iterator<> const i_end (i.make_end());
     parseLoop(i, i_end, filename, cb);
 }
 
 prefix_ void senf::console::CommandParser::parseArguments(std::string const & arguments,
                                                           ParseCommandInfo & info)
 {
-    typedef boost::spirit::position_iterator<
+    typedef detail::boost_spirit::position_iterator<
         std::string::const_iterator, detail::FilePositionWithIndex> PositionIterator;
     PositionIterator b (arguments.begin(), arguments.end(), std::string("<unknown>"));
     PositionIterator e (arguments.end(), arguments.end(), std::string("<unknown>"));
     detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
-    boost::spirit::parse_info<PositionIterator> result;
+    detail::boost_spirit::parse_info<PositionIterator> result;
     try {
-        result = boost::spirit::parse( b, e,
+        result = detail::boost_spirit::parse( b, e,
                                        impl().grammar.use_parser<Impl::Grammar::ArgumentsParser>(),
                                        impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
     }
-    catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
+    catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
         throwParserError(ex);
     }
     if (! result.full) {
@@ -415,18 +429,18 @@ prefix_ void senf::console::CommandParser::parseArguments(std::string const & ar
 prefix_ void senf::console::CommandParser::parsePath(std::string const & path,
                                                      ParseCommandInfo & info)
 {
-    typedef boost::spirit::position_iterator<
+    typedef detail::boost_spirit::position_iterator<
         std::string::const_iterator, detail::FilePositionWithIndex> PositionIterator;
     PositionIterator b (path.begin(), path.end(), std::string("<unknown>"));
     PositionIterator e (path.end(), path.end(), std::string("<unknown>"));
     detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
-    boost::spirit::parse_info<PositionIterator> result;
+    detail::boost_spirit::parse_info<PositionIterator> result;
     try {
-        result = boost::spirit::parse( b, e,
+        result = detail::boost_spirit::parse( b, e,
                                        impl().grammar.use_parser<Impl::Grammar::PathParser>(),
                                        impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
     }
-    catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
+    catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
         throwParserError(ex);
     }
     if (! result.full) {
index 8bfb8f8..1fd7d2d 100644 (file)
 // Custom includes
 #include <vector>
 #include <senf/config.hh>
-#include <boost/spirit.hpp>
-#include <boost/spirit/utility/grammar_def.hpp>
-#include <boost/spirit/dynamic.hpp>
-#include <boost/spirit/phoenix.hpp>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+#  include <boost/spirit/include/classic.hpp>
+#  include <boost/spirit/include/classic_grammar_def.hpp>
+#  include <boost/spirit/include/classic_dynamic.hpp>
+#  include <boost/spirit/include/phoenix1.hpp>
+#else
+#  include <boost/spirit.hpp>
+#  include <boost/spirit/utility/grammar_def.hpp>
+#  include <boost/spirit/dynamic.hpp>
+#  include <boost/spirit/phoenix.hpp>
+#endif
+
 #include <senf/Utils/Phoenix.hh>
 
 ///////////////////////////////ih.p////////////////////////////////////////
@@ -41,21 +50,27 @@ namespace senf {
 namespace console {
 namespace detail {
 
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+    namespace boost_spirit = ::boost::spirit::classic;
+#else
+    namespace boost_spirit = ::boost::spirit;
+#endif
+
 #ifndef DOXYGEN
 
     struct FilePositionWithIndex
-        : public boost::spirit::file_position
+        : public boost_spirit::file_position
     {
         int index;
 
         FilePositionWithIndex(std::string const & file_ = std::string(),
                                  int line_ = 1, int column_ = 1, int index_ = 0)
-            : boost::spirit::file_position (file_, line_, column_), index (index_)
+            : boost_spirit::file_position (file_, line_, column_), index (index_)
             {}
 
         bool operator==(const FilePositionWithIndex & fp) const
             {
-                return boost::spirit::file_position::operator==(fp) && index == fp.index;
+                return boost_spirit::file_position::operator==(fp) && index == fp.index;
             }
     };
 
@@ -71,7 +86,7 @@ namespace detail {
     // Grammar
 
     template <class ParseDispatcher>
-    struct CommandGrammar : boost::spirit::grammar<CommandGrammar<ParseDispatcher> >
+    struct CommandGrammar : boost_spirit::grammar<CommandGrammar<ParseDispatcher> >
     {
         ///////////////////////////////////////////////////////////////////////////
         // Start rules
@@ -106,12 +121,12 @@ namespace detail {
         //////////////////////////////////////////////////////////////////////////
         // charachter sets
 
-        static boost::spirit::chset<> special_p;
-        static boost::spirit::chset<> punctuation_p;
-        static boost::spirit::chset<> space_p;
-        static boost::spirit::chset<> invalid_p;
-        static boost::spirit::chset<> word_p;
-        static boost::spirit::distinct_parser<> keyword_p;
+        static boost_spirit::chset<> special_p;
+        static boost_spirit::chset<> punctuation_p;
+        static boost_spirit::chset<> space_p;
+        static boost_spirit::chset<> invalid_p;
+        static boost_spirit::chset<> word_p;
+        static boost_spirit::distinct_parser<> keyword_p;
 
         ///////////////////////////////////////////////////////////////////////////
         // Errors
@@ -130,19 +145,19 @@ namespace detail {
 
         template <class Scanner>
         struct definition
-            : public boost::spirit::grammar_def< boost::spirit::rule<Scanner>,
-                                                 boost::spirit::rule<Scanner>,
-                                                 boost::spirit::rule<Scanner>,
-                                                 boost::spirit::rule<Scanner> >
+            : public boost_spirit::grammar_def< boost_spirit::rule<Scanner>,
+                                                 boost_spirit::rule<Scanner>,
+                                                 boost_spirit::rule<Scanner>,
+                                                 boost_spirit::rule<Scanner> >
         {
-            boost::spirit::rule<Scanner> command, path, argument, word, string, hexstring, token,
+            boost_spirit::rule<Scanner> command, path, argument, word, string, hexstring, token,
                 punctuation, hexbyte, balanced_tokens, simple_argument, complex_argument, builtin,
                 skip, statement, relpath, abspath, arguments, group_start, group_close,
                 statement_end, opt_path;
 
             definition(CommandGrammar const & self)
             {
-                using namespace boost::spirit;
+                using namespace boost_spirit;
                 using namespace ::phoenix;
                 using namespace senf::phoenix;
                 typedef ParseDispatcher PD;
@@ -410,18 +425,18 @@ namespace detail {
         };
     };
 
-    template <class PD> boost::spirit::chset<> CommandGrammar<PD>::special_p (
+    template <class PD> boost_spirit::chset<> CommandGrammar<PD>::special_p (
         "/(){};\"");
-    template <class PD> boost::spirit::chset<> CommandGrammar<PD>::punctuation_p (
+    template <class PD> boost_spirit::chset<> CommandGrammar<PD>::punctuation_p (
         ",=");
-    template <class PD> boost::spirit::chset<> CommandGrammar<PD>::space_p (
+    template <class PD> boost_spirit::chset<> CommandGrammar<PD>::space_p (
         " \t\n\r");
-    template <class PD> boost::spirit::chset<> CommandGrammar<PD>::invalid_p (
-        (boost::spirit::chset<>('\0') | boost::spirit::chset<>("\x01-\x20")) - space_p );
-    template <class PD> boost::spirit::chset<> CommandGrammar<PD>::word_p (
-        boost::spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p);
-    template <class PD> boost::spirit::distinct_parser<> CommandGrammar<PD>::keyword_p (
-        word_p | boost::spirit::ch_p('/'));
+    template <class PD> boost_spirit::chset<> CommandGrammar<PD>::invalid_p (
+        (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p );
+    template <class PD> boost_spirit::chset<> CommandGrammar<PD>::word_p (
+        boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p);
+    template <class PD> boost_spirit::distinct_parser<> CommandGrammar<PD>::keyword_p (
+        word_p | boost_spirit::ch_p('/'));
 
 #endif
 
index 27f1697..a214186 100644 (file)
@@ -97,7 +97,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
             "                x\"01 02 # Inner comment\n"
             "                   0304\";";
 
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          text,
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -127,7 +127,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "ls //foo/bar;",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -136,7 +136,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "lr /foo/bar;",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -145,7 +145,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "cd /foo/bar;",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -154,7 +154,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "exit;",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -163,7 +163,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "foo/bar// {",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -175,7 +175,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "}",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
@@ -184,7 +184,7 @@ SENF_AUTO_UNIT_TEST(commandGrammar)
 
     {
         ss.str("");
-        BOOST_CHECK( boost::spirit::parse(
+        BOOST_CHECK( senf::console::detail::boost_spirit::parse(
                          "help /foo/bar",
                          grammar.use_parser<Grammar::CommandParser>(),
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
index 4f1e6e0..40fcd96 100644 (file)
 #define HH_SENF_Utils_Phoenix_ 1
 
 // Custom includes
-#include <boost/spirit/phoenix/functions.hpp>
+#include <senf/config.hh>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+#  include <boost/spirit/include/phoenix1_functions.hpp>
+#else
+#  include <boost/spirit/phoenix/functions.hpp>
+#endif
 
 //#include "Phoenix.mpp"
 #include "Phoenix.ih"
index cfa9319..31c1b45 100644 (file)
@@ -39,6 +39,7 @@ namespace config {
 
 }}
 
+# include "autoconf.hh"
 # include "local_config.hh"
 #
 # ifndef SENF_ABSOLUTE_INCLUDE_PATH
@@ -115,4 +116,3 @@ namespace config {
 // ispell-local-dictionary: "american"
 // compile-command: "scons -u all_tests"
 // End:
-
index 246f72e..f63873b 100644 (file)
@@ -196,11 +196,16 @@ def Glob(env, exclude=[], subdirs=[]):
 
 
 def Configure(env):
-    conf = env.Configure(clean=False, help=False, custom_tests = senfconf.Tests())
+    conf = env.Configure(clean=False, 
+                         help=False, 
+                         custom_tests=senfconf.Tests(), 
+                         config_h="#/senf/autoconf.hh")
     env.Replace(
         BOOST_VERSION  =  conf.CheckBoostVersion(),
         BOOST_VARIANT  = conf.CheckBoostVariants( '', 'mt' ),
         NEED_BOOST_EXT = not conf.CheckCXXHeader("boost/bimap.hpp"),
+        HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP = conf.CheckCXXHeader(
+            "boost/spirit/include/classic.hpp"),
     )
     conf.Finish()