From: g0dil Date: Mon, 3 May 2010 10:52:49 +0000 (+0000) Subject: Utils/Console: Fix classic spirit include warnings X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=463db052ea9d1c292bfd40301d0dc4963411485e;p=senf.git Utils/Console: Fix classic spirit include warnings git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1614 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/.gitignore b/senf/.gitignore index e75ff76..a4de1b0 100644 --- a/senf/.gitignore +++ b/senf/.gitignore @@ -1 +1,2 @@ /local_config.hh +/autoconf.hh diff --git a/senf/Utils/Console/Parse.cc b/senf/Utils/Console/Parse.cc index f9b2d21..a2ace99 100644 --- a/senf/Utils/Console/Parse.cc +++ b/senf/Utils/Console/Parse.cc @@ -30,8 +30,16 @@ #include #include #include -#include -#include +#include + +#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP +# include +# include +#else +# include +# include +#endif + #include #include @@ -279,6 +287,9 @@ namespace { namespace boost { namespace spirit { +#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP +namespace classic { +#endif template <> struct position_policy @@ -305,6 +316,9 @@ namespace spirit { } }; +#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP +} +#endif }} prefix_ senf::console::CommandParser::CommandParser() @@ -321,27 +335,27 @@ template 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 result; + detail::boost_spirit::parse_info result; for(;;) { - result = boost::spirit::parse( + result = detail::boost_spirit::parse( b, e, * impl().grammar.use_parser()); 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.use_parser()); } - catch (boost::spirit::parser_error & ex) { + catch (detail::boost_spirit::parser_error & 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("")); PositionIterator e (arguments.end(), arguments.end(), std::string("")); detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info); - boost::spirit::parse_info result; + detail::boost_spirit::parse_info result; try { - result = boost::spirit::parse( b, e, + result = detail::boost_spirit::parse( b, e, impl().grammar.use_parser(), impl().grammar.use_parser() ); } - catch (boost::spirit::parser_error & ex) { + catch (detail::boost_spirit::parser_error & 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("")); PositionIterator e (path.end(), path.end(), std::string("")); detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info); - boost::spirit::parse_info result; + detail::boost_spirit::parse_info result; try { - result = boost::spirit::parse( b, e, + result = detail::boost_spirit::parse( b, e, impl().grammar.use_parser(), impl().grammar.use_parser() ); } - catch (boost::spirit::parser_error & ex) { + catch (detail::boost_spirit::parser_error & ex) { throwParserError(ex); } if (! result.full) { diff --git a/senf/Utils/Console/Parse.ih b/senf/Utils/Console/Parse.ih index 8bfb8f8..1fd7d2d 100644 --- a/senf/Utils/Console/Parse.ih +++ b/senf/Utils/Console/Parse.ih @@ -29,10 +29,19 @@ // Custom includes #include #include -#include -#include -#include -#include + +#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP +# include +# include +# include +# include +#else +# include +# include +# include +# include +#endif + #include ///////////////////////////////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 - struct CommandGrammar : boost::spirit::grammar > + struct CommandGrammar : boost_spirit::grammar > { /////////////////////////////////////////////////////////////////////////// // 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 struct definition - : public boost::spirit::grammar_def< boost::spirit::rule, - boost::spirit::rule, - boost::spirit::rule, - boost::spirit::rule > + : public boost_spirit::grammar_def< boost_spirit::rule, + boost_spirit::rule, + boost_spirit::rule, + boost_spirit::rule > { - boost::spirit::rule command, path, argument, word, string, hexstring, token, + boost_spirit::rule 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 boost::spirit::chset<> CommandGrammar::special_p ( + template boost_spirit::chset<> CommandGrammar::special_p ( "/(){};\""); - template boost::spirit::chset<> CommandGrammar::punctuation_p ( + template boost_spirit::chset<> CommandGrammar::punctuation_p ( ",="); - template boost::spirit::chset<> CommandGrammar::space_p ( + template boost_spirit::chset<> CommandGrammar::space_p ( " \t\n\r"); - template boost::spirit::chset<> CommandGrammar::invalid_p ( - (boost::spirit::chset<>('\0') | boost::spirit::chset<>("\x01-\x20")) - space_p ); - template boost::spirit::chset<> CommandGrammar::word_p ( - boost::spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p); - template boost::spirit::distinct_parser<> CommandGrammar::keyword_p ( - word_p | boost::spirit::ch_p('/')); + template boost_spirit::chset<> CommandGrammar::invalid_p ( + (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p ); + template boost_spirit::chset<> CommandGrammar::word_p ( + boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p); + template boost_spirit::distinct_parser<> CommandGrammar::keyword_p ( + word_p | boost_spirit::ch_p('/')); #endif diff --git a/senf/Utils/Console/Parse.test.cc b/senf/Utils/Console/Parse.test.cc index 27f1697..a214186 100644 --- a/senf/Utils/Console/Parse.test.cc +++ b/senf/Utils/Console/Parse.test.cc @@ -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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . 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.use_parser() ) . full ); diff --git a/senf/Utils/Phoenix.hh b/senf/Utils/Phoenix.hh index 4f1e6e0..40fcd96 100644 --- a/senf/Utils/Phoenix.hh +++ b/senf/Utils/Phoenix.hh @@ -27,7 +27,13 @@ #define HH_SENF_Utils_Phoenix_ 1 // Custom includes -#include +#include + +#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP +# include +#else +# include +#endif //#include "Phoenix.mpp" #include "Phoenix.ih" diff --git a/senf/config.hh b/senf/config.hh index cfa9319..31c1b45 100644 --- a/senf/config.hh +++ b/senf/config.hh @@ -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: - diff --git a/site_scons/senfutil.py b/site_scons/senfutil.py index 246f72e..f63873b 100644 --- a/site_scons/senfutil.py +++ b/site_scons/senfutil.py @@ -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()