Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-28 10:48:08


Author: matus.chochlik
Date: 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
New Revision: 44854
URL: http://svn.boost.org/trac/boost/changeset/44854

Log:
                        - Added meta_attribs for boost::tuple
Added meta_attribs for std::vector
Reimplemented meta_attributes::for_each
The for_each function is now available also for all attributes
Updated several examples to show new functionality
NOTE: tested only with MSVC++ 2008

Added:
   sandbox/mirror/boost/mirror/meta_classes/boost_tuple.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_classes/std_pair.hpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp | 73 +++++++++++++
   sandbox/mirror/boost/mirror/detail/static_log10.hpp | 1
   sandbox/mirror/boost/mirror/detail/template_name.hpp | 15 ++
   sandbox/mirror/boost/mirror/meta_attribs_base.hpp | 208 ++++++++++++++++++++++++++-------------
   sandbox/mirror/boost/mirror/meta_class.hpp | 3
   sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp | 14 --
   sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml | 8 +
   sandbox/mirror/libs/mirror/example/Jamfile.v2 | 2
   sandbox/mirror/libs/mirror/example/registering/classes.cpp | 11 +
   sandbox/mirror/libs/mirror/example/registering/virtual_bases.cpp | 22 ++++
   sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp | 42 +++++++
   sandbox/mirror/libs/mirror/example/special/std_pair.cpp | 5
   12 files changed, 307 insertions(+), 97 deletions(-)

Modified: sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -18,6 +18,11 @@
 #include <boost/mirror/detail/static_pow10.hpp>
 #include <boost/char_type_switch/string.hpp>
 
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/plus.hpp>
+
 namespace boost {
 namespace mirror {
 namespace detail {
@@ -26,8 +31,8 @@
 struct static_int_to_str
 {
         // the length of the string needed to hold the given integer
- typedef typename mpl::next<
- typename static_log10<I>::type
+ typedef typename mpl::int_<
+ static_log10<I>::type::value + 1
>::type length;
         //
         //
@@ -59,6 +64,70 @@
         }
 };
 
+template <>
+struct static_int_to_str<0>
+{
+ typedef mpl::int_<1>::type length;
+ static bchar* convert(bchar* _str, size_t _max_len)
+ {
+ assert(_max_len > 1);
+ _str[0] = BOOST_STR_LIT('0');
+ _str[1] = BOOST_STR_LIT('\0');
+ return _str;
+ }
+};
+
+template <class mpl_vector_c, int I>
+struct static_int_to_str_w_prefix
+{
+ typedef mpl_vector_c prefix;
+ typedef mpl::int_<mpl::size<prefix>::value> prefix_length;
+ typedef typename static_int_to_str<I>::length number_length;
+ // the length of the string needed to hold the given integer with the prefix
+ typedef typename mpl::int_<
+ prefix_length::value +
+ number_length::value
+ > length;
+ //
+ static inline void do_apply_prefix_to(bchar* _str, mpl::int_<0>){ }
+ //
+ template <int J>
+ static inline void do_apply_prefix_to(bchar* _str, mpl::int_<J> pos)
+ {
+ _str[J-1] = mpl::at<
+ prefix,
+ mpl::int_<J - 1>
+ >::type::value;
+ do_apply_prefix_to(_str, mpl::int_<J - 1>());
+ }
+ //
+ static bchar* convert(bchar* _str, size_t _max_len)
+ {
+ // check the length
+ assert(_max_len > length::value);
+ // apply prefix
+ do_apply_prefix_to(_str, prefix_length());
+ // calculate offset
+ const int offs = mpl::size<prefix>::type::value;
+ // append given int as string
+ static_int_to_str<I>::convert(_str + offs, _max_len - offs);
+ // finalize the string
+ _str[length::value] = BOOST_STR_LIT('\0');
+ return _str;
+ }
+ //
+ struct holder
+ {
+ static const bchar* get(void)
+ {
+ static bchar str[length::value+1] = {0};
+ if(!str[0]) convert(str, length::value+1);
+ return str;
+ }
+ };
+
+};
+
 } // namespace detail
 } // namespace mirror
 } // namespace boost

