File indexing completed on 2025-01-18 09:50:37
0001
0002
0003
0004
0005
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
0025
0026
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
0054
0055
0056
0057 template <class T>
0058 struct registered<T&>
0059 : registered<T> {};
0060 # endif
0061
0062
0063
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 }}}
0123
0124 #endif