|
Boost-Commit : |
From: oryol_at_[hidden]
Date: 2008-05-02 20:35:44
Author: jeremypack
Date: 2008-05-02 20:35:43 EDT (Fri, 02 May 2008)
New Revision: 45048
URL: http://svn.boost.org/trac/boost/changeset/45048
Log:
add missing header
Added:
sandbox/boost/reflection/impl/reflection_functions.hpp (contents, props changed)
Added: sandbox/boost/reflection/impl/reflection_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/reflection/impl/reflection_functions.hpp 2008-05-02 20:35:43 EDT (Fri, 02 May 2008)
@@ -0,0 +1,84 @@
+/*
+ * Boost.Reflection / implementation header for Boost.PreProcessor
+ *
+ * (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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+# define N BOOST_PP_ITERATION()
+#include <iostream>
+// 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());
+
+ std::cout << "Seeking: " << ctr_info.type_info_.type.name() << std::endl;
+ // 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);
+ }
+}
+
+// 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);
+
+ std::cout << "Seeking: " << func_info.type_info_.type.name() << std::endl;
+ // 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()) {
+ for (typename std::map<function_info,
+ std::pair<impl::MemberFunctionPtr, impl::FunctionPtr> >::iterator it = functions_.begin();
+ it != functions_.end(); ++it) {
+ std::cout << "Found: " << it->first.type_info_.type.name() << " " << it->first.info_ << std::endl;
+ }
+ // 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);
+ }
+}
+
+#undef N
\ No newline at end of file
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