Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64258 - in trunk: boost/spirit/home/qi/detail boost/spirit/home/support libs/spirit/test libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-07-22 09:24:24


Author: hkaiser
Date: 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
New Revision: 64258
URL: http://svn.boost.org/trac/boost/changeset/64258

Log:
Spirit: fixed a problem while handling single element sequence attributes
Added:
   trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/qi/detail/assign_to.hpp | 11 +++++++++++
   trunk/boost/spirit/home/support/attributes.hpp | 20 ++++++++++++--------
   trunk/boost/spirit/home/support/attributes_fwd.hpp | 8 ++++++--
   trunk/libs/spirit/test/Jamfile | 1 +
   4 files changed, 30 insertions(+), 10 deletions(-)

Modified: trunk/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/assign_to.hpp 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
@@ -128,6 +128,16 @@
         }
     };
 
+ template <typename Attribute>
+ struct assign_to_attribute_from_value<Attribute, Attribute>
+ {
+ static void
+ call(Attribute const& val, Attribute& attr)
+ {
+ attr = val;
+ }
+ };
+
     template <typename Attribute, typename T>
     struct assign_to_attribute_from_value<reference_wrapper<Attribute>, T>
     {
@@ -147,6 +157,7 @@
         }
     };
 
+ ///////////////////////////////////////////////////////////////////////////
     template <typename T, typename Attribute>
     inline void
     assign_to(T const& val, Attribute& attr)

Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
@@ -898,18 +898,22 @@
     };
 
     template <typename Out, typename T>
- inline void print_attribute(Out& out, T const& val)
+ struct print_attribute_debug<Out, boost::optional<T> >
     {
- print_attribute_debug<Out, T>::call(out, val);
- }
+ static void call(Out& out, T const& val)
+ {
+ if (val)
+ print_attribute(out, *val);
+ else
+ out << "<empty>";
+ }
+ };
 
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Out, typename T>
- inline void print_attribute(Out& out, boost::optional<T> const& val)
+ inline void print_attribute(Out& out, T const& val)
     {
- if (val)
- print_attribute(out, *val);
- else
- out << "<empty>";
+ print_attribute_debug<Out, T>::call(out, val);
     }
 
     template <typename Out>

Modified: trunk/boost/spirit/home/support/attributes_fwd.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes_fwd.hpp (original)
+++ trunk/boost/spirit/home/support/attributes_fwd.hpp 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
@@ -181,13 +181,17 @@
     struct print_attribute_debug;
 
     template <typename Out, typename T>
- void print_attribute(Out& out, T const& val);
+ void print_attribute(Out&, T const&);
 
+ template <typename Out>
+ void print_attribute(Out&, unused_type);
+
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Char, typename Enable = void>
     struct token_printer_debug;
 
     template<typename Out, typename T>
- void print_token(Out& out, T const& val);
+ void print_token(Out&, T const&);
 
 }}}
 

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
@@ -159,6 +159,7 @@
     [ run qi/reorder_test.cpp : : : : ]
     [ run karma/karma_optional_double.cpp : : : : ]
     [ run karma/semantic_action_attribute.cpp : : : : ]
+ [ compile qi/single_element_sequence_attribute.cpp : : qi_single_element_sequence_attribute ]
 
     ;
 

Added: trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp 2010-07-22 09:24:20 EDT (Thu, 22 Jul 2010)
@@ -0,0 +1,40 @@
+// Copyright (c) 2010 Josh Wilson
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/spirit/include/qi.hpp>
+#include <boost/fusion/include/adapt_struct.hpp>
+#include <boost/variant.hpp>
+#include <string>
+
+namespace qi = boost::spirit::qi;
+
+///////////////////////////////////////////////////////////////////////////////
+struct Number { float base; };
+
+BOOST_FUSION_ADAPT_STRUCT( Number, (float, base) )
+
+void instantiate1()
+{
+ qi::symbols<char, Number> sym;
+ qi::rule<std::string::const_iterator, Number()> rule;
+ rule %= sym; // Caused compiler error after getting r61322
+}
+
+///////////////////////////////////////////////////////////////////////////////
+typedef boost::variant<int, float> internal_type;
+
+struct Number2 { internal_type base; };
+
+BOOST_FUSION_ADAPT_STRUCT( Number2, (internal_type, base) )
+
+void instantiate2()
+{
+ qi::symbols<char, Number2> sym;
+ qi::rule<std::string::const_iterator, Number2()> rule;
+ rule %= sym; // Caused compiler error after getting r61322
+}
+


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