Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52861 - in sandbox/mirror: boost/mirror boost/mirror/detail libs/mirror/example/factories
From: chochlik_at_[hidden]
Date: 2009-05-09 08:52:18


Author: matus.chochlik
Date: 2009-05-09 08:52:17 EDT (Sat, 09 May 2009)
New Revision: 52861
URL: http://svn.boost.org/trac/boost/changeset/52861

Log:
[mirror 0.4.x]
- update of the meta-functions / meta-constructors

Text files modified:
   sandbox/mirror/boost/mirror/detail/function_meta_data.hpp | 22 ++++++++++++++++++++
   sandbox/mirror/boost/mirror/meta_constructors.hpp | 43 ++++++++++++++++++++++++++++++++++-----
   sandbox/mirror/boost/mirror/meta_mem_functions.hpp | 23 +++++---------------
   sandbox/mirror/libs/mirror/example/factories/inserter.cpp | 1
   4 files changed, 66 insertions(+), 23 deletions(-)

Modified: sandbox/mirror/boost/mirror/detail/function_meta_data.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/function_meta_data.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/function_meta_data.hpp 2009-05-09 08:52:17 EDT (Sat, 09 May 2009)
@@ -15,6 +15,8 @@
 #include <boost/mpl/size.hpp>
 #include <boost/mpl/push_back.hpp>
 
+#include <boost/typeof/typeof.hpp>
+
 #include <boost/preprocessor/repetition/enum.hpp>
 #include <boost/preprocessor/repetition/repeat.hpp>
 #include <boost/preprocessor/seq/size.hpp>
@@ -46,6 +48,7 @@
 template <class BaseMetaData, class FunctionIndex>
 struct meta_function
 {
+public:
         typedef typename BaseMetaData::template get_scope<FunctionIndex>::type
                 scope;
         // returns the name of the member function
@@ -153,7 +156,26 @@
                 static inline void call_for_each(const Functor&, size)
                 {
                 }
+
         };
+private:
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ nested_wrapper,
+ BaseMetaData::get_wrapper_of(FunctionIndex())
+ );
+
+ typedef typename nested_wrapper::type wrapper;
+public:
+ template <class Class>
+ static inline wrapper wrap(Class& instance)
+ {
+ return BaseMetaData::wrap(FunctionIndex(), instance);
+ }
+
+ static inline wrapper wrap(void)
+ {
+ return BaseMetaData::wrap(FunctionIndex());
+ }
 };
 
 /** Registers the parameter name of the j-th parameter

Modified: sandbox/mirror/boost/mirror/meta_constructors.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_constructors.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_constructors.hpp 2009-05-09 08:52:17 EDT (Sat, 09 May 2009)
@@ -18,7 +18,10 @@
 /** Forward declaration of the meta-constructors base template
  */
 template <class Class /*, class VariantTag*/ >
-struct meta_constructors_base;
+struct meta_constructors_base
+{
+ typedef mpl::vector0<> param_type_lists;
+};
 
 /** Begins the registering of template class' constructors
  */
@@ -48,7 +51,7 @@
         { \
                 typedef typename get_scope<FunctionIndex>::type scope; \
                 return scope::get_name(full_or_base, traits); \
- }
+ }
 
 
 /** Ends the registering of (template) class' constructors
@@ -64,7 +67,19 @@
 /** Registers a single default constructor
  */
 #define BOOST_MIRROR_REG_DEFAULT_CONSTRUCTOR(CONSTR_INDEX) \
- param_type_lists_ ## CONSTR_INDEX ; \
+ BOOST_PP_CAT(param_type_lists_, CONSTR_INDEX) ; \
+ struct BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ { \
+ inline _detail_class operator()(void) const \
+ { \
+ return _detail_class(); \
+ } \
+ }; \
+ static BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ get_wrapper_of( mpl::int_< CONSTR_INDEX >); \
+ static inline BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ wrap( mpl::int_< CONSTR_INDEX >) \
+ {return BOOST_PP_CAT(wrapper_, CONSTR_INDEX)();} \
         BOOST_MIRROR_REG_META_FUNCTION_DEFINE_EMPTY_PARAM_TYPELIST(CONSTR_INDEX)\
         BOOST_MIRROR_REG_META_FUNCTION_PUSH_BACK_PARAM_TYPES(\
                 CONSTR_INDEX, \
@@ -78,7 +93,23 @@
         PARAM_SEQ, \
         TYPENAME_KW\
 ) \
