Boost logo

Boost-Commit :

From: oryol_at_[hidden]
Date: 2008-02-07 19:18:56


Author: jeremypack
Date: 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
New Revision: 43170
URL: http://svn.boost.org/trac/boost/changeset/43170

Log:
Add basic requirements for parameter info.

Text files modified:
   sandbox/boost/reflection/constructor.hpp | 18 +-
   sandbox/boost/reflection/factory.hpp | 26 ++++
   sandbox/boost/reflection/function.hpp | 10 +-
   sandbox/boost/reflection/instance.hpp | 10 +-
   sandbox/boost/reflection/method_info.hpp | 38 +++---
   sandbox/boost/reflection/parameter_map.hpp | 186 ++++++++++++++++----------------------
   sandbox/boost/reflection/reflection.hpp | 168 +++++++++++++++++++++++++++++----
   sandbox/boost/reflection/reflector.hpp | 194 ++++++++++++++++++++++++++++++++++-----
   sandbox/libs/reflection/examples/extension/extension.cpp | 22 ++-
   sandbox/libs/reflection/test/Jamfile.v2 | 2
   sandbox/libs/reflection/test/basic_test.cpp | 28 ++--
   sandbox/libs/reflection/test/shared_library_test.cpp | 4
   12 files changed, 484 insertions(+), 222 deletions(-)

Modified: sandbox/boost/reflection/constructor.hpp
==============================================================================
--- sandbox/boost/reflection/constructor.hpp (original)
+++ sandbox/boost/reflection/constructor.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -7,19 +7,19 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_CONSTRUCTOR_HPP
-#define BOOST_EXTENSION_CONSTRUCTOR_HPP
+#ifndef BOOST_REFLECTION_CONSTRUCTOR_HPP
+#define BOOST_REFLECTION_CONSTRUCTOR_HPP
 #include <boost/reflection/instance.hpp>
 namespace boost {namespace reflections {
 template <BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(\
- BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param, void)>
-class constructor;
+ BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), class Param, void)>
+class instance_constructor;
 
-#define BOOST_REFLECTION_CONSTRUCTOR_CLASS(Z, N, _) \
+#define BOOST_REFLECTION_INSTANCE_CONSTRUCTOR_CLASS(Z, N, _) \
 template <BOOST_PP_ENUM_PARAMS(N, class Param)> \
-class constructor<BOOST_PP_ENUM_PARAMS(N, Param)> { \
+class instance_constructor<BOOST_PP_ENUM_PARAMS(N, Param)> { \
 public: \
- constructor(instance (*func)(BOOST_PP_ENUM_PARAMS(N, Param)) = 0) \
+ instance_constructor(instance (*func)(BOOST_PP_ENUM_PARAMS(N, Param)) = 0) \
   : func_(func) { \
   } \
   instance call(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
@@ -33,7 +33,7 @@
   instance (*func_)(BOOST_PP_ENUM_PARAMS(N, Param)); \
 };
 
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_CONSTRUCTOR_CLASS, _)
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_INSTANCE_CONSTRUCTOR_CLASS, _)
 }}
 #endif

Modified: sandbox/boost/reflection/factory.hpp
==============================================================================
--- sandbox/boost/reflection/factory.hpp (original)
+++ sandbox/boost/reflection/factory.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -9,8 +9,10 @@
 
 #ifndef BOOST_REFLECTION_FACTORY_HPP
 #define BOOST_REFLECTION_FACTORY_HPP
-#include <boost/reflection/generic_constructor.hpp>
+#include <boost/reflection/common.hpp>
+// #include <boost/reflection/generic_constructor.hpp>
 namespace boost {namespace reflections {
+ /*
 template <class T>
 class factory : public generic_constructor<T> {
 public:
@@ -19,6 +21,26 @@
   virtual T * create(void ** params) {return (*factory_func_)();}
 private:
   T (*factory_func_)();
-};
+};*/
+#define BOOST_REFLECTION_CONSTRUCT_FUNCTION(Z, N, _) \
+template <class Actual \
+BOOST_PP_COMMA_IF(N) \
+BOOST_PP_ENUM_PARAMS(N, class Param) > \
+Actual * construct(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return new Actual(BOOST_PP_ENUM_PARAMS(N, p)); \
+}
+
+#define BOOST_REFLECTION_CONSTRUCTI_FUNCTION(Z, N, _) \
+template <class Interface, class Actual \
+BOOST_PP_COMMA_IF(N) \
+BOOST_PP_ENUM_PARAMS(N, class Param) > \
+Interface * construct_interface(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return new Actual(BOOST_PP_ENUM_PARAMS(N, p)); \
+}
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_CONSTRUCT_FUNCTION, _)
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_CONSTRUCTI_FUNCTION, _)
+
 }}
 #endif

Modified: sandbox/boost/reflection/function.hpp
==============================================================================
--- sandbox/boost/reflection/function.hpp (original)
+++ sandbox/boost/reflection/function.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -7,8 +7,8 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_FUNCTION_HPP
-#define BOOST_EXTENSION_FUNCTION_HPP
+#ifndef BOOST_REFLECTION_FUNCTION_HPP
+#define BOOST_REFLECTION_FUNCTION_HPP
 
 #include <boost/reflection/instance.hpp>
 
