Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51954 - in sandbox/mirror: boost/mirror boost/mirror/detail boost/mirror/intrinsic libs/mirror/example
From: chochlik_at_[hidden]
Date: 2009-03-24 08:55:30


Author: matus.chochlik
Date: 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
New Revision: 51954
URL: http://svn.boost.org/trac/boost/changeset/51954

Log:
[mirror 0.3.x]
- major rewrite of class generators
- source cleanup
- minor update of meta-attribute traits
- added the by_name meta-function for meta-attributes
- added a second hello world example showing the by-name meta-function

Added:
   sandbox/mirror/boost/mirror/detail/meta_all_attribs_base.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/detail/meta_attrib_traits.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/intrinsic/by_name.hpp (contents, props changed)
   sandbox/mirror/libs/mirror/example/hello_world_2.cpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/detail/class_generators.hpp | 115 ++-
   sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp | 104 +--
   sandbox/mirror/boost/mirror/meta_attributes.hpp | 1094 +++++++--------------------------------
   sandbox/mirror/boost/mirror/meta_data_fwd.hpp | 15
   sandbox/mirror/libs/mirror/example/Jamfile.v2 | 1
   5 files changed, 331 insertions(+), 998 deletions(-)

Modified: sandbox/mirror/boost/mirror/detail/class_generators.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/class_generators.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/class_generators.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -11,96 +11,121 @@
 #ifndef BOOST_MIRROR_META_DETAIL_CLASS_GENERATOR_HPP
 #define BOOST_MIRROR_META_DETAIL_CLASS_GENERATOR_HPP
 
-#include <boost/mirror/detail/meta_attribs_outline.hpp>
-#include <boost/mirror/algorithm/size.hpp>
+#include <boost/mirror/intrinsic/size.hpp>
+#include <boost/typeof/typeof.hpp>
 
 namespace boost {
 namespace mirror {
 namespace detail {
 
-
 template <
- class MetaAttributes,
- template <class> class Model,
- class Position
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction,
+ class Position
>
 struct class_generator_unit
 {
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
- outline_holder,
- (MetaAttributes::get_outline_holder((Model<void>*)0, Position()))
- );
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ generator_plugin,
+ (MetaClassAttributes::template get_generator_plugin<
+ MetaClassAttributes,
+ MetaFunction
+ >(Position()))
+ );
+ typedef typename generator_plugin::type type;
 };
 
+
 template <
- class Class,
- template <class> class Model,
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction,
         class Position,
         class Size
->
-struct class_generator_base
+> struct class_generator_base
 : public class_generator_unit<
- meta_class_attributes<Class>, Model, Position
->::outline_holder::type
+ MetaClassAttributes,
+ MetaFunction,
+ Position
+>::type
 , public class_generator_base<
- Class, Model, mpl::int_<Position::value+1>, Size
+ MetaClassAttributes,
+ MetaFunction,
+ mpl::int_<Position::value + 1>,
+ Size
>
 {
         typedef typename class_generator_unit<
- meta_class_attributes<Class>, Model, Position
- >::outline_holder::type head;
+ MetaClassAttributes,
+ MetaFunction,
+ Position
+ >::type head;
 
         typedef class_generator_base<
- Class, Model, mpl::int_<Position::value+1>, Size
+ MetaClassAttributes,
+ MetaFunction,
+ mpl::int_<Position::value + 1>,
+ Size
> tail;
 
- class_generator_base(Model<void>& model)
- : head(model)
- , tail(model)
+ class_generator_base(void)
         { }
 
- class_generator_base(const Model<void>& model)
- : head(model)
- , tail(model)
+ template <class Param>
+ class_generator_base(Param& init)
+ : head(init)
+ , tail(init)
         { }
 };
 
 template <
- class Class,
- template <class> class Model,
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction,
         class Size
>
-struct class_generator_base<Class, Model, Size, Size>
+struct class_generator_base<
+ MetaClassAttributes,
+ MetaFunction,
+ Size,
+ Size
+>
 {
- class_generator_base(Model<void>& model){ }
- class_generator_base(const Model<void>& model){ }
+ class_generator_base(void){ }
+
+ template <class Param>
+ class_generator_base(Param&){ }
 };
 
 } // namespace detail
 
+/** Creates a class hierarchy based on the results
+ * of the GeneratorUnit meta-function, with the
+ * metaObjectSequence, individual meta-object
+ * Positions and the Data as parameters.
+ */
 template <
- class Class,
- template <class> class Model
->
-struct class_generator
-: detail::class_generator_base<
- Class,
- Model,
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction
+> struct class_generator
+ : detail::class_generator_base<
+ MetaClassAttributes,
+ MetaFunction,
         mpl::int_<0>,
- mpl::int_<mirror::size<meta_class_attributes<Class> >::value>
+ mpl::int_<mirror::size<MetaClassAttributes>::value>
>
 {
 private:
- Model<void> model;
         typedef detail::class_generator_base<
- Class,
- Model,
+ MetaClassAttributes,
+ MetaFunction,
                 mpl::int_<0>,
- mpl::int_<mirror::size<meta_class_attributes<Class> >::value>
+ mpl::int_<mirror::size<MetaClassAttributes>::value>
> base_generator;
 public:
- class_generator(void)
- : base_generator(model)
+ class_generator(void) { }
+
+ template <class Param>
+ class_generator(Param& init)
+ : base_generator(init)
         { }
 };
 

