|
Boost-Commit : |
From: chochlik_at_[hidden]
Date: 2008-05-29 13:01:56
Author: matus.chochlik
Date: 2008-05-29 13:01:56 EDT (Thu, 29 May 2008)
New Revision: 45914
URL: http://svn.boost.org/trac/boost/changeset/45914
Log:
Added experimental support for class generators
Tested with MSVC++ EE
Added:
sandbox/mirror/boost/mirror/detail/class_generators.hpp (contents, props changed)
sandbox/mirror/boost/mirror/detail/meta_attribs_outline.hpp (contents, props changed)
Text files modified:
sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
Added: sandbox/mirror/boost/mirror/detail/class_generators.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/class_generators.hpp 2008-05-29 13:01:56 EDT (Thu, 29 May 2008)
@@ -0,0 +1,112 @@
+/**
+ * \file boost/mirror/detail/class_generator.hpp
+ *
+ * Custom class generators
+ *
+ * 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_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>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+
+template <
+ class MetaAttributes,
+ template <class> class Model,
+ class Position
+>
+struct class_generator_unit
+{
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ outline_holder,
+ (MetaAttributes::get_outline_holder((Model<void>*)0, Position()))
+ );
+};
+
+template <
+ class Class,
+ template <class> class Model,
+ class Position,
+ class Size
+>
+struct class_generator_base
+: public class_generator_unit<
+ meta_class_attributes<Class>, Model, Position
+>::outline_holder::type
+, public class_generator_base<
+ Class, Model, mpl::int_<Position::value+1>, Size
+>
+{
+ typedef typename class_generator_unit<
+ meta_class_attributes<Class>, Model, Position
+ >::outline_holder::type head;
+
+ typedef class_generator_base<
+ Class, Model, mpl::int_<Position::value+1>, Size
+ > tail;
+
+ class_generator_base(Model<void>& model)
+ : head(model)
+ , tail(model)
+ { }
+
+ class_generator_base(const Model<void>& model)
+ : head(model)
+ , tail(model)
+ { }
+};
+
+template <
+ class Class,
+ template <class> class Model,
+ class Size
+>
+struct class_generator_base<Class, Model, Size, Size>
+{
+ class_generator_base(Model<void>& model){ }
+ class_generator_base(const Model<void>& model){ }
+};
+
+} // namespace detail
+
+template <
+ class Class,
+ template <class> class Model
+>
+struct class_generator
+: detail::class_generator_base<
+ Class,
+ Model,
+ mpl::int_<0>,
+ mpl::int_<mirror::size<meta_class_attributes<Class> >::value>
+>
+{
+private:
+ Model<void> model;
+ typedef detail::class_generator_base<
+ Class,
+ Model,
+ mpl::int_<0>,
+ mpl::int_<mirror::size<meta_class_attributes<Class> >::value>
+ > base_generator;
+public:
+ class_generator(void)
+ : base_generator(model)
+ { }
+};
+
+
+} // 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 2008-05-29 13:01:56 EDT (Thu, 29 May 2008)
@@ -14,6 +14,8 @@
#include <boost/mirror/common_defs.hpp>
// forward declarations
#include <boost/mirror/meta_data_fwd.hpp>
+// class generation related
+#include <boost/mirror/detail/meta_attribs_outline.hpp>
//
#include <boost/preprocessor/repetition/enum_params.hpp>
//
@@ -43,6 +45,7 @@
template <> struct meta_class_attributes< THE_CLASS , detail::default_meta_class_variant> \
{ \
typedef THE_CLASS Class; \
+ typedef detail::default_meta_class_variant variant_tag; \
typedef mpl::vector<>
/** This macro starts the declaration of member attributes
@@ -57,6 +60,7 @@
{ \
typedef THE_TEMPLATE < BOOST_PP_ENUM_PARAMS(TEMPL_ARG_COUNT, T) > \
Class; \
+ typedef detail::default_meta_class_variant variant_tag; \
typedef typename mpl::vector<>
@@ -75,6 +79,7 @@
* after the specific stuff.
*/
#define BOOST_MIRROR_REG_CLASS_OR_TEMPL_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME, TYPENAME_KW) \
+ BOOST_MIRROR_DECLARE_ATTRIB_OUTLINE(NUMBER, TYPE, NAME) \
typedef TYPENAME_KW mpl::push_back<_partial_list_##NUMBER, TYPE>::type
Added: sandbox/mirror/boost/mirror/detail/meta_attribs_outline.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/meta_attribs_outline.hpp 2008-05-29 13:01:56 EDT (Thu, 29 May 2008)
@@ -0,0 +1,91 @@
+/**
+ * \file boost/mirror/detail/meta_attribs_outline.hpp
+ *
+ * Meta-attribute outlines
+ *
+ * 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_META_ATTRIBS_OUTLINE_HPP
+#define BOOST_MIRROR_META_DETAIL_META_ATTRIBS_OUTLINE_HPP
+
+#include <boost/typeof/typeof.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+
+template <typename MetaAttribute, template <class> class Model>
+class meta_attribute_outline
+{
+private:
+ typedef typename MetaAttribute::type type;
+ typedef typename MetaAttribute::position position;
+
+ Model<type> model;
+ typedef Model<type>* PModel;
+public:
+ meta_attribute_outline(Model<void>& classModel)
+ : model(classModel){ }
+ meta_attribute_outline(const Model<void>& classModel)
+ : model(classModel){ }
+
+ // the return value type of the getter function
+ typedef BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ result_of_get,
+ (((PModel)0)->get(0, position()))
+ )
+
+ // the getter member function
+ inline typename result_of_get::type get(void) const
+ {
+ return model.get(MetaAttribute::base_name(), position());
+ }
+};
+
+#define BOOST_MIRROR_DECLARE_ATTRIB_OUTLINE(NUMBER, TYPE, NAME) \
+ template <template <class> class Model> \
+ struct NAME##_outline_holder \
+ { \
+ struct outline : public mirror::detail::meta_attribute_outline< \
+ mirror::detail::meta_class_attribute< \
+ Class, \
+ variant_tag, \
+ meta_class_attributes<Class, variant_tag>, \
+ mpl::int_<NUMBER> \
+ >, \
+ Model \
+ > \
+ {\
+ typedef mirror::detail::meta_attribute_outline< \
+ mirror::detail::meta_class_attribute< \
+ Class, \
+ variant_tag, \
+ meta_class_attributes<Class, variant_tag>, \
+ mpl::int_<NUMBER> \
+ >, \
+ Model \
+ > base; \
+ outline(Model<void>& classModel) \
+ : base(classModel){ } \
+ outline(const Model<void>& classModel) \
+ : base(classModel){ } \
+ } NAME; \
+ NAME##_outline_holder(Model<void>& classModel) \
+ : NAME(classModel){ } \
+ NAME##_outline_holder(const Model<void>& classModel) \
+ : NAME(classModel){ } \
+ }; \
+ template <template <class> class Model> \
+ static NAME##_outline_holder<Model> get_outline_holder(Model<void>*, mpl::int_<NUMBER>);
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
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