@@ -16,9 +16,9 @@
 
 typedef void (instance::*MemberFunctionPtr)();
 template <class ReturnValue = void
- BOOST_PP_COMMA_IF(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS)
+ BOOST_PP_COMMA_IF(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS)
           BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC
- (BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param, void)>
+ (BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), class Param, void)>
 class function;
   
 #define BOOST_REFLECTION_FUNCTION_CLASS(Z, N, _) \
@@ -55,7 +55,7 @@
 };
 
 
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
                 BOOST_REFLECTION_FUNCTION_CLASS, _)
 }}
 #endif

Modified: sandbox/boost/reflection/instance.hpp
==============================================================================
--- sandbox/boost/reflection/instance.hpp (original)
+++ sandbox/boost/reflection/instance.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -7,10 +7,10 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_INSTANCE_HPP
-#define BOOST_EXTENSION_INSTANCE_HPP
+#ifndef BOOST_REFLECTION_INSTANCE_HPP
+#define BOOST_REFLECTION_INSTANCE_HPP
 
-#include <boost/extension/common.hpp>
+#include <boost/reflection/common.hpp>
 namespace boost {namespace reflections {
 class instance {
 public:
@@ -41,9 +41,9 @@
   }
 private:
   template <class ReturnValue
- BOOST_PP_COMMA_IF(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS)
+ BOOST_PP_COMMA_IF(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS)
   BOOST_PP_ENUM_PARAMS(BOOST_PP_INC
- (BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param)>
+ (BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), class Param)>
   friend class function;
   mutable void * val_;
   void (*destructor_)(void *);

Modified: sandbox/boost/reflection/method_info.hpp
==============================================================================
--- sandbox/boost/reflection/method_info.hpp (original)
+++ sandbox/boost/reflection/method_info.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -9,8 +9,8 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_METHOD_INFO_HPP
-#define BOOST_EXTENSION_METHOD_INFO_HPP
+#ifndef BOOST_REFLECTION_METHOD_INFO_HPP
+#define BOOST_REFLECTION_METHOD_INFO_HPP
 
 #include <boost/function.hpp>
 
@@ -19,35 +19,35 @@
 
 
 namespace boost {
- namespace extension {
+ namespace reflection {
 
-#ifdef BOOST_EXTENSION_USE_PP
+#ifdef BOOST_REFLECTION_USE_PP
 
-#ifndef BOOST_EXTENSION_REFLECTION_PARAMS
-#define BOOST_EXTENSION_REFLECTION_PARAMS(z, n, dummy) \
+#ifndef BOOST_REFLECTION_REFLECTION_PARAMS
+#define BOOST_REFLECTION_REFLECTION_PARAMS(z, n, dummy) \
   BOOST_PP_CAT(MethodParam,n),BOOST_PP_CAT(MethodParamID,n)
 #endif
 
-#ifndef BOOST_EXTENSION_REFLECTION_CLASS_PARAMS
-#define BOOST_EXTENSION_REFLECTION_CLASS_PARAMS(z, n, dummy) \
+#ifndef BOOST_REFLECTION_REFLECTION_CLASS_PARAMS
+#define BOOST_REFLECTION_REFLECTION_CLASS_PARAMS(z, n, dummy) \
   BOOST_PP_CAT(class MethodParam,n),BOOST_PP_CAT(class MethodParamID,n)
 #endif
 
     template<class Implementation, class MethodID, \
              class MethodReturnValue, \
              BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
- BOOST_PP_ADD(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS) \
- ,BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS)), \
+ BOOST_PP_ADD(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) \
+ ,BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS)), \
              class P, void) \
> class method_info;
 
-#define BOOST_EXTENSION_METHOD_INFO(Z, N, _) \
+#define BOOST_REFLECTION_METHOD_INFO(Z, N, _) \
 template<class Implementation, class MethodID, class MethodReturnValue \
   BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_CLASS_PARAMS, dummy) > \
+ BOOST_PP_ENUM(N, BOOST_REFLECTION_REFLECTION_CLASS_PARAMS, dummy) > \
 class method_info<Implementation, MethodID, MethodReturnValue \
   BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
+ BOOST_PP_ENUM(N, BOOST_REFLECTION_REFLECTION_PARAMS, dummy) > \
   { \
     public: \
           typedef BOOST_PP_CAT(boost::function,BOOST_PP_INC(N)) \
@@ -76,11 +76,11 @@
 /**/
 
 
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_METHOD_INFO, _)
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_METHOD_INFO, _)
 
 
-#undef BOOST_EXTENSION_METHOD_INFO
+#undef BOOST_REFLECTION_METHOD_INFO
 
 #else
 
@@ -168,9 +168,9 @@
         method_type f_;
     };
 
-#endif // BOOST_EXTENSION_USE_PP
+#endif // BOOST_REFLECTION_USE_PP
 