Added: sandbox/mirror/boost/mirror/detail/meta_all_attribs_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/meta_all_attribs_base.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -0,0 +1,761 @@
+/**
+ * \file boost/mirror/detail/meta_all_attribs_base.hpp
+ * Registering and reflection of class attributes
+ *
+ * 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_DETAIL_META_ALL_ATTRIBS_BASE_HPP
+#define BOOST_MIRROR_DETAIL_META_ALL_ATTRIBS_BASE_HPP
+
+#include <boost/mirror/access_spec.hpp>
+#include <boost/mirror/inherit_spec.hpp>
+// macros for declaration of simple meta attributes
+#include <boost/mirror/detail/meta_attribs_base.hpp>
+//
+#include <boost/char_type_switch/string.hpp>
+//
+#include <boost/typeof/typeof.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/remove_if.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/insert_range.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/contains.hpp>
+#include <boost/mpl/less.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+/* contains the basic inheritance information from
+ * a meta_inheritance.
+ */
+template <
+ class InheritanceSpecifier,
+ class MetaClass
+> struct base_class_inheritance_info
+{
+ typedef InheritanceSpecifier inheritance;
+ typedef MetaClass base_class;
+};
+
+
+/** This is basically the same as the "attributes" structure
+ * but allows to work with all member attributes including
+ * the inherited ones.
+ */
+template <
+ class ReflectedType,
+ class VariantTag
+>
+struct meta_class_all_attributes_base
+{
+ // the scope of the MetaAttributeSequence
+ typedef boost::mirror::meta_class<ReflectedType, VariantTag>
+ scope;
+
+ /** This struct "hides" the internal helpers. Anything inside
+ * is implementation detail and can change without any
+ * notice.
+ */
+ struct detail
+ {
+ /** Tells whether a base class is inherited virtually
+ */
+ template <class BaseInheritanceInfo>
+ struct is_inherited_virtually
+ : public is_same<
+ typename BaseInheritanceInfo::inheritance,
+ virtual_base_
+ >{ };
+
+ /* extracts the basic inheritance information from
+ * a meta_inheritance.
+ */
+ template <typename MetaInheritance>
+ struct get_base_info_from_meta_inheritance
+ {
+ typedef ::boost::mirror::detail::base_class_inheritance_info<
+ typename MetaInheritance::inheritance,
+ typename MetaInheritance::base_class
+ > type;
+ };
+
+ /** Accumulate the basic inheritance information
+ * about the base classes of this class
+ */
+ typedef typename mpl::accumulate<
+ typename scope::base_classes::list,
+ mpl::vector0<>,
+ mpl::push_back<
+ mpl::_1,
+ get_base_info_from_meta_inheritance<
+ mpl::_2
+ >
+ >
+ >::type list_of_base_class_infos;
+
+ /** The list of non-virtual base classes in the same
+ * order as they were registered.
+ */
+ typedef typename mpl::remove_if<
+ list_of_base_class_infos,
+ is_inherited_virtually<mpl::_1>
+ >::type list_of_regular_base_classes;
+
+ /** The list of directly inherited virtual base classes.
+ */
+ typedef typename mpl::remove_if<
+ list_of_base_class_infos,
+ mpl::not_<is_inherited_virtually<mpl::_1> >
+ >::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 MetaInheritance>
+ struct get_base_class_regular_layout
+ {
+ typedef MetaInheritance meta_inheritance;
+ typedef typename
+ meta_inheritance::
+ base_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 MetaInheritance>
+ struct get_base_class_virtual_layout
+ {
+ typedef MetaInheritance meta_inheritance;
+ typedef typename
+ meta_inheritance::
+ base_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 MetaInheritance>
+ struct get_base_class_layout
+ {
+ typedef MetaInheritance meta_inheritance;
+ typedef typename
+ meta_inheritance::
+ base_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<
+ list_of_base_class_infos,
+ mpl::vector0<>,
+ mpl::if_<
+ is_inherited_virtually<
+ 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 MetaInheritance>
+ struct get_base_class_attrib_type_list
+ {
+ typedef MetaInheritance meta_inheritance;
+ typedef typename meta_inheritance::
+ base_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 scope::attributes::type_list
+ >::type member_attrib_type_list;
+
+
+ /** This template gets the list of the owner classes
+ * for the inherited attributes.
+ */
+ template <class CurrentList, class MetaInheritance>
+ struct get_base_class_attrib_owner_and_offs
+ {
+ typedef CurrentList current_list;
+ typedef MetaInheritance meta_inheritance;
+
+ typedef typename meta_inheritance::
+ base_class base_class;
+
+ typedef typename base_class::
+ attributes::
+ type_list type_list;
+
+ typedef typename mpl::size<
+ current_list
+ >::type offset;
+ typedef typename mpl::pair<
+ base_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 template is used to query the return value
+ * type of the getter for the I-th member attribute
+ */
+ template <int I>
+ struct type_of_address
+ {
+ typedef typename mpl::at<
+ member_attrib_type_list,
+ mpl::int_<I>
+ >::type* type;
+ };
+
+ template <int I>
+ struct inherited_attrib_meta_class_and_pos
+ {
+ typedef typename mpl::at<
+ typename detail::inherited_attrib_owners_and_offsets,
+ mpl::int_<I>
+ >::type owner_and_offset;
+
+ typedef typename owner_and_offset::first ancestor;
+ typedef typename mpl::int_<mpl::minus<
+ mpl::int_<I>,
+ typename owner_and_offset::second
+ >::value> position;
+ };
+
+ template <int I>
+ struct own_attrib_meta_class_and_pos
+ {
+ 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, typename CharT>
+ static inline const ::std::basic_string<CharT>& get_name(
+ mpl::int_<I> pos,
+ mpl::false_ full_name,
+ ::std::char_traits<CharT> cht,
+ mpl::bool_<true> is_inherited
+ )
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor ancestor;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ return ancestor::attributes::get_name(
+ new_position(),
+ full_name,
+ cht
+ );
+ }
+
+ template <int I, typename CharT>
+ static inline const ::std::basic_string<CharT>& get_name(
+ mpl::int_<I> pos,
+ mpl::false_ full_name,
+ ::std::char_traits<CharT> cht,
+ mpl::bool_<false> is_inherited
+ )
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ return scope::attributes::get_name(
+ new_position(),
+ full_name,
+ cht
+ );
+ }
+
+
+ /** This function is used to point to the member attributes
+ * from the base classes.
+ */
+ template <class Class, int I>
+ static inline typename type_of_address<I>::type
+ address(Class& instance, mpl::int_<I> pos, mpl::bool_<true>)
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor ancestor;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ return ancestor::attributes::address(instance, new_position());
+
+ }
+ template <class Class, int I>
+ static inline typename type_of_address<I>::type
+ address(Class& instance, mpl::int_<I> pos, mpl::bool_<false>)
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_position;
+ return scope::attributes::address(instance, new_position());
+ }
+
+ /** This function is used to get the member attribute
+ * from the base classes.
+ */
+ template <class Class, int I>
+ static inline typename result_of_get<I>::type
+ get(const Class& instance, mpl::int_<I> pos, mpl::bool_<true>)
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor ancestor;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ return ancestor::attributes::get(instance, new_position());
+
+ }
+ template <class Class, int I>
+ static inline typename result_of_get<I>::type
+ get(const Class& instance, mpl::int_<I> pos, mpl::bool_<false>)
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_position;
+ return scope::attributes::get(instance, new_position());
+ }
+
+
+ /** This function is used to query the member attributes
+ * from the base classes.
+ */
+ template <class Class, int I, typename DestType>
+ static inline DestType&
+ query(Class instance, mpl::int_<I> pos, DestType& dest, mpl::bool_<true>)
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor ancestor;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ return ancestor::attributes::query(instance, new_position(), dest);
+
+ }
+
+ template <class Class, int I, typename DestType>
+ static inline DestType&
+ query(Class instance, mpl::int_<I> pos, DestType& dest, mpl::bool_<false>)
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_position;
+ return scope::attributes::query(instance, new_position(), dest);
+ }
+
+
+ /** This function is used to query the member attributes
+ * from the base classes.
+ */
+ template <class Class, int I, typename ValueType>
+ static inline void
+ set(Class& instance, mpl::int_<I> pos, ValueType value, mpl::bool_<true>)
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor ancestor;
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position new_position;
+
+ ancestor::attributes::set(instance, new_position(), value);
+ }
+
+ template <class Class, int I, typename ValueType>
+ static inline void
+ set(Class& instance, mpl::int_<I> pos, ValueType value, mpl::bool_<false>)
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position new_position;
+ scope::attributes::set(instance, new_position(), value);
+ }
+
+ template <int I>
+ struct inherited_attrib_meta_class
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::ancestor type;
+ };
+
+ struct own_attrib_meta_class
+ {
+ typedef scope type;
+ };
+
+ template <int I>
+ struct inherited_attrib_position
+ {
+ typedef typename inherited_attrib_meta_class_and_pos<I>
+ ::position type;
+ };
+
+ template <int I>
+ struct own_attrib_position
+ {
+ typedef typename own_attrib_meta_class_and_pos<I>
+ ::position type;
+ };
+
+ template <int I, class Inherited>
+ struct result_of_get_traits
+ {
+ // get the right meta-class
+ typedef typename mpl::eval_if<
+ Inherited,
+ inherited_attrib_meta_class<I>,
+ own_attrib_meta_class
+ >::type ancestor;
+
+ // get the position inside of the meta-class' attributes
+ typedef typename mpl::eval_if<
+ Inherited,
+ inherited_attrib_position<I>,
+ own_attrib_position<I>
+ >::type position;
+
+
+ // get the return value type of the get_traits function
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ detail,
+ ancestor::attributes::get_traits(position())
+ )
+
+ // the traits of the i-th attribute
+ typedef typename detail::type type;
+
+ }; // struct result_of_get_traits
+
+ template <
+ int I,
+ class Inherited,
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction
+ > struct result_of_get_generator_plugin
+ {
+ // get the right meta-class
+ typedef typename mpl::eval_if<
+ Inherited,
+ inherited_attrib_meta_class<I>,
+ own_attrib_meta_class
+ >::type ancestor;
+
+ // get the position inside of the meta-class' attributes
+ typedef typename mpl::eval_if<
+ Inherited,
+ inherited_attrib_position<I>,
+ own_attrib_position<I>
+ >::type position;
+
+
+ // get the return value type of the get_traits function
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ detail,
+ (ancestor::attributes::template get_generator_plugin<
+ MetaClassAttributes,
+ MetaFunction
+ >(position()))
+ )
+
+ // the traits of the i-th attribute
+ typedef typename detail::type type;
+
+ }; // struct result_of_get_meta_attrib_holder
+
+ }; // 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.
+ * WARNING: this is an implementation detail which
+ * can change without any notice.
+ */
+ typedef typename detail::member_attrib_type_list type_list;
+
+ /** The size of the type_list, i.e. the count of all attributes
+ * WARNING: this is an implementation detail which
+ * can change without any notice.
+ */
+ struct size : public mpl::size<type_list> { };
+
+private:
+ template <int I>
+ struct result_of_is_inherited
+ {
+ typedef typename mpl::less<
+ mpl::int_<I>,
+ inherited_size
+ >::type type;
+ };
+
+ /** Returns mpl::bool_<true> if the i-th attrib is inherited
+ * returns mpl::bool_<false> otherwise
+ */
+ template <int I>
+ static typename result_of_is_inherited<I>::type
+ is_inherited(mpl::int_<I>)
+ {
+ return typename result_of_is_inherited<I>::type();
+ }
+public:
+
+ /** Gets the name of the I-th member (including
+ * the inherited ones)
+ */
+ template <int I, typename CharT>
+ static inline const ::std::basic_string<CharT>& get_name(
+ mpl::int_<I> pos,
+ mpl::false_ full_name,
+ ::std::char_traits<CharT> cht
+ )
+ {
+ return detail::get_name(
+ pos,
+ full_name,
+ cht,
+ is_inherited(pos)
+ );
+ }
+
+ /** Gets the address of the I-th member (including
+ * the inherited ones)
+ */
+ template <class Class, int I>
+ static inline typename detail::template type_of_address<I>::type
+ address(Class& instance, mpl::int_<I> pos)
+ {
+ return detail::address(
+ instance,
+ pos,
+ is_inherited(pos)
+ );
+ }
+
+ /** Gets the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class Class, int I>
+ static inline typename detail::template result_of_get<I>::type
+ get(const Class& instance, mpl::int_<I> pos)
+ {
+ return detail::get(
+ instance,
+ pos,
+ is_inherited(pos)
+ );
+ }
+
+ /** Queries the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class Class, int I, typename DestType>
+ static inline DestType&
+ query(Class instance, mpl::int_<I> pos, DestType& dest)
+ {
+ return detail::query(
+ instance,
+ pos,
+ dest,
+ is_inherited(pos)
+ );
+ }
+
+ /** Sets the value of the I-th member (including
+ * the inherited ones)
+ */
+ template <class Class, int I, typename ValueType>
+ static inline void
+ set(Class& instance, mpl::int_<I> pos, ValueType value)
+ {
+ detail::set(
+ instance,
+ pos,
+ value,
+ is_inherited(pos)
+ );
+ }
+
+ /** The attribute traits getter
+ */
+ template <int I>
+ static typename detail:: template result_of_get_traits<
+ I,
+ typename result_of_is_inherited<I>::type
+ >::type get_traits(mpl::int_<I>);
+
+ /** The meta-attribute generator plugin getter
+ */
+ template <
+ class MetaClassAttributes,
+ template <class, class, class, class> class MetaFunction,
+ int I
+ > static typename detail:: template result_of_get_generator_plugin<
+ I,
+ typename result_of_is_inherited<I>::type,
+ MetaClassAttributes,
+ MetaFunction
+ >::type get_generator_plugin(mpl::int_<I>);
+
+}; // all_attributes_base
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/detail/meta_attrib_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/meta_attrib_traits.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -0,0 +1,80 @@
+/**
+ * \file boost/mirror/detail/meta_attrib_traits.hpp
+ *
+ * Additional traits of meta-attributes
+ *
+ * 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_DETAIL_META_ATTRIB_TRAITS_HPP
+#define BOOST_MIRROR_DETAIL_META_ATTRIB_TRAITS_HPP
+
+namespace boost {
+namespace mirror {
+
+/** Possible class attribute storage specifiers
+ */
+namespace attrib_storage_specifiers {
+ // static class attribute
+ struct static_ { };
+ // mutable class attribute
+ struct mutable_ { };
+ // regular class attribure
+ struct __ { };
+}
+
+/** Additional attribute traits containing information
+ * about storage class specifiers and some information
+ * about the type of the attribute
+ */
+template <
+ class Specifiers,
+ class TypeOrTypedefSelector
+> struct meta_class_attribute_traits;
+
+/** Specialization for non-static, non-mutable members
+ */
+template <class TypeOrTypedefSelector>
+struct meta_class_attribute_traits<
+ attrib_storage_specifiers::__,
+ TypeOrTypedefSelector
+>
+{
+ typedef mpl::false_ is_static;
+ typedef mpl::false_ is_mutable;
+ typedef TypeOrTypedefSelector meta_type_selector;
+};
+
+/** Specialization for static member attribs
+ */
+template <class TypeOrTypedefSelector>
+struct meta_class_attribute_traits<
+ attrib_storage_specifiers::static_,
+ TypeOrTypedefSelector
+>
+{
+ typedef mpl::true_ is_static;
+ typedef mpl::false_ is_mutable;
+ typedef TypeOrTypedefSelector meta_type_selector;
+};
+
+/** Specialization for mutable member attribs
+ */
+template <class TypeOrTypedefSelector>
+struct meta_class_attribute_traits<
+ attrib_storage_specifiers::mutable_,
+ TypeOrTypedefSelector
+>
+{
+ typedef mpl::false_ is_static;
+ typedef mpl::true_ is_mutable;
+ typedef TypeOrTypedefSelector meta_type_selector;
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

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-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -15,6 +15,7 @@
 // forward declarations
 #include <boost/mirror/meta_data_fwd.hpp>
 // class generation related
+#include <boost/mirror/detail/meta_attrib_traits.hpp>
 #include <boost/mirror/detail/meta_attribs_outline.hpp>
 //
 #include <boost/preprocessor/repetition/enum_params.hpp>
@@ -32,7 +33,6 @@
 
 namespace boost {
 namespace mirror {
-
 namespace detail {
 
 /** Allows to detect the type of the member attribute.
@@ -61,64 +61,6 @@
                 scope;
 };
 
-/** Possible class attribute storage specifiers
- */
-namespace attrib_storage_specifiers {
- // static class attribute
- struct static_ { };
- // mutable class attribute
- struct mutable_ { };
- // regular class attribure
- struct __ { };
-}
-
-/** Additional attribute traits containing information
- * about storage class specifiers and some information
- * about the type of the attribute
- */
-template <class Specifiers, class TypeOrTypedefSelector>
-struct meta_class_attribute_traits;
-
-/** Specialization for non-static, non-mutable members
- */
-template <class TypeOrTypedefSelector>
-struct meta_class_attribute_traits<
- attrib_storage_specifiers::__,
- TypeOrTypedefSelector
->
-{
- typedef mpl::false_ is_static;
- typedef mpl::false_ is_mutable;
- typedef TypeOrTypedefSelector meta_type_selector;
-};
-
-/** Specialization for static member attribs
- */
-template <class TypeOrTypedefSelector>
-struct meta_class_attribute_traits<
- attrib_storage_specifiers::static_,
- TypeOrTypedefSelector
->
-{
- typedef mpl::true_ is_static;
- typedef mpl::false_ is_mutable;
- typedef TypeOrTypedefSelector meta_type_selector;
-};
-
-/** Specialization for mutable member attribs
- */
-template <class TypeOrTypedefSelector>
-struct meta_class_attribute_traits<
- attrib_storage_specifiers::mutable_,
- TypeOrTypedefSelector
->
-{
- typedef mpl::false_ is_static;
- typedef mpl::true_ is_mutable;
- typedef TypeOrTypedefSelector meta_type_selector;
-};
-
-
 /** This macro starts the declaration of member attributes
  * of the given class
  */
@@ -200,6 +142,34 @@
                 TYPE_SELECTOR \
> get_traits(position_of_##NAME);
 
+/**
+ */
+#define BOOST_MIRROR_REG_META_CLASS_ATTRIB_HOLDER(NAME) \
+ template < \
+ class MetaClassAttributes, \
+ template <class, class, class, class> \
+ class MetaFunction \
+ > \
+ struct NAME##_generator_plugin \
+ { \
+ typedef typename MetaFunction< \
+ Class, \
+ variant_tag, \
+ MetaClassAttributes, \
+ position_of_##NAME \
+ >::type NAME; \
+ }; \
+ template < \
+ class MetaClassAttributes, \
+ template <class, class, class, class> \
+ class MetaFunction \
+ > \
+ static NAME##_generator_plugin< \
+ MetaClassAttributes, \
+ MetaFunction \
+ > get_generator_plugin(position_of_##NAME);
+
+
 /** Helper macro expanding into an epilogue of a meta-attribute
  * declaration
  */
@@ -207,10 +177,12 @@
         TYPE_SELECTOR, \
         NAME, \
         TYPENAME_KW \
-) typedef TYPENAME_KW mpl::push_back< \
- partial_list_##NAME, \
- type_of_##NAME \
->::type
+) \
+ BOOST_MIRROR_REG_META_CLASS_ATTRIB_HOLDER(NAME) \
+ typedef TYPENAME_KW mpl::push_back< \
+ partial_list_##NAME, \
+ type_of_##NAME \
+ >::type
 
 /** Helper macro expanding into the declaraion of getter
  * function of the meta-attribute
@@ -529,7 +501,7 @@
                 TYPE_SELECTOR, \
                 NAME, \
                 TYPENAME_KW \
- ) \
+ )
 
 
 #define BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB_OUTLINE( \
@@ -663,11 +635,12 @@
         }
 };
 
+
 } // namespace detail
 
 /** Declaration of the meta_class_attributes<> template
  */
-template <class Class, class VariantTag = detail::default_meta_class_variant>
+template <class Class, class VariantTag>
 struct meta_class_attributes
  : public detail::meta_class_attributes_offset_calculator<
         Class,
@@ -681,6 +654,7 @@
> offs_calc;
         typedef typename offs_calc::byte byte;
         typedef typename offs_calc::byte_ptr byte_ptr;
+
 public:
         template <int I>
         static inline ptrdiff_t offset_of(mpl::int_<I> pos)

Added: sandbox/mirror/boost/mirror/intrinsic/by_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/intrinsic/by_name.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -0,0 +1,57 @@
+/**
+ * \file boost/mirror/intrinsic/empty.hpp
+ * Gets count of meta-attributes/meta-inheritences/etc.
+ *
+ * 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_INTRINSIC_BY_NAME_HPP
+#define BOOST_MIRROR_INTRINSIC_BY_NAME_HPP
+
+#include <boost/mirror/meta_attributes.hpp>
+#include <boost/mirror/detail/class_generators.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+/** A class generator unit which "returns" the result type of the
+ * get_meta_attrib_holder function on the MetaClassAttributes.
+ */
+template <
+ class Class,
+ class VariantTag,
+ class MetaClassAttributes,
+ class Position
+>
+struct get_meta_attrib_generator_plugin
+{
+ typedef meta_class_attribute<
+ Class,
+ VariantTag,
+ MetaClassAttributes,
+ Position
+ > type;
+};
+
+
+template <class MetaClassAttributes>
+struct attrib_by_name : public class_generator<
+ MetaClassAttributes,
+ get_meta_attrib_generator_plugin
+> { };
+
+
+} // namespace detail
+
+template <class MetaObjectSequence>
+struct by_name : detail::attrib_by_name<MetaObjectSequence>
+{ };
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/meta_attributes.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_attributes.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_attributes.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -10,908 +10,226 @@
 #ifndef BOOST_MIRROR_META_ATTRIBUTES_HPP
 #define BOOST_MIRROR_META_ATTRIBUTES_HPP
 
-#include <boost/mirror/access_spec.hpp>
-#include <boost/mirror/inherit_spec.hpp>
 // macros for declaration of simple meta attributes
 #include <boost/mirror/detail/meta_attribs_base.hpp>
-//
-#include <boost/char_type_switch/string.hpp>
-//
-#include <boost/typeof/typeof.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/remove_if.hpp>
-#include <boost/mpl/push_back.hpp>
-#include <boost/mpl/insert_range.hpp>
-#include <boost/mpl/accumulate.hpp>
-#include <boost/mpl/contains.hpp>
-#include <boost/mpl/less.hpp>
+#include <boost/mirror/detail/meta_all_attribs_base.hpp>
 
 namespace boost {
 namespace mirror {
 
-namespace detail {
- /* contains the basic inheritance information from
- * a meta_inheritance.
- */
- template <
- class InheritanceSpecifier,
- class MetaClass
- > struct base_class_inheritance_info
+template < class Class, class VariantTag >
+struct meta_class_all_attributes
+ : public detail::meta_class_attributes_offset_calculator<
+ Class,
+ detail::meta_class_all_attributes_base<Class, VariantTag>
+>
+{
+private:
+ typedef ::boost::mirror::detail::meta_class_attributes_offset_calculator<
+ Class,
+ detail::meta_class_all_attributes_base<
+ Class,
+ VariantTag
+ >
+ > offs_calc;
+
+public:
+ template <int I>
+ static inline ptrdiff_t offset_of(mpl::int_<I> pos)
         {
- typedef InheritanceSpecifier inheritance;
- typedef MetaClass base_class;
+ return offs_calc::get_offset_of(pos, (Class*)0);
+ }
+
+};
+
+/** Instances of this template are used to store information
+ * about single class' member attribute and are used mainly
+ * in the algorithms.
+ */
+template <
+ class ReflectedType,
+ class VariantTag,
+ class MetaAttributes,
+ class AttribPos
+>
+struct meta_class_attribute
+{
+public:
+ // the meta-class for the class to which
+ // the attribute belongs
+ // this is actually the scope of the meta-attribute
+ typedef ::boost::mirror::meta_class<ReflectedType, VariantTag>
+ scope;
+private:
+ struct result_of_get
+ {
+ typedef typename mpl::at<
+ typename MetaAttributes::type_list,
+ AttribPos
+ >::type type;
         };
+ typedef typename scope::reflected_type
+ owner_class;
 
-} // namespace detail
+ inline static const char* get_double_colon(::std::char_traits<char>)
+ {
+ return "::";
+ }
 
- /** This is basically the same as the "attributes" structure
- * but allows to work with all member attributes including
- * the inherited ones.
- */
- template <
- class ReflectedType,
- class VariantTag
- >
- struct meta_class_all_attributes_base
- {
- // the scope of the MetaAttributeSequence
- typedef boost::mirror::meta_class<ReflectedType, VariantTag>
- scope;
-
- /** This struct "hides" the internal helpers. Anything inside
- * is implementation detail and can change without any
- * notice.
- */
- struct detail
- {
- /** Tells whether a base class is inherited virtually
- */
- template <class BaseInheritanceInfo>
- struct is_inherited_virtually
- : public is_same<
- typename BaseInheritanceInfo::inheritance,
- virtual_base_
- >{ };
-
- /* extracts the basic inheritance information from
- * a meta_inheritance.
- */
- template <typename MetaInheritance>
- struct get_base_info_from_meta_inheritance
- {
- typedef ::boost::mirror::detail::base_class_inheritance_info<
- typename MetaInheritance::inheritance,
- typename MetaInheritance::base_class
- > type;
- };
-
- /** Accumulate the basic inheritance information
- * about the base classes of this class
- */
- typedef typename mpl::accumulate<
- typename scope::base_classes::list,
- mpl::vector0<>,
- mpl::push_back<
- mpl::_1,
- get_base_info_from_meta_inheritance<
- mpl::_2
- >
- >
- >::type list_of_base_class_infos;
-
- /** The list of non-virtual base classes in the same
- * order as they were registered.
- */
- typedef typename mpl::remove_if<
- list_of_base_class_infos,
- is_inherited_virtually<mpl::_1>
- >::type list_of_regular_base_classes;
-
- /** The list of directly inherited virtual base classes.
- */
- typedef typename mpl::remove_if<
- list_of_base_class_infos,
- mpl::not_<is_inherited_virtually<mpl::_1> >
- >::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 MetaInheritance>
- struct get_base_class_regular_layout
- {
- typedef MetaInheritance meta_inheritance;
- typedef typename
- meta_inheritance::
- base_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 MetaInheritance>
- struct get_base_class_virtual_layout
- {
- typedef MetaInheritance meta_inheritance;
- typedef typename
- meta_inheritance::
- base_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 MetaInheritance>
- struct get_base_class_layout
- {
- typedef MetaInheritance meta_inheritance;
- typedef typename
- meta_inheritance::
- base_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<
- list_of_base_class_infos,
- mpl::vector0<>,
- mpl::if_<
- is_inherited_virtually<
- 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 MetaInheritance>
- struct get_base_class_attrib_type_list
- {
- typedef MetaInheritance meta_inheritance;
- typedef typename meta_inheritance::
- base_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 scope::attributes::type_list
- >::type member_attrib_type_list;
-
-
- /** This template gets the list of the owner classes
- * for the inherited attributes.
- */
- template <class CurrentList, class MetaInheritance>
- struct get_base_class_attrib_owner_and_offs
- {
- typedef CurrentList current_list;
- typedef MetaInheritance meta_inheritance;
-
- typedef typename meta_inheritance::
- base_class base_class;
-
- typedef typename base_class::
- attributes::
- type_list type_list;
-
- typedef typename mpl::size<
- current_list
- >::type offset;
- typedef typename mpl::pair<
- base_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 template is used to query the return value
- * type of the getter for the I-th member attribute
- */
- template <int I>
- struct type_of_address
- {
- typedef typename mpl::at<
- member_attrib_type_list,
- mpl::int_<I>
- >::type* type;
- };
-
- template <int I>
- struct inherited_attrib_meta_class_and_pos
- {
- typedef typename mpl::at<
- typename detail::inherited_attrib_owners_and_offsets,
- mpl::int_<I>
- >::type owner_and_offset;
-
- typedef typename owner_and_offset::first ancestor;
- typedef typename mpl::int_<mpl::minus<
- mpl::int_<I>,
- typename owner_and_offset::second
- >::value> position;
- };
-
- template <int I>
- struct own_attrib_meta_class_and_pos
- {
- 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, typename CharT>
- static inline const ::std::basic_string<CharT>& get_name(
- mpl::int_<I> pos,
- mpl::false_ full_name,
- ::std::char_traits<CharT> cht,
- mpl::bool_<true> is_inherited
- )
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor ancestor;
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- return ancestor::attributes::get_name(
- new_position(),
- full_name,
- cht
- );
- }
-
- template <int I, typename CharT>
- static inline const ::std::basic_string<CharT>& get_name(
- mpl::int_<I> pos,
- mpl::false_ full_name,
- ::std::char_traits<CharT> cht,
- mpl::bool_<false> is_inherited
- )
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- return scope::attributes::get_name(
- new_position(),
- full_name,
- cht
- );
- }
-
-
- /** This function is used to point to the member attributes
- * from the base classes.
- */
- template <class Class, int I>
- static inline typename type_of_address<I>::type
- address(Class& instance, mpl::int_<I> pos, mpl::bool_<true>)
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor ancestor;
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- return ancestor::attributes::address(instance, new_position());
-
- }
- template <class Class, int I>
- static inline typename type_of_address<I>::type
- address(Class& instance, mpl::int_<I> pos, mpl::bool_<false>)
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position new_position;
- return scope::attributes::address(instance, new_position());
- }
-
- /** This function is used to get the member attribute
- * from the base classes.
- */
- template <class Class, int I>
- static inline typename result_of_get<I>::type
- get(const Class& instance, mpl::int_<I> pos, mpl::bool_<true>)
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor ancestor;
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- return ancestor::attributes::get(instance, new_position());
-
- }
- template <class Class, int I>
- static inline typename result_of_get<I>::type
- get(const Class& instance, mpl::int_<I> pos, mpl::bool_<false>)
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position new_position;
- return scope::attributes::get(instance, new_position());
- }
-
-
- /** This function is used to query the member attributes
- * from the base classes.
- */
- template <class Class, int I, typename DestType>
- static inline DestType&
- query(Class instance, mpl::int_<I> pos, DestType& dest, mpl::bool_<true>)
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor ancestor;
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- return ancestor::attributes::query(instance, new_position(), dest);
-
- }
-
- template <class Class, int I, typename DestType>
- static inline DestType&
- query(Class instance, mpl::int_<I> pos, DestType& dest, mpl::bool_<false>)
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position new_position;
- return scope::attributes::query(instance, new_position(), dest);
- }
-
-
- /** This function is used to query the member attributes
- * from the base classes.
- */
- template <class Class, int I, typename ValueType>
- static inline void
- set(Class& instance, mpl::int_<I> pos, ValueType value, mpl::bool_<true>)
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor ancestor;
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position new_position;
-
- ancestor::attributes::set(instance, new_position(), value);
- }
-
- template <class Class, int I, typename ValueType>
- static inline void
- set(Class& instance, mpl::int_<I> pos, ValueType value, mpl::bool_<false>)
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position new_position;
- scope::attributes::set(instance, new_position(), value);
- }
-
- template <int I>
- struct inherited_attrib_meta_class
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::ancestor type;
- };
-
- struct own_attrib_meta_class
- {
- typedef scope type;
- };
-
- template <int I>
- struct inherited_attrib_position
- {
- typedef typename inherited_attrib_meta_class_and_pos<I>
- ::position type;
- };
-
- template <int I>
- struct own_attrib_position
- {
- typedef typename own_attrib_meta_class_and_pos<I>
- ::position type;
- };
-
- template <int I, class Inherited>
- struct result_of_get_traits
- {
- // get the right meta-class
- typedef typename mpl::eval_if<
- Inherited,
- inherited_attrib_meta_class<I>,
- own_attrib_meta_class
- >::type ancestor;
-
- // get the position inside of the meta-class' attributes
- typedef typename mpl::eval_if<
- Inherited,
- inherited_attrib_position<I>,
- own_attrib_position<I>
- >::type position;
-
-
- // get the return value type of the get_traits function
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
- detail,
- ancestor::attributes::get_traits(position())
- )
-
- // the traits of the i-th attribute
- typedef typename detail::type type;
-
- }; // struct result_of_get_traits
-
- }; // 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.
- * WARNING: this is an implementation detail which
- * can change without any notice.
- */
- typedef typename detail::member_attrib_type_list type_list;
-
- /** The size of the type_list, i.e. the count of all attributes
- * WARNING: this is an implementation detail which
- * can change without any notice.
- */
- struct size : public mpl::size<type_list> { };
-
- private:
- template <int I>
- struct result_of_is_inherited
- {
- typedef typename mpl::less<
- mpl::int_<I>,
- inherited_size
- >::type type;
- };
-
- /** Returns mpl::bool_<true> if the i-th attrib is inherited
- * returns mpl::bool_<false> otherwise
- */
- template <int I>
- static typename result_of_is_inherited<I>::type
- is_inherited(mpl::int_<I>)
- {
- return typename result_of_is_inherited<I>::type();
- }
- public:
-
- /** Gets the name of the I-th member (including
- * the inherited ones)
- */
- template <int I, typename CharT>
- static inline const ::std::basic_string<CharT>& get_name(
- mpl::int_<I> pos,
- mpl::false_ full_name,
- ::std::char_traits<CharT> cht
- )
- {
- return detail::get_name(
- pos,
- full_name,
- cht,
- is_inherited(pos)
- );
- }
-
- /** Gets the address of the I-th member (including
- * the inherited ones)
- */
- template <class Class, int I>
- static inline typename detail::template type_of_address<I>::type
- address(Class& instance, mpl::int_<I> pos)
- {
- return detail::address(
- instance,
- pos,
- is_inherited(pos)
- );
- }
-
- /** Gets the value of the I-th member (including
- * the inherited ones)
- */
- template <class Class, int I>
- static inline typename detail::template result_of_get<I>::type
- get(const Class& instance, mpl::int_<I> pos)
- {
- return detail::get(
- instance,
- pos,
- is_inherited(pos)
- );
- }
-
- /** Queries the value of the I-th member (including
- * the inherited ones)
- */
- template <class Class, int I, typename DestType>
- static inline DestType&
- query(Class instance, mpl::int_<I> pos, DestType& dest)
- {
- return detail::query(
- instance,
- pos,
- dest,
- is_inherited(pos)
- );
- }
-
- /** Sets the value of the I-th member (including
- * the inherited ones)
- */
- template <class Class, int I, typename ValueType>
- static inline void
- set(Class& instance, mpl::int_<I> pos, ValueType value)
- {
- detail::set(
- instance,
- pos,
- value,
- is_inherited(pos)
- );
- }
-
- /** The attribute traits getter
- */
- template <int I>
- static typename detail:: template result_of_get_traits<
- I,
- typename result_of_is_inherited<I>::type
- >::type get_traits(mpl::int_<I>);
-
- }; // all_attributes_base
-
- template < class Class, class VariantTag >
- struct meta_class_all_attributes
- : public detail::meta_class_attributes_offset_calculator<
- Class,
- meta_class_all_attributes_base<Class, VariantTag>
- >
- {
- private:
- typedef ::boost::mirror::detail::meta_class_attributes_offset_calculator<
- Class,
- meta_class_all_attributes_base<Class, VariantTag>
- > offs_calc;
- public:
- template <int I>
- static inline ptrdiff_t offset_of(mpl::int_<I> pos)
- {
- return offs_calc::get_offset_of(pos, (Class*)0);
- }
+ inline static const wchar_t* get_double_colon(::std::char_traits<wchar_t>)
+ {
+ return L"::";
+ }
 
- };
+ template <typename CharT>
+ inline static ::std::basic_string<CharT> init_full_name(
+ ::std::char_traits<CharT> cht
+ )
+ {
+ typedef ::std::basic_string<CharT> str_type;
+ str_type name(scope::get_name(mpl::true_(), cht));
+ name.append(str_type(get_double_colon(cht)));
+ name.append(base_name());
+ return name;
+ }
+
+public:
+
+ // the meta-attributes list (own/all)
+ // into which the attribute belongs
+ // in this instance
+ typedef MetaAttributes container;
+ typedef MetaAttributes meta_attributes;
+ // the position of the meta-attribute
+ typedef AttribPos position;
+private:
+ // use type::reflected_type to get the type
+ // of the attribute
+ typedef typename mpl::at<
+ typename MetaAttributes::type_list,
+ position
+ >::type attribute_type;
+public:
+
+
+ template <typename CharT>
+ inline static const ::std::basic_string<CharT>& get_name(
+ mpl::false_ full_name,
+ ::std::char_traits<CharT> cht
+ )
+ {
+ return meta_attributes::get_name(
+ position(),
+ full_name,
+ cht
+ );
+ }
+
+ // base name getter
+ inline static const cts::bstring& base_name(void)
+ {
+ return get_name(
+ mpl::false_(),
+ cts::bchar_traits()
+ );
+ }
+
+ template <typename CharT>
+ inline static const ::std::basic_string<CharT>& get_name(
+ mpl::true_ full_name,
+ ::std::char_traits<CharT> cht
+ )
+ {
+ typedef ::std::basic_string<CharT> str_type;
+ static str_type name(init_full_name(cht));
+ return name;
+ }
+
+ // full name getter
+ inline static const cts::bstring& full_name(void)
+ {
+ return get_name(
+ mpl::true_(),
+ cts::bchar_traits()
+ );
+ }
 
