Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-21 05:36:52


Author: matus.chochlik
Date: 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
New Revision: 44690
URL: http://svn.boost.org/trac/boost/changeset/44690

Log:
Added support for querying the types of all class members including the inherited ones.
Updated the example 'registering/virtual_base.cpp' showing the registering of virtual base classes and the access to all memebr atributes.
Text files modified:
   sandbox/mirror/boost/mirror/meta_attribs_base.hpp | 15 +
   sandbox/mirror/boost/mirror/meta_class.hpp | 304 +++++++++++++++++++++++++++++++++------
   sandbox/mirror/boost/mirror/meta_inheritance.hpp | 12 +
   sandbox/mirror/boost/mirror/meta_namespace.hpp | 19 +-
   sandbox/mirror/boost/mirror/utils/name_to_stream/namespace.hpp | 5
   sandbox/mirror/boost/mirror/utils/name_to_stream/type.hpp | 25 ++
   sandbox/mirror/libs/examples/registering/classes.cpp | 40 +++--
   sandbox/mirror/libs/examples/registering/virtual_bases.cpp | 129 +++++++++++++++-
   sandbox/mirror/libs/examples/serialization/cube.cpp | 6
   9 files changed, 452 insertions(+), 103 deletions(-)

Modified: sandbox/mirror/boost/mirror/meta_attribs_base.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_attribs_base.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_attribs_base.hpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -54,8 +54,12 @@
         {
                 typedef mpl::int_<attrib_index> position;
                 typedef mpl::int_<position::value+1> next;
+ typedef typename meta_class::attributes::type_list type_list;
                 // get the type of the attribute
- typedef mpl::at<meta_class::attributes::type_list, position>::type attrib_type;
+ typedef typename mpl::at<
+ type_list,
+ position
+ >::type attrib_type;
                 //
                 // execute the operation
                 op((meta_class*)0, position(), (attrib_type*)0);
@@ -63,7 +67,7 @@
                 meta_class_attrib_for_each_impl<
                         meta_attributes,
                         is_same<
- mpl::int_<mpl::size<meta_class::attributes::type_list>::value>,
+ mpl::int_<mpl::size<type_list>::value>,
                                 next
>::value
>::apply(op, (meta_class*)0, next());
@@ -80,21 +84,22 @@
 {
         typedef the_class base_class;
         typedef BOOST_MIRROR_REFLECT_CLASS_VT(the_class, variant_tag) meta_class;
- typedef typename meta_class_attributes<the_class, variant_tag > meta_attributes;
+ typedef meta_class_attributes<the_class, variant_tag > meta_attributes;
         /**
          */
         template <class meta_attrib_op>
         static meta_attrib_op for_each(meta_attrib_op op)
         {
+ typedef typename meta_class::attributes::type_list type_list;
                 meta_class_attrib_for_each_impl<
                         meta_attributes,
                         is_same<
- mpl::int_<mpl::size<meta_class::attributes::type_list>::value>,
+ mpl::int_<mpl::size<type_list>::value>,
                                 mpl::int_<0>
>::value
>::apply(op, (meta_class*)0, mpl::int_<0>());
                 return op;
- };
+ }
 };
 
 } // namespace detail

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 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -11,8 +11,15 @@
 #define BOOST_MIRROR_META_CLASS_HPP
 
 #include <boost/mpl/if.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/plus.hpp>
+#include <boost/mpl/minus.hpp>
+#include <boost/mpl/comparison.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/mpl/transform.hpp>
 #include <boost/mpl/accumulate.hpp>
 #include <boost/mpl/remove_if.hpp>
+#include <boost/mpl/contains.hpp>
 #include <boost/mpl/insert_range.hpp>
 #include <boost/mpl/joint_view.hpp>
 //