- } // extension
+ } // reflection
 } // boost
 
-#endif // BOOST_EXTENSION_METHOD_INFO_HPP
+#endif // BOOST_REFLECTION_METHOD_INFO_HPP

Modified: sandbox/boost/reflection/parameter_map.hpp
==============================================================================
--- sandbox/boost/reflection/parameter_map.hpp (original)
+++ sandbox/boost/reflection/parameter_map.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -10,113 +10,85 @@
  */
 
 
-#ifndef BOOST_EXTENSION_PARAMETER_MAP_HPP
-#define BOOST_EXTENSION_PARAMETER_MAP_HPP
-
-
-namespace boost {
- namespace extension {
-
- template<class ParameterType, class ParameterIDType>
- struct parameter_pair
- {
- parameter_pair() {}
- parameter_pair(ParameterType p, ParameterIDType p_id)
- : parameter(p), parameter_id(p_id) {}
-
- ParameterType parameter;
- ParameterIDType parameter_id;
- };
-
-
- class parameter_map
- {
- class generic_parameter_map_container
- {
- public:
- virtual ~generic_parameter_map_container(void) {}
- };
-
- template<class ParameterType, class ParameterIDType>
- class parameter_map_container
- : public parameter_pair<ParameterType, ParameterIDType>,
- public generic_parameter_map_container
- {
- public:
- parameter_map_container(void) {}
- virtual ~parameter_map_container(void) {}
- };
-
-
- typedef std::list<generic_parameter_map_container *> ParameterList;
- ParameterList parameters_;
-
-
- template<class ParameterType, class ParameterIDType>
- typename ParameterList::iterator
- find_parameter(ParameterIDType id)
- {
- typename ParameterList::iterator it = parameters_.begin();
-
- for(; it != parameters_.end(); ++it) {
- parameter_map_container<ParameterType, ParameterIDType> *pc =
- dynamic_cast< parameter_map_container<ParameterType,
- ParameterIDType> *>(*it);
-
- if(pc == NULL) {
- // if the cast failed it means that this element of the list
- // it isn't of the expected type, so we skip it.
- continue;
- }
-
- // now we check if the id is correct (knowing that the parameters
- // types are correct)
- if(pc->parameter_id == id) {
- return it;
- }
- }
- return parameters_.end();
- }
-
-
- template<class ParameterType, class ParameterIDType>
- parameter_pair<ParameterType, ParameterIDType> &
- get(ParameterIDType id)
- {
- typename ParameterList::iterator it =
- find_parameter<ParameterType, ParameterIDType>(id);
+#ifndef BOOST_REFLECTION_PARAMETER_MAP_HPP
+#define BOOST_REFLECTION_PARAMETER_MAP_HPP
+#include <boost/reflection/typeinfo.hpp>
+#include <multimap>
+#include <vector>
+namespace boost { namespace reflections {
+
+typedef void (*FunctionPtr)();
+template <class TypeInfo>
+class generic_parameter {
+public:
+ virtual ~basic_parameter() {}
+ virtual TypeInfo type() = 0;
+};
+
+template <class S, class T>
+S convert(generic_parameter param) {
+ T val =
+ return static_cast<S>(val);
+}
+
+
+
+template <class T, class TypeInfo = reflections::default_type_info>
+class parameter : public generic_parameter<TypeInfo> {
+public:
+ template <class A, B, C>
+ friend class parameter_map;
+ parameter(T value) : value_(value) {}
+ template <class S>
+ void converts_to(S (*convert_func)(T) = &convert<S, T>) {
+ converters_.push_back
+ (make_pair(reflections::type_info_handler<TypeInfo, S>::get_class_type(),
+ reinterpret_cast<FunctionPtr>(convert_func)));
+ }
+private:
+ typedef std::vector<std::pair<TypeInfo, FunctionPtr> > vector_type;
+ vector_type converters_;
+ T value_;
+};
+
+class parameter_unavailable_exception : public std::exception {
+public:
+ virtual const char * what() {
+ return "Type not found in parameter_map";
+ }
+};
+
+template <class Info = std::string,
+ class TypeInfo = reflections::default_type_info>
+class basic_parameter_map
+ : public std::multimap<Info, basic_parameter*> {
+public:
+ ~basic_parameter_map() {
+ for (iterator it = begin(); it != end(); ++it) {
+ delete it->second;
+ }
+ }
+ typedef std::multimap<Info, basic_parameter*> map_type;
+ using map_type::equal_range;
+ using map_type::begin;
+ using map_type::end;
+ typedef MapType::iterator iterator;
+ template <class T>
+ T get(Info info) {
+ TypeInfo current_type =
+ reflections::type_info_handler<TypeInfo, T>::get_class_type();
+ std::pair<iterator, iterator> its = equal_range(info);
+ for (iterator current = its->first; current != its->second; ++current) {
       
- if(it == parameters_.end()) {
- // FIXME: free
- parameter_map_container<ParameterType, ParameterIDType> * ret = new
- parameter_map_container<ParameterType, ParameterIDType>();
-
- parameters_.push_back(ret);
- return *ret;
- } else {
- // Change to dynamic if this fails
- return static_cast<parameter_map_container<ParameterType,
- ParameterIDType> &> (*(*it));
- }
+ for (current->second->type() == current_type) {
+
       }
+ }
+ }
+private:
+
+};
+typedef basic_paramter_map<> parameter_map;
+}}
 
- public:
-
- template<class ParameterType, class ParameterIDType>
- void add(ParameterType p, ParameterIDType parameter_id)
- {
- typedef parameter_pair<ParameterType, ParameterIDType> ElementType;
-
- ElementType & s = this->get<ParameterType,
- ParameterIDType>(parameter_id);
-
- parameter_pair<ParameterType, ParameterIDType> pp(p, parameter_id);
- s = pp;
- }
-
- };
-
- } // extension
-} // boost
-
-#endif // BOOST_EXTENSION_PARAMETER_MAP_HPP
+#endif // BOOST_REFLECTION_PARAMETER_MAP_HPP

Modified: sandbox/boost/reflection/reflection.hpp
==============================================================================
--- sandbox/boost/reflection/reflection.hpp (original)
+++ sandbox/boost/reflection/reflection.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -9,28 +9,30 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_REFLECTION_HPP
-#define BOOST_EXTENSION_REFLECTION_HPP
+#ifndef BOOST_REFLECTION_REFLECTION_HPP
+#define BOOST_REFLECTION_REFLECTION_HPP
 #include <map>
-#include <boost/extension/impl/typeinfo.hpp>
+#include <vector>
+
+#include <boost/reflection/impl/typeinfo.hpp>
 #include <boost/reflection/constructor.hpp>
 #include <boost/reflection/factory.hpp>
 #include <boost/reflection/function.hpp>
-
+// #include <boost/reflection/parameter_map.hpp>
 
 namespace boost {namespace reflections {
 #define BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION(Z, N, _) \
 template <class ParamFirst BOOST_PP_COMMA_IF(N) \
   BOOST_PP_ENUM_PARAMS(N, class Param)> \
-constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
+instance_constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
             BOOST_PP_ENUM_PARAMS(N, Param)> get_constructor() { \
- TypeInfo t = extensions::type_info_handler<TypeInfo, \
+ constructor_info t(reflections::type_info_handler<TypeInfo, \
   instance (*)(ParamFirst BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param))>::get_class_type(); \
- typename std::map<TypeInfo, FunctionPtr>::iterator it = \
+ BOOST_PP_ENUM_PARAMS(N, Param))>::get_class_type()); \
+ typename std::map<constructor_info, FunctionPtr>::iterator it = \
     constructors_.find(t); \
   if (it == constructors_.end()) { \
- return constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
+ return instance_constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
                        BOOST_PP_ENUM_PARAMS(N, Param)>(); \
   } else { \
     return reinterpret_cast<instance (*)(ParamFirst BOOST_PP_COMMA_IF(N) \
@@ -44,7 +46,7 @@
           BOOST_PP_ENUM_PARAMS(N, class Param)> \
 function<ReturnValue BOOST_PP_COMMA_IF(N) \
          BOOST_PP_ENUM_PARAMS(N, Param)> get_function(Info info) { \
- function_info f(extensions::type_info_handler<TypeInfo, \
+ function_info f(reflections::type_info_handler<TypeInfo, \
                   ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
                   ::get_class_type(), info); \
   typename std::map<function_info, \
@@ -65,12 +67,64 @@
 }
   
   
-
+
 typedef void (*FunctionPtr)();
-template<class Info, class TypeInfo>
+/*
+template <class Info = std::string,
+ class TypeInfo = reflections::default_type_info>
+class parameter_info {
+public:
+ virtual size_t num_parameters() = 0;
+ virtual const Info & operator[](unsigned position) = 0;
+ virtual TypeInfo type() = 0;
+ template <class T = void, class S = void>
+ class specific_parameter_info : public parameter_info {
+ public:
+ specific_parameter_info() {
+ }
+ private:
+ };
+
+ template <class T>
+ class specific_parameter_info<T> : public parameter_info {
+ public:
+ specific_parameter_info() {
+ }
+ private:
+ };
+ specific_parameter_info<int> * create() {
+ return new specific_parameter_info<int>();
+ }
+private:
+
+};*/
+
+template<class Info, class TypeInfo, class ParameterInfo = void>
 struct basic_function_info {
   TypeInfo type_info_;
   Info info_;
+ std::vector<ParameterInfo> parameter_info_;
+ basic_function_info(TypeInfo t, Info i) : type_info_(t), info_(i)
+ {
+ }
+ basic_function_info(const basic_function_info & s)
+ : type_info_(s.type_info_), info_(s.info_) {}
+ basic_function_info & operator=(basic_function_info & s) {
+ type_info_ = s.type_info_;
+ info_ = s.info_;
+ }
+ friend inline bool operator<(const basic_function_info & t,
+ const basic_function_info & s) {
+ return t.type_info_ < s.type_info_ ||
+ (t.type_info_ == s.type_info_ &&
+ t.info_ < s.info_);
+ }
+};
+
+template<class Info, class TypeInfo>
+struct basic_function_info<Info, TypeInfo> {
+ TypeInfo type_info_;
+ Info info_;
   basic_function_info(TypeInfo t, Info i) : type_info_(t), info_(i)
   {
   }
@@ -87,34 +141,100 @@
      t.info_ < s.info_);
   }
 };
-template <class Info = std::string,
- class TypeInfo = extensions::default_type_info>
+
+template<class TypeInfo, class ParameterInfo = void>
+struct basic_constructor_info {
+ TypeInfo type_info_;
+ std::vector<ParameterInfo> parameter_info_;
+ basic_constructor_info(TypeInfo t) : type_info_(t)
+ {
+ }
+ basic_constructor_info(const basic_constructor_info & s)
+ : type_info_(s.type_info_) {}
+ basic_constructor_info & operator=(basic_constructor_info & s) {
+ type_info_ = s.type_info_;
+ }
+ friend inline bool operator<(const basic_constructor_info & t,
+ const basic_constructor_info & s) {
+ return t.type_info_ < s.type_info_;
+ }
+};
+
+template<class TypeInfo>
+struct basic_constructor_info<TypeInfo> {
+ TypeInfo type_info_;
+ basic_constructor_info(TypeInfo t) : type_info_(t)
+ {
+ }
+ basic_constructor_info(const basic_constructor_info & s)
+ : type_info_(s.type_info_) {}
+ basic_constructor_info & operator=(basic_constructor_info & s) {
+ type_info_ = s.type_info_;
+ }
+ friend inline bool operator<(const basic_constructor_info & t,
+ const basic_constructor_info & s) {
+ return t.type_info_ < s.type_info_;
+ }
+};
+
+template <class Info = std::string, class ParameterInfo = void,
+ class TypeInfo = reflections::default_type_info>
 class basic_reflection
 {
 public:
- template <class Q, class R, class S>
+ template <class Q, class R, class S, class T>
   friend class reflector;
- BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
                   BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION, _)
- constructor<> get_constructor() {
- TypeInfo t = extensions::type_info_handler<TypeInfo,
- instance (*)()>::get_class_type();
- typename std::map<TypeInfo, FunctionPtr>::iterator it =
+ instance_constructor<> get_constructor() {
+ constructor_info t(reflections::type_info_handler<TypeInfo,
+ instance (*)()>::get_class_type());
+ typename std::map<constructor_info, FunctionPtr>::iterator it =
       constructors_.find(t);
     if (it == constructors_.end()) {
- return constructor<>();
+ return instance_constructor<>();
     } else {
       return reinterpret_cast<instance (*)()>(it->second);
     }
   }
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTION_GET_FUNCTION_FUNCTION, _)
+private:
+ typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
+ typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
+ std::map<constructor_info, FunctionPtr> constructors_;
+ std::map<function_info,
+ std::pair<MemberFunctionPtr, FunctionPtr> > functions_;
+};
+template <class Info, class TypeInfo>
+class basic_reflection<Info, void, TypeInfo>
+{
+public:
+ template <class Q, class R, class S, class T>
+ friend class reflector;
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION, _)
+ instance_constructor<> get_constructor() {
+ constructor_info t(reflections::type_info_handler<TypeInfo,
+ instance (*)()>::get_class_type());
+ typename std::map<constructor_info, FunctionPtr>::iterator it =
+ constructors_.find(t);
+ if (it == constructors_.end()) {
+ return instance_constructor<>();
+ } else {
+ return reinterpret_cast<instance (*)()>(it->second);
+ }
+ }
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
                   BOOST_REFLECTION_REFLECTION_GET_FUNCTION_FUNCTION, _)
 private:
   typedef basic_function_info<Info, TypeInfo> function_info;
- std::map<TypeInfo, FunctionPtr> constructors_;
+ typedef basic_constructor_info<TypeInfo> constructor_info;
+ std::map<constructor_info, FunctionPtr> constructors_;
   std::map<function_info,
     std::pair<MemberFunctionPtr, FunctionPtr> > functions_;
 };