Modified: sandbox/mirror/boost/mirror/detail/static_log10.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/static_log10.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/static_log10.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -44,7 +44,6 @@
>
>::type position;
 
-
         typedef typename mpl::second<
                         typename mpl::deref<
                                 position

Modified: sandbox/mirror/boost/mirror/detail/template_name.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/template_name.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/template_name.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -64,17 +64,24 @@
 template <typename a_type>
 struct is_typelist_null_type : ::boost::false_type { };
 
-
-template <class meta_type, class full_typelist, bool base_name>
-struct static_template_name_base
+template <class full_typelist>
+struct template_with_null_args_type_list
 {
-protected:
         /** A typelist that contains all types from full_type_list
          * except those that are typelist_null_types
          */
         typedef typename mpl::remove_if<
                 full_typelist,
                 is_typelist_null_type<mpl::_1>
+ >::type type;
+};
+
+template <class meta_type, class full_typelist, bool base_name>
+struct static_template_name_base
+{
+protected:
+ typedef typename template_with_null_args_type_list<
+ full_typelist
>::type typelist;
 
         /** The 'position' of the last type in the template

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-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -14,6 +14,8 @@
 #include <boost/mirror/common_defs.hpp>
 // forward declarations
 #include <boost/mirror/meta_data_fwd.hpp>
+//
+#include <boost/preprocessor/repetition/enum_params.hpp>
 //
 // necessary type traits
 #include <boost/call_traits.hpp>
@@ -28,80 +30,60 @@
 
 namespace detail {
 
-/** Forward declaration of the meta_class_attrib_utils<>
- * template.
- */
-template <class meta_attributes>
-struct meta_class_attrib_utils;
-
-/** Template used in implementation of the
- * meta_class_attrib_utils::for_each function
+/** Implementation of the for_each function on meta_attributes
  */
-template <class meta_attributes, bool last_one>
-struct meta_class_attrib_for_each_impl
+template <class meta_class, class meta_attributes>
+struct meta_class_attrib_for_each
 {
- template <class meta_attrib_op, class meta_class, class position>
- static void apply(meta_attrib_op, meta_class*, position)
+protected:
+ template <class meta_attrib_op, int I>
+ static void do_apply_to(meta_attrib_op op, mpl::int_<I> pos)
         {
+ typedef typename meta_attributes::type_list type_list;
+ typedef typename mpl::at<type_list, mpl::int_<I> >::type attrib_type;
+ meta_class mc;
+ meta_attributes ma;
+ op(mc, ma, pos, (attrib_type*)0);
         }
-};
 
-template <class meta_attributes>
-struct meta_class_attrib_for_each_impl<meta_attributes, false>
-{
- template <class meta_attrib_op, class meta_class, int attrib_index>
- static void apply(meta_attrib_op& op, meta_class*, mpl::int_<attrib_index>)
+ template <class meta_attrib_op>
+ static void apply_to(meta_attrib_op op, mpl::int_< -1 > pos){ }
+
+ template <class meta_attrib_op>
+ static void apply_to(meta_attrib_op op, mpl::int_<0> pos)
         {
- 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 typename mpl::at<
- type_list,
- position
- >::type attrib_type;
- //
- // execute the operation
- op((meta_class*)0, position(), (attrib_type*)0);
- // and move to the next one
- meta_class_attrib_for_each_impl<
- meta_attributes,
- is_same<
- mpl::int_<mpl::size<type_list>::value>,
- next
- >::value
- >::apply(op, (meta_class*)0, next());
+ do_apply_to(op, pos);
         }
-};
 
+ template <class meta_attrib_op, int I>
+ static void apply_to(meta_attrib_op op, mpl::int_<I> pos)
+ {
+ apply_to(op, mpl::int_<I - 1>()),
+ do_apply_to(op, pos);
+ }
+public:
 
-/** This template implements several functions
- * for the specializations of the meta_class_attributes<>
- * template.
- */
-template <class the_class, class variant_tag>
-struct meta_class_attrib_utils<meta_class_attributes<the_class, variant_tag > >
-{
- typedef the_class base_class;
- typedef BOOST_MIRROR_REFLECT_CLASS_VT(the_class, variant_tag) meta_class;
- typedef meta_class_attributes<the_class, variant_tag > meta_attributes;
- /**
+ /** Performs op((meta_class*)0, mpl::int_<I>, 'type-of-I-th'*0
          */
         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<type_list>::value>,
- mpl::int_<0>
- >::value
- >::apply(op, (meta_class*)0, mpl::int_<0>());
+ typedef typename meta_attributes::type_list type_list;
+ typedef mpl::int_<mpl::size<type_list>::value - 1> last;
+ apply_to(op, last());
                 return op;
         }
 };
 