@@ -70,98 +77,293 @@
                 struct detail
                 {
                         /** The list of non-virtual base classes in the same
- * order as registered.
+ * order as they were registered.
                          */
                         typedef typename mpl::remove_if<
                                 typename base_classes::list,
                                 mpl::lambda<
- mpl::not_<reflects_virtual_inheritance<mpl::_1> >
+ reflects_virtual_inheritance<mpl::_1>
>::type
>::type list_of_regular_base_classes;
 
- /** The list of all virtual base classes with duplicates.
+ /** The list of directly inhertied virtual base classes.
                          */
                         typedef typename mpl::remove_if<
                                 typename base_classes::list,
                                 mpl::lambda<
- reflects_virtual_inheritance<mpl::_1>
+ mpl::not_<reflects_virtual_inheritance<mpl::_1> >
>::type
- >::type list_of_all_virtual_base_classes;
+ >::type list_of_virtual_base_classes;
 
- /** The list of virtual base classes with duplicates
- * removed.
- * TODO:
+ /** This template gets the regular_base_class_layout
+ * of a base class when given a meta_inheritance
+ * specialization for this base class.
                          */
- typedef typename list_of_all_virtual_base_classes
- list_of_virtual_base_classes;
+ template <class meta_inheritance>
+ struct get_base_class_regular_layout
+ {
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ all_attributes::
+ detail::
+ regular_base_class_layout type;
+ };
                         
- /** This tells whether the virtual base classes
- * go first or last into the list of base classes.
+ /** The layout of non-virtual base classes
+ * of this class, stored as a mpl::vector
+ * of meta_inheritances.
                          */
- typedef true_type virtual_first;
-
- /** The list of base classes of the reflected_class.
+ typedef typename mpl::accumulate<
+ list_of_regular_base_classes,
+ mpl::vector<>,
+ mpl::push_back<
+ mpl::insert_range<
+ mpl::_1,
+ mpl::end<mpl::_1>,
+ get_base_class_regular_layout<
+ mpl::_2
+ >
+ >,
+ mpl::_2
+ >
+ >::type regular_base_class_layout;
+
+ /** This template gets the virtual_base_class_layout
+ * of a base class when given a meta_inheritance
+ * specialization for this base class.
                          */
- typedef typename mpl::joint_view<
- typename mpl::if_<
- virtual_first,
- list_of_virtual_base_classes,
- list_of_regular_base_classes
- >::type,
- typename mpl::if_<
- virtual_first,
- list_of_regular_base_classes,
- list_of_virtual_base_classes
- >::type
- >::type list_of_base_classes;
-
- /** This template gets the list of attributes types
- * when given a meta_inheritance specialization.
+ template <class meta_inheritance>
+ struct get_base_class_virtual_layout
+ {
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ all_attributes::
+ detail::
+ virtual_base_class_layout type;
+ };
+
+ /** This template gets the base_class_layout
+ * of a base class when given a meta_inheritance
+ * specialization for this base class.
                          */
                         template <class meta_inheritance>
- struct get_bc_all_attrib_tl
+ struct get_base_class_layout
                         {
- typedef typename meta_inheritance::meta_class::all_attributes::type_list type;
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ all_attributes::
+ detail::
+ base_class_layout type;
                         };
-
- /** Definition of a list containing the lists
- * of all_attributes from the base classes.
+
+ /** The list of vitual base classes of this class.
+ * This list still contains dupplicates, that are
+ * removed to form virtual_base_class_layout
                          */
                         typedef typename mpl::accumulate<
- typename list_of_base_classes,
+ typename base_classes::list,
                                 mpl::vector<>,
- mpl::push_back<
- mpl::_1,
- mpl::lambda<get_bc_all_attrib_tl<mpl::_2> >
+ mpl::if_<
+ reflects_virtual_inheritance<
+ mpl::_2
+ >,
+ mpl::push_back<
+ mpl::insert_range<
+ mpl::_1,
+ mpl::end<mpl::_1>,
+ get_base_class_layout<
+ mpl::_2
+ >
+ >,
+ mpl::_2
+ >,
+ mpl::insert_range<
+ mpl::_1,
+ mpl::end<mpl::_1>,
+ get_base_class_virtual_layout<
+ mpl::_2
+ >
+ >
>
- >::type att_type_lists_of_base_classes;
+ >::type virtual_base_class_layout_w_dups;
                         
- /** Defintion of a mpl::vector containing the member
- * attributes inherited from the base classes.
+ /** The layout of virtual base classes
+ * of this class, stored as a mpl::vector
+ * of meta_inheritances.
+ */
+ typedef typename mpl::fold<
+ virtual_base_class_layout_w_dups,
+ mpl::vector0<>,
+ mpl::if_<
+ mpl::contains<
+ mpl::_1,
+ mpl::_2
+ >,
+ mpl::_1,
+ mpl::push_back<
+ mpl::_1,
+ mpl::_2
+ >
+ >
+ >::type virtual_base_class_layout;
+
+ /** This template gets the list of member
+ * attrbute types of a base class when
+ * given a meta_inheritance<> specialization
+ */
+ template <class meta_inheritance>
+ struct get_base_class_attrib_type_list
+ {
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ attributes::
+ type_list type;
+
+ };
+
+ typedef typename mpl::joint_view<
+ virtual_base_class_layout,
+ regular_base_class_layout
+ >::type base_class_layout;
+
+ /** The list of inherited member attributes
+ * of the reflected class.
+ * NOTE: this implementation puts the
+ * members of the virtual bases before
+ * the other members
                          */
                         typedef typename mpl::accumulate<
- att_type_lists_of_base_classes,
- mpl::vector<>,
+ base_class_layout,
+ mpl::vector0<>,
                                 mpl::insert_range<
                                         mpl::_1,
                                         mpl::end<mpl::_1>,
- mpl::_2
+ get_base_class_attrib_type_list<
+ mpl::_2
+ >
+ >
+ >::type inherited_member_attrib_type_list;
+
+ /** The list of types of all attributes including
+ * the inherited ones.
+ */
+ typedef typename mpl::joint_view<
+ typename detail::inherited_member_attrib_type_list,
+ typename meta_class<reflected_class, variant_tag>::attributes::type_list
+ >::type member_attrib_type_list;
+
+ /** The count of virtually inherited attributes
+ */
+ typedef typename mpl::accumulate<
+ typename mpl::transform<
+ virtual_base_class_layout,
+ get_base_class_attrib_type_list<
+ mpl::_1
+ >
+ >::type,
+ mpl::int_<0>,
+ mpl::plus<
+ mpl::_1,
+ mpl::size< mpl::_2 >
>
- >::type inherited_attrib_type_list;
+ >::type virtual_attrib_count;
+
+
+ /** Is a true type if the I-th member attribute is
+ * virtually inherited.
+ */
+ template <int I>
+ struct is_virtually_inherited
+ : mpl::less<
+ mpl::int_<I>,
+ virtual_attrib_count
+ >::type { };
+
+ /** This template is used to query the return value
+ * type of the getter for the I-th member attribute
+ */
+ template <int I>
+ struct result_of_get
+ {
+ typedef typename mpl::at<
+ member_attrib_type_list,
+ mpl::int_<I>
+ >::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
+ * 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_<false>)
+ {
+ typedef meta_class<a_class, variant_tag> meta_class;
+
+ return meta_class::attributes::get(context, pos);
+
+ }
                 }; // struct detail
                 