- /** Instances of this template are used to store information
- * about single class' member attribute and are used mainly
- * in the algorithms.
+ // address getter
+ inline static attribute_type* address(owner_class& instance)
+ {
+ return meta_attributes::address(instance, position());
+ }
+
+ // offset getter
+ inline static ptrdiff_t offset(owner_class& instance)
+ {
+ return meta_attributes::offset(instance, position());
+ }
+
+ // offset getter
+ inline static ptrdiff_t offset_of(void)
+ {
+ return meta_attributes::offset_of(position());
+ }
+
+ // value getter
+ inline static typename result_of_get::type get(
+ const owner_class& instance
+ )
+ {
+ return meta_attributes::get(instance, position());
+ }
+
+ // value query
+ template <typename DestType>
+ inline static DestType& query(
+ const owner_class& instance,
+ DestType& dest
+ )
+ {
+ return meta_attributes::query(instance, position(), dest);
+ }
+
+ // value setter
+ inline static void set(
+ owner_class& instance,
+ typename call_traits<attribute_type>::param_type val
+ )
+ {
+ meta_attributes::set(instance, position(), val);
+ }
+
+ // value setter
+ inline static void set(
+ const owner_class& instance,
+ typename call_traits<attribute_type>::param_type val
+ )
+ {
+ meta_attributes::set(instance, position(), val);
+ }
+
+private:
+ // attribute traits
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ detail_traits,
+ meta_attributes::get_traits(position())
+ )
+public:
+ typedef typename detail_traits::type traits;
+private:
+ // mirror type selector
+ typedef typename traits::meta_type_selector
+ typedef_or_type;
+public:
+ /** the meta_class/meta_type reflecting
+ * the type of the attribute.
          */
