|
Boost-Commit : |
From: oryol_at_[hidden]
Date: 2008-05-02 20:18:54
Author: jeremypack
Date: 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
New Revision: 45047
URL: http://svn.boost.org/trac/boost/changeset/45047
Log:
Various fixes -
Fix a minor bug in the previous change, concerning template parameters.
Simplify a number of files - reduce duplication.
Fix copyrights.
Removed:
sandbox/boost/reflection/static_reflection.hpp
sandbox/libs/reflection/test/basic_static_test.cpp
Text files modified:
sandbox/boost/extension/common.hpp | 2
sandbox/boost/extension/convenience.hpp | 2
sandbox/boost/extension/extension.hpp | 2
sandbox/boost/extension/factory.hpp | 2
sandbox/boost/extension/factory_map.hpp | 2
sandbox/boost/extension/filesystem.hpp | 2
sandbox/boost/extension/functor.hpp | 2
sandbox/boost/extension/impl/factory_map.hpp | 2
sandbox/boost/extension/impl/function.hpp | 2
sandbox/boost/extension/impl/shared_library.hpp | 2
sandbox/boost/extension/impl/typeinfo.hpp | 2
sandbox/boost/extension/shared_library.hpp | 2
sandbox/boost/reflection/adapter.hpp | 2
sandbox/boost/reflection/common.hpp | 2
sandbox/boost/reflection/constructor.hpp | 2
sandbox/boost/reflection/constructor_info.hpp | 42 +------
sandbox/boost/reflection/data.hpp | 2
sandbox/boost/reflection/data_info.hpp | 2
sandbox/boost/reflection/factory.hpp | 2
sandbox/boost/reflection/function.hpp | 2
sandbox/boost/reflection/function_info.hpp | 57 +-------
sandbox/boost/reflection/generic_constructor.hpp | 2
sandbox/boost/reflection/impl/constructor.hpp | 2
sandbox/boost/reflection/impl/function.hpp | 2
sandbox/boost/reflection/impl/reflection.hpp | 197 ++++++++++++++++++++++----------
sandbox/boost/reflection/impl/reflector_free_functions.hpp | 2
sandbox/boost/reflection/impl/reflector_functions.hpp | 104 +++++++++++++++-
sandbox/boost/reflection/impl/reflector_parameter_functions.hpp | 2
sandbox/boost/reflection/instance.hpp | 2
sandbox/boost/reflection/parameter.hpp | 2
sandbox/boost/reflection/parameter_map.hpp | 2
sandbox/boost/reflection/reflection.hpp | 239 ++-------------------------------------
sandbox/libs/reflection/doc/extension.qbk | 2
sandbox/libs/reflection/examples/extension/car_lib.cpp | 2
sandbox/libs/reflection/examples/extension/extension.cpp | 2
sandbox/libs/reflection/test/Jamfile.v2 | 3
sandbox/libs/reflection/test/basic_test.cpp | 8 +
sandbox/libs/reflection/test/data_test.cpp | 2
sandbox/libs/reflection/test/multi_param_test.cpp | 2
sandbox/libs/reflection/test/parameter_info_test.cpp | 2
sandbox/libs/reflection/test/parameter_map_test.cpp | 2
sandbox/libs/reflection/test/parameters_test.cpp | 2
sandbox/libs/reflection/test/shared_library_test.cpp | 2
sandbox/libs/reflection/test/single_param_test.cpp | 2
44 files changed, 302 insertions(+), 422 deletions(-)
Modified: sandbox/boost/extension/common.hpp
==============================================================================
--- sandbox/boost/extension/common.hpp (original)
+++ sandbox/boost/extension/common.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / common:
* common include files
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/convenience.hpp
==============================================================================
--- sandbox/boost/extension/convenience.hpp (original)
+++ sandbox/boost/extension/convenience.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -3,7 +3,7 @@
* for now only one to load a library and register it in the factory
* map.
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/extension.hpp
==============================================================================
--- sandbox/boost/extension/extension.hpp (original)
+++ sandbox/boost/extension/extension.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / main header:
* main header for extensions
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/factory.hpp
==============================================================================
--- sandbox/boost/extension/factory.hpp (original)
+++ sandbox/boost/extension/factory.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / factory:
* factory to register the implementations and create them
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/factory_map.hpp
==============================================================================
--- sandbox/boost/extension/factory_map.hpp (original)
+++ sandbox/boost/extension/factory_map.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / factory map:
* map of factories (for the implementations)
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/filesystem.hpp
==============================================================================
--- sandbox/boost/extension/filesystem.hpp (original)
+++ sandbox/boost/extension/filesystem.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / filesystem functions:
* functions to navigate folders/directories and get the libraries
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/functor.hpp
==============================================================================
--- sandbox/boost/extension/functor.hpp (original)
+++ sandbox/boost/extension/functor.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -3,7 +3,7 @@
* functor used as the exported function of the libraries (the one that
* registers the implementations at library loading time)
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/impl/factory_map.hpp
==============================================================================
--- sandbox/boost/extension/impl/factory_map.hpp (original)
+++ sandbox/boost/extension/impl/factory_map.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/impl/function.hpp
==============================================================================
--- sandbox/boost/extension/impl/function.hpp (original)
+++ sandbox/boost/extension/impl/function.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/impl/shared_library.hpp
==============================================================================
--- sandbox/boost/extension/impl/shared_library.hpp (original)
+++ sandbox/boost/extension/impl/shared_library.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Extension / implementation header for Boost.PreProcessor
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/impl/typeinfo.hpp
==============================================================================
--- sandbox/boost/extension/impl/typeinfo.hpp (original)
+++ sandbox/boost/extension/impl/typeinfo.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / typeinfo:
* implementations name management with RTTI
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/extension/shared_library.hpp
==============================================================================
--- sandbox/boost/extension/shared_library.hpp (original)
+++ sandbox/boost/extension/shared_library.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Extension / shared_library:
* functions for shared_library loading
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/adapter.hpp
==============================================================================
--- sandbox/boost/reflection/adapter.hpp (original)
+++ sandbox/boost/reflection/adapter.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / adapter (call functions using a parameter map)
*
- * (C) Copyright Mariano G. Consoni 2007
+ * (C) Copyright Mariano G. Consoni 2008
* 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)
Modified: sandbox/boost/reflection/common.hpp
==============================================================================
--- sandbox/boost/reflection/common.hpp (original)
+++ sandbox/boost/reflection/common.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -2,7 +2,7 @@
* Boost.Reflection / common:
* common include files
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/constructor.hpp
==============================================================================
--- sandbox/boost/reflection/constructor.hpp (original)
+++ sandbox/boost/reflection/constructor.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/constructor_info.hpp
==============================================================================
--- sandbox/boost/reflection/constructor_info.hpp (original)
+++ sandbox/boost/reflection/constructor_info.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / constructor information header
*
- * (C) Copyright Mariano G. Consoni and Jeremy Pack 2007
+ * (C) Copyright Mariano G. Consoni and Jeremy Pack 2008
* 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)
@@ -9,54 +9,27 @@
* See http://www.boost.org/ for latest version.
*/
-#ifndef BOOST_REFLECTION_CONSTRUCTOR_INFO_HPP
-#define BOOST_REFLECTION_CONSTRUCTOR_INFO_HPP
-
-#include <vector>
-
-namespace boost {
-namespace reflections {
+// No header guards, as this header is intended to be included multiple times.
// The basic_constructor_info class is used as a key in the map
// of constructors available for the current reflection.
// There are two types - those with ParameterInfo defined, and
// those without.
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
template<class TypeInfo, class ParameterInfo = void>
struct basic_constructor_info {
- // The type of the function pointer used to construct
- // the object this constructor_info is for.
- TypeInfo type_info_;
-
// A description for each parameter of the function.
// If ParameterInfo=void, this does not appear.
std::vector<ParameterInfo> parameter_info_;
-
- // Constructors.
- explicit 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_;
- }
-
- // Less than operator - for maps.
- friend inline bool operator<(const basic_constructor_info & t,
- const basic_constructor_info & s) {
- return t.type_info_ < s.type_info_;
- }
-};
-
+#else
template<class TypeInfo>
struct basic_constructor_info<TypeInfo> {
+#endif
// The type of the function pointer used to construct
// the object this constructor_info is for.
TypeInfo type_info_;
- // Constructors
+ // Constructors.
explicit basic_constructor_info(TypeInfo t) : type_info_(t) {
}
@@ -74,6 +47,3 @@
return t.type_info_ < s.type_info_;
}
};
-} // namespace reflections
-} // namespace boost
-#endif // BOOST_REFLECTION_CONSTRUCTOR_INFO_HPP
Modified: sandbox/boost/reflection/data.hpp
==============================================================================
--- sandbox/boost/reflection/data.hpp (original)
+++ sandbox/boost/reflection/data.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/data_info.hpp
==============================================================================
--- sandbox/boost/reflection/data_info.hpp (original)
+++ sandbox/boost/reflection/data_info.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / data info
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/factory.hpp
==============================================================================
--- sandbox/boost/reflection/factory.hpp (original)
+++ sandbox/boost/reflection/factory.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/function.hpp
==============================================================================
--- sandbox/boost/reflection/function.hpp (original)
+++ sandbox/boost/reflection/function.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/function_info.hpp
==============================================================================
--- sandbox/boost/reflection/function_info.hpp (original)
+++ sandbox/boost/reflection/function_info.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / main header
*
- * (C) Copyright Mariano G. Consoni and Jeremy Pack 2007
+ * (C) Copyright Mariano G. Consoni and Jeremy Pack 2008
* 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)
@@ -9,66 +9,35 @@
* See http://www.boost.org/ for latest version.
*/
-#ifndef BOOST_REFLECTION_FUNCTION_INFO_HPP
-#define BOOST_REFLECTION_FUNCTION_INFO_HPP
-
-#include <vector>
-
-namespace boost {
-namespace reflections {
+// No header guard, as this is intended to be included multiple times
+// by reflection.hpp.
// The basic_function_info class is used as a key in the map
// of functions available for the current reflection.
// There are two types - those with ParameterInfo defined, and
// those without.
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
template<class Info, class TypeInfo, class ParameterInfo = void>
struct basic_function_info {
- // The type of the function pointer in the map.
- TypeInfo type_info_;
- // A description of the function pointer.
- Info info_;
-
- bool has_return_;
-
// A description for each parameter of the function.
// If ParameterInfo=void, this does not appear.
std::vector<ParameterInfo> parameter_info_;
-
- // Constructors
- basic_function_info(TypeInfo t, Info i, bool has_return = true)
- : type_info_(t), info_(i), has_return_(has_return) {
- }
-
- 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_;
- }
-
- // Less-than operator - for maps.
- 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_);
- }
-};
-
+#else
// Same as the above, but without ParameterInfo.
template<class Info, class TypeInfo>
struct basic_function_info<Info, TypeInfo> {
+#endif
// The type of the function pointer in the map.
TypeInfo type_info_;
// A description of the function pointer.
Info info_;
+ bool has_return_;
+
- // Constructors.
- basic_function_info(TypeInfo t, Info i)
- : type_info_(t), info_(i) {
+ // Constructors
+ basic_function_info(TypeInfo t, Info i, bool has_return = true)
+ : type_info_(t), info_(i), has_return_(has_return) {
}
basic_function_info(const basic_function_info & s)
@@ -88,7 +57,3 @@
t.info_ < s.info_);
}
};
-
-} // namespace reflections
-} // namespace boost
-#endif // BOOST_REFLECTION_FUNCTION_INFO_HPP
Modified: sandbox/boost/reflection/generic_constructor.hpp
==============================================================================
--- sandbox/boost/reflection/generic_constructor.hpp (original)
+++ sandbox/boost/reflection/generic_constructor.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/impl/constructor.hpp
==============================================================================
--- sandbox/boost/reflection/impl/constructor.hpp (original)
+++ sandbox/boost/reflection/impl/constructor.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/impl/function.hpp
==============================================================================
--- sandbox/boost/reflection/impl/function.hpp (original)
+++ sandbox/boost/reflection/impl/function.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/impl/reflection.hpp
==============================================================================
--- sandbox/boost/reflection/impl/reflection.hpp (original)
+++ sandbox/boost/reflection/impl/reflection.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,76 +1,147 @@
/*
- * Boost.Reflection / implementation header for Boost.PreProcessor
+ * Boost.Reflection / main header
*
- * (C) Copyright Mariano G. Consoni and Jeremy Pack 2007
+ * (C) Copyright Mariano G. Consoni and Jeremy Pack 2008
* 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.
*/
-# define N BOOST_PP_ITERATION()
-// No ifndef headers - this is meant to be included multiple times.
-// Search for a constructor of the given type. instance_constructor
-// has a method to determine if a suitable constructor was found.
-template <class ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, class Param)>
-instance_constructor<ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)> get_constructor() {
- // Create a constructor_info structure to use for looking up
- // a constructor in the constructor map. Initialize it with the
- // function type requested.
- constructor_info ctr_info(reflections::type_info_handler<TypeInfo,
- instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param))>
- ::get_class_type());
-
- // Determine whether or not such a constructor exists.
- typename std::map<constructor_info, impl::FunctionPtr>::iterator it =
- constructors_.find(ctr_info);
-
- if (it == constructors_.end()) {
- // If none exists, return an empty instance_constructor.
- return instance_constructor<ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>();
- } else {
- // reinterpret_cast is safe, because we looked it up by its type.
- return reinterpret_cast<instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param))>
- (it->second);
+// No header guard, as this file is intended to be included multiple times.
+
+// By default, ParameterInfo is not used. Note that using adapters
+// requires ParameterInfo.
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+template <class Info = std::string, class ParameterInfo = void,
+ class TypeInfo = extensions::default_type_info>
+class basic_reflection {
+#else
+template <class Info, class TypeInfo>
+class basic_reflection<Info, void, TypeInfo> {
+#endif
+public:
+#ifndef BOOST_REFLECTION_WITH_PARAMETER_INFO
+typedef void ParameterInfo;
+#endif
+ // A reflector is used to add functions and constructors to
+ // a reflected class.
+
+ template <class T>
+ class reflector
+ {
+ public:
+ // Initialize with a pointer to the reflection
+ // this reflector will be reflecting into
+ reflector(basic_reflection<Info, ParameterInfo, TypeInfo>*
+ current_reflection)
+ : reflection_(current_reflection) {
+ }
+
+ // Typedefs for the specific instantiations used by this class.
+ typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
+ typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
+
+ reflector& constructor() {
+ instance (*ctor_func)()(&impl::construct_instance<T>);
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, impl::FunctionPtr>(
+ reflections::type_info_handler<TypeInfo, instance (*)()>
+ ::get_class_type(), reinterpret_cast<impl::FunctionPtr>(ctor_func)));
+ return *this;
+ }
+
+ template <class Data>
+ reflector& data(Data T::*data_ptr, Info info) {
+ data_info f(reflections::type_info_handler<TypeInfo, Data>
+ ::get_class_type(), info);
+ Data& (*func)(void*, impl::MemberPtr) = &impl::get_data_from_ptr<T, Data>;
+ std::pair<impl::MemberPtr, impl::FunctionPtr>
+ p(reinterpret_cast<impl::MemberPtr>(data_ptr),
+ reinterpret_cast<impl::FunctionPtr>(func));
+ std::pair<data_info, std::pair<impl::MemberPtr, impl::FunctionPtr> >
+ p2(f, p);
+ reflection_->data_.insert(p2);
+ return *this;
+ }
+ #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()
+ reflector& function(void (T::*func)(), Info info) {
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+ function_info f(reflections::type_info_handler<TypeInfo,
+ void (*)()>::get_class_type(), info, false);
+#else
+ function_info f(reflections::type_info_handler<TypeInfo,
+ void (*)()>::get_class_type(), info);
+#endif
+ void (*f2)(void *, impl::MemberFunctionPtr) = &impl::call_member<T, void>;
+ std::pair<impl::MemberFunctionPtr, impl::FunctionPtr>
+ in_pair(reinterpret_cast<impl::MemberFunctionPtr>(func),
+ reinterpret_cast<impl::FunctionPtr>(f2));
+ std::pair<function_info,
+ std::pair<impl::MemberFunctionPtr,
+ impl::FunctionPtr> >
+ out_pair(f, in_pair);
+ reflection_->functions_.insert(out_pair);
+ return *this;
+ }
+ private:
+ basic_reflection<Info, ParameterInfo, TypeInfo>* reflection_;
+ };
+#define BOOST_PP_ITERATION_LIMITS (0, \
+ BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
+#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflection_functions.hpp>
+#include BOOST_PP_ITERATE()
+ instance_constructor<> get_constructor() {
+ constructor_info t(reflections::type_info_handler<TypeInfo,
+ instance (*)()>::get_class_type());
+ typename std::map<constructor_info, impl::FunctionPtr>::iterator it =
+ constructors_.find(t);
+ if (it == constructors_.end()) {
+ return instance_constructor<>();
+ } else {
+ return reinterpret_cast<instance (*)()>(it->second);
+ }
}
-}
-// Search for a member function matching the given signature and Info.
-template <class ReturnValue BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, class Param)>
-function<ReturnValue BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)> get_function(Info info) {
- // Construct a function_info structure to look up the function in the map.
- // has_return is set to true here because it makes no difference when doing
- // a lookup in the map.
- function_info func_info(reflections::type_info_handler<TypeInfo,
- ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))>
- ::get_class_type(), info);
-
- // Look up the function.
- typename std::map<function_info,
- std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> >::iterator it =
- functions_.find(func_info);
-
- if (it == functions_.end()) {
- // If it does not exist, return an empty function object.
- return function<ReturnValue BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>();
- } else {
- return function<ReturnValue BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param)>
- // reinterpret_cast is safe, because we looked it up by its type.
- (reinterpret_cast<ReturnValue (*)(void *, impl::MemberFunctionPtr
- BOOST_PP_COMMA_IF(N)
- BOOST_PP_ENUM_PARAMS(N, Param))>
- (it->second.second), it->second.first);
+ template <class Data>
+ data<Data> get_data(Info info) {
+ // Construct a data_info structure to look up the function in the map.
+ data_info d(reflections::type_info_handler<TypeInfo, Data>
+ ::get_class_type(), info);
+
+ // Look up the function.
+ typename std::map<data_info,
+ std::pair<impl::MemberPtr, impl::FunctionPtr> >::iterator it =
+ data_.find(d);
+
+ if (it == data_.end()) {
+ // If it does not exist, return an empty function object.
+ return data<Data>();
+ } else {
+ return data<Data>
+ // reinterpret_cast is safe, because we looked it up by its type.
+ (it->second.first,
+ reinterpret_cast<Data& (*)(void*, impl::MemberPtr)>
+ (it->second.second));
+ }
}
-}
-#undef N
\ No newline at end of file
+ template <class T>
+ reflector<T> reflect() {
+ return reflector<T>(this);
+ }
+private:
+ typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
+ typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
+ typedef basic_data_info<Info, TypeInfo> data_info;
+
+ std::map<constructor_info, impl::FunctionPtr> constructors_;
+ std::map<function_info,
+ std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> > functions_;
+ std::map<data_info,
+ std::pair<impl::MemberPtr, impl::FunctionPtr> > data_;
+};
\ No newline at end of file
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-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/impl/reflector_functions.hpp
==============================================================================
--- sandbox/boost/reflection/impl/reflector_functions.hpp (original)
+++ sandbox/boost/reflection/impl/reflector_functions.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* Distributed under the Boost Software License, Version 1.0. (See
- * accompanying file LICENSE_1_0.txt or copy at
+ * 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.
@@ -11,43 +11,127 @@
// No header guard - this file is intended to be included multiple times.
# define N BOOST_PP_ITERATION()
+#include <iostream>
+// 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)>
+ BOOST_PP_ENUM_PARAMS(N, class Param)>
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+reflector& constructor(BOOST_PP_ENUM_PARAMS(N, ParameterInfo i)) {
+#else
reflector& constructor() {
+#endif
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, impl::FunctionPtr>(
- reflections::type_info_handler
+ constructor_info f(reflections::type_info_handler
<TypeInfo, instance (*)(ParamFirst BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, Param))>
- ::get_class_type(),
- reinterpret_cast<impl::FunctionPtr>(ctor_func)));
+ ::get_class_type());
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N);
+#endif
+ reflection_->constructors_.insert(
+ std::make_pair<constructor_info, impl::FunctionPtr>(
+ f, reinterpret_cast<impl::FunctionPtr>(ctor_func)));
return *this;
}
+// This version of the function is for reflecting functions that have
+// return values - so that the name of the return value can be set.
template <class ReturnValue BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, class Param)>
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+reflector& function(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)) {
+ // Create the function_info for this function.
+ function_info f(reflections::type_info_handler<TypeInfo,
+ ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))>
+ ::get_class_type(), info, true);
+ // Add the ParameterInfo for each parameter to the function_info.
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N);
+ // Add the ParameterInfo for the return type.
+ f.parameter_info_.push_back(i_return);
+#else
reflector& function(ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)),
Info info) {
+ // Create the function_info for this function.
function_info f(reflections::type_info_handler<TypeInfo,
ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))>
::get_class_type(), info);
+#endif
+
+ // Get a function pointer to a function that calls this member
+ // function when given a void* that actually points to an instance
+ // of this class.
ReturnValue (*f2)(void *, impl::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)>;
+
+ // Create the pair objects to insert into the map.
+ std::pair<impl::MemberFunctionPtr, impl::FunctionPtr>
+ in_pair(reinterpret_cast<impl::MemberFunctionPtr>(func),
+ reinterpret_cast<impl::FunctionPtr>(f2));
+ std::pair<function_info, std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> >
+ out_pair(f, in_pair);
+ reflection_->functions_.insert(out_pair);
+ return *this;
+}
+
+// This version of the function is for reflecting functions that have
+// no return value.
+template <class ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, class Param)>
+#ifdef BOOST_REFLECTION_WITH_PARAMETER_INFO
+reflector& function(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 (*)(ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param))>
+ ::get_class_type(), info, false);
+ f.parameter_info_.push_back(i_first);
+ BOOST_REFLECTION_PUSH_PARAMETER_INFO(f, N);
+#else
+reflector& function(void (T::*func)(ParamFirst p_first BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param)),
+ Info info) {
+ function_info f(reflections::type_info_handler<TypeInfo,
+ void (*)(ParamFirst BOOST_PP_COMMA_IF(N)
+ BOOST_PP_ENUM_PARAMS(N, Param))>
+ ::get_class_type(), info);
+#endif
+ void (*f2)(void *, impl::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<impl::MemberFunctionPtr, impl::FunctionPtr>
- p(reinterpret_cast<impl::MemberFunctionPtr>(func),
+ in_pair(reinterpret_cast<impl::MemberFunctionPtr>(func),
reinterpret_cast<impl::FunctionPtr>(f2));
std::pair<function_info, std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> >
- p2(f, p);
- reflection_->functions_.insert(p2);
+ out_pair(f, in_pair);
+ reflection_->functions_.insert(out_pair);
return *this;
}
+#undef BOOST_REFLECTION_PUSH_PARAMETER_INFO_SINGLE
+#undef BOOST_REFLECTION_PUSH_PARAMETER_INFO
#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-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/instance.hpp
==============================================================================
--- sandbox/boost/reflection/instance.hpp (original)
+++ sandbox/boost/reflection/instance.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
/*
- * Copyright Jeremy Pack 2007
+ * Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/boost/reflection/parameter.hpp
==============================================================================
--- sandbox/boost/reflection/parameter.hpp (original)
+++ sandbox/boost/reflection/parameter.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / paramater map (store parameter information for calls)
*
- * (C) Copyright Mariano G. Consoni 2007
+ * (C) Copyright Mariano G. Consoni 2008
* 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)
Modified: sandbox/boost/reflection/parameter_map.hpp
==============================================================================
--- sandbox/boost/reflection/parameter_map.hpp (original)
+++ sandbox/boost/reflection/parameter_map.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / paramater map (store parameter information for calls)
*
- * (C) Copyright Mariano G. Consoni 2007
+ * (C) Copyright Mariano G. Consoni 2008
* 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)
Modified: sandbox/boost/reflection/reflection.hpp
==============================================================================
--- sandbox/boost/reflection/reflection.hpp (original)
+++ sandbox/boost/reflection/reflection.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / main header
*
- * (C) Copyright Mariano G. Consoni and Jeremy Pack 2007
+ * (C) Copyright Mariano G. Consoni and Jeremy Pack 2008
* 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)
@@ -18,12 +18,10 @@
#include <boost/extension/impl/typeinfo.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/reflection/constructor.hpp>
-#include <boost/reflection/constructor_info.hpp>
#include <boost/reflection/data.hpp>
#include <boost/reflection/data_info.hpp>
#include <boost/reflection/factory.hpp>
#include <boost/reflection/function.hpp>
-#include <boost/reflection/function_info.hpp>
namespace boost {
namespace reflections {
@@ -46,230 +44,17 @@
} // namespace impl
-
-// By default, ParameterInfo is not used. Note that using adapters
-// requires ParameterInfo.
-template <class Info = std::string, class ParameterInfo = void,
- class TypeInfo = extensions::default_type_info>
-class basic_reflection {
-public:
- // A reflector is used to add functions and constructors to
- // a reflected class.
-
- template <class T>
- class reflector
- {
- public:
- // Initialize with a pointer to the reflection
- // this reflector will be reflecting into
- reflector(basic_reflection<Info, ParameterInfo, TypeInfo>*
- current_reflection)
- : reflection_(current_reflection) {
- }
-
- // Typedefs for the specific instantiations used by this class.
- typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
- typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
-
- reflector& constructor() {
- instance (*ctor_func)()(&impl::construct_instance<T>);
- reflection_->constructors_.insert(std::make_pair<TypeInfo, impl::FunctionPtr>(
- reflections::type_info_handler<TypeInfo, instance (*)()>
- ::get_class_type(), reinterpret_cast<impl::FunctionPtr>(ctor_func)));
- return *this;
- }
-
- template <class S>
- reflector& data(S T::*data_ptr, Info info) {
- data_info f(reflections::type_info_handler<TypeInfo, S>
- ::get_class_type(), info);
-
- std::pair<impl::MemberPtr, impl::FunctionPtr>
- p(reinterpret_cast<impl::MemberPtr>(data_ptr),
- reinterpret_cast<impl::FunctionPtr>(&impl::get_data_from_ptr<T, S>));
- std::pair<data_info, std::pair<impl::MemberPtr, impl::FunctionPtr> >
- p2(f, p);
- reflection_->data_.insert(p2);
- return *this;
- }
- #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()
- reflector& function(void (T::*func)(), Info info) {
- function_info f(reflections::type_info_handler<TypeInfo,
- void (*)()>::get_class_type(), info, false);
- void (*f2)(void *, impl::MemberFunctionPtr) = &impl::call_member<T, void>;
- std::pair<impl::MemberFunctionPtr, impl::FunctionPtr>
- in_pair(reinterpret_cast<impl::MemberFunctionPtr>(func),
- reinterpret_cast<impl::FunctionPtr>(f2));
- std::pair<function_info,
- std::pair<impl::MemberFunctionPtr,
- impl::FunctionPtr> >
- out_pair(f, in_pair);
- reflection_->functions_.insert(out_pair);
- return *this;
- }
- private:
- basic_reflection<Info, ParameterInfo, TypeInfo>* reflection_;
- };
-#define BOOST_PP_ITERATION_LIMITS (0, \
- BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
-#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflection.hpp>
-#include BOOST_PP_ITERATE()
- instance_constructor<> get_constructor() {
- constructor_info t(reflections::type_info_handler<TypeInfo,
- instance (*)()>::get_class_type());
- typename std::map<constructor_info, impl::FunctionPtr>::iterator it =
- constructors_.find(t);
- if (it == constructors_.end()) {
- return instance_constructor<>();
- } else {
- return reinterpret_cast<instance (*)()>(it->second);
- }
- }
-
- template <class T>
- data<T> get_data(Info info) {
- // Construct a data_info structure to look up the function in the map.
- data_info d(reflections::type_info_handler<TypeInfo, T>
- ::get_class_type(), info);
-
- // Look up the function.
- typename std::map<data_info,
- std::pair<impl::MemberPtr, impl::FunctionPtr> >::iterator it =
- data_.find(d);
-
- if (it == data_.end()) {
- // If it does not exist, return an empty function object.
- return data<T>();
- } else {
- return data<T>
- // reinterpret_cast is safe, because we looked it up by its type.
- (it->second.first,
- reinterpret_cast<T& (*)(void*, impl::MemberPtr)>
- (it->second.second));
- }
- }
-
- template <class T>
- reflector<T> reflect() {
- return reflector<T>(this);
- }
-private:
- typedef basic_function_info<Info, TypeInfo, ParameterInfo> function_info;
- typedef basic_constructor_info<TypeInfo, ParameterInfo> constructor_info;
- typedef basic_data_info<Info, TypeInfo> data_info;
- std::map<constructor_info, impl::FunctionPtr> constructors_;
- std::map<function_info,
- std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> > functions_;
- std::map<data_info,
- std::pair<impl::MemberPtr, impl::FunctionPtr> > data_;
-};
-template <class Info, class TypeInfo>
-class basic_reflection<Info, void, TypeInfo>
-{
-public:
- template <class T>
- class reflector
- {
- 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) {
- }
-
- // Typedefs for the specific instantiations used by this class.
- typedef basic_function_info<Info, TypeInfo> function_info;
- typedef basic_constructor_info<Info, TypeInfo> constructor_info;
-
- // Reflect the default constructor (other constructors in
- // impl/reflector_functions.hpp).
- reflector& constructor() {
- instance (*ctor_func)()(&impl::construct_instance<T>);
- reflection_->constructors_.insert(std::make_pair<TypeInfo, impl::FunctionPtr>(
- reflections::type_info_handler<TypeInfo, instance (*)()>
- ::get_class_type(), reinterpret_cast<impl::FunctionPtr>(ctor_func)));
- return *this;
- }
-
- template <class S>
- reflector& data(S T::*data_ptr, Info info) {
- data_info f(reflections::type_info_handler<TypeInfo, S>
- ::get_class_type(), info);
- S& (*func)(void*, impl::MemberPtr) = &impl::get_data_from_ptr<T, S>;
- std::pair<impl::MemberPtr, impl::FunctionPtr>
- p(reinterpret_cast<impl::MemberPtr>(data_ptr),
- reinterpret_cast<impl::FunctionPtr>(func));
- std::pair<data_info, std::pair<impl::MemberPtr, impl::FunctionPtr> >
- p2(f, p);
- reflection_->data_.insert(p2);
- return *this;
- }
- #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:
- basic_reflection<Info, void, TypeInfo> * reflection_;
- };
-
-#define BOOST_PP_ITERATION_LIMITS (0, \
- BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS) - 1)
-#define BOOST_PP_FILENAME_1 <boost/reflection/impl/reflection.hpp>
-#include BOOST_PP_ITERATE()
- instance_constructor<> get_constructor() {
- constructor_info t(reflections::type_info_handler<TypeInfo,
- instance (*)()>::get_class_type());
- typename std::map<constructor_info, impl::FunctionPtr>::iterator it =
- constructors_.find(t);
- if (it == constructors_.end()) {
- return instance_constructor<>();
- } else {
- return reinterpret_cast<instance (*)()>(it->second);
- }
- }
-
- template <class T>
- data<T> get_data(Info info) {
- // Construct a data_info structure to look up the function in the map.
- data_info d(reflections::type_info_handler<TypeInfo, T>
- ::get_class_type(), info);
-
- // Look up the function.
- typename std::map<data_info,
- std::pair<impl::MemberPtr, impl::FunctionPtr> >::iterator it =
- data_.find(d);
-
- if (it == data_.end()) {
- // If it does not exist, return an empty function object.
- return data<T>();
- }
- return data<T>
- // reinterpret_cast is safe, because we looked it up by its type.
- (it->second.first,
- reinterpret_cast<T& (*)(void*, impl::MemberPtr)>
- (it->second.second));
- }
-
- template <class T>
- reflector<T> reflect() {
- return reflector<T>(this);
- }
-
-private:
- typedef basic_function_info<Info, TypeInfo> function_info;
- typedef basic_constructor_info<TypeInfo> constructor_info;
- typedef basic_data_info<Info, TypeInfo> data_info;
- std::map<constructor_info, impl::FunctionPtr> constructors_;
- std::map<function_info,
- std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> > functions_;
- std::map<data_info,
- std::pair<impl::MemberPtr, impl::FunctionPtr> > data_;
-};
+// Since there are two specializations, with and without parameter
+// information - but which are otherwise mostly the same - the
+// implementation file is included twice.
+#define BOOST_REFLECTION_WITH_PARAMETER_INFO
+#include <boost/reflection/function_info.hpp>
+#include <boost/reflection/constructor_info.hpp>
+#include <boost/reflection/impl/reflection.hpp>
+#undef BOOST_REFLECTION_WITH_PARAMETER_INFO
+#include <boost/reflection/function_info.hpp>
+#include <boost/reflection/constructor_info.hpp>
+#include <boost/reflection/impl/reflection.hpp>
typedef basic_reflection<> reflection;
}}
Deleted: sandbox/boost/reflection/static_reflection.hpp
==============================================================================
--- sandbox/boost/reflection/static_reflection.hpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
+++ (empty file)
@@ -1,115 +0,0 @@
-/*
- * Boost.Reflection / static_reflection:
- * reflections of static functions
- *
- * (C) 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.
- */
-
-#ifndef BOOST_REFLECTION_STATIC_REFLECTION_HPP
-#define BOOST_REFLECTION_STATIC_REFLECTION_HPP
-#include <map>
-#include <boost/extension/impl/typeinfo.hpp>
-#include <boost/reflection/factory.hpp>
-
-namespace boost { namespace reflections {
-using extensions::type_info_handler;
-#define BOOST_REFLECTION_FACTORY_MAP_GET_FUNCTION(Z, N, _) \
- template <class Info, class ReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
- std::map<Info, \
- ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> & get() { \
- typedef ReturnValue (*FuncType)(BOOST_PP_ENUM_PARAMS(N, Param)); \
- TypeInfo t = type_info_handler<TypeInfo, FuncType> \
- ::get_class_type(); \
- typename std::map<TypeInfo, generic_map_holder*>::iterator it = \
- maps_.find(t); \
- map_holder<std::map<Info, \
- FuncType> > * holder; \
- if (it == maps_.end()) { \
- holder = new map_holder<std::map<Info, FuncType > >; \
- it = maps_.insert(std::make_pair \
- (t, holder)).first; \
- } else { \
- holder = \
- static_cast<map_holder<std::map<Info, FuncType> > *> \
- (it->second); \
- } \
- return *static_cast<std::map<Info, \
- FuncType> * >(holder); \
- }
-
-#define BOOST_REFLECTION_FACTORY_MAP_GET_FUNCTION_WITH_INFO(Z, N, _) \
- template <class Info, class ReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
- ReturnValue (*get(Info info))(BOOST_PP_ENUM_PARAMS(N, Param)) { \
- typedef ReturnValue (*FuncType)(BOOST_PP_ENUM_PARAMS(N, Param)); \
- std::map<Info, FuncType>& fm = get<Info, ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) >(); \
- typename std::map<Info, FuncType>::iterator it = fm.find(info); \
- if (it == fm.end()) { \
- return 0; \
- } \
- return it->second; \
- }
-
-#define BOOST_REFLECTION_FACTORY_MAP_SET_FUNCTION(Z, N, _) \
- template <class Info, class ReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
- void set(Info info, ReturnValue (*func)(BOOST_PP_ENUM_PARAMS(N, Param))) { \
- typedef ReturnValue (*FuncType)(BOOST_PP_ENUM_PARAMS(N, Param)); \
- get<Info, ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) >()[info] = func; \
- }
-
-#define BOOST_REFLECTION_FACTORY_MAP_CONVERT_FUNCTION(Z, N, _) \
- template <class Info, class ReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
- operator std::map<Info, \
- ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))>() { \
- return get<Info, ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param)>(); \
- }
-
-template <class TypeInfo>
-class basic_static_reflection {
-public:
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_FACTORY_MAP_GET_FUNCTION, _)
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_FACTORY_MAP_GET_FUNCTION_WITH_INFO, _)
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_FACTORY_MAP_SET_FUNCTION, _)
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_REFLECTION_MAX_FUNCTOR_PARAMS), \
- BOOST_REFLECTION_FACTORY_MAP_CONVERT_FUNCTION, _)
- ~basic_static_reflection() {
- for (typename std::map<TypeInfo, generic_map_holder*>
- ::iterator it =maps_.begin();
- it != maps_.end(); ++it) {
- delete it->second;
- }
- }
-private:
- class generic_map_holder {
- public:
- virtual ~generic_map_holder() {}
- };
- template <class T>
- class map_holder : public generic_map_holder, public T{
- };
- std::map<TypeInfo, generic_map_holder*> maps_;
-};
-typedef basic_static_reflection<extensions::default_type_info> static_reflection;
-}}
-
-#undef BOOST_REFLECTION_STATIC_REFLECTION_GET_FUNCTION
-#undef BOOST_REFLECTION_STATIC_REFLECTION_CONVERT_FUNCTION
-#endif
Modified: sandbox/libs/reflection/doc/extension.qbk
==============================================================================
--- sandbox/libs/reflection/doc/extension.qbk (original)
+++ sandbox/libs/reflection/doc/extension.qbk 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,5 +1,5 @@
[/ Boost.Reflection - main doc ]
-[/ Copyright 2007 Jeremy Pack ]
+[/ Copyright 2008 Jeremy Pack ]
[/ 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) ]
Modified: sandbox/libs/reflection/examples/extension/car_lib.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/car_lib.cpp (original)
+++ sandbox/libs/reflection/examples/extension/car_lib.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Extension / car library implementations
*
- * (C) Copyright Mariano G. Consoni 2007
+ * (C) Copyright Mariano G. Consoni 2008
* 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)
Modified: sandbox/libs/reflection/examples/extension/extension.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/extension.cpp (original)
+++ sandbox/libs/reflection/examples/extension/extension.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / extension integration example
*
- * (C) Copyright Mariano G. Consoni 2007
+ * (C) Copyright Mariano G. Consoni 2008
* 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)
Modified: sandbox/libs/reflection/test/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/test/Jamfile.v2 (original)
+++ sandbox/libs/reflection/test/Jamfile.v2 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,6 +1,6 @@
# Boost.Reflection - tests Jamfile
#
-# Copyright 2007 Mariano G. Consoni
+# Copyright 2008 Mariano G. Consoni
# 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)
@@ -31,7 +31,6 @@
[ 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 ]
[ run data_test.cpp ]
:
Deleted: sandbox/libs/reflection/test/basic_static_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/basic_static_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
+++ (empty file)
@@ -1,39 +0,0 @@
-/*
- * Boost.Reflection / basic unit test
- *
- * (C) Copyright Mariano G. Consoni and 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.
- */
-
-
-#include <string>
-#include <iostream>
-
-#define BOOST_TEST_MAIN
-#define BOOST_TEST_DYN_LINK 1
-#include <boost/test/unit_test.hpp>
-#include <boost/reflection/static_reflection.hpp>
-
-
-int func1(int j) {
- return j * 2;
-}
-int func2(int j) {
- return j + 2;
-}
-int func3(int j, float f) {
- return j - 2;
-}
-using namespace boost::reflections;
-BOOST_AUTO_TEST_CASE(argless) {
- static_reflection sr;
- sr.set<std::string, int, int>("First Function", &func1);
- sr.set<std::string, int, int>("Second Function", &func2);
- sr.set<std::string, int, int, float>("Third Function", &func3);
- int result = sr.get<std::string, int, int, float>("Third Function")(3, 2.0f);
- BOOST_CHECK_EQUAL(result, 1);
-}
\ No newline at end of file
Modified: sandbox/libs/reflection/test/basic_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/basic_test.cpp (original)
+++ sandbox/libs/reflection/test/basic_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic unit test
*
- * (C) Copyright Mariano G. Consoni and Jeremy Pack 2007
+ * (C) Copyright Mariano G. Consoni and Jeremy Pack 2008
* 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)
@@ -55,6 +55,9 @@
}
void start(float speed) {
}
+ int mileage(float day, double time) {
+ return 3;
+ }
private:
int year_;
};
@@ -64,12 +67,15 @@
car_reflection.reflect<porsche>()
.constructor<int>()
.function(&porsche::start, "start")
+ .function(&porsche::mileage, "mileage")
.function(&porsche::get_year, "get_year");
// Check for argless constructor
BOOST_CHECK(car_reflection.get_constructor<int>().valid());
BOOST_CHECK(!car_reflection.get_constructor().valid());
boost::reflections::instance car_instance =
car_reflection.get_constructor<int>()(1987);
+ function<int, float, double> f0(car_reflection.get_function<int, float, double>("mileage"));
+ BOOST_CHECK(f0.valid());
function<void, float> f1(car_reflection.get_function<void, float>("start"));
BOOST_CHECK(f1.valid());
// Make sure it doesn't have this undeclared method
Modified: sandbox/libs/reflection/test/data_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/data_test.cpp (original)
+++ sandbox/libs/reflection/test/data_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -32,7 +32,7 @@
using namespace boost::reflections;
-BOOST_AUTO_TEST_CASE(argless)
+BOOST_AUTO_TEST_CASE(simple)
{
reflection r;
r.reflect<data_holder>()
Modified: sandbox/libs/reflection/test/multi_param_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/multi_param_test.cpp (original)
+++ sandbox/libs/reflection/test/multi_param_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic many parameter unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/libs/reflection/test/parameter_info_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/parameter_info_test.cpp (original)
+++ sandbox/libs/reflection/test/parameter_info_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/libs/reflection/test/parameter_map_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/parameter_map_test.cpp (original)
+++ sandbox/libs/reflection/test/parameter_map_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/libs/reflection/test/parameters_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/parameters_test.cpp (original)
+++ sandbox/libs/reflection/test/parameters_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / parameter map unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
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-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic single parameter unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
Modified: sandbox/libs/reflection/test/single_param_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/single_param_test.cpp (original)
+++ sandbox/libs/reflection/test/single_param_test.cpp 2008-05-02 20:18:50 EDT (Fri, 02 May 2008)
@@ -1,7 +1,7 @@
/*
* Boost.Reflection / basic single parameter unit test
*
- * (C) Copyright Jeremy Pack 2007
+ * (C) Copyright Jeremy Pack 2008
* 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)
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