+ /** The list of inherited attribute types
+ */
+ typedef typename detail::inherited_member_attrib_type_list inherited_type_list;
+
+ /** The size of the type_list, i.e. the count of inherited attributes
+ */
+ struct inherited_size : public mpl::size<inherited_type_list> { };
+
                 /** The list of types of all attributes including
                  * the inherited ones.
                  */
- typedef typename mpl::joint_view<
- typename detail::inherited_attrib_type_list,
- typename meta_class<reflected_class, variant_tag>::attributes::type_list
- >::type type_list;
+ typedef typename detail::member_attrib_type_list type_list;
                 
                 /** The size of the type_list, i.e. the count of all attributes
                  */
                 struct size : public mpl::size<type_list> { };
- };
+
+ /**
+ template <class a_class, int I>
+ static typename detail::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
+ );
+ }
+ */
+ }; // all_attrbutes
 
 };
 

Modified: sandbox/mirror/boost/mirror/meta_inheritance.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_inheritance.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_inheritance.hpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -118,9 +118,7 @@
  */
 template <
         class the_base_class,
- typename access_spec = class_kind_default_access<
- meta_class_kind<the_base_class>::result
- >::specifier,
+ typename access_spec,
         typename inheritance_spec = nonvirtual_base_
>
 struct meta_inheritance
