|
Boost-Commit : |
From: chochlik_at_[hidden]
Date: 2008-04-24 12:52:54
Author: matus.chochlik
Date: 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
New Revision: 44751
URL: http://svn.boost.org/trac/boost/changeset/44751
Log:
Added wrappers to two cstring functions (strcmp/strcpy).
Added support for querying non-trivial type names through the base_name function.
Added base_name_length static member to the meta_namespaces and meta_types.
Added support for reflecting std::pairs.
Added an example showing reflection of std::pairs
NOTE: this revision was only tested with MSVC++ 2008 EE it may fail to compile with g++
Added:
sandbox/mirror/boost/mirror/detail/array_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/const_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/cv_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/pointer_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/ptr_ref_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/reference_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/template_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/volatile_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_classes/
sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/std_pair.hpp (contents, props changed)
sandbox/mirror/libs/examples/special/
sandbox/mirror/libs/examples/special/std_pair.cpp (contents, props changed)
Text files modified:
sandbox/mirror/boost/char_type_switch/string.hpp | 47 +++++++++++++++
sandbox/mirror/boost/mirror/common_defs.hpp | 3
sandbox/mirror/boost/mirror/meta_attribs_base.hpp | 2
sandbox/mirror/boost/mirror/meta_class.hpp | 125 ++++++++++++++++++++++++++-------------
sandbox/mirror/boost/mirror/meta_namespace.hpp | 10 ++
sandbox/mirror/boost/mirror/meta_type.hpp | 72 +++++++++++++++++-----
6 files changed, 199 insertions(+), 60 deletions(-)
Modified: sandbox/mirror/boost/char_type_switch/string.hpp
==============================================================================
--- sandbox/mirror/boost/char_type_switch/string.hpp (original)
+++ sandbox/mirror/boost/char_type_switch/string.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -13,6 +13,9 @@
#include <boost/char_type_switch/choice.hpp>
// Needed for ::std::string / ::std::wstring
#include <string>
+//
+// c string functions
+#include <cstring>
namespace boost {
@@ -37,6 +40,50 @@
# define BOOST_STR_LIT(STR) STR
#endif // NOT BOOST_USE_WIDE_CHARS
+// define macro expanding into a compile time const lenght
+// of the given string literal
+#define BOOST_STR_LIT_LENGTH(STR) ((sizeof(STR)/sizeof(char))-1)
+
+
+/** Wrappers of cstring functions
+ */
+
+// disable the deprecated function warning on msvc
+// this warning is issued when not using the "safe"
+// versions of string functions like strcpy_s (vs. strcpy)
+#pragma warning(push)
+#pragma warning(disable : 4996)
+
+
+/** string compare
+ */
+inline int bstrcmp(const bchar* a, const bchar* b)
+{
+#ifdef BOOST_USE_WIDE_CHARS
+ return ::std::wcscmp(a, b);
+#else
+ return ::std::strcmp(a, b);
+#endif
+}
+
+/** string copy
+ */
+inline bchar* bstrcpy(bchar* dst, const bchar* src)
+{
+#ifdef BOOST_USE_WIDE_CHARS
+ return ::std::wcscpy(dst, src);
+#else
+ return ::std::strcpy(dst, src);
+#endif
+}
+
+// enable the deprecated function warnings on msvc
+#pragma warning(pop)
+
+
+
} // namespace boost
#endif //include guard
+
+
Modified: sandbox/mirror/boost/mirror/common_defs.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/common_defs.hpp (original)
+++ sandbox/mirror/boost/mirror/common_defs.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -13,6 +13,9 @@
namespace boost {
namespace mirror {
+/** Defines a constant class member attribute, named NAME
+ * initialized with the VALUE and possibly being instace of TYPE
+ */
#define BOOST_MIRROR_CONST_MEMBER_ATTRIB(TYPE, NAME, VALUE) \
enum {NAME = VALUE};
Added: sandbox/mirror/boost/mirror/detail/array_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/array_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,61 @@
+/**
+ * \file boost/mirror/detail/array_type_name.hpp
+ * Helpers for composing array type names
+ *
+ * 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_DETAIL_ARRAY_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_ARRAY_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+
+template <class meta_type, size_t array_size>
+struct static_array_type_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (meta_type::base_name_length + 3)
+ )
+
+protected:
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the template
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ //
+ // append the " [N]"
+ *(cur_pos++) = BOOST_STR_LIT(' ');
+ *(cur_pos++) = BOOST_STR_LIT('[');
+ *(cur_pos++) = BOOST_STR_LIT(']');
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type, size_t array_size>
+struct static_array_type_name : static_nontrivial_type_name<
+ static_array_type_name_base<meta_type, array_size>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/const_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/const_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,59 @@
+/**
+ * \file boost/mirror/detail/const_type_name.hpp
+ * Helpers for composing const type names
+ *
+ * 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_DETAIL_CONST_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_CONST_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <class meta_type>
+struct static_const_type_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (meta_type::base_name_length + 6)
+ )
+
+protected:
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the base type
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ //
+ // append the const keyword
+ bstrcpy(cur_pos, BOOST_STR_LIT(" const"));
+ cur_pos += 6;
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type>
+struct static_const_type_name : static_nontrivial_type_name<
+ static_const_type_name_base<meta_type>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/cv_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/cv_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,59 @@
+/**
+ * \file boost/mirror/detail/cv_type_name.hpp
+ * Helpers for composing a const volatile type name
+ *
+ * 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_DETAIL_CV_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_CV_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <class meta_type>
+struct static_cv_type_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (meta_type::base_name_length + 15)
+ )
+
+protected:
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the base type
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ //
+ // append the const keyword
+ bstrcpy(cur_pos, BOOST_STR_LIT(" const volatile"));
+ cur_pos += 15;
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type>
+struct static_cv_type_name : static_nontrivial_type_name<
+ static_cv_type_name_base<meta_type>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,35 @@
+/**
+ * \file boost/mirror/detail/nontrivial_type_name.hpp
+ * Helpers for composing a nontrivial typenames
+ *
+ * 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_DETAIL_NONTRIVIAL_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_NONTRIVIAL_TYPE_NAME_HPP
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <class implementation>
+struct static_nontrivial_type_name : implementation
+{
+ static const bchar* base_name(void)
+ {
+ static bchar the_base_name[implementation::base_name_length+1]
+ = {BOOST_STR_LIT("")};
+ if(!the_base_name[0])
+ implementation::init_base_name(the_base_name);
+ return the_base_name;
+ }
+};
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/pointer_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/pointer_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,32 @@
+/**
+ * \file boost/mirror/detail/pointer_type_name.hpp
+ * Helpers for composing a pointer type name
+ *
+ * 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_DETAIL_POINTER_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_POINTER_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/ptr_ref_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+
+template <class meta_type>
+struct static_pointer_type_name : static_ptr_ref_type_name<
+ meta_type, BOOST_STR_LIT('*')
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/ptr_ref_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/ptr_ref_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,61 @@
+/**
+ * \file boost/mirror/detail/ptr_ref_type_name.hpp
+ * Helpers for composing pointer and reference type names
+ *
+ * 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_DETAIL_PTRREF_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_PTRREF_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <class meta_type, bchar token, bchar token2>
+struct static_ptr_ref_type_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (meta_type::base_name_length + 3)
+ )
+
+protected:
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the template
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ //
+ // append the " * " or " & "
+ assert(cur_pos+3 == (the_base_name + base_name_length));
+ *(cur_pos++) = BOOST_STR_LIT(' ');
+ *(cur_pos++) = token;
+ *(cur_pos++) = token2;
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type, bchar token, bchar token2 = BOOST_STR_LIT(' ')>
+struct static_ptr_ref_type_name : static_nontrivial_type_name<
+ static_ptr_ref_type_name_base<meta_type, token, token2>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/reference_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/reference_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,32 @@
+/**
+ * \file boost/mirror/detail/reference_type_name.hpp
+ * Helpers for composing a reference type name
+ *
+ * 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_DETAIL_REFERENCE_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_REFERENCE_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/ptr_ref_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+
+template <class meta_type>
+struct static_reference_type_name : static_ptr_ref_type_name<
+ meta_type, BOOST_STR_LIT('&')
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/template_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/template_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,139 @@
+/**
+ * \file boost/mirror/detail/template_name.hpp
+ * Helpers for composing a template name
+ *
+ * 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_DETAIL_TEMPLATE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_TEMPLATE_NAME_HPP
+
+#include <assert.h>
+
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/at.hpp>
+
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <typename base_type>
+struct get_base_type_name_length_type
+{
+ typedef typename mpl::int_<
+ BOOST_MIRROR_REFLECT_TYPE(base_type)::base_name_length
+ > type;
+};
+
+/** The length is calculated assuming that the string is
+ * going to be formatted like this:
+ * template_name|< |T1|, |T2|, |...|Tn| > (without the
+ * delimiting '|'s.
+ */
+template <class meta_type, class typelist, int template_name_length>
+struct static_template_name_length
+{
+ typedef typename mpl::accumulate<
+ typelist,
+ mpl::int_<template_name_length+2>,
+ mpl::plus<
+ mpl::_1,
+ mpl::plus<
+ get_base_type_name_length_type<mpl::_2>,
+ mpl::int_<2>
+ >
+ >
+ >::type type;
+};
+
+
+template <class meta_type, class typelist, int template_name_length>
+struct static_template_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (static_template_name_length<
+ meta_type,
+ typelist,
+ template_name_length
+ >::type::value)
+ )
+
+protected:
+ /** The 'position' of the last type in the template
+ * type list.
+ */
+ typedef typename mpl::int_<
+ mpl::size< typelist >::value - 1
+ > last_type_pos;
+
+ template <int I>
+ static bchar* do_append_type_name(bchar* cur_pos, mpl::int_<I>)
+ {
+ typedef typename mpl::at<typelist, mpl::int_<I> >::type type;
+ typedef BOOST_MIRROR_REFLECT_TYPE(type) meta_type;
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ return cur_pos;
+ }
+
+ static bchar* append_type_name(bchar* cur_pos, mpl::int_<0> type_pos)
+ {
+ return do_append_type_name(cur_pos, type_pos);
+ }
+
+ template <int I>
+ static bchar* append_type_name(bchar* cur_pos, mpl::int_<I> type_pos)
+ {
+ cur_pos = append_type_name(cur_pos, mpl::int_<I - 1>());
+ bstrcpy(cur_pos, BOOST_STR_LIT(", "));
+ cur_pos += 2;
+ return do_append_type_name(cur_pos, type_pos);
+ }
+
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the template
+ bstrcpy(cur_pos, meta_type::template_name());
+ cur_pos += template_name_length;
+ //
+ // append the leading "< "
+ assert(cur_pos+2 < (the_base_name + base_name_length));
+ bstrcpy(cur_pos, BOOST_STR_LIT("< "));
+ cur_pos += 2;
+ //
+ // append the typenames
+ cur_pos = append_type_name(cur_pos, last_type_pos());
+ //
+ // append the final " >"
+ assert(cur_pos+2 == (the_base_name + base_name_length));
+ bstrcpy(cur_pos, BOOST_STR_LIT(" >"));
+ cur_pos += 2;
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type, class typelist, int template_name_length>
+struct static_template_name : static_nontrivial_type_name<
+ static_template_name_base<meta_type, typelist, template_name_length>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/volatile_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/volatile_type_name.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,59 @@
+/**
+ * \file boost/mirror/detail/volatile_type_name.hpp
+ * Helpers for composing volatile type names
+ *
+ * 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_DETAIL_VOLATILE_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_VOLATILE_TYPE_NAME_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/nontrivial_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <class meta_type>
+struct static_volatile_type_name_base
+{
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(
+ size_t,
+ base_name_length,
+ (meta_type::base_name_length + 9)
+ )
+
+protected:
+ static void init_base_name(bchar* the_base_name)
+ {
+ bchar* cur_pos = the_base_name;
+ //
+ // copy the name of the base type
+ bstrcpy(cur_pos, meta_type::base_name());
+ cur_pos += meta_type::base_name_length;
+ //
+ // append the const keyword
+ bstrcpy(cur_pos, BOOST_STR_LIT(" volatile"));
+ cur_pos += 9;
+ //
+ // finalize the string
+ assert(cur_pos == (the_base_name + base_name_length));
+ *cur_pos = BOOST_STR_LIT('\0');
+ }
+};
+
+template <class meta_type>
+struct static_volatile_type_name : static_nontrivial_type_name<
+ static_volatile_type_name_base<meta_type>
+>{ };
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
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-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -134,7 +134,7 @@
*/
#define BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, NAME) \
_partial_list_##NUMBER;\
- static const bchar* base_name(mpl::int_<NUMBER>){return BOOST_STR_LIT(#NAME);}
+ static const bchar* base_name(mpl::int_<NUMBER>){return BOOST_STR_LIT(#NAME);}\
/** This is a helper for the BOOST_MIRROR_CLASS_ATTRIB*
* macros.
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-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -314,15 +314,10 @@
member_attrib_type_list,
mpl::int_<I>
>::type type;
- };
-
-
- /** This function is used to get the member attributes
- * from the 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>)
+ };
+
+ template <int I>
+ struct inherited_attrib_meta_class_and_pos
{
typedef typename mpl::at<
typename detail::inherited_attrib_owners_and_offsets,
@@ -333,7 +328,56 @@
typedef typename mpl::int_<mpl::minus<
mpl::int_<I>,
typename owner_and_offset::second
- >::value> new_pos_type;
+ >::value> position;
+ };
+
+ template <int I>
+ struct own_attrib_meta_class_and_pos
+ {
+ typedef typename meta_class meta_class;
+ typedef typename mpl::int_<mpl::minus<
+ mpl::int_<I>,
+ typename mpl::size<inherited_member_attrib_type_list>::type
+ >::value> position;
+ };
+
+ /** This function is used to get the names of the member
+ * attributes from the base classes.
+ */
+ template <int I>
+ static const bchar*
+ base_name(mpl::int_<I> pos, mpl::bool_<true>)
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::meta_class meta_class;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
+
+ return meta_class::attributes::base_name(new_pos_type());
+ }
+
+ template <int I>
+ static const bchar*
+ base_name(mpl::int_<I> pos, mpl::bool_<false>)
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
+
+ return meta_class::attributes::base_name(new_pos_type());
+ }
+
+
+ /** This function is used to get the member attributes
+ * from the 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 typename inherited_attrib_meta_class_and_pos<I>
+ ::meta_class meta_class;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
return meta_class::attributes::get(context, new_pos_type());
@@ -342,10 +386,8 @@
static typename result_of_get<I>::type
get(a_class context, mpl::int_<I> pos, mpl::bool_<false>)
{
- typedef typename mpl::int_<mpl::minus<
- mpl::int_<I>,
- typename mpl::size<inherited_member_attrib_type_list>::type
- >::value> new_pos_type;
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
return meta_class::attributes::get(context, new_pos_type());
}
@@ -357,16 +399,10 @@
static dest_type&
query(a_class context, mpl::int_<I> pos, dest_type& dest, mpl::bool_<true>)
{
- 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::int_<mpl::minus<
- mpl::int_<I>,
- typename owner_and_offset::second
- >::value> new_pos_type;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::meta_class meta_class;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
return meta_class::attributes::query(context, new_pos_type(), dest);
@@ -376,10 +412,8 @@
static dest_type&
query(a_class context, mpl::int_<I> pos, dest_type& dest, mpl::bool_<false>)
{
- typedef typename mpl::int_<mpl::minus<
- mpl::int_<I>,
- typename mpl::size<inherited_member_attrib_type_list>::type
- >::value> new_pos_type;
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
return meta_class::attributes::query(context, new_pos_type(), dest);
}
@@ -391,16 +425,10 @@
static void
set(a_class& context, mpl::int_<I> pos, value_type value, mpl::bool_<true>)
{
- 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::int_<mpl::minus<
- mpl::int_<I>,
- typename owner_and_offset::second
- >::value> new_pos_type;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::meta_class meta_class;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
meta_class::attributes::set(context, new_pos_type(), value);
}
@@ -409,10 +437,8 @@
static void
set(a_class& context, mpl::int_<I> pos, value_type value, mpl::bool_<false>)
{
- typedef typename mpl::int_<mpl::minus<
- mpl::int_<I>,
- typename mpl::size<inherited_member_attrib_type_list>::type
- >::value> new_pos_type;
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_pos_type;
meta_class::attributes::set(context, new_pos_type(), value);
}
@@ -435,6 +461,21 @@
*/
struct size : public mpl::size<type_list> { };
+ /** Gets the name of the I-th member (including
+ * the inherited ones)
+ */
+ template <int I>
+ static const bchar*
+ base_name(mpl::int_<I>)
+ {
+ typedef typename mpl::less<
+ mpl::int_<I>,
+ inherited_size
+ >::type is_inherited;
+
+ return detail::base_name(pos, is_inherited());
+ }
+
/** Gets the value of the I-th member (including
* the inherited ones)
*/
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-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -22,6 +22,8 @@
#include <boost/char_type_switch/string.hpp>
// forward declarations
#include <boost/mirror/meta_data_fwd.hpp>
+// implementation helpers
+#include <boost/mirror/common_defs.hpp>
namespace boost {
namespace mirror {
@@ -37,6 +39,7 @@
typedef void parent;
typedef mpl::vector0<> scope;
static const bchar* base_name (void) {return BOOST_STR_LIT("");}
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(size_t, base_name_length, 0)
};
@@ -47,7 +50,12 @@
typedef meta_namespace< namespaces :: PARENT_NS_ALIAS > parent; \
typedef mpl::push_back<parent::scope, parent>::type scope; \
static const bchar* base_name (void) {return BOOST_STR_LIT(#NAMESPACE_NAME);} \
-}; \
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB(\
+ size_t, \
+ base_name_length, \
+ BOOST_STR_LIT_LENGTH(#NAMESPACE_NAME)\
+ ) \
+};
/** Macro for registering new general namespaces (top level or nested)
Modified: sandbox/mirror/boost/mirror/meta_type.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_type.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_type.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -16,6 +16,14 @@
#include <boost/mirror/meta_data_fwd.hpp>
// for declarations of meta-types for groups of types
#include <boost/preprocessor.hpp>
+//
+//
+#include <boost/mirror/detail/pointer_type_name.hpp>
+#include <boost/mirror/detail/reference_type_name.hpp>
+#include <boost/mirror/detail/array_type_name.hpp>
+#include <boost/mirror/detail/const_type_name.hpp>
+#include <boost/mirror/detail/volatile_type_name.hpp>
+#include <boost/mirror/detail/cv_type_name.hpp>
namespace boost {
namespace mirror {
@@ -46,6 +54,11 @@
typedef BOOST_MIRROR_REFLECT_NAMESPACE(NAMESPACE_ALIAS) scope; \
typedef NAMESPACE::BASE_NAME base_type; \
static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_NAME);}\
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB( \
+ size_t, \
+ base_name_length, \
+ BOOST_STR_LIT_LENGTH(#BASE_NAME)\
+ ) \
};
/** Macro for declaration of meta-types for typedefined types
@@ -60,35 +73,50 @@
typedef BOOST_MIRROR_REFLECT_NAMESPACE(NAMESPACE_ALIAS) scope; \
typedef NAMESPACE::TYPEDEFD_NAME base_type; \
static const bchar* base_name (void) {return BOOST_STR_LIT(#TYPEDEFD_NAME);}\
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB( \
+ size_t, \
+ base_name_length, \
+ BOOST_STR_LIT_LENGTH(#TYPEDEFD_NAME)\
+ ) \
};
/** Declaration of meta types for types in the global scope
*/
-#define BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_TYPE) \
- template <> struct meta_type< BASE_TYPE > \
+#define BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_NAME) \
+ template <> struct meta_type< BASE_NAME > \
{ \
typedef BOOST_MIRROR_REFLECT_NAMESPACE(_) scope; \
- typedef BASE_TYPE base_type; \
- static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_TYPE);}\
+ typedef BASE_NAME base_type; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_NAME);}\
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB( \
+ size_t, \
+ base_name_length, \
+ BOOST_STR_LIT_LENGTH( #BASE_NAME ) \
+ ) \
};
/** Declaration of meta types for types in declared inside
* of a class.
*/
-#define BOOST_MIRROR_REG_META_TYPE_EMBEDDED(WRAPPER, BASE_TYPE) \
- template <> struct meta_type< WRAPPER::BASE_TYPE > \
+#define BOOST_MIRROR_REG_META_TYPE_EMBEDDED(WRAPPER, BASE_NAME) \
+ template <> struct meta_type< WRAPPER::BASE_NAME > \
{ \
typedef meta_class< WRAPPER > scope; \
- typedef WRAPPER::BASE_TYPE base_type; \
- static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_TYPE);}\
+ typedef WRAPPER::BASE_NAME base_type; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_NAME);}\
+ BOOST_MIRROR_CONST_MEMBER_ATTRIB( \
+ size_t, \
+ base_name_length, \
+ BOOST_STR_LIT_LENGTH(#BASE_NAME)\
+ ) \
};
/** Helper macro used for batch registering of the meta-types for
* the C++ native types
*/
-#define BOOST_MIRROR_REG_ITH_META_TYPE_NATIVE(I, _, BASE_TYPE)\
- BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_TYPE)
+#define BOOST_MIRROR_REG_ITH_META_TYPE_NATIVE(I, _, BASE_NAME)\
+ BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_NAME)
#define BOOST_MIRROR_NATIVE_TYPES \
BOOST_PP_TUPLE_TO_LIST( \
@@ -126,7 +154,9 @@
/** Meta-types for pointers
*/
template <class pointee_type>
-struct meta_type<pointee_type*>
+struct meta_type<pointee_type*> : detail::static_pointer_type_name<
+ meta_type<pointee_type>
+>
{
typedef typename meta_type<pointee_type>::scope scope;
typedef pointee_type* base_type;
@@ -135,7 +165,9 @@
/** Meta-types for arrays
*/
template <class element_type, size_t size>
-struct meta_type<element_type[size]>
+struct meta_type<element_type[size]> : detail::static_array_type_name<
+ meta_type<element_type>, size
+>
{
typedef typename meta_type<element_type>::scope scope;
typedef element_type base_type[size];
@@ -144,7 +176,9 @@
/** Meta-types for references
*/
template <class refered_to_type>
-struct meta_type<refered_to_type&>
+struct meta_type<refered_to_type&> : detail::static_reference_type_name<
+ meta_type<refered_to_type>
+>
{
typedef typename meta_type<refered_to_type>::scope scope;
typedef refered_to_type& base_type;
@@ -153,7 +187,9 @@
/** Meta-types for const types
*/
template <class non_const_type>
-struct meta_type<const non_const_type>
+struct meta_type<const non_const_type> : detail::static_const_type_name<
+ meta_type<non_const_type>
+>
{
typedef typename meta_type<non_const_type>::scope scope;
typedef const non_const_type base_type;
@@ -162,7 +198,9 @@
/** Meta-types for volatile types
*/
template <class non_volatile_type>
-struct meta_type<volatile non_volatile_type>
+struct meta_type<volatile non_volatile_type> : detail::static_volatile_type_name<
+ meta_type<non_volatile_type>
+>
{
typedef typename meta_type<non_volatile_type>::scope scope;
typedef volatile non_volatile_type base_type;
@@ -171,7 +209,9 @@
/** Meta-types for const volatile types
*/
template <class non_cv_type>
-struct meta_type<const volatile non_cv_type>
+struct meta_type<const volatile non_cv_type> : detail::static_cv_type_name<
+ meta_type<non_cv_type>
+>
{
typedef typename meta_type<non_cv_type>::scope scope;
typedef const volatile non_cv_type base_type;
Added: sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,479 @@
+/**
+ * \file boost/mirror/meta_types/boost_tuple.hpp
+ * Meta-type for boost::tuple<>
+ *
+ * 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_TYPES_BOOST_TUPLE_HPP
+#define BOOST_MIRROR_META_TYPES_BOOST_TUPLE_HPP
+
+#include <boost/mirror/meta_type.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Meta class - specializes the meta_type for classes
+ */
+template <
+ class reflected_class,
+ class variant_tag
+>
+struct meta_class : public meta_type<reflected_class>
+{
+ /** The base classes of a class.
+ * The member base_classes::list is a mpl::vector of
+ * meta_inheritance<> specializations, one for every
+ * base class.
+ */
+ typedef meta_base_classes<reflected_class, variant_tag> base_classes;
+
+ /** The member attributes of the class (not includeing the inherited
+ * member attribs.
+ * The attributes::type_list is a mpl::vector of types
+ * of the attributes.
+ *
+ * The attributes::get(mpl::int_<I>) functions allow to get the value
+ * of the I-th attribute, if the attribute is not write-only, where:
+ * 0 <= I < N; N = $mpl::size<attributes::type_list>::value
+ *
+ * The attributes::set(mpl::int_<I>), T val) functions allow to set
+ * the value of the I-th attribute, if it's not read-only, where
+ * 0 <= I < N; N = $mpl::size<attributes::type_list>::value
+ *
+ */
+ typedef meta_class_attributes<reflected_class, variant_tag> attributes;
+
+ /** This is basically the same as the "attributes" structure
+ * but allows to work with all member attributes including
+ * the inherited ones.
+ */
+ struct all_attributes
+ {
+ /** This struct "hides" the internal helpers
+ */
+ struct detail
+ {
+ /** The list of non-virtual base classes in the same
+ * order as they were registered.
+ */
+ typedef typename mpl::remove_if<
+ typename base_classes::list,
+ mpl::lambda<
+ reflects_virtual_inheritance<mpl::_1>
+ >::type
+ >::type list_of_regular_base_classes;
+
+ /** The list of directly inhertied virtual base classes.
+ */
+ typedef typename mpl::remove_if<
+ typename base_classes::list,
+ mpl::lambda<
+ mpl::not_<reflects_virtual_inheritance<mpl::_1> >
+ >::type
+ >::type list_of_virtual_base_classes;
+
+ /** 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_regular_layout
+ {
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ all_attributes::
+ detail::
+ regular_base_class_layout type;
+ };
+
+ /** The layout of non-virtual base classes
+ * of this class, stored as a mpl::vector
+ * of meta_inheritances.
+ */
+ typedef typename mpl::accumulate<
+ list_of_regular_base_classes,
+ mpl::vector0<>,
+ 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.
+ */
+ 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_base_class_layout
+ {
+ typedef typename
+ meta_inheritance::
+ meta_class::
+ all_attributes::
+ detail::
+ base_class_layout type;
+ };
+
+ /** 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 base_classes::list,
+ mpl::vector0<>,
+ 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 virtual_base_class_layout_w_dups;
+
+ /** 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<
+ base_class_layout,
+ mpl::vector0<>,
+ mpl::insert_range<
+ mpl::_1,
+ mpl::end<mpl::_1>,
+ 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;
+
+
+ /** This template gets the list of the owner classes
+ * for the inherited attributes.
+ */
+ template <class current_list, class meta_inheritance>
+ struct get_base_class_attrib_owner_and_offs
+ {
+ typedef typename meta_inheritance::
+ meta_class base_meta_class;
+
+ typedef typename base_meta_class::
+ attributes::
+ type_list type_list;
+
+ typedef typename mpl::size<
+ current_list
+ >::type offset;
+ typedef typename mpl::pair<
+ base_meta_class,
+ offset
+ > pair;
+
+ template<typename T>
+ struct get_pair
+ {
+ typedef pair type;
+ };
+
+ typedef typename mpl::accumulate<
+ type_list,
+ current_list,
+ mpl::push_back<
+ mpl::_1,
+ get_pair<mpl::_>
+ >
+ >::type type;
+ };
+
+ /** This is a list that contains a pair of owner meta_class
+ * and the index offset for every inherited attribute.
+ */
+ typedef typename mpl::accumulate<
+ base_class_layout,
+ mpl::vector0<>,
+ get_base_class_attrib_owner_and_offs<
+ mpl::_1,
+ mpl::_2
+ >
+ >::type inherited_attrib_owners_and_offsets;
+
+ /** 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 member attributes
+ * from the 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 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::int_<mpl::minus<
+ mpl::int_<I>,
+ typename owner_and_offset::second
+ >::value> new_pos_type;
+
+ return meta_class::attributes::get(context, new_pos_type());
+
+ }
+ 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 typename mpl::int_<mpl::minus<
+ mpl::int_<I>,
+ typename mpl::size<inherited_member_attrib_type_list>::type
+ >::value> new_pos_type;
+ return meta_class::attributes::get(context, new_pos_type());
+ }
+
+
+ /** This function is used to query the member attributes
+ * from the base classes.
+ */
+ template <class a_class, int I, typename dest_type>
+ static dest_type&
+ query(a_class context, mpl::int_<I> pos, dest_type& dest, mpl::bool_<true>)
+ {
+ 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::int_<mpl::minus<
+ mpl::int_<I>,
+ typename owner_and_offset::second
+ >::value> new_pos_type;
+
+ return meta_class::attributes::query(context, new_pos_type(), dest);
+
+ }
+
+ template <class a_class, int I, typename dest_type>
+ static dest_type&
+ query(a_class context, mpl::int_<I> pos, dest_type& dest, mpl::bool_<false>)
+ {
+ typedef typename mpl::int_<mpl::minus<
+ mpl::int_<I>,
+ typename mpl::size<inherited_member_attrib_type_list>::type
+ >::value> new_pos_type;
+ return meta_class::attributes::query(context, new_pos_type(), dest);
+ }
+
+
+ /** This function is used to query the member attributes
+ * from the base classes.
+ */
+ template <class a_class, int I, typename value_type>
+ static void
+ set(a_class& context, mpl::int_<I> pos, value_type value, mpl::bool_<true>)
+ {
+ 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::int_<mpl::minus<
+ mpl::int_<I>,
+ typename owner_and_offset::second
+ >::value> new_pos_type;
+
+ meta_class::attributes::set(context, new_pos_type(), value);
+ }
+
+ template <class a_class, int I, typename value_type>
+ static void
+ set(a_class& context, mpl::int_<I> pos, value_type value, mpl::bool_<false>)
+ {
+ typedef typename mpl::int_<mpl::minus<
+ mpl::int_<I>,
+ typename mpl::size<inherited_member_attrib_type_list>::type
+ >::value> new_pos_type;
+ meta_class::attributes::set(context, new_pos_type(), value);
+ }
+
+ }; // 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 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> { };
+
+ /** Gets the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class a_class, int I>
+ static typename detail::template result_of_get<I>::type
+ get(a_class context, mpl::int_<I> pos)
+ {
+ typedef typename mpl::less<
+ mpl::int_<I>,
+ inherited_size
+ >::type is_inherited;
+
+ return detail::get(context, pos, is_inherited());
+ }
+
+ /** Queries the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class a_class, int I, typename dest_type>
+ static dest_type&
+ query(a_class context, mpl::int_<I> pos, dest_type& dest)
+ {
+ typedef typename mpl::less<
+ mpl::int_<I>,
+ inherited_size
+ >::type is_inherited;
+
+ return detail::query(context, pos, dest, is_inherited());
+ }
+
+ /** Sets the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class a_class, int I, typename value_type>
+ static void
+ set(a_class& context, mpl::int_<I> pos, value_type value)
+ {
+ typedef typename mpl::less<
+ mpl::int_<I>,
+ inherited_size
+ >::type is_inherited;
+
+ detail::set(context, pos, value, is_inherited());
+ }
+ }; // all_attributes
+
+};
+
+
+/** This macro should be included in the definition of every class
+ * with private or protected members, that should be refleccted
+ */
+#define BOOST_MIRROR_FRIENDLY_CLASS(CLASS_NAME) \
+ friend struct ::boost::mirror::meta_class_attributes<CLASS_NAME>;
+
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/std_pair.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/std_pair.hpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,39 @@
+/**
+ * \file boost/mirror/meta_types/std_pair.hpp
+ * Meta-type 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_TYPES_STD_PAIR_HPP
+#define BOOST_MIRROR_META_TYPES_STD_PAIR_HPP
+
+#include <boost/mirror/meta_type.hpp>
+#include <boost/mirror/detail/template_name.hpp>
+//std::pair
+#include <utility>
+
+namespace boost {
+namespace mirror {
+
+template <typename first_type, typename second_type>
+struct meta_type< ::std::pair<first_type, second_type> >
+: detail::static_template_name<
+ meta_type< ::std::pair<first_type, second_type> > ,
+ mpl::vector2<first_type, second_type>,
+ BOOST_STR_LIT_LENGTH("pair")
+>
+{
+ typedef BOOST_MIRROR_REFLECT_NAMESPACE(_std) scope;
+ typedef ::std::pair<first_type, second_type> base_type;
+ static const bchar* template_name(void){return BOOST_STR_LIT("pair");}
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/libs/examples/special/std_pair.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/examples/special/std_pair.cpp 2008-04-24 12:52:52 EDT (Thu, 24 Apr 2008)
@@ -0,0 +1,43 @@
+/**
+ * \file examples/special/std_pair.cpp
+ *
+ * Example showing reflection of std::pairs
+ *
+ *
+ * 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)
+ */
+
+
+#include <boost/char_type_switch/string.hpp>
+#include <boost/char_type_switch/iostream.hpp>
+
+#include <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/meta_type.hpp>
+#include <boost/mirror/meta_class.hpp>
+
+#include <boost/mirror/utils/name_to_stream.hpp>
+
+#include <boost/mirror/meta_types/std_pair.hpp>
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ //
+ typedef ::std::pair<const int*, double [3]> T1;
+ typedef ::std::pair<float, const long&> T2;
+ typedef ::std::pair<T1 const volatile, T2 volatile const> T3;
+ typedef ::std::pair<T2, T1 volatile> T4;
+ typedef ::std::pair<T3 const * volatile, const T4&> T;
+ //
+ typedef BOOST_MIRROR_REFLECT_TYPE(T) meta_T;
+ bcout << "The type name length = " << meta_T::base_name_length << endl;
+ bcout << "The type name is: "<< meta_T::base_name() << 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