- template <
- class ReflectedType,
- class VariantTag,
- class MetaAttributes,
- class AttribPos
- >
- struct meta_class_attribute
- {
- public:
- // the meta-class for the class to which
- // the attribute belongs
- // this is actually the scope of the meta-attribute
- typedef ::boost::mirror::meta_class<ReflectedType, VariantTag>
- scope;
- private:
- struct result_of_get
- {
- typedef typename mpl::at<
- typename MetaAttributes::type_list,
- AttribPos
- >::type type;
- };
- typedef typename scope::reflected_type
- owner_class;
-
- inline static const char* get_double_colon(::std::char_traits<char>)
- {
- return "::";
- }
- inline static const wchar_t* get_double_colon(::std::char_traits<wchar_t>)
- {
- return L"::";
- }
- template <typename CharT>
- inline static ::std::basic_string<CharT> init_full_name(
- ::std::char_traits<CharT> cht
- )
- {
- typedef ::std::basic_string<CharT> str_type;
- str_type name(scope::get_name(mpl::true_(), cht));
- name.append(str_type(get_double_colon(cht)));
- name.append(base_name());
- return name;
- }
-
- public:
-
- // the meta-attributes list (own/all)
- // into which the attribute belongs
- // in this instance
- typedef MetaAttributes container;
- typedef MetaAttributes meta_attributes;
- // the position of the meta-attribute
- typedef AttribPos position;
- private:
- // use type::reflected_type to get the type
- // of the attribute
- typedef typename mpl::at<
- typename MetaAttributes::type_list,
- position
- >::type attribute_type;
- public:
-
-
- template <typename CharT>
- inline static const ::std::basic_string<CharT>& get_name(
- mpl::false_ full_name,
- ::std::char_traits<CharT> cht
- )
- {
- return meta_attributes::get_name(
- position(),
- full_name,
- cht
- );
- }
-
- // base name getter
- inline static const cts::bstring& base_name(void)
- {
- return get_name(
- mpl::false_(),
- cts::bchar_traits()
- );
- }
-
- template <typename CharT>
- inline static const ::std::basic_string<CharT>& get_name(
- mpl::true_ full_name,
- ::std::char_traits<CharT> cht
- )
- {
- typedef ::std::basic_string<CharT> str_type;
- static str_type name(init_full_name(cht));
- return name;
- }
-
- // full name getter
- inline static const cts::bstring& full_name(void)
- {
- return get_name(
- mpl::true_(),
- cts::bchar_traits()
- );
- }
-
- // address getter
- inline static attribute_type* address(owner_class& instance)
- {
- return meta_attributes::address(instance, position());
- }
-
- // offset getter
- inline static ptrdiff_t offset(owner_class& instance)
- {
- return meta_attributes::offset(instance, position());
- }
-
- // offset getter
- inline static ptrdiff_t offset_of(void)
- {
- return meta_attributes::offset_of(position());
- }
-
- // value getter
- inline static typename result_of_get::type get(
- const owner_class& instance
- )
- {
- return meta_attributes::get(instance, position());
- }
-
- // value query
- template <typename DestType>
- inline static DestType& query(
- const owner_class& instance,
- DestType& dest
- )
- {
- return meta_attributes::query(instance, position(), dest);
- }
-
- // value setter
- inline static void set(
- owner_class& instance,
- typename call_traits<attribute_type>::param_type val
- )
- {
- meta_attributes::set(instance, position(), val);
- }
-
- // value setter
- inline static void set(
- const owner_class& instance,
- typename call_traits<attribute_type>::param_type val
- )
- {
- meta_attributes::set(instance, position(), val);
- }
-
- private:
- // attribute traits
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
- detail_traits,
- meta_attributes::get_traits(position())
- )
- public:
- typedef typename detail_traits::type traits;
- private:
- // mirror type selector
- typedef typename traits::meta_type_selector
- typedef_or_type;
- public:
- /** the meta_class/meta_type reflecting
- * the type of the attribute.
- */
- // TODO: this need to be fixed to work with the selector
- //typedef BOOST_MIRRORED_CLASS(typedef_or_type)
- typedef BOOST_MIRRORED_CLASS(attribute_type)
- type;
+ // TODO: this need to be fixed to work with the selector
+ //typedef BOOST_MIRRORED_CLASS(typedef_or_type)
+ typedef BOOST_MIRRORED_CLASS(attribute_type)
+ type;
 