@@ -158,7 +156,13 @@
  * zero, declarations must be ordered by number.
  */
 #define BOOST_MIRROR_REG_BASE_CLASS_SIMPLE(NUMBER, A_BASE_CLASS) \
- BOOST_PP_COMMA_IF(NUMBER) meta_inheritance<A_BASE_CLASS>
+ BOOST_PP_COMMA_IF(NUMBER) \
+ meta_inheritance<\
+ A_BASE_CLASS, \
+ class_kind_default_access<\
+ meta_class_kind< A_BASE_CLASS >::result \
+ >::specifier \
+ >
 
 /** This macro declares that the A_BASE_CLASS class is the i-th
  * base class of the given class, with the given access specifier

Modified: sandbox/mirror/boost/mirror/meta_namespace.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_namespace.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_namespace.hpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -39,14 +39,13 @@
         static const bchar* base_name (void) {return BOOST_STR_LIT("");}
 };
 
+
 /** Helper macro for registering new general namespaces (top level or nested)
  */
-#define BOOST_MIRROR_REG_META_NAMESPACE_HELPER(PARENT_NS_ALIAS, PREFIX, NAMESPACE_NAME) \
-namespace namespaces {struct PREFIX##_##NAMESPACE_NAME { }; }\
-template<> struct meta_namespace< namespaces :: PREFIX##_##NAMESPACE_NAME > \
+#define BOOST_MIRROR_REG_META_NAMESPACE_HELPER(PARENT_NS_ALIAS, NAMESPACE_NAME) \
 { \
         typedef meta_namespace< namespaces :: PARENT_NS_ALIAS > parent; \
- typedef mpl::push_back<typedef parent::scope, parent>::type scope; \
+ typedef mpl::push_back<parent::scope, parent>::type scope; \
         static const bchar* base_name (void) {return BOOST_STR_LIT(#NAMESPACE_NAME);} \
 }; \
 
@@ -54,16 +53,16 @@
 /** Macro for registering new general namespaces (top level or nested)
  */
 #define BOOST_MIRROR_REG_META_NAMESPACE(PARENT_NS_ALIAS, NAMESPACE_NAME) \
- BOOST_MIRROR_REG_META_NAMESPACE_HELPER(PARENT_NS_ALIAS, PARENT_NS_ALIAS, NAMESPACE_NAME)
+ namespace namespaces {struct PARENT_NS_ALIAS##_##NAMESPACE_NAME { }; }\
+ template<> struct meta_namespace< namespaces :: PARENT_NS_ALIAS##_##NAMESPACE_NAME > \
+ BOOST_MIRROR_REG_META_NAMESPACE_HELPER(PARENT_NS_ALIAS, NAMESPACE_NAME)
 
 /** Macro for registering of top-level namespaces
  */
 #define BOOST_MIRROR_REG_META_NAMESPACE_TOP_LEVEL(NAMESPACE_NAME) \
- BOOST_MIRROR_REG_META_NAMESPACE_HELPER(\
- _, \
- BOOST_PP_EMPTY(), \
- NAMESPACE_NAME \
- )
+ namespace namespaces {struct _##NAMESPACE_NAME { }; }\
+ template<> struct meta_namespace< namespaces :: _##NAMESPACE_NAME > \
+ BOOST_MIRROR_REG_META_NAMESPACE_HELPER(_, NAMESPACE_NAME)
 
 // Registration of the ::std namespace
 BOOST_MIRROR_REG_META_NAMESPACE_TOP_LEVEL(std)

Modified: sandbox/mirror/boost/mirror/utils/name_to_stream/namespace.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/utils/name_to_stream/namespace.hpp (original)
+++ sandbox/mirror/boost/mirror/utils/name_to_stream/namespace.hpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -40,10 +40,11 @@
         template <class out_stream>
         static out_stream& put(out_stream& s, bool ldng_dbl_cln)
         {
+ typedef typename meta_ns::parent parent_ns;
                 // let the printer print out the base name of the parent namespace
- name_to_stream<meta_ns::parent>::put(s, ldng_dbl_cln);
+ name_to_stream<parent_ns>::put(s, ldng_dbl_cln);
                 // if the parent is not the global scope
- if(!reflects_global_scope<meta_ns::parent>::value)
+ if(!reflects_global_scope<parent_ns>::value)
                         s << BOOST_STR_LIT("::");
                 // let the printer print out the base name of the parent namespace
                 return s << meta_ns::base_name();

Modified: sandbox/mirror/boost/mirror/utils/name_to_stream/type.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/utils/name_to_stream/type.hpp (original)
+++ sandbox/mirror/boost/mirror/utils/name_to_stream/type.hpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -27,7 +27,9 @@
         static out_stream& put(out_stream& s, bool ldng_dbl_cln)
         {
                 if(!reflects_global_scope<typename meta_type<base_type>::scope>::value)
- name_to_stream<meta_type<base_type>::scope>::put(s, ldng_dbl_cln) << BOOST_STR_LIT("::");
+ name_to_stream<
+ typename meta_type<base_type>::scope
+ >::put(s, ldng_dbl_cln) << BOOST_STR_LIT("::");
                 else if(ldng_dbl_cln) s << BOOST_STR_LIT("::");
                 return s << meta_type<base_type>::base_name();
         }
@@ -45,15 +47,14 @@
         }
 };
 
-/** Specialization for meta-types for arrays
+/** Specialization for meta-types for non-cv element arrays
  */
 template <typename element_type, size_t size>
-struct name_to_stream_helper<meta_type<const element_type[size]> >
+struct name_to_stream_helper<meta_type<element_type[size]> >
 {
         template <class out_stream>
         static out_stream& put(out_stream& s, bool ldng_dbl_cln)
         {
- s << BOOST_STR_LIT("const ");
                 return name_to_stream_helper<meta_type<element_type> >::put(s,ldng_dbl_cln) <<
                         BOOST_STR_LIT("[") <<
                         size <<
@@ -61,6 +62,22 @@
         }
 };
 
+/** Specialization for meta-types for const element arrays
+ */
+template <typename element_type, size_t size>
+struct name_to_stream_helper<meta_type<const element_type[size]> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln)
+ {
+
+ s << BOOST_STR_LIT("const ");
+ return name_to_stream_helper<
+ meta_type<element_type[size]>
+ >::put(s, ldng_dbl_cln);
+ }
+};
+
 /** Specialization for meta-types for references
  */
 template <typename refered_to_type>

Modified: sandbox/mirror/libs/examples/registering/classes.cpp
==============================================================================
--- sandbox/mirror/libs/examples/registering/classes.cpp (original)
+++ sandbox/mirror/libs/examples/registering/classes.cpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -184,10 +184,10 @@
  * some info about the given meta_object into
  * a stream.
  */
-template <class meta_object>
+template <class a_meta_object>
 struct pretty_printer
 {
- typedef meta_object meta_object;
+ typedef a_meta_object meta_object;
         //
         // prints some info about the meta-object t
         // to the given stream
@@ -195,7 +195,7 @@
         out_stream& print(out_stream& s) const
         {
                 typedef pretty_printer<meta_object> prn_type;
- typedef prn_type::meta_object meta_object;
+ typedef typename prn_type::meta_object meta_object;
                 //
                 using namespace ::std;
                 //
@@ -210,17 +210,19 @@
                 // print out it's name
                 s << name_to_stream<meta_object>() << "' " << endl;
                 //
+ //
+ typedef typename meta_object::scope meta_scope;
                 // print info about the scope where the meta-object
                 // is defined
                 s << "is defined ";
                 // if the scope is the global scope
- if(reflects_global_scope<meta_object::scope>::value)
+ if(reflects_global_scope<meta_scope>::value)
                         s << "on the global scope";
                 // if it's a class
- else if(reflects_class<meta_object::scope>::value)
- s << "inside of the '" << name_to_stream<meta_object::scope>() << "' class";
+ else if(reflects_class<meta_scope>::value)
+ s << "inside of the '" << name_to_stream<meta_scope>() << "' class";
                 // otherwise
- else s << "in the '" << name_to_stream<meta_object::scope>() << "' namespace";
+ else s << "in the '" << name_to_stream<meta_scope>() << "' namespace";
                 s << "." << endl;
                 //
                 // print the base classes if any
@@ -252,8 +254,8 @@
                         // it's base_class typedef is the type
                         // of the base class
                         using namespace ::std;
- s << endl << " - " <<
- name_to_stream<BOOST_MIRROR_REFLECT_CLASS(meta_inheritance::base_class)>();
+ typedef typename meta_inheritance::meta_class meta_class;
+ s << endl << " - " << name_to_stream<meta_class>();
                 }
         };
         //
@@ -265,15 +267,18 @@
                 //
                 // print out the count of (registered) base classes that
                 // the inspected class has
+ //
+ typedef typename meta_object::base_classes::list base_class_list;
+ //
                 s << "It has ";
- if(mpl::size<meta_object::base_classes::list>::value == 1)
+ if(mpl::size<base_class_list>::value == 1)
                         s << "this one base class:";
- else if(mpl::size<meta_object::base_classes::list>::value > 1)
- s << "these " << mpl::size<meta_object::base_classes::list>::value << " base classes:";
+ else if(mpl::size<base_class_list>::value > 1)
+ s << "these " << mpl::size<base_class_list>::value << " base classes:";
                 else s << "no base classes.";
                 //
                 // execute the printer on the list of base classes
- mpl::for_each<meta_object::base_classes::list>(base_class_printer<out_stream>(s));
+ mpl::for_each<base_class_list>(base_class_printer<out_stream>(s));
                 //
                 return s << endl;
         }
@@ -323,11 +328,14 @@
         {
                 //
                 // print the number of the registered attributes
+ //
+ typedef typename meta_object::attributes::type_list attrib_type_list;
+ //
                 s << "It has ";
- if(mpl::size<meta_object::attributes::type_list>::value == 1)
+ if(mpl::size<attrib_type_list>::value == 1)
                         s << "this one member attribute:";
- else if(mpl::size<meta_object::attributes::type_list>::value > 1)
- s << "these " << mpl::size<meta_object::attributes::type_list>::value << " member attributes:";
+ else if(mpl::size<attrib_type_list>::value > 1)
+ s << "these " << mpl::size<attrib_type_list>::value << " member attributes:";
                 else s << "no member attributes.";
                 //
                 // execute the printer on the list of member attributes

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 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -21,6 +21,8 @@
 #include <boost/mpl/size.hpp>
 #include <boost/mpl/at.hpp>
 
+#include <boost/static_assert.hpp>
+
 #include <boost/char_type_switch/iostream.hpp>
 
 #include <boost/mirror/meta_namespace.hpp>
@@ -60,6 +62,22 @@
                 float f;
         };
 
+ struct F : virtual E
+ {
+ bool b;
+ };
+
+ struct G : virtual E
+ {
+ char c;
+ };
+
+ struct H : F, G
+ {
+ wchar_t w;
+ };
+
+
 } // namespace Test
 
 