+/** This template ties together several function implementations
+ * for the specializations of the meta_class_attributes<>
+ * template.
+ */
+template <class meta_class, class meta_attribs>
+struct meta_class_attrib_utils
+: meta_class_attrib_for_each<meta_class, meta_attribs>
+{ };
+
 } // namespace detail
 
 /** Defaut (empty) list of base attributes of a meta class
@@ -109,6 +91,7 @@
 template <class the_class, class variant_tag>
 struct meta_class_attributes
 : public detail::meta_class_attrib_utils<
+ meta_class<the_class, variant_tag>,
         meta_class_attributes<the_class, variant_tag>
>
 {
@@ -119,14 +102,40 @@
  * of the given class
  */
 #define BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(THE_CLASS) \
- template <> struct meta_class_attributes<THE_CLASS, detail::default_meta_class_variant> \
+ template <> struct meta_class_attributes< THE_CLASS , detail::default_meta_class_variant> \
         : public detail::meta_class_attrib_utils<\
+ meta_class<THE_CLASS, detail::default_meta_class_variant>, \
                 meta_class_attributes<THE_CLASS, detail::default_meta_class_variant> \
>\
         { \
                 typedef THE_CLASS the_class; \
                 typedef mpl::vector<>
 
+/** This macro starts the declaration of member attributes
+ * of the given template
+ */
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_BEGIN(THE_TEMPLATE, TEMPL_ARG_COUNT) \
+ template < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, typename T) > \
+ struct meta_class_attributes< \
+ THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) >, \
+ detail::default_meta_class_variant \
+ > \
+ : public detail::meta_class_attrib_utils<\
+ meta_class< \
+ THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) >, \
+ detail::default_meta_class_variant \
+ >, \
+ meta_class_attributes< \
+ THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) >, \
+ detail::default_meta_class_variant \
+ > \
+ >\
+ { \
+ typedef THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) > \
+ the_class; \
+ typedef typename mpl::vector<>
+
+
 /** This is a helper for the BOOST_MIRROR_CLASS_ATTRIB*
  * macros.
  * It declares all common things that need to be declared
@@ -141,25 +150,39 @@
  * It declares all common things that need to be declared
  * after the specific stuff.
  */
+#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME, TYPENAME_KW) \
+ typedef TYPENAME_KW mpl::push_back<_partial_list_##NUMBER, TYPE>::type
+
+
 #define BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME) \
- typedef mpl::push_back<_partial_list_##NUMBER, TYPE>::type
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME, BOOST_PP_EMPTY())
+
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME, typename)
+
 
 /** This is a helper for the BOOST_MIRROR_CLASS_ATTRIB*_TD
  * macros.
  * It declares all common things that need to be declared
  * after the specific stuff.
  */
-#define BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME) \
- typedef mpl::push_back<\
+#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME, TYPENAME_KW) \
+ typedef TYPENAME_KW mpl::push_back<\
                 _partial_list_##NUMBER, \
                 BOOST_MIRROR_TYPEDEFD_SELECTOR(TYPE_NS_ALIAS##_##TYPE, TYPE_NAMESPACE::TYPE)\
>::type
 
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME, BOOST_PP_EMPTY())
+
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME, typename)
+
 /** Helper macro for implementing simple attrib value getting
  * querying scheme
  */
