Warning, file /include/boost/python/object/make_ptr_instance.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef MAKE_PTR_INSTANCE_DWA200296_HPP
0006 # define MAKE_PTR_INSTANCE_DWA200296_HPP
0007
0008 # include <boost/python/object/make_instance.hpp>
0009 # include <boost/python/converter/registry.hpp>
0010 # include <boost/python/detail/type_traits.hpp>
0011 # include <boost/get_pointer.hpp>
0012 # include <boost/detail/workaround.hpp>
0013 # include <typeinfo>
0014
0015 namespace boost { namespace python { namespace objects {
0016
0017 template <class T, class Holder>
0018 struct make_ptr_instance
0019 : make_instance_impl<T, Holder, make_ptr_instance<T,Holder> >
0020 {
0021 template <class Arg>
0022 static inline Holder* construct(void* storage, PyObject*, Arg& x)
0023 {
0024 #if defined(BOOST_NO_CXX11_SMART_PTR)
0025 return new (storage) Holder(x);
0026 #else
0027 return new (storage) Holder(std::move(x));
0028 #endif
0029 }
0030
0031 template <class Ptr>
0032 static inline PyTypeObject* get_class_object(Ptr const& x)
0033 {
0034 return get_class_object_impl(get_pointer(x));
0035 }
0036 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0037 static inline PyTypeObject const* get_pytype()
0038 {
0039 return converter::registered<T>::converters.get_class_object();
0040 }
0041 #endif
0042 private:
0043 template <class U>
0044 static inline PyTypeObject* get_class_object_impl(U const volatile* p)
0045 {
0046 if (p == 0)
0047 return 0;
0048
0049 PyTypeObject* derived = get_derived_class_object(
0050 BOOST_DEDUCED_TYPENAME boost::python::detail::is_polymorphic<U>::type(), p);
0051
0052 if (derived)
0053 return derived;
0054 return converter::registered<T>::converters.get_class_object();
0055 }
0056
0057 template <class U>
0058 static inline PyTypeObject* get_derived_class_object(boost::python::detail::true_, U const volatile* x)
0059 {
0060 converter::registration const* r = converter::registry::query(
0061 type_info(typeid(*x))
0062 );
0063 return r ? r->m_class_object : 0;
0064 }
0065
0066 template <class U>
0067 static inline PyTypeObject* get_derived_class_object(boost::python::detail::false_, U*)
0068 {
0069 return 0;
0070 }
0071 };
0072
0073
0074 }}}
0075
0076 #endif