+
 typedef basic_reflection<> reflection;
 }}
-#endif // BOOST_EXTENSION_REFLECTION_HPP
+#endif // BOOST_REFLECTION_REFLECTION_HPP

Modified: sandbox/boost/reflection/reflector.hpp
==============================================================================
--- sandbox/boost/reflection/reflector.hpp (original)
+++ sandbox/boost/reflection/reflector.hpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -7,10 +7,10 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#ifndef BOOST_EXTENSION_REFLECTOR_HPP
-#define BOOST_EXTENSION_REFLECTOR_HPP
+#ifndef BOOST_REFLECTION_REFLECTOR_HPP
+#define BOOST_REFLECTION_REFLECTOR_HPP
 
-#include <boost/extension/common.hpp>
+#include <boost/reflection/common.hpp>
 #include <boost/reflection/factory.hpp>
 #include <boost/reflection/function.hpp>
 #include <boost/reflection/constructor.hpp>
@@ -18,13 +18,14 @@
 #include <boost/reflection/reflection.hpp>
 
 namespace boost {namespace reflections {
-
+
+
 #define BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION(Z, N, _) \
   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)>(&construct<T, ParamFirst \
+ BOOST_PP_ENUM_PARAMS(N, Param)>(&construct_instance<T, ParamFirst \
                                   BOOST_PP_COMMA_IF(N) \
                                   BOOST_PP_ENUM_PARAMS(N, Param)>); \
 }
@@ -33,7 +34,7 @@
           BOOST_PP_ENUM_PARAMS(N, class Param)> \
 void reflect(ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)), \
              Info info) { \
- function_info f(extensions::type_info_handler<TypeInfo, \
+ function_info f(reflections::type_info_handler<TypeInfo, \
                   ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
                     ::get_class_type(), info); \
   ReturnValue (*f2)(void *, MemberFunctionPtr BOOST_PP_COMMA_IF(N) \
@@ -53,17 +54,101 @@
 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>( \
- extensions::type_info_handler \
+ 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))); \
 }