@@ -78,6 +96,9 @@
 BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, C)
 BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, D)
 BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, E)
+BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, F)
+BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, G)
+BOOST_MIRROR_REG_META_TYPE(_Test, ::Test, H)
 
 
 BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::Test::B)
@@ -98,6 +119,19 @@
 BOOST_MIRROR_REG_BASE_CLASS_SIMPLE(2, ::Test::D)
 BOOST_MIRROR_REG_BASE_CLASSES_END
 
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::Test::F)
+BOOST_MIRROR_REG_BASE_CLASS_VIRTUAL(0, public, ::Test::E)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::Test::G)
+BOOST_MIRROR_REG_BASE_CLASS_VIRTUAL(0, public, ::Test::E)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::Test::H)
+BOOST_MIRROR_REG_BASE_CLASS_SIMPLE(0, ::Test::F)
+BOOST_MIRROR_REG_BASE_CLASS_SIMPLE(1, ::Test::G)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+
 
 /** Class attributes
  */
@@ -121,11 +155,24 @@
         BOOST_MIRROR_REG_CLASS_ATTRIB(0, float, f)
 BOOST_MIRROR_REG_CLASS_ATTRIBS_END
 
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::Test::F)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(0, bool, b)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::Test::G)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(0, char, c)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::Test::H)
+ BOOST_MIRROR_REG_CLASS_ATTRIB(0, wchar_t, w)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
 
 
 } // namespace mirror
 } // namespace boost
 
