|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-12-03 01:18:44
Author: eric_niebler
Date: 2007-12-03 01:18:43 EST (Mon, 03 Dec 2007)
New Revision: 41633
URL: http://svn.boost.org/trac/boost/changeset/41633
Log:
clean-up
Text files modified:
branches/proto/v3/boost/xpressive/detail/static/grammar.hpp | 5
branches/proto/v3/boost/xpressive/proto/traits.hpp | 83 ++++++++++++++
branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 2
branches/proto/v3/boost/xpressive/proto/transform/when.hpp | 227 +++++++--------------------------------
4 files changed, 130 insertions(+), 187 deletions(-)
Modified: branches/proto/v3/boost/xpressive/detail/static/grammar.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar.hpp 2007-12-03 01:18:43 EST (Mon, 03 Dec 2007)
@@ -532,9 +532,8 @@
_
, repeat_end_matcher<Greedy>(
mark_number(_arg(_left))
- // BUGBUG work around gcc bug
- , always<min_type<Tag> > //, min_type<Tag>()
- , always<max_type<Tag> > //, max_type<Tag>()
+ , always<min_type<Tag> > // min_type<Tag>()
+ , always<max_type<Tag> > // max_type<Tag>()
)
)
)
Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-03 01:18:43 EST (Mon, 03 Dec 2007)
@@ -593,6 +593,89 @@
return result_of::as_arg<T, Domain>::call(t);
}
+ namespace detail
+ {
+ template<typename... Args>
+ struct back;
+
+ template<typename A0>
+ struct back<A0>
+ {
+ typedef A0 type;
+ };
+
+ template<typename A0, typename A1>
+ struct back<A0, A1>
+ {
+ typedef A1 type;
+ };
+
+ template<typename A0, typename A1, typename A2>
+ struct back<A0, A1, A2>
+ {
+ typedef A2 type;
+ };
+
+ template<typename A0, typename A1, typename A2, typename A3>
+ struct back<A0, A1, A2, A3>
+ {
+ typedef A3 type;
+ };
+
+ template<typename A0, typename A1, typename A2, typename A3, typename... Rest>
+ struct back<A0, A1, A2, A3, Rest...>
+ : back<Rest...>
+ {};
+
+ template<typename T, typename EnableIf = void>
+ struct is_transform2_
+ : mpl::false_
+ {};
+
+ template<typename T>
+ struct is_transform2_<T, typename T::proto_is_transform_>
+ : mpl::true_
+ {};
+
+ template<typename T>
+ struct is_transform_
+ : is_transform2_<T>
+ {};
+
+ // TODO when gcc #33965 is fixed, change the idiom to
+ // template<typename X, bool IsTransform = true> struct my_transform {...};
+ template<template<typename...> class T, typename... Args>
+ struct is_transform_<T<Args...> >
+ : is_same<typename back<Args...>::type, transform_base>
+ {};
+
+ } // namespace detail
+
+ /// is_transform
+ ///
+ template<typename T>
+ struct is_transform
+ : proto::detail::is_transform_<T>
+ {};
+
+ // work around GCC bug
+ template<typename Tag, typename Args, long N>
+ struct is_transform<expr<Tag, Args, N> >
+ : mpl::false_
+ {};
+
+ /// is_aggregate
+ ///
+ template<typename T>
+ struct is_aggregate
+ : is_pod<T>
+ {};
+
+ template<typename Tag, typename Args, long N>
+ struct is_aggregate<expr<Tag, Args, N> >
+ : mpl::true_
+ {};
+
}}
#undef CV
Modified: branches/proto/v3/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/make.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/make.hpp 2007-12-03 01:18:43 EST (Mon, 03 Dec 2007)
@@ -89,7 +89,7 @@
template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
struct apply_lambda_<R(*)(Args...), Expr, State, Visitor, false>
- : boost::result_of<when<_, R(*)(Args...)>(Expr, State, Visitor)>
+ : boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>
{};
// work around GCC bug
Modified: branches/proto/v3/boost/xpressive/proto/transform/when.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/when.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/when.hpp 2007-12-03 01:18:43 EST (Mon, 03 Dec 2007)
@@ -1,210 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
-/// \file transform.hpp
+/// \file when.hpp
/// Definition of when transform.
//
// Copyright 2007 Eric Niebler. 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_PROTO_TRANSFORM_CASE_HPP_EAN_10_29_2007
-#define BOOST_PROTO_TRANSFORM_CASE_HPP_EAN_10_29_2007
+#ifndef BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
+#define BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
#include <boost/mpl/if.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/type_traits.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/traits.hpp>
#include <boost/xpressive/proto/transform/call.hpp>
#include <boost/xpressive/proto/transform/make.hpp>
-namespace boost { namespace proto
+namespace boost { namespace proto { namespace transform
{
- template<typename T>
- struct is_aggregate
- : is_pod<T>
- {};
-
- template<typename Tag, typename Args, long N>
- struct is_aggregate<expr<Tag, Args, N> >
- : mpl::true_
- {};
-
- namespace detail
+ // Simple transform, takes a raw transform and
+ // applies it directly.
+ template<typename Grammar, typename Fun>
+ struct when : Fun
{
- template<typename... Args>
- struct back;
-
- template<typename A0>
- struct back<A0>
- {
- typedef A0 type;
- };
-
- template<typename A0, typename A1>
- struct back<A0, A1>
- {
- typedef A1 type;
- };
-
- template<typename A0, typename A1, typename A2>
- struct back<A0, A1, A2>
- {
- typedef A2 type;
- };
-
- template<typename A0, typename A1, typename A2, typename A3>
- struct back<A0, A1, A2, A3>
- {
- typedef A3 type;
- };
-
- template<typename A0, typename A1, typename A2, typename A3, typename... Rest>
- struct back<A0, A1, A2, A3, Rest...>
- : back<Rest...>
- {};
-
- template<typename T, typename EnableIf = void>
- struct is_transform2_
- : mpl::false_
- {};
-
- template<typename T>
- struct is_transform2_<T, typename T::proto_is_transform_>
- : mpl::true_
- {};
+ typedef typename Grammar::proto_base_expr proto_base_expr;
+ };
- template<typename T>
- struct is_transform_
- : is_transform2_<T>
- {};
-
- template<template<typename...> class T, typename... Args>
- struct is_transform_<T<Args...> >
- : is_same<typename back<Args...>::type, transform_base>
- {};
- }
-
- template<typename T>
- struct is_transform
- : proto::detail::is_transform_<T>
+ // Function-style transforms, handled below...
+ template<typename Grammar, typename Return, typename... Args>
+ struct when<Grammar, Return(*)(Args...)>
+ : when<Grammar, Return(Args...)>
{};
- // work around GCC bug
- template<typename Tag, typename Args, long N>
- struct is_transform<expr<Tag, Args, N> >
- : mpl::false_
- {};
-
- namespace transform
+ // Lambda-style transform, takes a function-style
+ // transform with arguments and calls it, OR takes a
+ // (possibly lambda) type and constructor arguments.
+ template<typename Grammar, typename Return, typename... Args>
+ struct when<Grammar, Return(Args...)>
+ : transform_base
{
- namespace detail
- {
- template<
- typename Expr
- , typename State
- , typename Visitor
- , bool IsTransform
- , typename Return
- , typename... Args
- >
- struct apply
- {
- typedef typename boost::result_of<
- transform::make<Return, Args...>(Expr, State, Visitor)
- >::type type;
-
- static type call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return transform::make<Return, Args...>()(expr, state, visitor);
- }
-
- //typedef
- // typename boost::result_of<
- // transform::make<Return, Args...>(Expr, State, Visitor)
- // >::type
- //lambda_type;
-
- //// If the result of applying the lambda on the return type is a transform,
- //// apply the transform rather than trying to construct it.
- //typedef
- // typename mpl::if_<
- // proto::detail::is_transform2_<lambda_type>
- // , transform::call<lambda_type, Args...>
- // , transform::make<Return, Args...>
- // >::type
- //transform_type;
-
- //typedef typename boost::result_of<transform_type(Expr, State, Visitor)>::type type;
-
- //static type call(Expr const &expr, State const &state, Visitor &visitor)
- //{
- // return transform_type()(expr, state, visitor);
- //}
- };
-
- template<
- typename Expr
- , typename State
- , typename Visitor
- , typename Return
- , typename... Args
- >
- struct apply<Expr, State, Visitor, true, Return, Args...>
- {
- typedef typename boost::result_of<
- transform::call<Return, Args...>(Expr, State, Visitor)
- >::type type;
-
- static type call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return transform::call<Return, Args...>()(expr, state, visitor);
- }
- };
+ typedef typename Grammar::proto_base_expr proto_base_expr;
- }
-
- // Simple transform, takes a raw transform and
- // applies it directly.
- template<typename Grammar, typename Fun>
- struct when
- : Fun
- {
- typedef typename Grammar::proto_base_expr proto_base_expr;
- };
+ template<typename Sig>
+ struct result;
- // Function-style transforms, handled below...
- template<typename Grammar, typename Return, typename... Args>
- struct when<Grammar, Return(*)(Args...)>
- : when<Grammar, Return(Args...)>
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : boost::result_of<
+ typename mpl::if_<
+ is_transform<Return>
+ , call<Return, Args...> // "Return" is a function to call
+ , make<Return, Args...> // "Return" is an object to construct
+ >::type(Expr, State, Visitor)
+ >
{};
- // Lambda-style transform, takes a raw or function-style
- // transform with arguments and applies it, OR takes a
- // (possibly lambda) type and constructor arguments.
- template<typename Grammar, typename Return, typename... Args>
- struct when<Grammar, Return(Args...)>
- : transform_base
- {
- typedef typename Grammar::proto_base_expr proto_base_expr;
-
- template<typename Sig>
- struct result;
-
- template<typename This, typename Expr, typename State, typename Visitor>
- struct result<This(Expr, State, Visitor)>
- : detail::apply<Expr, State, Visitor, is_transform<Return>::value, Return, Args...>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- typename result<when(Expr, State, Visitor)>::type
- operator()(Expr const &expr, State const &state, Visitor &visitor) const
- {
- return result<when(Expr, State, Visitor)>::call(expr, state, visitor);
- }
- };
-
- }
+ template<typename Expr, typename State, typename Visitor>
+ typename result<when(Expr, State, Visitor)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return typename mpl::if_<
+ is_transform<Return>
+ , call<Return, Args...>
+ , make<Return, Args...>
+ >::type()(expr, state, visitor);
+ }
+ };
-}}
+}}} // namespace boost::proto::transform
#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