|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65445 - in trunk: boost/fusion/adapted/adt/detail boost/fusion/adapted/struct/detail boost/spirit/home/support libs/fusion/test/sequence
From: mr.chr.schmidt_at_[hidden]
Date: 2010-09-17 16:38:28
Author: cschmidt
Date: 2010-09-17 16:38:23 EDT (Fri, 17 Sep 2010)
New Revision: 65445
URL: http://svn.boost.org/trac/boost/changeset/65445
Log:
Fusion/Spirit: adt_attribute_proxy refactorization
Text files modified:
trunk/boost/fusion/adapted/adt/detail/adapt_base.hpp | 70 ++++++++++++++++++++++++++++++---------
trunk/boost/fusion/adapted/struct/detail/extension.hpp | 7 ++-
trunk/boost/spirit/home/support/adapt_adt_attributes.hpp | 68 ++++++++++++++------------------------
trunk/libs/fusion/test/sequence/adapt_adt.cpp | 24 +++++++++++++
4 files changed, 108 insertions(+), 61 deletions(-)
Modified: trunk/boost/fusion/adapted/adt/detail/adapt_base.hpp
==============================================================================
--- trunk/boost/fusion/adapted/adt/detail/adapt_base.hpp (original)
+++ trunk/boost/fusion/adapted/adt/detail/adapt_base.hpp 2010-09-17 16:38:23 EDT (Fri, 17 Sep 2010)
@@ -33,7 +33,39 @@
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
- struct access::adt_attribute_proxy< \
+ struct access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ > \
+ { \
+ template<class Arg> \
+ static void \
+ boost_fusion_adapt_adt_impl_set( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \
+ Arg const& val) \
+ { \
+ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \
+ } \
+ \
+ static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \
+ boost_fusion_adapt_adt_impl_get( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj) \
+ { \
+ return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ } \
+ \
+ static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \
+ boost_fusion_adapt_adt_impl_get( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj) \
+ { \
+ return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ } \
+ }; \
+ \
+ template< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
+ > \
+ struct adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, true \
@@ -43,25 +75,25 @@
\
explicit \
adt_attribute_proxy( \
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& o) \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const*const o) \
: obj(o) \
{} \
\
operator type() const \
{ \
- return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ return access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_get(*obj); \
} \
\
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj; \
- \
- private: \
- adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const* obj; \
}; \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
- struct access::adt_attribute_proxy< \
+ struct adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, false \
@@ -70,7 +102,8 @@
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
\
explicit \
- adt_attribute_proxy(BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& o) \
+ adt_attribute_proxy( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)*const o) \
: obj(o) \
{} \
\
@@ -78,19 +111,22 @@
adt_attribute_proxy& \
operator=(Arg const& val) \
{ \
- BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \
+ access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_set(*obj, val); \
return *this; \
} \
\
operator type() const \
{ \
- return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ return access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_get(*obj); \
} \
\
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
- \
- private: \
- adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)* obj; \
}; \
\
template< \
@@ -117,7 +153,7 @@
struct apply \
{ \
typedef \
- access::adt_attribute_proxy< \
+ adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, is_const<Seq>::value \
@@ -127,7 +163,7 @@
static type \
call(Seq& obj) \
{ \
- return type(obj); \
+ return type(&obj); \
} \
}; \
};
Modified: trunk/boost/fusion/adapted/struct/detail/extension.hpp
==============================================================================
--- trunk/boost/fusion/adapted/struct/detail/extension.hpp (original)
+++ trunk/boost/fusion/adapted/struct/detail/extension.hpp 2010-09-17 16:38:23 EDT (Fri, 17 Sep 2010)
@@ -32,10 +32,13 @@
template<typename Seq, int N>
struct struct_member;
- template <typename T, int N, bool Const>
- struct adt_attribute_proxy;
+ template<typename Seq, int N>
+ struct adt_attribute_access;
};
+ template <typename T, int N, bool Const>
+ struct adt_attribute_proxy;
+
template<typename Seq, int N>
struct struct_member_name;
Modified: trunk/boost/spirit/home/support/adapt_adt_attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/adapt_adt_attributes.hpp (original)
+++ trunk/boost/spirit/home/support/adapt_adt_attributes.hpp 2010-09-17 16:38:23 EDT (Fri, 17 Sep 2010)
@@ -21,18 +21,14 @@
{
///////////////////////////////////////////////////////////////////////////
template <typename T, int N, bool Const>
- struct is_container<
- fusion::extension::access::adt_attribute_proxy<T, N, Const> >
+ struct is_container<fusion::extension::adt_attribute_proxy<T, N, Const> >
: is_container<
- typename fusion::extension::access::adt_attribute_proxy<
- T, N, Const
- >::type
+ typename fusion::extension::adt_attribute_proxy<T, N, Const>::type
>
{};
template <typename T, int N, bool Const>
- struct container_value<
- fusion::extension::access::adt_attribute_proxy<T, N, Const> >
+ struct container_value<fusion::extension::adt_attribute_proxy<T, N, Const> >
: container_value<
typename fusion::extension::access::adt_attribute_proxy<
T, N, Const
@@ -42,45 +38,39 @@
template <typename T, int N, typename Val>
struct push_back_container<
- fusion::extension::access::adt_attribute_proxy<T, N, false>
+ fusion::extension::adt_attribute_proxy<T, N, false>
, Val
, typename enable_if<is_reference<
- typename fusion::extension::access::adt_attribute_proxy<
- T, N, false
- >::type
+ typename fusion::extension::adt_attribute_proxy<T, N, false>::type
> >::type>
{
static bool call(
- fusion::extension::access::adt_attribute_proxy<T, N, false>& p
+ fusion::extension::adt_attribute_proxy<T, N, false>& p
, Val const& val)
{
typedef typename
- fusion::extension::access::adt_attribute_proxy<
- T, N, false
- >::type
+ fusion::extension::adt_attribute_proxy<T, N, false>::type
type;
return push_back(type(p), val);
}
};
template <typename T, int N, bool Const>
- struct container_iterator<
- fusion::extension::access::adt_attribute_proxy<T, N, Const> >
+ struct container_iterator<fusion::extension::adt_attribute_proxy<T, N, Const> >
: container_iterator<
- typename fusion::extension::access::adt_attribute_proxy<
- T, N, Const
- >::type
+ typename fusion::extension::adt_attribute_proxy<T, N, Const>::type
>
{};
///////////////////////////////////////////////////////////////////////////
template <typename T, int N, bool Const, typename Val>
struct assign_to_attribute_from_value<
- fusion::extension::access::adt_attribute_proxy<T, N, false>, Val>
+ fusion::extension::adt_attribute_proxy<T, N, false>
+ , Val>
{
static void
call(Val const& val
- , fusion::extension::access::adt_attribute_proxy<T, N, false>& attr)
+ , fusion::extension::adt_attribute_proxy<T, N, false>& attr)
{
attr = val;
}
@@ -88,33 +78,30 @@
///////////////////////////////////////////////////////////////////////////
template <typename T, int N, bool Const>
- struct attribute_type<
- fusion::extension::access::adt_attribute_proxy<T, N, Const> >
- : fusion::extension::access::adt_attribute_proxy<T, N, Const>
+ struct attribute_type<fusion::extension::adt_attribute_proxy<T, N, Const> >
+ : fusion::extension::adt_attribute_proxy<T, N, Const>
{};
///////////////////////////////////////////////////////////////////////////
template <typename T, int N, typename Attribute, typename Domain>
struct transform_attribute<
- fusion::extension::access::adt_attribute_proxy<T, N, false>
+ fusion::extension::adt_attribute_proxy<T, N, false>
, Attribute
, Domain
, typename disable_if<is_reference<
- typename fusion::extension::access::adt_attribute_proxy<
- T, N, false
- >::type
+ typename fusion::extension::adt_attribute_proxy<T, N, false>::type
> >::type>
{
typedef Attribute type;
static Attribute
- pre(fusion::extension::access::adt_attribute_proxy<T, N, false>& val)
+ pre(fusion::extension::adt_attribute_proxy<T, N, false>& val)
{
return val;
}
static void
post(
- fusion::extension::access::adt_attribute_proxy<T, N, false>& val
+ fusion::extension::adt_attribute_proxy<T, N, false>& val
, Attribute const& attr)
{
val = attr;
@@ -128,11 +115,11 @@
template <
typename T, int N, bool Const, typename Attribute, typename Domain>
struct transform_attribute<
- fusion::extension::access::adt_attribute_proxy<T, N, Const>
+ fusion::extension::adt_attribute_proxy<T, N, Const>
, Attribute
, Domain
, typename enable_if<is_reference<
- typename fusion::extension::access::adt_attribute_proxy<
+ typename fusion::extension::adt_attribute_proxy<
T, N, Const
>::type
> >::type>
@@ -140,33 +127,30 @@
typedef Attribute& type;
static Attribute&
- pre(fusion::extension::access::adt_attribute_proxy<T, N, Const>& val)
+ pre(fusion::extension::adt_attribute_proxy<T, N, Const>& val)
{
return val;
}
static void
post(
- fusion::extension::access::adt_attribute_proxy<T, N, Const>&
+ fusion::extension::adt_attribute_proxy<T, N, Const>&
, Attribute const&)
{
}
static void
- fail(fusion::extension::access::adt_attribute_proxy<T, N, Const>&)
+ fail(fusion::extension::adt_attribute_proxy<T, N, Const>&)
{
}
};
template <typename T, int N, bool Const>
- struct clear_value<
- fusion::extension::access::adt_attribute_proxy<T, N, Const> >
+ struct clear_value<fusion::extension::adt_attribute_proxy<T, N, Const> >
{
static void call(
- fusion::extension::access::adt_attribute_proxy<T, N, Const>& val)
+ fusion::extension::adt_attribute_proxy<T, N, Const>& val)
{
typedef typename
- fusion::extension::access::adt_attribute_proxy<
- T, N, Const
- >::type
+ fusion::extension::adt_attribute_proxy<T, N, Const>::type
type;
clear(type(val));
}
Modified: trunk/libs/fusion/test/sequence/adapt_adt.cpp
==============================================================================
--- trunk/libs/fusion/test/sequence/adapt_adt.cpp (original)
+++ trunk/libs/fusion/test/sequence/adapt_adt.cpp 2010-09-17 16:38:23 EDT (Fri, 17 Sep 2010)
@@ -28,6 +28,7 @@
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
#include <iostream>
#include <string>
@@ -174,6 +175,29 @@
}
#endif
+ {
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point>::type,
+ boost::fusion::extension::adt_attribute_proxy<ns::point,0,false>
+ >));
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point>::type::type,
+ int
+ >));
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point const>::type,
+ boost::fusion::extension::adt_attribute_proxy<ns::point,0,true>
+ >));
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point const>::type::type,
+ int
+ >));
+ }
+
return boost::report_errors();
}
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