- };
+};
 
 
 } // namespace mirror

Modified: sandbox/mirror/boost/mirror/meta_data_fwd.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_data_fwd.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_data_fwd.hpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -156,6 +156,21 @@
 #define BOOST_MIRRORED_CONSTRUCTORS(TYPE)\
         meta_constructors< TYPE >
 
+template <
+ class ReflectedType,
+ class VariantTag,
+ class MetaAttributes,
+ class AttribPos
+> struct meta_class_attribute;
+
+template <
+ class Class,
+ class VariantTag = detail::default_meta_class_variant
+> struct meta_class_attributes;
+
+template < class Class, class VariantTag>
+struct meta_class_all_attributes;
+
 
 } // namespace mirror
 } // namespace boost

Modified: sandbox/mirror/libs/mirror/example/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/example/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/example/Jamfile.v2 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -17,6 +17,7 @@
 # basics
 #
 exe hello_world : hello_world.cpp ;
+exe hello_world_2 : hello_world_2.cpp ;
 #
 # registering
 #

Added: sandbox/mirror/libs/mirror/example/hello_world_2.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/example/hello_world_2.cpp 2009-03-24 08:55:28 EDT (Tue, 24 Mar 2009)
@@ -0,0 +1,72 @@
+/**
+ * \file examples/hello_world_2.cpp
+ *
+ * Simple yet not very useful hello world example.
+ * Shows the basics of namespace and type registration and reflection
+ *
+ * NOTE: if You are not familiar with registration
+ * and reflection, You should probably
+ * see examples in examples/registering/ first.
+ *
+ * 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/iostream.hpp>
+#include <boost/mirror/meta_class.hpp>
+#include <boost/mirror/intrinsic/by_name.hpp>
+#include <boost/mirror/intrinsic/at.hpp>
+
+struct Greeting
+{
+ int Hello;
+ int World;
+};
+
+namespace boost {
+namespace mirror {
+
+/** Register the ::Greeting class and it's member
+ * attributes.
+ */
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(Greeting)
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::Greeting)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, Hello)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, World)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+} // namespace mirror
+} // namespace boost
+
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ //
+ typedef BOOST_MIRRORED_CLASS(::Greeting) meta_Greeting;
+ //
+ // cts::bcout() returns a reference to ::std::cout
+ // or ::std::wcout based on the used character type
+ //
+ cts::bcout() <<
+ by_name<meta_Greeting::all_attributes>::Hello::base_name() <<
+ BOOST_CTS_LIT(", ") <<
+ by_name<meta_Greeting::all_attributes>::World::base_name() <<
+ BOOST_CTS_LIT(".") <<
+ endl;
+ //
+ cts::bcout() <<
+ at<meta_Greeting::attributes, mpl::int_<0> >::type::base_name() <<
+ BOOST_CTS_LIT(", ") <<
+ at<meta_Greeting::attributes, mpl::int_<1> >::type::base_name() <<
+ BOOST_CTS_LIT(".") <<
+ 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