Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-12 13:27:29


Author: eric_niebler
Date: 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
New Revision: 45302
URL: http://svn.boost.org/trac/boost/changeset/45302

Log:
loop statements
Added:
   branches/proto/v4/boost/phoenix/statement/do_while.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/statement/for.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/statement/while.hpp (contents, props changed)
Text files modified:
   branches/proto/v4/boost/phoenix/core/actor.hpp | 7 +++----
   branches/proto/v4/boost/phoenix/statement.hpp | 6 +++---
   branches/proto/v4/boost/phoenix/statement/if.hpp | 9 ++++++---
   3 files changed, 12 insertions(+), 10 deletions(-)

Modified: branches/proto/v4/boost/phoenix/core/actor.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/core/actor.hpp (original)
+++ branches/proto/v4/boost/phoenix/core/actor.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -71,6 +71,7 @@
               : proto::switch_<struct is_nullary_cases>
             {};
 
+ ////////////////////////////////////////////////////////////////////////////////////////
             struct is_nullary_cases
             {
                 template<typename Tag>
@@ -86,10 +87,8 @@
               : proto::otherwise<is_terminal_nullary<proto::_value>()>
             {};
 
- struct evaluator;
-
             ////////////////////////////////////////////////////////////////////////////////////////
- struct cases
+ struct evaluator_cases
             {
                 template<typename Tag>
                 struct case_
@@ -99,7 +98,7 @@
 
             ////////////////////////////////////////////////////////////////////////////////////////
             struct evaluator
- : proto::switch_<cases>
+ : proto::switch_<evaluator_cases>
             {};
 
             ////////////////////////////////////////////////////////////////////////////////////////

Modified: branches/proto/v4/boost/phoenix/statement.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/statement.hpp (original)
+++ branches/proto/v4/boost/phoenix/statement.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -8,12 +8,12 @@
 #define PHOENIX_STATEMENT_HPP
 
 #include <boost/phoenix/version.hpp>
-//#include <boost/phoenix/statement/do_while.hpp>
-//#include <boost/phoenix/statement/for.hpp>
+#include <boost/phoenix/statement/do_while.hpp>
+#include <boost/phoenix/statement/for.hpp>
 #include <boost/phoenix/statement/if.hpp>
 //#include <boost/phoenix/statement/sequence.hpp>
 //#include <boost/phoenix/statement/switch.hpp>
-//#include <boost/phoenix/statement/while.hpp>
+#include <boost/phoenix/statement/while.hpp>
 //#include <boost/phoenix/statement/throw.hpp>
 //#include <boost/phoenix/statement/try_catch.hpp>
 

Added: branches/proto/v4/boost/phoenix/statement/do_while.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/statement/do_while.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -0,0 +1,119 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_DO_WHILE_HPP_EAN_2008_05_09
+#define BOOST_PHOENIX_DO_WHILE_HPP_EAN_2008_05_09
+
+#include <boost/ref.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4355) // 'this' : used in base member initializer list
+#endif
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace tag
+ {
+ struct do_while_ {};
+ }
+
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Body>
+ struct do_while_generator
+ {
+ explicit do_while_generator(Body const &b)
+ : body(b)
+ {}
+
+ template<typename Cond>
+ typename proto::result_of::make_expr<
+ tag::do_while_
+ , domain
+ , Body const &
+ , Cond const &
+ >::type const
+ operator()(Cond const &cond) const
+ {
+ return proto::implicit_expr(this->body, cond);
+ }
+
+ private:
+ do_while_generator &operator =(do_while_generator const &);
+ Body const &body;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Body>
+ struct do_body
+ {
+ explicit do_body(Body const &body)
+ : while_(body)
+ {}
+
+ do_while_generator<Body> while_;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ struct do_generator
+ {
+ template<typename Body>
+ do_body<Body> const
+ operator[](Body const &body) const
+ {
+ return do_body<Body>(body);
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Proto transform that evaluates do_[ body ].while_( condition )
+ struct do_while_evaluator : proto::transform<do_while_evaluator>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : proto::transform_impl<Expr, State, Data>
+ {
+ typedef void result_type;
+
+ void operator()(
+ typename impl::expr_param expr
+ , typename impl::state_param state
+ , typename impl::data_param data
+ ) const
+ {
+ do
+ {
+ evaluator()(proto::child_c<0>(expr), state, data);
+ }
+ while(evaluator()(proto::child_c<1>(expr), state, data));
+ }
+ };
+ };
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ detail::do_generator const do_ = {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<tag::do_while_, void>
+ : proto::when<
+ proto::nary_expr<tag::do_while_, evaluator, evaluator>
+ , detail::do_while_evaluator
+ >
+ {};
+
+}}
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+#endif

Added: branches/proto/v4/boost/phoenix/statement/for.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/statement/for.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -0,0 +1,100 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_FOR_HPP_EAN_2008_05_09
+#define BOOST_PHOENIX_FOR_HPP_EAN_2008_05_09
+
+#include <boost/ref.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace tag
+ {
+ struct for_ {};
+ }
+
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Init, typename Cond, typename Oper>
+ struct for_generator
+ {
+ explicit for_generator(Init const &i, Cond const &c, Oper const &o)
+ : init(i)
+ , cond(c)
+ , oper(o)
+ {}
+
+ template<typename Body>
+ typename proto::result_of::make_expr<
+ tag::for_
+ , domain
+ , Init const &
+ , Cond const &
+ , Oper const &
+ , Body const &
+ >::type const
+ operator[](Body const &body) const
+ {
+ return proto::implicit_expr(this->init, this->cond, this->oper, body);
+ }
+
+ private:
+ for_generator &operator =(for_generator const &);
+ Init const &init;
+ Cond const &cond;
+ Oper const &oper;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Proto transform that evaluates for_(x,y,z)[expr]
+ struct for_evaluator : proto::transform<for_evaluator>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : proto::transform_impl<Expr, State, Data>
+ {
+ typedef void result_type;
+
+ void operator()(
+ typename impl::expr_param expr
+ , typename impl::state_param state
+ , typename impl::data_param data
+ ) const
+ {
+ for(evaluator()(proto::child_c<0>(expr), state, data)
+ ; evaluator()(proto::child_c<1>(expr), state, data)
+ ; evaluator()(proto::child_c<2>(expr), state, data))
+ {
+ evaluator()(proto::child_c<3>(expr), state, data);
+ }
+ }
+ };
+ };
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Init, typename Cond, typename Oper>
+ detail::for_generator<Init, Cond, Oper> const
+ for_(Init const &i, Cond const &c, Oper const &o)
+ {
+ return detail::for_generator<Init, Cond, Oper>(i, c, o);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<tag::for_, void>
+ : proto::when<
+ proto::nary_expr<tag::for_, evaluator, evaluator, evaluator, evaluator>
+ , detail::for_evaluator
+ >
+ {};
+
+}}
+
+#endif

Modified: branches/proto/v4/boost/phoenix/statement/if.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/statement/if.hpp (original)
+++ branches/proto/v4/boost/phoenix/statement/if.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -56,6 +56,7 @@
             }
 
         private:
+ else_generator &operator =(else_generator const &);
             Expr const &if_;
         };
 
@@ -102,6 +103,7 @@
             }
 
         private:
+ if_generator &operator =(if_generator const &);
             Cond const &cond;
         };
 
@@ -114,7 +116,7 @@
             {
                 typedef void result_type;
 
- result_type operator()(
+ void operator()(
                     typename impl::expr_param expr
                   , typename impl::state_param state
                   , typename impl::data_param data
@@ -137,7 +139,7 @@
             {
                 typedef void result_type;
 
- result_type operator()(
+ void operator()(
                     typename impl::expr_param expr
                   , typename impl::state_param state
                   , typename impl::data_param data
@@ -158,7 +160,8 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////
     template<typename Expr>
- detail::if_generator<Expr> const if_(Expr const &expr)
+ detail::if_generator<Expr> const
+ if_(Expr const &expr)
     {
         return detail::if_generator<Expr>(expr);
     }

Added: branches/proto/v4/boost/phoenix/statement/while.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/statement/while.hpp 2008-05-12 13:27:29 EDT (Mon, 12 May 2008)
@@ -0,0 +1,92 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_WHILE_HPP_EAN_2008_05_09
+#define BOOST_PHOENIX_WHILE_HPP_EAN_2008_05_09
+
+#include <boost/ref.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace tag
+ {
+ struct while_ {};
+ }
+
+ namespace detail
+ {
+ ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Cond>
+ struct while_generator
+ {
+ explicit while_generator(Cond const &c)
+ : cond(c)
+ {}
+
+ template<typename Body>
+ typename proto::result_of::make_expr<
+ tag::while_
+ , domain
+ , Cond const &
+ , Body const &
+ >::type const
+ operator[](Body const &body) const
+ {
+ return proto::implicit_expr(this->cond, body);
+ }
+
+ private:
+ while_generator &operator =(while_generator const &);
+ Cond const &cond;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Proto transform that evaluates if_(condition)[ expression ]
+ struct while_evaluator : proto::transform<while_evaluator>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : proto::transform_impl<Expr, State, Data>
+ {
+ typedef void result_type;
+
+ void operator()(
+ typename impl::expr_param expr
+ , typename impl::state_param state
+ , typename impl::data_param data
+ ) const
+ {
+ while(evaluator()(proto::left(expr), state, data))
+ {
+ evaluator()(proto::right(expr), state, data);
+ }
+ }
+ };
+ };
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Expr>
+ detail::while_generator<Expr> const
+ while_(Expr const &expr)
+ {
+ return detail::while_generator<Expr>(expr);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<>
+ struct extension<tag::while_, void>
+ : proto::when<
+ proto::binary_expr<tag::while_, evaluator, evaluator>
+ , detail::while_evaluator
+ >
+ {};
+
+}}
+
+#endif


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