-#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME) \
- static call_traits<TYPE>::param_type get(const the_class& context, mpl::int_<NUMBER>)\
+#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME, TYPENAME_KW) \
+ static TYPENAME_KW call_traits<TYPE>::param_type get(const the_class& context, mpl::int_<NUMBER>)\
         {\
                 return context.NAME;\
         }\
@@ -170,6 +193,13 @@
                 return dest;\
         }
 
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME)\
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME, BOOST_PP_EMPTY())
+
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME)\
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME, typename)
+
+
 /** Helper macro for implementing no-op query meta-class function
  */
 #define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_GETTER(NUMBER, TYPE) \
@@ -177,24 +207,38 @@
         template <typename dest_type>\
         static void query(const the_class& context, mpl::int_<NUMBER>, dest_type& dest){ }
 
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_NO_GETTER(NUMBER, TYPE) \
+
+
 /** Helper macros
  */
-#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
- static void set(the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val)\
+#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME, TYPENAME_KW) \
+ static void set(the_class& context, mpl::int_<NUMBER>, TYPENAME_KW call_traits<TYPE>::param_type val)\
         {\
                 context.NAME = val;\
         } \
- static void set(const the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val)\
+ static void set(const the_class& context, mpl::int_<NUMBER>, TYPENAME_KW call_traits<TYPE>::param_type val)\
         {\
         }
 
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME, BOOST_PP_EMPTY())
+
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME, typename)
+
 
 /** Helper macro for implementing no-op set meta-class function
  */
-#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE) \
+#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE, TYPENAME_KW) \
         static void set(the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val){ }\
         static void set(const the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val){ }
 
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE, BOOST_PP_EMPTY())
+
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE) \
+ BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE, typename)
 
 /** This macro declares the meta-data for a single class' attribute
  */
@@ -204,6 +248,14 @@
         BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
         BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME)
 
+/** This macro declares the meta-data for a single templates attribute
+ */
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME)
+
 /** This macro declares the meta-data for a single class' typedefd attribute
  */
 #define BOOST_MIRROR_REG_CLASS_ATTRIB_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME) \
@@ -212,13 +264,29 @@
         BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE_NAMESPACE::TYPE, NAME) \
         BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME)
 
+/** This macro declares the meta-data for a single templates typedefd attribute
+ */
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIB_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE_NAMESPACE::TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE_NAMESPACE::TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE_NAMESPACE::TYPE, NAME) \
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB_EPILOGUE_TD(NUMBER, TYPE_NS_ALIAS, TYPE_NAMESPACE, TYPE, NAME)
+
 /** This macro finishes the declaration of attributes
  * of the given class
  */
 #define BOOST_MIRROR_REG_CLASS_ATTRIBS_END \
- type_list; \
-struct size : public mpl::size<type_list>{ };\
-};
+ type_list; \
+ struct size : public mpl::size<type_list>{ };\
+ };
+
+/** This macro finishes the declaration of attributes
+ * of the given template
+ */
+#define BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_END \
+ BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+
 } // namespace mirror
 } // namespace boost
 

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-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -71,6 +71,7 @@
          * the inherited ones.
          */
         struct all_attributes