+
+// Versions with included info about parameters
+#define BOOST_REFLECTION_PUSH_PARAMETER_INFO_SINGLE(f, N) \
+(f).parameter_info_.push_back(BOOST_PP_CAT(i, N));
+
+#define BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N) \
+BOOST_PP_IF(N, BOOST_REFLECTION_PUSH_PARAMETER_INFO_SINGLE(f, BOOST_PP_DEC(N)),) \
+BOOST_PP_IF(BOOST_PP_DEC(N), BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, BOOST_PP_DEC(N)),)
+
+#define BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_INFO_FUNCTION(Z, N, _) \
+ 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)>(&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)); \
+}
+#define BOOST_REFLECTION_REFLECTOR_REFLECT_INFO_FUNCTION(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+void reflect(ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)), \
+ Info info, ParameterInfo i_return BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, ParameterInfo i)) { \
+ function_info f(reflections::type_info_handler<TypeInfo, \
+ ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(), info); \
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N); \
+ f.parameter_info_.push_back(i_return); \
+ ReturnValue (*f2)(void *, MemberFunctionPtr BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)) = \
+ &call_member<T, ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>; \
+ std::pair<MemberFunctionPtr, FunctionPtr> \
+ in_pair(reinterpret_cast<MemberFunctionPtr>(func), \
+ reinterpret_cast<FunctionPtr>(f2)); \
+ std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> > \
+ out_pair(f, in_pair); \
+ reflection_->functions_.insert(out_pair); \
+}
+#define BOOST_REFLECTION_REFLECTOR_REFLECT_INFO_VOID_RET_FUNCTION(Z, N, _) \
+template <class ParamFirst BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, class Param)> \
+void reflect(void (T::*func)(ParamFirst p_first BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param)), \
+ Info info, ParameterInfo i_first BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, ParameterInfo i)) { \
+ function_info f(reflections::type_info_handler<TypeInfo, \
+ void (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(), info); \
+ f.parameter_info_.push_back(i_first); \
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N); \
+ void (*f2)(void *, MemberFunctionPtr BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)) = \
+ &call_member<T, void BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>; \
+ std::pair<MemberFunctionPtr, FunctionPtr> \
+ in_pair(reinterpret_cast<MemberFunctionPtr>(func), \
+ reinterpret_cast<FunctionPtr>(f2)); \
+ std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> > \
+ out_pair(f, in_pair); \
+ reflection_->functions_.insert(out_pair); \
+}
+#define BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_INFO_FUNCTION(Z, N, _) \
+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)) \
+ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, ParameterInfo i)) { \
+ 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>(func))); \
+}
+
+
+
+// Free functions
 #define BOOST_REFLECTION_REFLECTOR_CONSTRUCT_FUNCTION(Z, N, _) \
 template <class T BOOST_PP_COMMA_IF(N) \
           BOOST_PP_ENUM_PARAMS(N, class Param)> \
