Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66628 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/object boost/phoenix/operator boost/phoenix/operator/detail libs/phoenix/test libs/phoenix/test/object libs/phoenix/test/operator
From: thom.heller_at_[hidden]
Date: 2010-11-17 16:14:47


Author: theller
Date: 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
New Revision: 66628
URL: http://svn.boost.org/trac/boost/changeset/66628

Log:
made unpack work in proto transforms
finished implementation of member function pointer

Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp | 117 +++++++++++++++------------------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/object.hpp | 12 ++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/object/dynamic_cast.hpp | 19 ++++++
   sandbox/SOC/2010/phoenix3/boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp | 12 ++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp | 87 ++++++++++++++---------------
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 4
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp | 12 +++-
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp | 5 -
   9 files changed, 129 insertions(+), 141 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/limits.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -12,7 +12,7 @@
 #include <boost/preprocessor/dec.hpp>
 
 #if !defined(PHOENIX_LIMIT)
-# define PHOENIX_LIMIT 10
+# define PHOENIX_LIMIT 5
 #elif (PHOENIX_LIMIT < 5)
 # error "PHOENIX_LIMIT is set too low"
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/unpack.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -26,7 +26,7 @@
     UNPACK BOOST_PP_REPEAT_FROM_TO(N, ARITY, M3, ARITY) \
 /**/
 
-#define M0(_, N, __) BOOST_PP_REPEAT(BOOST_PP_INC(N), M1, N)
+#define M0(Z, N, __) BOOST_PP_CAT(BOOST_PP_REPEAT_, Z)(BOOST_PP_INC(N), M1, N)
 
 namespace boost { namespace phoenix
 {
@@ -77,75 +77,46 @@
                 typename proto::detail::uncvref<typename proto::when<proto::_, Seq>::template impl<Expr, State, Data>::result_type>::type
>::value>
         struct unpack_impl;
-
- template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R>
- struct unpack_impl<Expr, State, Data, Seq, Fun, R(), 1>
- : proto::transform_impl<Expr, State, Data>
- {
- typedef int result_type;
-
- result_type
- operator()(
- typename unpack_impl::expr_param e
- , typename unpack_impl::state_param s
- , typename unpack_impl::data_param d
- ) const
- {
- std::cout << "yeha ... unpack without params 1\n";
- return 5;
- }
- };
-
- template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R>
- struct unpack_impl<Expr, State, Data, Seq, Fun, R(), 2>
- : proto::transform_impl<Expr, State, Data>
- {
- typedef int result_type;
-
- result_type
- operator()(
- typename unpack_impl::expr_param e
- , typename unpack_impl::state_param s
- , typename unpack_impl::data_param d
- ) const
- {
- std::cout << "yeha ... unpack with Seq 2\n";
- return 5;
- }
- };
-
- template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R>
- struct unpack_impl<Expr, State, Data, Seq, Fun, R(), 3>
- : proto::transform_impl<Expr, State, Data>
- {
- //typedef proto::when<proto::_, Fun> fun_type;
- struct fun_type : proto::when<proto::_, Fun> {};
-
- // OK to evaluate is_callable<R> here. R should be compete by now.
- typedef
- typename mpl::if_c<
- proto::is_callable<R>::value
- , proto::call<R(fun_type(fusion_at_c<0>(Seq)), fun_type(fusion_at_c<1>(Seq)), fun_type(fusion_at_c<2>(Seq)))> // "R" is a function to call
- , proto::make<R(fun_type(fusion_at_c<0>(Seq)), fun_type(fusion_at_c<1>(Seq)), fun_type(fusion_at_c<2>(Seq)))> // "R" is an object to constructa
- >::type
- which;
-
- typedef typename which::template impl<Expr, State, Data>::result_type result_type;
-
- result_type
- operator()(
- typename unpack_impl::expr_param e
- , typename unpack_impl::state_param s
- , typename unpack_impl::data_param d
- ) const
- {
- return typename which::template impl<Expr, State, Data>()(e, s, d);
- }
- };
 
- #define M1(Z, N, ARITY)
 
- BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, _)
+#define M5(_, N, __) fun_type(fusion_at_c< N >(Seq))
+
+ #define M1(Z, N, ARITY) \
+ template <typename Expr, typename State, typename Data, typename Seq, typename Fun, typename R BOOST_PP_ENUM_TRAILING_PARAMS(ARITY, typename A)> \
+ struct unpack_impl<Expr, State, Data, Seq, Fun, R(M2(unpack, N, ARITY)), EXPR_N> \
+ : proto::transform_impl<Expr, State, Data> \
+ { \
+ struct fun_type : proto::when<proto::_, Fun> {}; \
+ \
+ typedef \
+ typename mpl::if_c< \
+ proto::is_callable<R>::value \
+ , proto::call<R(M2(BOOST_PP_ENUM(EXPR_N, M5, EXPR_N), N, ARITY))> \
+ , proto::make<R(M2(BOOST_PP_ENUM(EXPR_N, M5, EXPR_N), N, ARITY))> \
+ >::type \
+ which; \
+ \
+ typedef typename which::template impl<Expr, State, Data>::result_type result_type; \
+ \
+ result_type \
+ operator()( \
+ typename unpack_impl::expr_param e \
+ , typename unpack_impl::state_param s \
+ , typename unpack_impl::data_param d \
+ ) const \
+ { \
+ return typename which::template impl<Expr, State, Data>()(e, s, d); \
+ } \
+ \
+ }; \
+ /**/
+
+
+
+#define PHOENIX_ITERATION_PARAMS \
+ (3, (1, BOOST_PROTO_MAX_ARITY, \
+ <boost/phoenix/core/unpack.hpp>))
+#include PHOENIX_ITERATE()
 
         #undef M1
         }
