Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51345 - in sandbox/mirror/boost/mirror: . detail
From: chochlik_at_[hidden]
Date: 2009-02-20 05:04:28


Author: matus.chochlik
Date: 2009-02-20 05:04:27 EST (Fri, 20 Feb 2009)
New Revision: 51345
URL: http://svn.boost.org/trac/boost/changeset/51345

Log:
[mirror 0.3.x]
- some more bugfixes
Text files modified:
   sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp | 43 ++++++++++++++++++++++++++++++++++-----
   sandbox/mirror/boost/mirror/meta_class.hpp | 2
   2 files changed, 38 insertions(+), 7 deletions(-)

Modified: sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp 2009-02-20 05:04:27 EST (Fri, 20 Feb 2009)
@@ -40,15 +40,14 @@
 
 } // namespace detail
 
-/** Forward declaration of the meta_class_attributes<> template
- */
 template <class Class, class VariantTag = detail::default_meta_class_variant>
-struct meta_class_attributes;
+struct meta_class_attributes_base;
+
 
 /** Defaut (empty) list of base attributes of a meta class
  */
 template <class Class, class VariantTag>
-struct meta_class_attributes
+struct meta_class_attributes_base
 {
         typedef mpl::vector0<> type_list;
         typedef ::boost::mirror::meta_class<Class, VariantTag>
@@ -117,7 +116,7 @@
  * of the given class
  */
 #define BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(THE_CLASS) \
- template <> struct meta_class_attributes< \
+ template <> struct meta_class_attributes_base< \
                 THE_CLASS , \
                 detail::default_meta_class_variant \
> \
@@ -136,7 +135,7 @@
         TEMPL_ARG_COUNT \
 ) \
         template < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, typename T) > \
- struct meta_class_attributes< \
+ struct meta_class_attributes_base< \
                 THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) >, \
                 detail::default_meta_class_variant \
> \
@@ -541,6 +540,38 @@
                 BOOST_PP_EMPTY() \
         )
 
+/** Declaration of the meta_class_attributes<> template
+ */
+template <class Class, class VariantTag = detail::default_meta_class_variant>
+struct meta_class_attributes
+ : public meta_class_attributes_base<Class, VariantTag>
+{
+private:
+ typedef meta_class_attributes_base<Class, VariantTag> base_class;
+ static inline ptrdiff_t calculate_offset(
+ const unsigned char* base_ptr,
+ const unsigned char* attr_ptr
+ )
+ {
+ // we are unable to calculate the offset
+ if(attr_ptr == 0) return -1;
+ else return attr_ptr - base_ptr;
+ }
+public:
+ /** Gets the byte-offset of the I-th member
+ */
+ template <class Class, int I>
+ static inline ptrdiff_t offset(Class& instance, mpl::int_<I> pos)
+ {
+ return calculate_offset(
+ (const unsigned char*)&instance,
+ (const unsigned char*)base_class::address(instance, pos)
+ );
+ }
+};
+
+
+
 } // 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 2009-02-20 05:04:27 EST (Fri, 20 Feb 2009)
@@ -124,7 +124,7 @@
  * 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>;
+ friend struct ::boost::mirror::meta_class_attributes_base<CLASS_NAME>;
 
 
 


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