Boost logo

Boost-Commit :

From: oryol_at_[hidden]
Date: 2008-04-10 02:10:48


Author: jeremypack
Date: 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
New Revision: 44144
URL: http://svn.boost.org/trac/boost/changeset/44144

Log:
Further simplifications to reflector.hpp.

Remove redundant functions.

Text files modified:
   sandbox/boost/reflection/impl/reflector_free_functions.hpp | 2 +-
   sandbox/boost/reflection/impl/reflector_functions.hpp | 36 +++++++++++++++++++-----------------
   sandbox/boost/reflection/impl/reflector_parameter_functions.hpp | 19 +++++++++++++------
   sandbox/boost/reflection/reflector.hpp | 15 ++++++++-------
   sandbox/libs/extension/examples/Jamfile.v2 | 2 +-
   5 files changed, 42 insertions(+), 32 deletions(-)

Modified: sandbox/boost/reflection/impl/reflector_free_functions.hpp
==============================================================================
--- sandbox/boost/reflection/impl/reflector_free_functions.hpp (original)
+++ sandbox/boost/reflection/impl/reflector_free_functions.hpp 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
@@ -17,7 +17,7 @@
 // This is a generic factory function to construct an instance of
 // a given class using a constructor with the given signature.
 template <class T BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, class Param)>
-instance construct_instance(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) {
+static instance construct_instance(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) {
   // An instance is similar to boost::any. Initialize it with
   // a void ptr.
   return instance(static_cast<void*>(

Modified: sandbox/boost/reflection/impl/reflector_functions.hpp
==============================================================================
--- sandbox/boost/reflection/impl/reflector_functions.hpp (original)
+++ sandbox/boost/reflection/impl/reflector_functions.hpp 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
@@ -13,13 +13,25 @@
 # define N BOOST_PP_ITERATION()
 
 
- template <class ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, class Param)>
+template <class ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, class Param)>
 void reflect_constructor() {
- add_constructor<ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>(&impl::construct_instance<T, ParamFirst
- BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>);
+ instance (*ctor_func)(
+ ParamFirst BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param))
+ (&impl::construct_instance<T, ParamFirst
+ BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param)>);
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
+ reflections::type_info_handler
+ <TypeInfo, instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param))>
+ ::get_class_type(),
+ reinterpret_cast<FunctionPtr>(ctor_func)));
+
+ // add_constructor<ParamFirst BOOST_PP_COMMA_IF(N)
+ // BOOST_PP_ENUM_PARAMS(N, Param)>(&impl::construct_instance<T, ParamFirst
+ // BOOST_PP_COMMA_IF(N)
+ // BOOST_PP_ENUM_PARAMS(N, Param)>);
 }
 template <class ReturnValue BOOST_PP_COMMA_IF(N)
           BOOST_PP_ENUM_PARAMS(N, class Param)>
@@ -39,16 +51,6 @@
     p2(f, p);
   reflection_->functions_.insert(p2);
 }
-template <class ParamFirst BOOST_PP_COMMA_IF(N)
-BOOST_PP_ENUM_PARAMS(N, class Param)>
-void add_constructor(instance (*func)(ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param))) {
- reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
- reflections::type_info_handler
- <TypeInfo, instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param))>
- ::get_class_type(),
- reinterpret_cast<FunctionPtr>(func)));
-}
+
 
 #undef N
\ No newline at end of file

Modified: sandbox/boost/reflection/impl/reflector_parameter_functions.hpp
==============================================================================
--- sandbox/boost/reflection/impl/reflector_parameter_functions.hpp (original)
+++ sandbox/boost/reflection/impl/reflector_parameter_functions.hpp 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
@@ -29,12 +29,19 @@
 template <class ParamFirst BOOST_PP_COMMA_IF(N)
   BOOST_PP_ENUM_PARAMS(N, class Param)>
 void reflect_constructor(BOOST_PP_ENUM_PARAMS(N, ParameterInfo i)) {
- add_constructor<ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>(&impl::construct_instance<T, ParamFirst
- BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>
- BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, i));
+ instance (*ctor_func)(
+ ParamFirst BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param))
+ (&impl::construct_instance<T, ParamFirst
+ BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param)>);
+
+ constructor_info f(reflections::type_info_handler
+ <TypeInfo, instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param))>
+ ::get_class_type());
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N);
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
+ f, reinterpret_cast<FunctionPtr>(ctor_func)));
 }
 
 template <class ReturnValue BOOST_PP_COMMA_IF(N)

Modified: sandbox/boost/reflection/reflector.hpp
==============================================================================
--- sandbox/boost/reflection/reflector.hpp (original)
+++ sandbox/boost/reflection/reflector.hpp 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
@@ -47,7 +47,10 @@
   typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
   typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
   void reflect_constructor() {
- add_constructor(&impl::construct_instance<T>);
+ instance (*ctor_func)()(&impl::construct_instance<T>);
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
+ reflections::type_info_handler<TypeInfo, instance (*)()>
+ ::get_class_type(), reinterpret_cast<FunctionPtr>(ctor_func)));
   }
 #define BOOST_PP_ITERATION_LIMITS (0, \
     BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
@@ -65,11 +68,6 @@
     reflection_->functions_.insert(out_pair);
   }
 private:
- void add_constructor(instance (*func)()) {
- reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
- reflections::type_info_handler<TypeInfo, instance (*)()>::get_class_type(),
- reinterpret_cast<FunctionPtr>(func)));
- }
   basic_reflection<Info, ParameterInfo, TypeInfo> * reflection_;
 };
 
@@ -85,7 +83,10 @@
   typedef basic_function_info<Info, TypeInfo> function_info;
   typedef basic_constructor_info<Info, TypeInfo> constructor_info;
   void reflect_constructor() {
- add_constructor(&impl::construct_instance<T>);
+ instance (*ctor_func)()(&impl::construct_instance<T>);
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
+ reflections::type_info_handler<TypeInfo, instance (*)()>
+ ::get_class_type(), reinterpret_cast<FunctionPtr>(ctor_func)));
   }
 #define BOOST_PP_ITERATION_LIMITS (0, \
     BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)

Modified: sandbox/libs/extension/examples/Jamfile.v2
==============================================================================
--- sandbox/libs/extension/examples/Jamfile.v2 (original)
+++ sandbox/libs/extension/examples/Jamfile.v2 2008-04-10 02:10:47 EDT (Thu, 10 Apr 2008)
@@ -69,7 +69,7 @@
  # RegistryExample
   ;
 
-install ../test :
+install ../test/ :
   HelloWorld HelloWorldLib
   Parameters ParametersLib
   MultilanguageWord MultilanguageHelloWorld


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