@@ -165,7 +136,7 @@
                 template <typename Expr, typename State, typename Data> \
                 struct impl \
                         : phoenix::detail::unpack_impl< \
- Expr, State, Data, proto::_, proto::_, R()> \
+ Expr, State, Data, proto::_, proto::_, R(M2(phoenix::unpack, N, ARITY))> \
                 {}; \
         }; \
                                                                                     \
@@ -176,7 +147,7 @@
                 template <typename Expr, typename State, typename Data> \
                 struct impl \
                         : phoenix::detail::unpack_impl< \
- Expr, State, Data, proto::_, proto::_, R()> \
+ Expr, State, Data, proto::_, proto::_, R(M2(phoenix::unpack, N, ARITY))> \
                 {}; \
         }; \
                                                                                     \
@@ -200,7 +171,7 @@
         { \
                 template <typename Expr, typename State, typename Data> \
                 struct impl \
- : phoenix::detail::unpack_impl<Expr, State, Data, Seq, Fun, R()> \
+ : phoenix::detail::unpack_impl<Expr, State, Data, Seq, Fun, R(M2(phoenix::unpack, N, ARITY))> \
                 {}; \
         }; \
     /**/
@@ -219,4 +190,8 @@
 
 #else // BOOST_PP_IS_ITERATING
 
+#define EXPR_N BOOST_PP_ITERATION()
+
+ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, _)
+
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/object.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/object.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/object.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -8,12 +8,12 @@
 #ifndef PHOENIX_OBJECT_HPP
 #define PHOENIX_OBJECT_HPP
 
-#include <boost/phoenix/object/const_cast.hpp>
-#include <boost/phoenix/object/construct.hpp>
-#include <boost/phoenix/object/delete.hpp>
+//#include <boost/phoenix/object/const_cast.hpp>
+//#include <boost/phoenix/object/construct.hpp>
+//#include <boost/phoenix/object/delete.hpp>
 #include <boost/phoenix/object/dynamic_cast.hpp>
-#include <boost/phoenix/object/new.hpp>
-#include <boost/phoenix/object/reinterpret_cast.hpp>
-#include <boost/phoenix/object/static_cast.hpp>
+//#include <boost/phoenix/object/new.hpp>
+//#include <boost/phoenix/object/reinterpret_cast.hpp>
+//#include <boost/phoenix/object/static_cast.hpp>
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/object/dynamic_cast.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/object/dynamic_cast.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/object/dynamic_cast.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -8,10 +8,27 @@
 #ifndef PHOENIX_OBJECT_DYNAMIC_CAST_HPP
 #define PHOENIX_OBJECT_DYNAMIC_CAST_HPP
 