+ : detail::meta_class_attrib_utils<meta_class, all_attributes>
         {
                 /** This struct "hides" the internal helpers
                  */
@@ -466,7 +467,7 @@
                  */
                 template <int I>
                 static const bchar*
- base_name(mpl::int_<I>)
+ base_name(mpl::int_<I> pos)
                 {
                         typedef typename mpl::less<
                                 mpl::int_<I>,

Added: sandbox/mirror/boost/mirror/meta_classes/boost_tuple.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_classes/boost_tuple.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -0,0 +1,88 @@
+/**
+ * \file boost/mirror/meta_classes/boost_tuple.hpp
+ * Meta-class for boost::tuple<T0, T1, ..., Tn>
+ *
+ * Copyright 2008 Matus Chochlik. 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_MIRROR_META_CLASSES_BOOST_TUPLE_HPP
+#define BOOST_MIRROR_META_CLASSES_BOOST_TUPLE_HPP
+
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/meta_types/boost_tuple.hpp>
+#include <boost/mirror/detail/static_int_to_str.hpp>
+
+namespace boost {
+namespace mirror {
+
+BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_BEGIN(::boost::tuples::tuple, 10)
+ __dummy_list;
+ //
+ //
+ // the full list tuple template arguments
+ // which is the list of types of it's member attributes
+ typedef typename mpl::vector10< BOOST_PP_ENUM_PARAMS(10, T) > all_template_params;
+ // the list of member attributes without the null types
+ typedef typename detail::template_with_null_args_type_list<
+ all_template_params
+ >::type template_params;
+ //
+ // member attribute base name getter
+ template <int I>
+ static const bchar* base_name(mpl::int_<I>)
+ {
+ typedef typename boost::mirror::detail::static_int_to_str_w_prefix<
+ mpl::vector_c<bchar, BOOST_STR_LIT('_') >, I
+ >::holder name;
+ //
+ return name::get();
+ }
+
+ template <int I>
+ struct att_val_pass
+ {
+ typedef typename call_traits<
+ typename mpl::at<template_params, mpl::int_<I> >::type
+ >::param_type type;
+ };
+
+ // member attrib value get
+ template <int I>
+ static typename att_val_pass<I>::type
+ get(const the_class& a_tuple, mpl::int_<I>)
+ {
+ return ::boost::tuples::get<I>(a_tuple);
+ }
+
+ // member attrib value query
+ template <typename dest_type, int I>
+ static dest_type& query(const the_class& a_tuple, mpl::int_<I>, dest_type& dest)
+ {
+ dest = dest_type(::boost::tuples::get<I>(a_tuple));
+ return dest;
+ }
+
+ // member attrib value set
+ template <int I>
+ static void set(the_class& a_tuple, mpl::int_<I>, typename att_val_pass<I>::type val)
+ {
+ ::boost::tuples::get<I>(a_tuple) = val;
+ }
+
+ // member attrib value set
+ template <int I>
+ static void set(const the_class& a_tuple, mpl::int_<I>, typename att_val_pass<I>::type val)
+ {
+ }
+ //
+ typedef template_params
+BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_END
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_classes/std_pair.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_classes/std_pair.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -0,0 +1,29 @@
+/**
+ * \file boost/mirror/meta_classes/std_pair.hpp
+ * Meta-class for std::pair<T1, T2>
+ *
+ * Copyright 2008 Matus Chochlik. 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_MIRROR_META_CLASSES_STD_PAIR_HPP
+#define BOOST_MIRROR_META_CLASSES_STD_PAIR_HPP
+
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/meta_types/std_pair.hpp>
+
+namespace boost {
+namespace mirror {
+
+BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_BEGIN(::std::pair, 2)
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB(0, T0, first)
+ BOOST_MIRROR_REG_TEMPLATE_ATTRIB(1, T1, second)
+BOOST_MIRROR_REG_TEMPLATE_ATTRIBS_END
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -14,26 +14,18 @@
 #include <boost/mirror/detail/template_name.hpp>
 #include <boost/mirror/meta_namespaces/boost_tuples.hpp>
 #include <boost/tuple/tuple.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
 
 namespace boost {
 namespace mirror {
 
 #define BOOST_MIRROR_TMP_BOOST_TUPLE_TEMPL_DECL() \
 template < \
- class T0, \
- class T1, \
- class T2, \
- class T3, \
- class T4, \
- class T5, \
- class T6, \
- class T7, \
- class T8, \
- class T9 \
+ BOOST_PP_ENUM_PARAMS(10, class T) \
>
 
 #define BOOST_MIRROR_TMP_BOOST_TUPLE_TEMPL_ARG_NAMES() \
- T0, T1, T2, T3, T4, T5, T6, T7, T8, T9
+ BOOST_PP_ENUM_PARAMS(10, T)
 
 
 namespace detail {

Modified: sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml (original)
+++ sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -81,5 +81,13 @@
                         - Modified several other internal headers
                         - NOTE: tested only with MSVC++ 2008 EE
                 </revision>
+ <revision id="20080428" major="0" minor="1" micro="13" author="m_ch">
+ - Added meta_attribs for boost::tuple
+ - Added meta_attribs for std::vector
+ - Reimplemented meta_attributes::for_each
+ - The for_each function is now available also for all attributes
+ - Updated several examples to show new functionality
+ - NOTE: tested only with MSVC++ 2008
+ </revision>
         </revisions>
 </library>

Modified: sandbox/mirror/libs/mirror/example/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/example/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/example/Jamfile.v2 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -5,7 +5,7 @@
 # (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
 #
 # In addition to this Jamfile You will need a Jamroot file
-# for the 'mirror/examples' project, specifying the project
+# for specifying the basic project
 # requirements mainly <include>/path/to/boost/root.
 # See accompanying _Jamroot_sample file for an example.
 

Modified: sandbox/mirror/libs/mirror/example/registering/classes.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/registering/classes.cpp (original)
+++ sandbox/mirror/libs/mirror/example/registering/classes.cpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -298,8 +298,13 @@
                 attrib_printer(out_stream& _s):s(_s){ }
                 //
                 // function call operator
- template <class meta_class, class iterator, class attrib_type>
- void operator()(meta_class*, iterator pos, attrib_type*) const
+ template <
+ class meta_class,
+ class meta_attributes,
+ class iterator,
+ class attrib_type
+ >
+ void operator()(meta_class mc, meta_attributes ma, iterator pos, attrib_type*) const
                 {
                         // the first argument is a undefined pointer to the
                         // meta_class which we are inspecting (it only conveys
@@ -318,7 +323,7 @@
                         s << endl << " - " <<
                                 name_to_stream<BOOST_MIRROR_REFLECT_TYPE(attrib_type)>() <<
                                 " " <<
- meta_class::attributes::base_name(pos);
+ ma.base_name(pos);
                 }
         };
         //

Modified: sandbox/mirror/libs/mirror/example/registering/virtual_bases.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/registering/virtual_bases.cpp (original)
+++ sandbox/mirror/libs/mirror/example/registering/virtual_bases.cpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -172,6 +172,26 @@
 } // namespace mirror
 } // namespace boost
 
+struct attrib_printer
+{
+ template <class meta_class, class meta_attributes, class iterator, class attrib_type>
+ void operator()(meta_class mc, meta_attributes ma, iterator pos, attrib_type*) const
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ typedef BOOST_MIRROR_REFLECT_TYPE(attrib_type) mt;
+ bcout <<
+ " " <<
+ iterator::value <<
+ ": " <<
+ mt::full_name() <<
+ " " <<
+ ma.base_name(pos) <<
+ ";" <<
+ endl;
+ }
+};
 
 int main(void)
 {
@@ -193,6 +213,8 @@
         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;
+ // execute an functor on all attributes
+ meta_T::all_attributes::for_each(attrib_printer());
         //
         // The attrbs of H are reflected in the following order
         // A::l (long)

Modified: sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp (original)
+++ sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -18,13 +18,16 @@
 
 #include <boost/mirror/utils/name_to_stream.hpp>
 
-#include <boost/mirror/meta_types/std_pair.hpp>
 #include <boost/mirror/meta_types/boost_tuple.hpp>
+#include <boost/mirror/meta_types/std_pair.hpp>
 #include <boost/mirror/meta_types/std_vector.hpp>
 #include <boost/mirror/meta_types/std_list.hpp>
 #include <boost/mirror/meta_types/std_map.hpp>
 #include <boost/mirror/meta_types/std_set.hpp>
 
+#include <boost/mirror/meta_classes/boost_tuple.hpp>
+
+
 int main(void)
 {
         using namespace ::std;
@@ -39,9 +42,10 @@
         typedef tuple<char, wchar_t, short int const> T5;
         typedef pair<T4, T5> T6;
         typedef vector<tuple<T1, T2, T3, T4, T5, T6> > T7;
- typedef set<map<list<T1>, T7> > T;
+ typedef set<map<list<T1>, T7> > T8;
+ typedef tuple<T1, T2, T8> T;
         //
- typedef BOOST_MIRROR_REFLECT_TYPE(T) meta_T;
+ typedef BOOST_MIRROR_REFLECT_CLASS(T) meta_T;
         //
         //
         bcout << "The type name length = " << meta_T::base_name_length << " characters" << endl;
@@ -52,7 +56,39 @@
         bcout << "---------------------------------------------------" << endl;
         bcout << "The full type name is: "<< meta_T::full_name() << endl;
         bcout << "---------------------------------------------------" << endl;
+ bcout << "The class has "<< meta_T::all_attributes::size::value << " members" << endl;
+ bcout << "---------------------------------------------------" << endl;
+ bcout << "---------------------------------------------------" << endl;
+ //
+ T1 t1(12, 34.56, 0);
+ typedef BOOST_MIRROR_REFLECT_CLASS(T1) meta_T1;
+ bcout << "The full type name length = " << meta_T1::full_name_length << " characters" << endl;
+ bcout << "---------------------------------------------------" << endl;
+ bcout << "The full type name is: "<< meta_T1::full_name() << endl;
+ bcout << "---------------------------------------------------" << endl;
+ bcout << "The class has "<< meta_T1::all_attributes::size::value << " members" << endl;
+ bcout << "---------------------------------------------------" << endl;
+ bcout << meta_T1::all_attributes::base_name(mpl::int_<0>()) << " = ";
+ bcout << meta_T1::all_attributes::get(t1, mpl::int_<0>()) << endl;
+ bcout << meta_T1::all_attributes::base_name(mpl::int_<1>()) << " = ";
+ bcout << meta_T1::all_attributes::get(t1, mpl::int_<1>()) << endl;
+ bcout << meta_T1::all_attributes::base_name(mpl::int_<2>()) << " = ";
+ bcout << meta_T1::all_attributes::get(t1, mpl::int_<2>()) << endl;
+ bcout << "---------------------------------------------------" << endl;
+ //
+ meta_T1::all_attributes::set(t1, mpl::int_<0>(), 23);
+ meta_T1::all_attributes::set(t1, mpl::int_<1>(), 45.67);
         //
+ assert(meta_T1::all_attributes::get(t1, mpl::int_<0>()) == tuples::get<0>(t1));
+ assert(meta_T1::all_attributes::get(t1, mpl::int_<1>()) == tuples::get<1>(t1));
+ //
+ tuple<int, int, int, int, int, int, int, int, int, int> x(0,1,2,3,4,5,6,7,8,9);
+ //
+ typedef BOOST_MIRROR_REFLECT_TYPEOF(x) meta_X;
+ //
+ //bcout << meta_X::all_attributes::base_name(mpl::int_<0>()) << " = ";
+ //bcout << meta_X::all_attributes::get(x, mpl::int_<0>()) << endl;
+
         return 0;
 }
 

Modified: sandbox/mirror/libs/mirror/example/special/std_pair.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/special/std_pair.cpp (original)
+++ sandbox/mirror/libs/mirror/example/special/std_pair.cpp 2008-04-28 10:48:07 EDT (Mon, 28 Apr 2008)
@@ -18,6 +18,7 @@
 #include <boost/mirror/meta_class.hpp>
 
 #include <boost/mirror/meta_types/std_pair.hpp>
+#include <boost/mirror/meta_classes/std_pair.hpp>
 
 int main(void)
 {
@@ -32,7 +33,7 @@
         typedef pair<T2, T1 volatile> T4;
         typedef pair<T3 const * volatile *, const T4&> T;
         //
- typedef BOOST_MIRROR_REFLECT_TYPE(T) meta_T;
+ typedef BOOST_MIRROR_REFLECT_CLASS(T) meta_T;
         //
         bcout << "The type name length = " << meta_T::base_name_length << " characters" << endl;
         bcout << "---------------------------------------------------" << endl;
@@ -42,6 +43,8 @@
         bcout << "---------------------------------------------------" << endl;
         bcout << "The full type name is: "<< meta_T::full_name() << endl;
         bcout << "---------------------------------------------------" << endl;
+ bcout << "The class has "<< meta_T::all_attributes::size::value << " members" << endl;
+ bcout << "---------------------------------------------------" << 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