- param_type_lists_ ## CONSTR_INDEX ; \
+ BOOST_PP_CAT(param_type_lists_, CONSTR_INDEX) ; \
+ struct BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ { \
+ inline _detail_class operator()( \
+ BOOST_MIRROR_REG_META_FUNCTION_ENUM_PARAM_TYPES_AND_NAMES(PARAM_SEQ) \
+ ) const \
+ { \
+ return _detail_class( \
+ BOOST_MIRROR_REG_META_FUNCTION_ENUM_PARAM_NAMES(PARAM_SEQ) \
+ ); \
+ } \
+ }; \
+ static BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ get_wrapper_of( mpl::int_< CONSTR_INDEX >); \
+ static inline BOOST_PP_CAT(wrapper_, CONSTR_INDEX) \
+ wrap( mpl::int_< CONSTR_INDEX >) \
+ {return BOOST_PP_CAT(wrapper_, CONSTR_INDEX)();} \
         BOOST_MIRROR_REG_META_FUNCTION_DEFINE_PARAM_TYPELIST( \
                 CONSTR_INDEX, \
                 PARAM_SEQ \
@@ -203,7 +234,7 @@
 /** Template providing meta-data about the constructors
  * of the Class.
  */
-template < class Class, class VariantTag>
+template <class Class, class VariantTag>
 struct meta_constructors : public meta_constructors_base<Class>
 {
         template <class ConstructorIndex>
@@ -211,12 +242,12 @@
          : detail::meta_function<meta_constructors, ConstructorIndex>
         {
                 typedef BOOST_MIRRORED_CLASS(Class) result_type;
+ typedef mpl::true_ is_constructor;
         };
 
         template <class FunctionIndex>
         struct function : constructor<FunctionIndex>
         {
- typedef mpl::true_ is_constructor;
          };
 };
 

Modified: sandbox/mirror/boost/mirror/meta_mem_functions.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_mem_functions.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_mem_functions.hpp 2009-05-09 08:52:17 EDT (Sat, 09 May 2009)
@@ -11,7 +11,6 @@
 #define BOOST_MIRROR_META_MEM_FUNCTIONS_HPP
 
 #include <boost/mirror/meta_constructors.hpp>
-#include <boost/typeof/typeof.hpp>
 #include <boost/mpl/eval_if.hpp>
 
 namespace boost {
@@ -20,7 +19,10 @@
 /** Forward declaration of the meta-constructors base template
  */
 template <class Class /*, class VariantTag*/ >
-struct meta_mem_functions_base;
+struct meta_mem_functions_base
+{
+ typedef mpl::vector0<> param_type_lists;
+};
 
 /** Begins the registering of template class' member_functions
  */
@@ -51,7 +53,7 @@
         FUNC_NAME, \
         CONST_KW \
 ) \
- param_type_lists_ ## FUNC_INDEX ; \
+ BOOST_PP_CAT(param_type_lists_, FUNC_INDEX) ; \
         static RET_VAL get_result_of( mpl::int_< FUNC_INDEX >); \
         struct BOOST_PP_CAT(wrapper_, FUNC_INDEX) \
         { \
@@ -122,7 +124,7 @@
         CONST_KW, \
         TYPENAME_KW\
 ) \
- param_type_lists_ ## FUNC_INDEX ; \
+ BOOST_PP_CAT(param_type_lists_, FUNC_INDEX) ; \
         static RET_VAL get_result_of( mpl::int_< FUNC_INDEX >); \
         struct BOOST_PP_CAT(wrapper_, FUNC_INDEX) \
         { \
@@ -297,14 +299,6 @@
                 {
                         typedef BOOST_MIRRORED_CLASS(T) type;
                 };
-
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
- nested_wrapper,
- base_meta_data::get_wrapper_of(FunctionIndex())
- );
-
- typedef typename nested_wrapper::type wrapper;
-
         public:
                 // meta-class reflecting the result type of this function
                 typedef typename mpl::eval_if<
@@ -314,11 +308,6 @@
>::type result_type;
 
                 typedef mpl::false_ is_constructor;
-
- static inline wrapper wrap(Class& instance)
- {
- return base_meta_data::wrap(FunctionIndex(), instance);
- }
         };
 };
 

Modified: sandbox/mirror/libs/mirror/example/factories/inserter.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/factories/inserter.cpp (original)
+++ sandbox/mirror/libs/mirror/example/factories/inserter.cpp 2009-05-09 08:52:17 EDT (Sat, 09 May 2009)
@@ -86,6 +86,7 @@
         {
                 factory<input_ui, person> fact;
                 persons.push_back(fact());
+ //
                 // check whether to insert more persons
                 do
                 {


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