-#include <boost/phoenix/core/compose.hpp>
+//#include <boost/phoenix/core/compose.hpp>
 
 namespace boost { namespace phoenix
 {
+ namespace tag {
+ struct dynamic_cast_ {};
+ }
+
+ namespace rule
+ {
+ struct dynamic_cast_
+ : proto::unary_expr<tag::dynamic_cast_, meta_grammar>
+ {};
+ }
+
+ template <typename Dummy>
+ struct meta_grammar::case_<tag::dynamic_cast_, Dummy>
+ : proto::when<rule::dynamic_cast_, proto::external_transform>
+ {};
+
+
     namespace result_of
     {
         template <typename Env, typename T, typename U>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -31,8 +31,8 @@
                 : proto::result_of::make_expr<
                       tag::mem_fun_ptr
                     , phoenix_domain
- , MemPtr
- , Object>
+ , Object
+ , MemPtr>
             {};
 
 #define PHOENIX_ITERATE_RESULT_OF 1
@@ -57,7 +57,7 @@
             operator()() const
             {
                 return proto::make_expr<
- tag::mem_fun_ptr, phoenix_domain>(ptr, obj);
+ tag::mem_fun_ptr, phoenix_domain>(obj, ptr);
             }
 
 #define PHOENIX_ITERATE_OPERATOR 2
@@ -87,8 +87,8 @@
                 : proto::result_of::make_expr<
                       tag::mem_fun_ptr
                     , phoenix_domain
- , MemPtr
                     , Object
+ , MemPtr
                     , PHOENIX_A>
             {};
 
@@ -99,7 +99,7 @@
             operator()(PHOENIX_A_const_ref_a) const
             {
                 return proto::make_expr<
- tag::mem_fun_ptr, phoenix_domain>(ptr, obj, PHOENIX_a);
+ tag::mem_fun_ptr, phoenix_domain>(obj, ptr, PHOENIX_a);
             }
 
             template <PHOENIX_typename_A>
@@ -107,7 +107,7 @@
             operator()(PHOENIX_A_ref_a) const
             {
                 return proto::make_expr<
- tag::mem_fun_ptr, phoenix_domain>(ptr, obj, PHOENIX_a);
+ tag::mem_fun_ptr, phoenix_domain>(obj, ptr, PHOENIX_a);
             }
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -1,3 +1,5 @@
+#if !PHOENIX_IS_ITERATING
+
 #ifndef PHOENIX_OPERATOR_MEMBER_HPP
 #define PHOENIX_OPERATOR_MEMBER_HPP
 
@@ -6,13 +8,14 @@
 #include <boost/phoenix/core/compose.hpp>
 #include <boost/phoenix/core/domain.hpp>
 #include <boost/phoenix/core/mem_obj_ptr.hpp>
-#include <boost/phoenix/support/iterate.hpp>
 #include <boost/proto/make_expr.hpp>
 #include <boost/proto/tags.hpp>
 #include <boost/type_traits/is_member_object_pointer.hpp>*/
 #include <boost/phoenix/core/unpack.hpp>
 #include <boost/phoenix/operator/detail/mem_fun_ptr_gen.hpp>
+#include <boost/phoenix/support/iterate.hpp>
 #include <boost/type_traits/is_member_function_pointer.hpp>
+#include <boost/get_pointer.hpp>
 
 namespace boost { namespace phoenix
 {
@@ -45,59 +48,51 @@
         struct mem_fun_ptr_eval
                 : proto::callable
         {
- typedef int result_type;
-
- result_type
- operator()() const
- {
- std::cout << "ok ... evaluate ... \n";
- return 5;
- }
-
- template <typename T1>
- result_type
- operator()(T1 const& t1) const
- {
- std::cout << "ok ... evaluate ... \n";
- return 5;
- }
-
- template <typename T1, typename T2>
- result_type
- operator()(T1 const& t1, T2 const& t2) const
- {
- std::cout << "ok ... evaluate ... \n";
- return 5;
- }
+ //typedef int result_type;
 
- template <typename T1, typename T2, typename T3>
- result_type
- operator()(T1 const& t1, T2 const& t2, T3 const& t3) const
- {
- std::cout << "ok ... evaluate ... \n";
- std::cout << typeid(T1).name() << "\n";
- std::cout << typeid(T2).name() << "\n";
- std::cout << typeid(T3).name() << "\n";
- return 5;
- }
+ template<typename Sig>
+ struct result;
 
- template <typename Env, typename T1, typename T2, typename T3>
- result_type
- operator()(Env & env, T1 const& t1, T2 const& t2, T3 const& t3) const
- {
- std::cout << "ok ... evaluate ... \n";
- std::cout << typeid(T1).name() << "\n";
- std::cout << typeid(T2).name() << "\n";
- std::cout << typeid(T3).name() << "\n";
- return 5;
- }
+ #define PHOENIX_MEMBER_RESULT_OF(_, N, __) \
+ typename boost::result_of<evaluator(BOOST_PP_CAT(A, N) const&, Env&)>::type
+ #define PHOENIX_MEMBER_EVAL(_, N, __) \
+ eval(BOOST_PP_CAT(a, N), env)
+
+ #define PHOENIX_ITERATION_PARAMS \
+ (4, (0, PHOENIX_LIMIT, \
+ <boost/phoenix/operator/member.hpp>, \
+ PHOENIX_ITERATE_OPERATOR))
+ #include PHOENIX_ITERATE()
+ #undef PHOENIX_MEMBER_RESULT_OF
+ #undef PHOENIX_MEMBER_EVAL
         };
 
     template <typename Dummy>
     struct default_actions::when<rule::mem_fun_ptr, Dummy>
- : proto::call<mem_fun_ptr_eval(unpack(proto::_, evaluator(proto::_, _env)))>
+ : proto::call<mem_fun_ptr_eval(_env, unpack)>//(proto::_, evaluator(proto::_, _env)))>
     {};
 }}
 
 #endif
 
+#else // PHOENIX_IS_ITERATING
+
+ template<typename This, typename Env, typename T1, typename T2 BOOST_PP_ENUM_TRAILING_PARAMS(PHOENIX_ITERATION, typename A)>
+ struct result<This(Env, T1 const&, T2 const& BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(PHOENIX_ITERATION, A, const & BOOST_PP_INTERCEPT))>
+ : boost::result_of<
+ typename boost::remove_reference<typename boost::result_of<evaluator(T2 const &, Env&)>::type>::type(
+ typename boost::result_of<evaluator(T1 const&, Env&)>::type
+ BOOST_PP_ENUM_TRAILING(PHOENIX_ITERATION, PHOENIX_MEMBER_RESULT_OF, _)
+ )
+ >
+ {};
+
+ template <typename Env, typename T1, typename T2 BOOST_PP_ENUM_TRAILING_PARAMS(PHOENIX_ITERATION, typename A)>
+ typename result<mem_fun_ptr_eval(Env &, T1 const&, T2 const& BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(PHOENIX_ITERATION, A, const & BOOST_PP_INTERCEPT))>::type
+ operator()(Env & env, T1 const& t1, T2 const& t2 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(PHOENIX_ITERATION, A, const & a)) const
+ {
+ return (get_pointer(eval(t1, env))->*eval(t2, env))(BOOST_PP_ENUM(PHOENIX_ITERATION, PHOENIX_MEMBER_EVAL, _));
+ }
+
+#endif
+

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -122,7 +122,7 @@
 # #[ run include/bind_bind_member_function.cpp ]
 # #[ run include/bind_bind_member_variable.cpp ]
 # [ run include/bind.cpp ]
-# [ run include/core_actor.cpp ]
+ [ run include/core_actor.cpp ]
 # [ run include/core_argument.cpp ]
 # [ run include/core_arity.cpp ]
 # [ run include/core_compose.cpp ]
@@ -152,7 +152,7 @@
 # [ run include/operator.cpp ]
 # [ run include/operator_if_else.cpp ]
 # [ run include/operator_io.cpp ]
-# #[ run include/operator_member.cpp ]
+# [ run include/operator_member.cpp ]
 # [ run include/operator_operator.cpp ]
 # [ run include/scope.cpp ]
 # [ run include/scope_dynamic.cpp ]

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/object/cast_tests.cpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -35,21 +35,25 @@
 main()
 {
     using boost::phoenix::arg_names::arg1;
- using boost::phoenix::const_cast_;
+ //using boost::phoenix::const_cast_;
     using boost::phoenix::dynamic_cast_;
- using boost::phoenix::reinterpret_cast_;
- using boost::phoenix::static_cast_;
+ //using boost::phoenix::reinterpret_cast_;
+ //using boost::phoenix::static_cast_;
 
+ /*
     {
         U u;
         BOOST_TEST(arg1(u).foo() == "U");
         BOOST_TEST(static_cast_<T&>(arg1)(u).foo() == "T");
     }
+ */
 
+ /*
     {
         U const u = U();
         BOOST_TEST(const_cast_<U&>(arg1)(u).foo() == "U");
     }
+ */
 
     {
         VU u;
@@ -58,10 +62,12 @@
         BOOST_TEST(dynamic_cast_<VU*>(arg1)(tp) != 0);
     }
 
+ /*
     {
         void* p = 0;
         reinterpret_cast_<VU*>(arg1)(p); // compile test only
     }
+ */
 
     return boost::report_errors();
 }

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp 2010-11-17 16:14:45 EST (Wed, 17 Nov 2010)
@@ -42,18 +42,14 @@
     const Test* cptr = &test;
     Test* ptr = &test;
 
- /*
     BOOST_TEST((val(ptr)->*&Test::value)() == 1);
     BOOST_TEST((val(cptr)->*&Test::value)() == 1);
     BOOST_TEST((arg1->*&Test::value)(cptr) == 1);
 
     ((val(ptr)->*&Test::value) = 2)();
     BOOST_TEST(test.value == 2);
- */
 
- (val(ptr)->*&Test::func)(3)();
 
- /*
     BOOST_TEST((val(ptr)->*&Test::func)(3)() == 3);
     int i = 33;
     BOOST_TEST((arg1->*&Test::func)(arg2)(cptr, i) == i);
@@ -92,7 +88,6 @@
 
     BOOST_TEST((arg1->*&Test::value)(captr) == 2);
     BOOST_TEST((arg1->*&Test::func)(11)(captr) == 11);
- */
 
     return 0;
 }


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