|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50272 - in sandbox/mirror: boost/mirror boost/mirror/detail libs/mirror/test
From: chochlik_at_[hidden]
Date: 2008-12-14 14:54:59
Author: matus.chochlik
Date: 2008-12-14 14:54:58 EST (Sun, 14 Dec 2008)
New Revision: 50272
URL: http://svn.boost.org/trac/boost/changeset/50272
Log:
[mirror 0.3.x]
Text files modified:
sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp | 32 +++++++++++++++++++
sandbox/mirror/boost/mirror/factory.hpp | 65 +++++++++++++++++++++++++++------------
sandbox/mirror/boost/mirror/meta_constructors.hpp | 17 +++++----
sandbox/mirror/libs/mirror/test/classes.hpp | 24 +++++++-------
4 files changed, 97 insertions(+), 41 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 2008-12-14 14:54:58 EST (Sun, 14 Dec 2008)
@@ -26,6 +26,20 @@
namespace boost {
namespace mirror {
+namespace detail {
+
+/** Allows to detect the type of the member attribute.
+ * Thanks to Jean-Louis Leroy for suggesting this
+ */
+template<typename Class, typename Type>
+Type detect_class_member_attrib_type(Type (Class::*));
+
+template <typename Type>
+Type detect_class_member_attrib_type(Type*);
+
+
+} // namespace detail
+
/** Forward declaration of the meta_class_attributes<> template
*/
template <class Class, class VariantTag = detail::default_meta_class_variant>
@@ -397,6 +411,24 @@
typename \
)
+
+/** Macro used for registering meta-data about class' attribute
+ * that can be accessed from the outside directly without
+ * getter / setter functions. This version automatically
+ * detects the type of the member attribute .
+ * Thanks to Jean-Louis Leroy for suggesting the auto-detection
+ * mechanism.
+ */
+#define BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(\
+ SPECIFIERS, \
+ NAME \
+) BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB( \
+ SPECIFIERS, \
+ BOOST_TYPEOF( ::boost::mirror::detail::detect_class_member_attrib_type( \
+ &Class :: NAME)), \
+ NAME \
+)
+
/** Macro used for registering meta-data about class' or template's
* attribute that can be accessed from the outside by calling
* the getter function as specified by GETTER_CALL and setter
Modified: sandbox/mirror/boost/mirror/factory.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/factory.hpp (original)
+++ sandbox/mirror/boost/mirror/factory.hpp 2008-12-14 14:54:58 EST (Sun, 14 Dec 2008)
@@ -12,6 +12,9 @@
#define BOOST_MIRROR_FACTORY_HPP
#include <boost/mirror/meta_constructors.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mirror/detail/argument_type_list.hpp>
+
namespace boost {
namespace mirror {
@@ -236,6 +239,44 @@
#undef BOOST_MIRROR_DECLARE_FACTORY_CONSTRUCTOR
#undef BOOST_MIRROR_CALL_FACTORY_FUNCTOR
+template <class TypeList>
+struct base_factory_remove_type_list_null_types
+{
+ typedef typename mpl::remove_if<
+ TypeList,
+ detail::is_typelist_null_type<
+ mpl::_
+ >
+ >::type type;
+};
+
+template <
+ template <class> class Manufacturer,
+ class Product
+> struct make_base_factory
+{
+ typedef typename meta_constructors<Product>::param_type_lists
+ raw_param_type_lists;
+
+ typedef typename mpl::accumulate<
+ raw_param_type_lists,
+ mpl::vector0<>,
+ mpl::push_back<
+ mpl::_1,
+ base_factory_remove_type_list_null_types<
+ mpl::_2
+ >
+ >
+ >::type param_type_lists;
+
+ typedef base_factory<
+ Manufacturer,
+ Product,
+ param_type_lists,
+ mpl::int_< mpl::size< param_type_lists >::value >
+ > type;
+};
+
} // namespace detail
/** the factory template
@@ -243,28 +284,10 @@
template <
template <class> class Manufacturer,
class Product
-> struct factory
- : ::boost::mirror::detail::base_factory<
- Manufacturer,
- Product,
- typename meta_constructors<Product>::param_type_lists,
- mpl::int_<
- mpl::size<
- typename meta_constructors<Product>::param_type_lists
- >::value
- >
->
+> struct factory : detail::make_base_factory<Manufacturer, Product>::type
{
- typedef ::boost::mirror::detail::base_factory<
- Manufacturer,
- Product,
- typename meta_constructors<Product>::param_type_lists,
- mpl::int_<
- mpl::size<
- typename meta_constructors<Product>::param_type_lists
- >::value
- >
- > base_class;
+ typedef typename detail::make_base_factory<Manufacturer, Product>::type
+ base_class;
factory(void)
: base_class(0, 0)
Modified: sandbox/mirror/boost/mirror/meta_constructors.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_constructors.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_constructors.hpp 2008-12-14 14:54:58 EST (Sun, 14 Dec 2008)
@@ -94,14 +94,18 @@
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_TAIL(TYPE_AND_NAME)) \
)
+#define BOOST_MIRROR_REG_CONSTRUCTOR_PUSH_BACK_PARAM_TYPES(CONSTR_INDEX, TYPENAME_KW) \
+ typedef TYPENAME_KW mpl::push_back< \
+ BOOST_PP_CAT(param_type_lists_, CONSTR_INDEX), \
+ BOOST_PP_CAT(BOOST_PP_CAT(constr_, CONSTR_INDEX), _params) \
+ >::type
+
+
#define BOOST_MIRROR_REG_DEFAULT_CONSTRUCTOR(CONSTR_INDEX) \
param_type_lists_ ## CONSTR_INDEX ; \
typedef mpl::vector0< \
> BOOST_PP_CAT(BOOST_PP_CAT(constr_, CONSTR_INDEX), _params) ;\
- typedef mpl::push_back< \
- BOOST_PP_CAT(param_type_lists_, CONSTR_INDEX), \
- BOOST_PP_CAT(BOOST_PP_CAT(constr_, CONSTR_INDEX), _params) \
- >::type
+ BOOST_MIRROR_REG_CONSTRUCTOR_PUSH_BACK_PARAM_TYPES(CONSTR_INDEX, BOOST_PP_EMPTY())
#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_CONSTRUCTOR(CONSTR_INDEX, PARAM_SEQ, TYPENAME_KW) \
param_type_lists_ ## CONSTR_INDEX ; \
@@ -109,10 +113,7 @@
BOOST_PP_SEQ_FOR_EACH(BOOST_MIRROR_REG_CONSTR_EXTRACT_PARAM_TYPE, 0, PARAM_SEQ) \
> BOOST_PP_CAT(BOOST_PP_CAT(constr_, CONSTR_INDEX), _params) ;\
BOOST_PP_SEQ_FOR_EACH(BOOST_MIRROR_REG_CONSTR_REG_CALL_PARAM_NAME, CONSTR_INDEX, PARAM_SEQ) \
- typedef TYPENAME_KW mpl::push_back< \
- BOOST_PP_CAT(param_type_lists_, CONSTR_INDEX), \
- BOOST_PP_CAT(BOOST_PP_CAT(constr_, CONSTR_INDEX), _params) \
- >::type
+ BOOST_MIRROR_REG_CONSTRUCTOR_PUSH_BACK_PARAM_TYPES(CONSTR_INDEX, TYPENAME_KW)
#define BOOST_MIRROR_REG_CONSTRUCTOR(CONSTR_INDEX, PARAM_SEQ) \
BOOST_MIRROR_REG_CLASS_OR_TEMPL_CONSTRUCTOR(CONSTR_INDEX, PARAM_SEQ, BOOST_PP_EMPTY())
Modified: sandbox/mirror/libs/mirror/test/classes.hpp
==============================================================================
--- sandbox/mirror/libs/mirror/test/classes.hpp (original)
+++ sandbox/mirror/libs/mirror/test/classes.hpp 2008-12-14 14:54:58 EST (Sun, 14 Dec 2008)
@@ -132,9 +132,9 @@
/** class ::test::A */
BOOST_MIRROR_REG_TYPE(::test, A)
BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::A)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a1)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a2)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a3)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, a1)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, a2)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, a3)
BOOST_MIRROR_REG_CLASS_ATTRIBS_END
/** class ::test::B */
@@ -143,8 +143,8 @@
BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::A)
BOOST_MIRROR_REG_BASE_CLASSES_END
BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::B)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(static, int, b1)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, int, b2)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(static, b1)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, b2)
BOOST_MIRROR_REG_CLASS_ATTRIBS_END
/** class ::test::C */
@@ -153,8 +153,8 @@
BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::A)
BOOST_MIRROR_REG_BASE_CLASSES_END
BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::C)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(mutable, double, c1)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, double, c2)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(mutable, c1)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, c2)
BOOST_MIRROR_REG_CLASS_ATTRIBS_END
/** class ::test::D */
@@ -194,8 +194,8 @@
BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::E)
BOOST_MIRROR_REG_BASE_CLASSES_END
BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::F)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, bool, f1)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, bool, f2)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, f1)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, f2)
BOOST_MIRROR_REG_CLASS_ATTRIBS_END
/** class ::test::G */
@@ -204,9 +204,9 @@
BOOST_MIRROR_REG_VIRTUAL_BASE_CLASS(0, public, ::test::E)
BOOST_MIRROR_REG_BASE_CLASSES_END
BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::G)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g1)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g2)
- BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, char, g3)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, g1)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, g2)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, g3)
BOOST_MIRROR_REG_CLASS_ATTRIBS_END
/** class ::test::H */
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