Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58872 - in branches/release: . boost boost/algorithm/string boost/archive boost/config boost/filesystem boost/functional/hash boost/fusion boost/graph boost/integer boost/interprocess boost/intrusive boost/iostreams boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/lex/lexer/lexertl boost/spirit/home/qi/detail boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/utility boost/variant boost/wave doc libs libs/config libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/regex libs/regex/doc libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/thread/doc libs/timer libs/tr1 libs/type_traits libs/unordered libs/utility libs/wave more people status tools tools/bcp tools/boostbook tools/build/v2 tools/inspect tools/quickbook tools/regression tools/release tools/wave wiki
From: hartmut.kaiser_at_[hidden]
Date: 2010-01-10 11:25:14


Author: hkaiser
Date: 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
New Revision: 58872
URL: http://svn.boost.org/trac/boost/changeset/58872

Log:
Spirit: merging from trunk
Properties modified:
   branches/release/ (props changed)
   branches/release/CMakeLists.txt (props changed)
   branches/release/INSTALL (props changed)
   branches/release/Jamroot (props changed)
   branches/release/LICENSE_1_0.txt (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost-build.jam (props changed)
   branches/release/boost.css (props changed)
   branches/release/boost.png (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/config/ (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/functional/hash/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/integer/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/iostreams/ (props changed)
   branches/release/boost/math/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/regex/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/statechart/ (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/tr1/ (props changed)
   branches/release/boost/type_traits/ (props changed)
   branches/release/boost/unordered/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/variant/ (props changed)
   branches/release/boost/version.hpp (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/bootstrap.bat (props changed)
   branches/release/bootstrap.sh (props changed)
   branches/release/doc/ (props changed)
   branches/release/index.htm (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/config/ (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/integer/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/iostreams/ (props changed)
   branches/release/libs/libraries.htm (props changed)
   branches/release/libs/maintainers.txt (props changed)
   branches/release/libs/math/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
   branches/release/libs/program_options/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/regex/ (props changed)
   branches/release/libs/regex/doc/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/statechart/ (props changed)
   branches/release/libs/static_assert/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/thread/doc/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/tr1/ (props changed)
   branches/release/libs/type_traits/ (props changed)
   branches/release/libs/unordered/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/more/ (props changed)
   branches/release/people/ (props changed)
   branches/release/rst.css (props changed)
   branches/release/status/ (props changed)
   branches/release/tools/ (props changed)
   branches/release/tools/bcp/ (props changed)
   branches/release/tools/boostbook/ (props changed)
   branches/release/tools/build/v2/ (props changed)
   branches/release/tools/inspect/ (props changed)
   branches/release/tools/quickbook/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
   branches/release/wiki/ (props changed)
Text files modified:
   branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 16 ++++++++++++++--
   branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp | 14 +++++++++++++-
   branches/release/boost/spirit/home/qi/detail/assign_to.hpp | 28 ++++++++++++++++++++++++++--
   branches/release/boost/spirit/home/qi/detail/pass_container.hpp | 12 +++++-------
   branches/release/boost/spirit/home/support/attributes_fwd.hpp | 3 +++
   branches/release/boost/spirit/home/support/container.hpp | 22 ++++++++++++++++++++++
   branches/release/libs/spirit/test/qi/lit.cpp | 2 ++
   branches/release/libs/spirit/test/qi/sequence.cpp | 35 +++++++++++++++++++++--------------
   8 files changed, 106 insertions(+), 26 deletions(-)

Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -59,7 +59,19 @@
 
             // The following functions are used by the implementation of the
             // placeholder '_state'.
- void set_state_name (char_type const*) {}
+ template <typename Char>
+ void set_state_name (Char const*)
+ {
+// some (random) versions of gcc instantiate this function even if it's not
+// needed leading to false static asserts
+#if !defined(__GNUC__)
+ // If you see a compile time assertion below you're probably
+ // using a token type not supporting lexer states (the 3rd
+ // template parameter of the token is mpl::false_), but your
+ // code uses state changes anyways.
+ BOOST_STATIC_ASSERT(false);
+#endif
+ }
             char_type const* get_state_name() const { return rules_.initial(); }
             std::size_t get_state_id (char_type const*) const
             {
@@ -362,4 +374,4 @@
 
 }}}}
 
-#endif
+#endif
\ No newline at end of file

Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -75,7 +75,19 @@
 
             // The following functions are used by the implementation of the
             // placeholder '_state'.
- void set_state_name (char_type const*) {}
+ template <typename Char>
+ void set_state_name (Char const*)
+ {
+// some (random) versions of gcc instantiate this function even if it's not
+// needed leading to false static asserts
+#if !defined(__GNUC__)
+ // If you see a compile time assertion below you're probably
+ // using a token type not supporting lexer states (the 3rd
+ // template parameter of the token is mpl::false_), but your
+ // code uses state changes anyways.
+ BOOST_STATIC_ASSERT(false);
+#endif
+ }
             char_type const* get_state_name() const
             {
                 return get_state_name_(0);

Modified: branches/release/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/assign_to.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -16,8 +16,10 @@
 #include <boost/spirit/home/qi/detail/construct.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/attributes_fwd.hpp>
+#include <boost/spirit/home/support/container.hpp>
 #include <boost/spirit/home/phoenix/core/actor.hpp>
 #include <boost/ref.hpp>
+#include <boost/range/iterator_range.hpp>
 
 namespace boost { namespace spirit { namespace traits
 {
@@ -32,7 +34,12 @@
         static void
         call(Iterator const& first, Iterator const& last, Attribute& attr)
         {
- attr = Attribute(first, last);
+ if (traits::is_empty(attr))
+ attr = Attribute(first, last);
+ else {
+ for (Iterator i = first; i != last; ++i)
+ push_back(attr, *i);
+ }
         }
     };
 
@@ -44,7 +51,24 @@
         call(Iterator const& first, Iterator const& last
           , reference_wrapper<Attribute> attr)
         {
- attr = Attribute(first, last);
+ if (traits::is_empty(attr))
+ attr = Attribute(first, last);
+ else {
+ for (Iterator i = first; i != last; ++i)
+ push_back(attr, *i);
+ }
+ }
+ };
+
+ template <typename Iterator>
+ struct assign_to_attribute_from_iterators<
+ iterator_range<Iterator>, Iterator>
+ {
+ static void
+ call(Iterator const& first, Iterator const& last
+ , iterator_range<Iterator>& attr)
+ {
+ attr = iterator_range<Iterator>(first, last);
         }
     };
 

Modified: branches/release/boost/spirit/home/qi/detail/pass_container.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/pass_container.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/pass_container.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -17,7 +17,6 @@
 #include <boost/type_traits/is_base_of.hpp>
 #include <boost/type_traits/is_convertible.hpp>
 #include <boost/mpl/bool.hpp>
-#include <boost/mpl/and.hpp>
 
 namespace boost { namespace spirit { namespace qi { namespace detail
 {
@@ -100,12 +99,11 @@
         template <typename Component>
         bool dispatch_attribute(Component const& component, mpl::true_) const
         {
- typedef typename traits::attribute_of<
- Component, context_type, iterator_type>::type attribute_type;
-
- typedef mpl::and_<
- traits::is_container<attribute_type>
- , is_convertible<attribute_type, Attr> > predicate;
+ typedef traits::is_container<
+ typename traits::attribute_of<
+ Component, context_type, iterator_type
+ >::type
+ > predicate;
 
             return dispatch_attribute_element(component, predicate());
         }

Modified: branches/release/boost/spirit/home/support/attributes_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes_fwd.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes_fwd.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -70,6 +70,9 @@
     template <typename Container, typename T, typename Enable = void>
     struct push_back_container;
 
+ template <typename Container, typename Enable = void>
+ struct is_empty_container;
+
     ///////////////////////////////////////////////////////////////////////
     // Determine the iterator type of the given container type
     ///////////////////////////////////////////////////////////////////////

Modified: branches/release/boost/spirit/home/support/container.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/container.hpp (original)
+++ branches/release/boost/spirit/home/support/container.hpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -327,6 +327,28 @@
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename Container, typename Enable/* = void*/>
+ struct is_empty_container
+ {
+ static bool call(Container const& c)
+ {
+ return c.empty();
+ }
+ };
+
+ template <typename Container>
+ bool is_empty(Container const& c)
+ {
+ return is_empty_container<Container>::call(c);
+ }
+
+ template <typename T>
+ bool is_empty(unused_type)
+ {
+ return true;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Container, typename Enable/* = void*/>
     struct begin_container
     {
         static typename container_iterator<Container>::type call(Container& c)

Modified: branches/release/libs/spirit/test/qi/lit.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/lit.cpp (original)
+++ branches/release/libs/spirit/test/qi/lit.cpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -84,8 +84,10 @@
         std::string s;
         BOOST_TEST((test_attr("kimpo", string("kimpo"), s)));
         BOOST_TEST(s == "kimpo");
+ s.clear();
         BOOST_TEST((test_attr(L"kimpo", string(L"kimpo"), s)));
         BOOST_TEST(s == "kimpo");
+ s.clear();
         BOOST_TEST((test_attr("x", string("x"), s)));
         BOOST_TEST(s == "x");
     }

Modified: branches/release/libs/spirit/test/qi/sequence.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/sequence.cpp (original)
+++ branches/release/libs/spirit/test/qi/sequence.cpp 2010-01-10 11:25:12 EST (Sun, 10 Jan 2010)
@@ -145,14 +145,21 @@
         BOOST_TEST(v[0] == 'a');
         BOOST_TEST(v[1] == 'b');
         BOOST_TEST(v[2] == 'c');
+ }
+
+ { // alternative forms of attributes. Allow sequences to take in
+ // stl containers.
 
+ std::string s;
+ BOOST_TEST(test_attr("foobar", string("foo") >> string("bar"), s));
+ BOOST_TEST(s == "foobar");
     }
 
- // alternative forms of attributes. Allow sequences to take in
- // stl containers of stl containers.
+// // alternative forms of attributes. Allow sequences to take in
+// // stl containers of stl containers.
 // {
 // // this use case still does not compile, needs some additional work
-//
+//
 // std::vector<std::string> v;
 // BOOST_TEST(test_attr("abc1,abc2,abc3",
 // *~char_(',') >> *(',' >> *~char_(',')), v));
@@ -162,17 +169,17 @@
 // BOOST_TEST(v[2] == "abc3");
 // }
 
- {
- std::vector<std::string> v;
- rule<char const*, std::string()> e = *~char_(',');
- rule<char const*, std::vector<std::string>()> l = e >> *(',' >> e);
-
- BOOST_TEST(test_attr("abc1,abc2,abc3", l, v));
- BOOST_TEST(v.size() == 3);
- BOOST_TEST(v[0] == "abc1");
- BOOST_TEST(v[1] == "abc2");
- BOOST_TEST(v[2] == "abc3");
- }
+// {
+// std::vector<std::string> v;
+// rule<char const*, std::string()> e = *~char_(',');
+// rule<char const*, std::vector<std::string>()> l = e >> *(',' >> e);
+//
+// BOOST_TEST(test_attr("abc1,abc2,abc3", l, v));
+// BOOST_TEST(v.size() == 3);
+// BOOST_TEST(v[0] == "abc1");
+// BOOST_TEST(v[1] == "abc2");
+// BOOST_TEST(v[2] == "abc3");
+// }
 
     {
         std::vector<char> v;


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