|
Boost-Commit : |
From: oryol_at_[hidden]
Date: 2008-04-10 01:28:21
Author: jeremypack
Date: 2008-04-10 01:28:20 EDT (Thu, 10 Apr 2008)
New Revision: 44143
URL: http://svn.boost.org/trac/boost/changeset/44143
Log:
Begin simplification of reflector.hpp. Split it up into 4 separate files.
Still to do:
Comments, remove extraneous code.
Added:
sandbox/boost/reflection/impl/reflector_free_functions.hpp (contents, props changed)
sandbox/boost/reflection/impl/reflector_functions.hpp (contents, props changed)
sandbox/boost/reflection/impl/reflector_parameter_functions.hpp (contents, props changed)
Text files modified:
sandbox/boost/reflection/reflector.hpp | 211 +++------------------------------------
1 files changed, 18 insertions(+), 193 deletions(-)
Added: sandbox/boost/reflection/impl/reflector_free_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/reflection/impl/reflector_free_functions.hpp 2008-04-10 01:28:20 EDT (Thu, 10 Apr 2008)
@@ -0,0 +1,48 @@
+/*
+ * Copyright Jeremy Pack 2007
+ * 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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+
+
+// No header guard - this file is intended to be included multiple times.
+
+# define N BOOST_PP_ITERATION()
+// Free functions. These should only be used internally by the
+// reflector class to generate function pointers.
+//
+// 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)) {
+ // An instance is similar to boost::any. Initialize it with
+ // a void ptr.
+ 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>);
+}
+
+// This auxiliary function is used to call a member function on
+// a given instance, assuming the instance is of type T.
+template <class T, class ReturnValue BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, class Param)>
+static ReturnValue call_member(void * val,
+ MemberFunctionPtr member_function
+ BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) {
+ // Convert to a T*.
+ T * actual = static_cast<T*>(val);
+
+ // Convert the MemberFunctionPtr to the requested type.
+ ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)) =
+ reinterpret_cast<ReturnValue (T::*)(BOOST_PP_ENUM_PARAMS(N, Param))>
+ (member_function);
+
+ // Call the function and return the result.
+ return (actual->*func)(BOOST_PP_ENUM_PARAMS(N, p));
+}
+#undef N
\ No newline at end of file
Added: sandbox/boost/reflection/impl/reflector_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/reflection/impl/reflector_functions.hpp 2008-04-10 01:28:20 EDT (Thu, 10 Apr 2008)
@@ -0,0 +1,54 @@
+/*
+ * Copyright Jeremy Pack 2007
+ * 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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+
+
+// No header guard - this file is intended to be included multiple times.
+
+# define N BOOST_PP_ITERATION()
+
+
+ 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)>);
+}
+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) {
+ 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)
+ BOOST_PP_ENUM_PARAMS(N, Param)) =
+ &impl::call_member<T, ReturnValue BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param)>;
+ 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);
+}
+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
Added: sandbox/boost/reflection/impl/reflector_parameter_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/reflection/impl/reflector_parameter_functions.hpp 2008-04-10 01:28:20 EDT (Thu, 10 Apr 2008)
@@ -0,0 +1,98 @@
+/*
+ * Copyright Jeremy Pack 2007
+ * 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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+
+
+// No header guard - this file is intended to be included multiple times.
+
+# define N BOOST_PP_ITERATION()
+
+// Versions with included info about parameters
+// An auxiliary macro to add a single parameter to a list
+// of parameter information.
+#define BOOST_REFLECTION_PUSH_PARAMETER_INFO_SINGLE(f, N) \
+(f).parameter_info_.push_back(BOOST_PP_CAT(i, N));
+
+// An auxiliary macro to add a series of parameters to a list
+// of parameter information.
+#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)),)
+
+// Reflect a constructor with the given signature.
+public:
+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));
+}
+
+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)) =
+ &impl::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);
+}
+
+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)) =
+ &impl::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);
+}
+
+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)));
+}
+
+#undef N
\ No newline at end of file
Modified: sandbox/boost/reflection/reflector.hpp
==============================================================================
--- sandbox/boost/reflection/reflector.hpp (original)
+++ sandbox/boost/reflection/reflector.hpp 2008-04-10 01:28:20 EDT (Thu, 10 Apr 2008)
@@ -10,6 +10,7 @@
#ifndef BOOST_REFLECTION_REFLECTOR_HPP
#define BOOST_REFLECTION_REFLECTOR_HPP
+#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/reflection/common.hpp>
#include <boost/reflection/factory.hpp>
#include <boost/reflection/function.hpp>
@@ -18,163 +19,19 @@
#include <boost/reflection/reflection.hpp>
namespace boost {namespace reflections {
-
using extensions::type_info_handler;
-
-#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_instance<T, ParamFirst \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param)>); \
-}
-#define BOOST_REFLECTION_REFLECTOR_REFLECT_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) { \
- 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) \
- 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> \
- p(reinterpret_cast<MemberFunctionPtr>(func), \
- reinterpret_cast<FunctionPtr>(f2)); \
- std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> > \
- p2(f, p); \
- reflection_->functions_.insert(p2); \
-}
-#define BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_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))) { \
- 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))); \
-}
-
-// 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_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, _) \
-template <class T, class ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param)> \
-static ReturnValue call_member(void * val, \
- MemberFunctionPtr member_function \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
- T * actual = static_cast<T*>(val); \
- ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)) = \
- reinterpret_cast<ReturnValue (T::*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
- (member_function); \
- return (actual->*func)(BOOST_PP_ENUM_PARAMS(N, p)); \
-}
+namespace impl {
template <class T>
void destruct(void * val) {
delete static_cast<T*>(val);
}
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_REFLECTOR_CONSTRUCT_FUNCTION, _)
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_REFLECTOR_CALL_MEMBER_FUNCTION, _)
+#define BOOST_PP_ITERATION_LIMITS (0, \
+ BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
+#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflector_free_functions.hpp>
+#include BOOST_PP_ITERATE()
+} // namespace impl
template <class T, class Info = std::string, class ParameterInfo = void,
class TypeInfo = extensions::default_type_info>
@@ -190,28 +47,16 @@
typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
void reflect_constructor() {
- add_constructor(&construct_instance<T>);
+ add_constructor(&impl::construct_instance<T>);
}
- 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(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_INFO_FUNCTION, _)
+#define BOOST_PP_ITERATION_LIMITS (0, \
+ BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
+#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflector_parameter_functions.hpp>
+#include BOOST_PP_ITERATE()
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>; \
+ void (*f2)(void *, MemberFunctionPtr) = &impl::call_member<T, void>; \
std::pair<MemberFunctionPtr, FunctionPtr>
in_pair(reinterpret_cast<MemberFunctionPtr>(func),
reinterpret_cast<FunctionPtr>(f2));
@@ -219,16 +64,12 @@
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>(
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_INFO_FUNCTION, _)
basic_reflection<Info, ParameterInfo, TypeInfo> * reflection_;
};
@@ -244,35 +85,19 @@
typedef basic_function_info<Info, TypeInfo> function_info;
typedef basic_constructor_info<Info, TypeInfo> constructor_info;
void reflect_constructor() {
- add_constructor(&construct_instance<T>);
+ add_constructor(&impl::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, _)
+#define BOOST_PP_ITERATION_LIMITS (0, \
+ BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
+#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflector_functions.hpp>
+#include BOOST_PP_ITERATE()
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
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