+
 int main(void)
 {
         using namespace ::std;
@@ -134,19 +181,85 @@
         //
         using namespace ::Test;
         //
- typedef BOOST_MIRROR_REFLECT_CLASS(::Test::E) meta_E;
+ typedef ::Test::H T;
+ //
+ typedef BOOST_MIRROR_REFLECT_CLASS(T) meta_T;
+ //
+ // Print some basic info about the reflected class
         //
- bcout << sizeof(E().l) << endl;
+ bcout << "The reflected class has " << endl;
         //
- bcout << "The class ::Test::E has " << endl;
+ bcout << meta_T::base_classes::size::value << " base class(es)" << endl;
+ bcout << meta_T::attributes::size::value << " own member attrib(s)" << endl;
+ bcout << meta_T::all_attributes::inherited_size::value << " inherited member attrib(s)" << endl;
+ bcout << meta_T::all_attributes::size::value << " member attrib(s)" << endl;
+ //
+ // The attrbs of H are reflected in the following order
+ // A::l (long)
+ // B::i (int)
+ // C::d (double)
+ // D::s (short)
+ // E::f (float)
+ // F::b (bool)
+ // G::c (char)
+ // H::w (wchar_t)
+ //
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<0> >::type,
+ BOOST_TYPEOF(T().l)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<1> >::type,
+ BOOST_TYPEOF(T().i)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<2> >::type,
+ BOOST_TYPEOF(T().d)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<3> >::type,
+ BOOST_TYPEOF(T().s)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<4> >::type,
+ BOOST_TYPEOF(T().f)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<5> >::type,
+ BOOST_TYPEOF(T().b)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<6> >::type,
+ BOOST_TYPEOF(T().c)
+ >::value));
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::all_attributes::type_list, mpl::int_<7> >::type,
+ BOOST_TYPEOF(T().w)
+ >::value));
+ //
+ BOOST_STATIC_ASSERT((is_same<
+ mpl::at<meta_T::attributes::type_list, mpl::int_<0> >::type,
+ BOOST_TYPEOF(T().w)
+ >::value));
+ //
+ //
+ //
+ T t;
+ // init the members of t
+ t.l = 123L;
+ t.i = 234;
+ t.d = 345.6;
+ t.s = 567;
+ t.f = 678.9f;
+ t.b = true;
+ t.c = '9';
+ t.w = L'0';
         //
