Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54796 - in trunk/boost/spirit/home: karma/detail karma/nonterminal karma/operator support
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-08 11:43:17


Author: hkaiser
Date: 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
New Revision: 54796
URL: http://svn.boost.org/trac/boost/changeset/54796

Log:
Spirit: fixing several (corner case) use cases
Text files modified:
   trunk/boost/spirit/home/karma/detail/generate_to.hpp | 7 ++++---
   trunk/boost/spirit/home/karma/detail/output_iterator.hpp | 20 +++++++++++++++++++-
   trunk/boost/spirit/home/karma/nonterminal/rule.hpp | 1 +
   trunk/boost/spirit/home/karma/operator/kleene.hpp | 5 +++--
   trunk/boost/spirit/home/karma/operator/plus.hpp | 3 ++-
   trunk/boost/spirit/home/support/container.hpp | 8 +++++++-
   6 files changed, 36 insertions(+), 8 deletions(-)

Modified: trunk/boost/spirit/home/karma/detail/generate_to.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/generate_to.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/generate_to.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
 
 namespace boost { namespace spirit { namespace karma { namespace detail
 {
@@ -28,7 +29,7 @@
     {
         *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), p);
         ++sink;
- return sink.good();
+ return detail::sink_is_good(sink);
     }
 
     template <typename OutputIterator, typename Attribute>
@@ -37,7 +38,7 @@
     {
         *sink = p;
         ++sink;
- return sink.good();
+ return detail::sink_is_good(sink);
     }
 
     template <typename OutputIterator, typename CharEncoding, typename Tag>
@@ -52,7 +53,7 @@
     {
         *sink = p;
         ++sink;
- return sink.good();
+ return detail::sink_is_good(sink);
     }
 
     template <typename OutputIterator>

Modified: trunk/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/output_iterator.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -289,7 +289,12 @@
         {}
 
         output_proxy operator*() { return output_proxy(*this); }
- output_iterator& operator++() { ++sink; return *this; }
+ output_iterator& operator++()
+ {
+ if (NULL == buffer)
+ ++sink; // increment only if not buffering
+ return *this;
+ }
         output_iterator operator++(int)
         {
             output_iterator t(*this);
@@ -445,6 +450,19 @@
         bool enabled;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Sink>
+ bool sink_is_good(Sink const& sink)
+ {
+ return true; // the general case is always good
+ }
+
+ template <typename OutputIterator, typename Derived>
+ bool sink_is_good(output_iterator<OutputIterator, Derived> const& sink)
+ {
+ return sink.good(); // our own output iterators are handled separately
+ }
+
 }}}}
 
 #endif

Modified: trunk/boost/spirit/home/karma/nonterminal/rule.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/nonterminal/rule.hpp (original)
+++ trunk/boost/spirit/home/karma/nonterminal/rule.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -40,6 +40,7 @@
 {
     BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
 
+ using spirit::_pass;
     using spirit::_val;
     using spirit::_a;
     using spirit::_b;

Modified: trunk/boost/spirit/home/karma/operator/kleene.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/kleene.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/kleene.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+ // Copyright (c) 2001-2007 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -14,6 +14,7 @@
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
 #include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/container.hpp>
@@ -74,7 +75,7 @@
             {
                 result = subject.generate(sink, ctx, d, traits::deref(it));
             }
- return sink.good();
+ return detail::sink_is_good(sink);
         }
 
         template <typename Context>

Modified: trunk/boost/spirit/home/karma/operator/plus.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/plus.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/plus.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -14,6 +14,7 @@
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
 #include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/container.hpp>
@@ -78,7 +79,7 @@
             {
                 result = subject.generate(sink, ctx, d, traits::deref(it));
             }
- return sink.good();
+ return detail::sink_is_good(sink);
         }
 
         template <typename Context>

Modified: trunk/boost/spirit/home/support/container.hpp
==============================================================================
--- trunk/boost/spirit/home/support/container.hpp (original)
+++ trunk/boost/spirit/home/support/container.hpp 2009-07-08 11:43:16 EDT (Wed, 08 Jul 2009)
@@ -272,7 +272,13 @@
     inline bool
     compare(unused_type*, unused_type*)
     {
- return true;
+ return false;
+ }
+
+ inline bool
+ compare(unused_type const*, unused_type const*)
+ {
+ return false;
     }
 
 }}}


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