55 #define IS_SHARED_PTR_DWA2003224_HPP
57 #include <boost/python/detail/is_xxx.hpp>
58 #include <boost/shared_ptr.hpp>
60 namespace boost {
namespace python {
namespace detail {
62 BOOST_PYTHON_IS_XXX_DEF(shared_ptr, shared_ptr, 1)
64 struct is_shared_ptr<std::shared_ptr<T> > : std::true_type {};
72 #include <boost/python/type_id.hpp>
73 #include <boost/python/converter/registry.hpp>
74 #include <boost/python/converter/registrations.hpp>
75 #include <boost/type_traits/transform_traits.hpp>
76 #include <boost/type_traits/cv_traits.hpp>
77 #include <boost/type_traits/is_void.hpp>
78 #include <boost/detail/workaround.hpp>
79 #include <boost/type.hpp>
82 namespace boost {
namespace python {
namespace converter {
namespace detail {
88 registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
95 #define VALUE_IS_SHARED_PTR_DWA2003224_HPP
96 #include <boost/python/detail/value_is_xxx.hpp>
97 #include <boost/python/detail/is_shared_ptr.hpp>
99 namespace boost {
namespace python {
namespace detail {
104 static bool const value = is_shared_ptr<
typename remove_cv<
105 typename remove_reference<X_>
109 typedef mpl::bool_<value>
type;
118 #define SHARED_PTR_FROM_PYTHON_DWA20021130_HPP
120 #include <boost/python/handle.hpp>
121 #include <boost/python/converter/shared_ptr_deleter.hpp>
122 #include <boost/python/converter/from_python.hpp>
123 #include <boost/python/converter/rvalue_from_python_data.hpp>
124 #include <boost/python/converter/registered.hpp>
125 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
126 # include <boost/python/converter/pytype_function.hpp>
128 #include <boost/shared_ptr.hpp>
130 namespace boost {
namespace python {
namespace converter {
132 template <
class T,
template <
typename>
class SP>
138 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
139 , &converter::expected_from_python_type_direct<T>::get_pytype
150 return converter::get_lvalue_from_python(
p, registered<T>::converters);
153 static void construct(PyObject* source, rvalue_from_python_stage1_data* data)
155 void*
const storage = ((converter::rvalue_from_python_storage<SP<T> >*)data)->storage.bytes;
157 if (data->convertible == source)
158 new (storage) SP<T>();
161 SP<void> hold_convertible_ref_count(
162 (
void*)0, shared_ptr_deleter(handle<>(borrowed(source))) );
164 new (storage) SP<T>(hold_convertible_ref_count,
165 static_cast<T*
>(data->convertible));
168 data->convertible = storage;
193 #include <boost/python/refcount.hpp>
194 #include <boost/python/converter/shared_ptr_deleter.hpp>
195 #include <boost/python/detail/none.hpp>
196 #include <boost/get_pointer.hpp>
198 namespace boost {
namespace python {
namespace converter {
204 return python::detail::none();
205 else if (shared_ptr_deleter* d = std::get_deleter<shared_ptr_deleter>(x))
206 return incref(get_pointer(d->owner));
208 return converter::registered<std::shared_ptr<T>
const&>::converters.to_python(&x);
219 #define TO_PYTHON_VALUE_DWA200221_HPP
220 #include <boost/python/detail/prefix.hpp>
222 #include <boost/python/refcount.hpp>
223 #include <boost/python/tag.hpp>
224 #include <boost/python/handle.hpp>
226 #include <boost/python/converter/registry.hpp>
227 #include <boost/python/converter/registered.hpp>
228 #include <boost/python/converter/builtin_converters.hpp>
229 #include <boost/python/converter/object_manager.hpp>
230 #include <boost/python/converter/shared_ptr_to_python.hpp>
232 #include <boost/python/detail/value_is_shared_ptr.hpp>
233 #include <boost/python/detail/value_arg.hpp>
235 #include <boost/type_traits/transform_traits.hpp>
237 #include <boost/mpl/if.hpp>
238 #include <boost/mpl/or.hpp>
239 #include <boost/type_traits/is_const.hpp>
241 namespace boost {
namespace python {
245 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
247 template <
bool is_const_ref>
251 static PyTypeObject
const*
get( U& (*)() =0)
253 return converter::object_manager_traits<U>::get_pytype();
261 static PyTypeObject
const*
get( U
const& (*)() =0)
263 return converter::object_manager_traits<U>::get_pytype();
275 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
277 typedef boost::detail::indirect_traits::is_reference_to_const<T>
is_t_const;
282 inline static PyTypeObject
const*
get_pytype_aux(mpl::true_*) {
return converter::object_manager_traits<T>::get_pytype();}
304 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
305 PyTypeObject
const*
get_pytype()
const {
return converter::registered<T>::converters.to_python_target_type();}
320 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
328 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
330 PyTypeObject
const*
get_pytype(boost::type<shared_ptr<U> &> *)
const {
return converter::registered<U>::converters.to_python_target_type();}
332 PyTypeObject
const*
get_pytype(boost::type<
const shared_ptr<U> &> *)
const {
return converter::registered<U>::converters.to_python_target_type();}
333 # if __cplusplus >= 201103L
335 PyTypeObject
const*
get_pytype(boost::type<std::shared_ptr<U> &> *)
const {
return converter::registered<U>::converters.to_python_target_type();}
337 PyTypeObject
const*
get_pytype(boost::type<
const std::shared_ptr<U> &> *)
const {
return converter::registered<U>::converters.to_python_target_type();}
346 detail::value_is_shared_ptr<T>
347 , detail::shared_ptr_to_python_value<T>
350 converter::is_object_manager<T>
351 , converter::is_reference_to_object_manager<T>
353 , detail::object_manager_to_python_value<T>
354 , detail::registry_to_python_value<T>
368 return converter::registered<argument_type>::converters.to_python(&x);
374 return python::upcast<PyObject>(
376 get_managed_object(x, tag))
void register_shared_ptr0(std::shared_ptr< T > *)
PyObject * shared_ptr_to_python(std::shared_ptr< T > const &x)
static void * convertible(PyObject *p)
static void construct(PyObject *source, rvalue_from_python_stage1_data *data)
shared_ptr_from_python_new()
static PyTypeObject const * get(U const &(*)()=0)
static PyTypeObject const * get(U &(*)()=0)
static PyTypeObject const * get_pytype_aux(mpl::true_ *)
boost::detail::indirect_traits::is_reference_to_const< T > is_t_const
PyObject * operator()(argument_type) const
PyTypeObject const * get_pytype() const
boost::mpl::bool_< is_handle< T >::value > is_t_handle
BOOST_STATIC_CONSTANT(bool, uses_registry=false)
static PyTypeObject const * get_pytype_aux(mpl::false_ *)
value_arg< T >::type argument_type
PyTypeObject const * get_pytype() const
BOOST_STATIC_CONSTANT(bool, uses_registry=true)
PyObject * operator()(argument_type) const
value_arg< T >::type argument_type
PyTypeObject const * get_pytype(boost::type< shared_ptr< U > & > *) const
PyTypeObject const * get_pytype() const
PyTypeObject const * get_pytype(boost::type< const shared_ptr< U > & > *) const
PyObject * operator()(argument_type) const
value_arg< T >::type argument_type
BOOST_STATIC_CONSTANT(bool, uses_registry=false)