1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/converter/registered.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,111 @@
1.4 +// Copyright David Abrahams 2002.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See
1.6 +// accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +#ifndef REGISTERED_DWA2002710_HPP
1.9 +# define REGISTERED_DWA2002710_HPP
1.10 +# include <boost/python/type_id.hpp>
1.11 +# include <boost/python/converter/registry.hpp>
1.12 +# include <boost/python/converter/registrations.hpp>
1.13 +# include <boost/type_traits/transform_traits.hpp>
1.14 +# include <boost/type_traits/cv_traits.hpp>
1.15 +# include <boost/type_traits/is_void.hpp>
1.16 +# include <boost/detail/workaround.hpp>
1.17 +# include <boost/python/type_id.hpp>
1.18 +# include <boost/type.hpp>
1.19 +
1.20 +namespace boost {
1.21 +
1.22 +// You'll see shared_ptr mentioned in this header because we need to
1.23 +// note which types are shared_ptrs in their registrations, to
1.24 +// implement special shared_ptr handling for rvalue conversions.
1.25 +template <class T> class shared_ptr;
1.26 +
1.27 +namespace python { namespace converter {
1.28 +
1.29 +struct registration;
1.30 +
1.31 +namespace detail
1.32 +{
1.33 + template <class T>
1.34 + struct registered_base
1.35 + {
1.36 + static registration const& converters;
1.37 + };
1.38 +}
1.39 +
1.40 +template <class T>
1.41 +struct registered
1.42 + : detail::registered_base<
1.43 + typename add_reference<
1.44 + typename add_cv<T>::type
1.45 + >::type
1.46 + >
1.47 +{
1.48 +};
1.49 +
1.50 +# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
1.51 + && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
1.52 +// collapses a few more types to the same static instance. MSVC7.1
1.53 +// fails to strip cv-qualification from array types in typeid. For
1.54 +// some reason we can't use this collapse there or array converters
1.55 +// will not be found.
1.56 +template <class T>
1.57 +struct registered<T&>
1.58 + : registered<T> {};
1.59 +# endif
1.60 +
1.61 +//
1.62 +// implementations
1.63 +//
1.64 +namespace detail
1.65 +{
1.66 + inline void
1.67 + register_shared_ptr0(...)
1.68 + {
1.69 + }
1.70 +
1.71 + template <class T>
1.72 + inline void
1.73 + register_shared_ptr0(shared_ptr<T>*)
1.74 + {
1.75 + registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
1.76 + }
1.77 +
1.78 + template <class T>
1.79 + inline void
1.80 + register_shared_ptr1(T const volatile*)
1.81 + {
1.82 + detail::register_shared_ptr0((T*)0);
1.83 + }
1.84 +
1.85 + template <class T>
1.86 + inline registration const&
1.87 + registry_lookup2(T&(*)())
1.88 + {
1.89 + detail::register_shared_ptr1((T*)0);
1.90 + return registry::lookup(type_id<T&>());
1.91 + }
1.92 +
1.93 + template <class T>
1.94 + inline registration const&
1.95 + registry_lookup1(type<T>)
1.96 + {
1.97 + return registry_lookup2((T(*)())0);
1.98 + }
1.99 +
1.100 + inline registration const&
1.101 + registry_lookup1(type<const volatile void>)
1.102 + {
1.103 + detail::register_shared_ptr1((void*)0);
1.104 + return registry::lookup(type_id<void>());
1.105 + }
1.106 +
1.107 + template <class T>
1.108 + registration const& registered_base<T>::converters = detail::registry_lookup1(type<T>());
1.109 +
1.110 +}
1.111 +
1.112 +}}} // namespace boost::python::converter
1.113 +
1.114 +#endif // REGISTERED_DWA2002710_HPP