Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-21 09:41:50


Author: matus.chochlik
Date: 2008-04-21 09:41:49 EDT (Mon, 21 Apr 2008)
New Revision: 44696
URL: http://svn.boost.org/trac/boost/changeset/44696

Log:
Minor changes to meta_class.hpp
Text files modified:
   sandbox/mirror/boost/mirror/meta_class.hpp | 128 ++++++++++++---------------------------
   sandbox/mirror/libs/examples/registering/virtual_bases.cpp | 20 ++++++
   2 files changed, 61 insertions(+), 87 deletions(-)

Modified: sandbox/mirror/boost/mirror/meta_class.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_class.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_class.hpp 2008-04-21 09:41:49 EDT (Mon, 21 Apr 2008)
@@ -258,7 +258,7 @@
                         /** This template gets the list of the owner classes
                          * for the inherited attributes.
                          */
- template <class meta_inheritance, class current_list>
+ template <class current_list, class meta_inheritance>
                         struct get_base_class_attrib_owner_and_offs
                         {
                                 typedef typename meta_inheritance::
@@ -271,14 +271,24 @@
                                 typedef typename mpl::size<
                                                 current_list
> offset;
+ typedef typename mpl::pair<
+ meta_class,
+ offset
+ > pair;
+
+ template<typename T>
+ struct get_pair
+ {
+ typedef pair type;
+ };
 
                                 typedef typename mpl::accumulate<
- type_list,
- mpl::vector0<>,
- mpl::pair<
- meta_class,
- offset
- >
+ type_list,
+ current_list,
+ mpl::push_back<
+ mpl::_1,
+ get_pair<mpl::_>
+ >
>::type type;
                         };
 
@@ -288,18 +298,14 @@
                         typedef typename mpl::accumulate<
                                 base_class_layout,
                                 mpl::vector0<>,
- mpl::insert_range<
+ get_base_class_attrib_owner_and_offs<
                                         mpl::_1,
- mpl::end<mpl::_1>,
- get_base_class_attrib_owner_and_offs<
- mpl::_2,
- mpl::_1
- >
+ mpl::_2
>
- >::type inherited_member_owners_and_offsets;
+ >::type inherited_attrib_owners_and_offsets;
 
                         
- /** The count of virtually attributes
+ /** The count of virtually inherited attributes
                          */
                         typedef typename mpl::accumulate<
                                 typename mpl::transform<
@@ -319,7 +325,7 @@
                         /** Is a true type if the I-th member attribute is
                          * virtually inherited.
                          */
- template <int I>
+ template <long I>
                         struct is_virtually_inherited
                         : mpl::less<
                                 mpl::int_<I>,
@@ -327,47 +333,11 @@
>::type { };
 
 
- /** This template gets the regular_base_class_layout
- * of a base class when given a meta_inheritance
- * specialization for this base class.
- template <class meta_inheritance>
- struct get_base_class_inheritance_hierarchy
- {
- typedef typename mpl::push_back<
- meta_inheritance::
- meta_class::
- all_attributes::
- detail::
- regular_base_class_layout type;
- };
- */
-
- /** The inheritance hierarchy of non-virtual
- * base classes of the reflected class.
- typedef typename mpl::accumulate<
- list_of_regular_base_classes,
- mpl::vector0<>,
- mpl::accumulate<
- get_base_class_regular_layout<
- mpl::_2
- >,
- mpl::vector0<>,
- >
- */
-/*
- mpl::insert_range<
- mpl::_1,
- mpl::end<mpl::_1>,
- >
- >::type regular_base_class_layout;
-*/
-
-
 
                         /** This template is used to query the return value
                          * type of the getter for the I-th member attribute
                          */
- template <int I>
+ template <long I>
                         struct result_of_get
                         {
                                 typedef typename mpl::at<
@@ -376,28 +346,26 @@
>::type type;
                         };
         
- /** This function is used to get the members of virtual
- * base classes.
- */
- template <class a_class, int I>
- static typename result_of_get<I>::type
- get(a_class context, mpl::int_<I> pos, mpl::bool_<true>)
- {
- typedef meta_class<a_class, variant_tag> meta_class;
-
- return meta_class::attributes::get(context, pos);
- }
                 
- /** This function is used to get the members of regular
+ /** This function is used to get the member attributes
                           * base classes.
                           */
- template <class a_class, int I>
+ template <class a_class, long I>
                         static typename result_of_get<I>::type
- get(a_class context, mpl::int_<I> pos, mpl::bool_<false>)
+ get(a_class context, mpl::int_<I> pos)
                         {
- typedef meta_class<a_class, variant_tag> meta_class;
+ typedef typename mpl::at<
+ typename detail::inherited_attrib_owners_and_offsets,
+ mpl::int_<I>
+ >::type owner_and_offset;
+
+ typedef typename owner_and_offset::first meta_class;
+ typedef typename mpl::minus<
+ mpl::int_<I>,
+ typename owner_and_offset::second
+ >::type new_pos_type;
 
- return meta_class::attributes::get(context, pos);
+ return meta_class::attributes::get(context, new_pos_type());
 
                         }
                 }; // struct detail
@@ -420,30 +388,16 @@
                 struct size : public mpl::size<type_list> { };
                 
                 /**
- template <class a_class, int I>
- static typename detail::result_of_get<I>::type
+ */
+ template <class a_class, long I>
+ static typename detail::template result_of_get<I>::type
                 get(a_class context, mpl::int_<I> pos)
                 {
- // is the attrib virtually inherited
- typedef typename detail::
- is_virtually_inherited<I> is_virtual;
- //
- // the index of the attribute
- typedef typename mpl::if<
- is_virtual,
- pos,
- mpl::minus<
- pos
- >
- >::type att_pos;
- //
                         return detail::get(
                                 context,
- att_pos,
- is_virtual
+ pos
                         );
                 }
- */
         }; // all_attrbutes
 
 };

Modified: sandbox/mirror/libs/examples/registering/virtual_bases.cpp
==============================================================================
--- sandbox/mirror/libs/examples/registering/virtual_bases.cpp (original)
+++ sandbox/mirror/libs/examples/registering/virtual_bases.cpp 2008-04-21 09:41:49 EDT (Mon, 21 Apr 2008)
@@ -255,12 +255,32 @@
         t.c = '9';
         t.w = L'0';
         //
+ bcout << meta_T::all_attributes::get(t, mpl::int_<0>()) << endl;
         //
         bcout << "--------------------------------------------" << endl;
         //
         bcout << meta_T::all_attributes::detail::is_virtually_inherited<4>::value << endl;
         bcout << meta_T::all_attributes::detail::is_virtually_inherited<5>::value << endl;
         //
+ //
         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