-instance construct(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
- return instance(static_cast<void*>(new T(BOOST_PP_ENUM_PARAMS(N, p))), \
+instance construct_instance(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return instance(static_cast<void*>( \
+ construct<T BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param)> \
+ (BOOST_PP_ENUM_PARAMS(N, p))), \
                   &destruct<T>); \
 }
 #define BOOST_REFLECTION_REFLECTOR_CALL_MEMBER_FUNCTION(Z, N, _) \
@@ -81,34 +166,36 @@
 }
 template <class T>
 void destruct(void * val) {
- delete static_cast<T*>(val);
+ delete static_cast<T*>(val);
 }
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
                 BOOST_REFLECTION_REFLECTOR_CONSTRUCT_FUNCTION, _)
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
                 BOOST_REFLECTION_REFLECTOR_CALL_MEMBER_FUNCTION, _)
 
 
 
-template <class T, class Info = std::string,
- class TypeInfo = extensions::default_type_info>
+template <class T, class Info = std::string, class ParameterInfo = void,
+ class TypeInfo = reflections::default_type_info>
 class reflector
 {
 public:
   // Initialize with a pointer to the reflection
   // this reflector will be reflecting into
- reflector(basic_reflection<Info, TypeInfo> * current_reflection)
+ reflector(basic_reflection<Info, ParameterInfo, TypeInfo>
+ * current_reflection)
   : reflection_(current_reflection) {
   }
- typedef basic_function_info<Info, TypeInfo> function_info;
+ typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
+ typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
   void reflect_constructor() {
- add_constructor(&construct<T>);
+ add_constructor(&construct_instance<T>);
   }
- BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
- BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION, _)
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_INFO_FUNCTION, _)
  /* template <class ReturnValue>
   void reflect(ReturnValue (T::*func)(), Info info) {
- function_info f(extensions::type_info_handler<TypeInfo,
+ function_info f(reflections::type_info_handler<TypeInfo,
                     ReturnValue (*)()>::get_class_type(), info);
     ReturnValue (*f2)(void *, MemberFunctionPtr) = &call_member<ReturnValue>;
     std::pair<MemberFunctionPtr, FunctionPtr>
@@ -118,18 +205,73 @@
       p2(f, p);
     reflection_->functions_.insert(p2);
   }*/
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_REFLECTOR_REFLECT_FUNCTION, _)
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_INFO_FUNCTION, _)
+ void reflect(void (T::*func)(), Info info) {
+ function_info f(reflections::type_info_handler<TypeInfo,
+ void (*)()>::get_class_type(), info);
+ void (*f2)(void *, MemberFunctionPtr) = &call_member<T, void>; \
+ std::pair<MemberFunctionPtr, FunctionPtr>
+ in_pair(reinterpret_cast<MemberFunctionPtr>(func),
+ reinterpret_cast<FunctionPtr>(f2));
+ std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> >
+ out_pair(f, in_pair);
+ reflection_->functions_.insert(out_pair);
+ }
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_INFO_VOID_RET_FUNCTION, _)
 private:
   void add_constructor(instance (*func)()) {
     reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
- extensions::type_info_handler<TypeInfo, instance (*)()>::get_class_type(),
+ reflections::type_info_handler<TypeInfo, instance (*)()>::get_class_type(),
       reinterpret_cast<FunctionPtr>(func)));
   }
- BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
- BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_FUNCTION, _)
- basic_reflection<Info, TypeInfo> * reflection_;
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_INFO_FUNCTION, _)
+ basic_reflection<Info, ParameterInfo, TypeInfo> * reflection_;
 };
+
+template <class T, class Info, class TypeInfo>
+class reflector<T, Info, void, TypeInfo>
+{
+public:
+ // Initialize with a pointer to the reflection
+ // this reflector will be reflecting into
+ reflector(basic_reflection<Info, void, TypeInfo> * current_reflection)
+ : reflection_(current_reflection) {
+ }
+ typedef basic_function_info<Info, TypeInfo> function_info;
+ typedef basic_constructor_info<Info, TypeInfo> constructor_info;
+ void reflect_constructor() {
+ add_constructor(&construct_instance<T>);
+ }
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION, _)
+ /* template <class ReturnValue>
+ void reflect(ReturnValue (T::*func)(), Info info) {
+ function_info f(reflections::type_info_handler<TypeInfo,
+ ReturnValue (*)()>::get_class_type(), info);
+ ReturnValue (*f2)(void *, MemberFunctionPtr) = &call_member<ReturnValue>;
+ std::pair<MemberFunctionPtr, FunctionPtr>
+ p(reinterpret_cast<MemberFunctionPtr>(func),
+ reinterpret_cast<FunctionPtr>(f2));
+ std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> >
+ p2(f, p);
+ reflection_->functions_.insert(p2);
+ }*/
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_FUNCTION, _)
+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)));
+ }
+ BOOST_PP_REPEAT(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_FUNCTION, _)
+ basic_reflection<Info, void, TypeInfo> * reflection_;
+};
+
 #undef BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION
 }}
 #endif

Modified: sandbox/libs/reflection/examples/extension/extension.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/extension.cpp (original)
+++ sandbox/libs/reflection/examples/extension/extension.cpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -16,6 +16,7 @@
 #include <boost/extension/shared_library.hpp>
 #include <boost/extension/convenience.hpp>
 #include <boost/reflection/reflection.hpp>
+#include <boost/reflection/reflector.hpp>
 #include <iostream>
 
 #if defined(MSC_VER) || defined(WIN32)
