Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:37

0001 // Copyright David Abrahams 2002.
0002 // Copyright Stefan Seefeld 2016.
0003 // Distributed under the Boost Software License, Version 1.0. (See
0004 // accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef boost_python_converter_registered_hpp_
0008 #define boost_python_converter_registered_hpp_
0009 
0010 #include <boost/python/type_id.hpp>
0011 #include <boost/python/converter/registry.hpp>
0012 #include <boost/python/converter/registrations.hpp>
0013 #include <boost/python/detail/type_traits.hpp>
0014 #include <boost/detail/workaround.hpp>
0015 #include <boost/type.hpp>
0016 #include <memory>
0017 #if defined(BOOST_PYTHON_TRACE_REGISTRY) \
0018  || defined(BOOST_PYTHON_CONVERTER_REGISTRY_APPLE_MACH_WORKAROUND)
0019 # include <iostream>
0020 #endif
0021 
0022 namespace boost {
0023 
0024 // You'll see shared_ptr mentioned in this header because we need to
0025 // note which types are shared_ptrs in their registrations, to
0026 // implement special shared_ptr handling for rvalue conversions.
0027 template <class T> class shared_ptr;
0028 
0029 namespace python { namespace converter { 
0030 
0031 struct registration;
0032 
0033 namespace detail
0034 {
0035   template <class T>
0036   struct registered_base
0037   {
0038       static registration const& converters;
0039   };
0040 }
0041 
0042 template <class T>
0043 struct registered
0044   : detail::registered_base<
0045         typename boost::python::detail::add_lvalue_reference<
0046             typename boost::python::detail::add_cv<T>::type
0047         >::type
0048     >
0049 {
0050 };
0051 
0052 # if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
0053 // collapses a few more types to the same static instance.  MSVC7.1
0054 // fails to strip cv-qualification from array types in typeid.  For
0055 // some reason we can't use this collapse there or array converters
0056 // will not be found.
0057 template <class T>
0058 struct registered<T&>
0059   : registered<T> {};
0060 # endif
0061 
0062 //
0063 // implementations
0064 //
0065 namespace detail
0066 {
0067   inline void
0068   register_shared_ptr0(...)
0069   {
0070   }
0071   
0072   template <class T>
0073   inline void
0074   register_shared_ptr0(shared_ptr<T>*)
0075   {
0076       registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
0077   }
0078 
0079 #if !defined(BOOST_NO_CXX11_SMART_PTR)
0080   template <class T>
0081   inline void
0082   register_shared_ptr0(std::shared_ptr<T>*)
0083   {
0084       registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
0085   }
0086 #endif
0087 
0088   template <class T>
0089   inline void
0090   register_shared_ptr1(T const volatile*)
0091   {
0092       detail::register_shared_ptr0((T*)0);
0093   }
0094   
0095   template <class T>
0096   inline registration const& 
0097   registry_lookup2(T&(*)())
0098   {
0099       detail::register_shared_ptr1((T*)0);
0100       return registry::lookup(type_id<T&>());
0101   }
0102 
0103   template <class T>
0104   inline registration const& 
0105   registry_lookup1(type<T>)
0106   {
0107       return registry_lookup2((T(*)())0);
0108   }
0109 
0110   inline registration const& 
0111   registry_lookup1(type<const volatile void>)
0112   {
0113       detail::register_shared_ptr1((void*)0);
0114       return registry::lookup(type_id<void>());
0115   }
0116 
0117   template <class T>
0118   registration const& registered_base<T>::converters = detail::registry_lookup1(type<T>());
0119 
0120 }
0121 
0122 }}} // namespace boost::python::converter
0123 
0124 #endif