- bcout << meta_E::base_classes::size::value << " base classes" << endl;
- bcout << meta_E::attributes::size::value << " own member attribs" << endl;
- // NOTE: this isn't working as expected yet
- bcout << meta_E::all_attributes::size::value << " member attribs" << endl;
         //
+ bcout << "--------------------------------------------" << endl;
         //
- bcout << "Finished" << 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;
 }

Modified: sandbox/mirror/libs/examples/serialization/cube.cpp
==============================================================================
--- sandbox/mirror/libs/examples/serialization/cube.cpp (original)
+++ sandbox/mirror/libs/examples/serialization/cube.cpp 2008-04-21 05:36:51 EDT (Mon, 21 Apr 2008)
@@ -35,11 +35,11 @@
 namespace Graphics {
 
         // coordinates
- template <typename float_type>
+ template <typename a_float_type>
         class CoordsTempl
         {
         public:
- typedef float_type float_type;
+ typedef a_float_type float_type;
                 CoordsTempl(
                         float_type _x = 0.0,
                         float_type _y = 0.0,
@@ -155,7 +155,7 @@
         //
         bcout << meta_Vector::base_classes::size::value << endl;
         bcout << meta_Vector::attributes::size::value << endl;
- bcout << meta_Vector::all_attributes::size::value << endl;
+ //bcout << meta_Vector::all_attributes::size::value << endl;
         //
         //
         bcout << "Finished" << endl;


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