@@ -26,36 +27,39 @@
 
 int main(void)
 {
-
- std::map<std::string, boost::reflections::reflection> reflection_map;
+ using boost::reflections::instance;
+ using boost::reflections::instance_constructor;
+ using boost::reflections::reflection;
+
+ std::map<std::string, reflection> reflection_map;
   boost::extensions::shared_library lib
   ((std::string(BOOST_EXTENSION_DIR_START) + "libcar_lib.extension").c_str());
   lib.open();
   lib.get<void, std::map<std::string,
- boost::reflections::reflection> &>
+ reflection> &>
     ("extension_export_car")(reflection_map);
   if (reflection_map.size() != size_t(2)) {
     std::cout << "Could not load reflections!";
     return 1;
   }
   // Let's create the reflection and add the methods
- boost::reflections::reflection & first_reflection =
+ reflection & first_reflection =
     reflection_map["suv"];
- boost::reflections::reflection & second_reflection =
+ reflection & second_reflection =
     reflection_map["compact"];
   
- boost::reflections::constructor<const char *> first_constructor =
+ instance_constructor<const char *> first_constructor =
     first_reflection.get_constructor<const char *>();
- boost::reflections::instance first_instance =
+ instance first_instance =
     first_constructor("First Instance");
   boost::reflections::function<const char *> first_function =
     first_reflection.get_function<const char *>("get_type");
   std::cout << "First reflection: " << first_function(first_instance)
             << std::endl;
   
- boost::reflections::constructor<const char *> second_constructor =
+ instance_constructor<const char *> second_constructor =
     second_reflection.get_constructor<const char *>();
- boost::reflections::instance second_instance =
+ instance second_instance =
     second_constructor("Second Instance");
   boost::reflections::function<const char *> second_function =
     second_reflection.get_function<const char *>("get_type");

Modified: sandbox/libs/reflection/test/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/test/Jamfile.v2 (original)
+++ sandbox/libs/reflection/test/Jamfile.v2 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -29,5 +29,7 @@
   [ run single_param_test.cpp ]
   [ run shared_library_test.cpp ]
   [ run multi_param_test.cpp ]
+ [ run basic_static_test.cpp ]
+ [ run parameter_info_test.cpp ]
 :
 ;

Modified: sandbox/libs/reflection/test/basic_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/basic_test.cpp (original)
+++ sandbox/libs/reflection/test/basic_test.cpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -13,8 +13,6 @@
 #include <string>
 #include <iostream>
 
-#define BOOST_EXTENSION_USE_PP 1
-
 #define BOOST_TEST_MAIN
 #define BOOST_TEST_DYN_LINK 1
 #include <boost/test/unit_test.hpp>
@@ -22,8 +20,10 @@
 
 class car {
 public:
- int start() {
- return 3;
+ car(int year) {
+ }
+ int start(int speed) {
+ return 3 + speed;
   }
 };
 using namespace boost::reflections;
@@ -31,24 +31,24 @@
 {
   reflection car_reflection;
   reflector<car> car_reflector(&car_reflection);
- car_reflector.reflect_constructor();
+ car_reflector.reflect_constructor<int>();
   car_reflector.reflect<int>(&car::start, "start");
 // Check for argless constructor
- BOOST_CHECK(car_reflection.get_constructor().valid());
+ BOOST_CHECK(car_reflection.get_constructor<int>().valid());
   instance car_instance =
- car_reflection.get_constructor().call();
- BOOST_CHECK(car_reflection.get_function<int>("start").valid());
+ car_reflection.get_constructor<int>().call(4);
+ bool start_valid = car_reflection.get_function<int, int>("start").valid();
+ BOOST_CHECK(start_valid);
   // Make sure it doesn't have this undeclared method
   BOOST_CHECK(!car_reflection.get_function<int>("stop").valid());
- BOOST_CHECK_EQUAL
- (car_reflection.get_function<int>("start").call(car_instance), 3);
- function<int> f =
- car_reflection.get_function<int>("start");
- BOOST_CHECK_EQUAL(f(car_instance), 3);
+ function<int, int> f =
+ car_reflection.get_function<int, int>("start");
+ int result = f(car_instance, 86);
+ BOOST_CHECK_EQUAL(result, 89);
 }
 class porsche : protected car {
 public:
- porsche(int year) : year_(year) {
+ porsche(int year) : car(year), year_(year) {
   }
   int get_year() {
     return year_;

Modified: sandbox/libs/reflection/test/shared_library_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/shared_library_test.cpp (original)
+++ sandbox/libs/reflection/test/shared_library_test.cpp 2008-02-07 19:18:55 EST (Thu, 07 Feb 2008)
@@ -40,7 +40,7 @@
   boost::reflections::reflection & second_reflection =
     reflection_map["compact"];
  
- boost::reflections::constructor<const char *> first_constructor =
+ boost::reflections::instance_constructor<const char *> first_constructor =
     first_reflection.get_constructor<const char *>();
   boost::reflections::instance first_instance =
     first_constructor("First Instance");
@@ -48,7 +48,7 @@
     first_reflection.get_function<const char *>("get_type");
   BOOST_CHECK_EQUAL(first_function(first_instance), "It's an SUV.");
   
- boost::reflections::constructor<const char *> second_constructor =
+ boost::reflections::instance_constructor<const char *> second_constructor =
     second_reflection.get_constructor<const char *>();
   boost::reflections::instance second_instance =
     second_constructor("Second Instance");


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