1 // Copyright David Abrahams 2004. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #ifndef WRAPPER_BASE_DWA2004722_HPP
5 # define WRAPPER_BASE_DWA2004722_HPP
7 # include <boost/python/detail/prefix.hpp>
8 # include <boost/python/detail/type_traits.hpp>
10 namespace boost { namespace python {
18 namespace wrapper_base_ // ADL disabler
20 inline PyObject* get_owner(wrapper_base const volatile& w);
23 owner_impl(void const volatile* /*x*/, detail::false_)
30 owner_impl(T const volatile* x, detail::true_);
34 owner(T const volatile* x)
36 return wrapper_base_::owner_impl(x,is_polymorphic<T>());
40 class BOOST_PYTHON_DECL wrapper_base
42 friend void initialize_wrapper(PyObject* self, wrapper_base* w);
43 friend PyObject* wrapper_base_::get_owner(wrapper_base const volatile& w);
45 wrapper_base() : m_self(0) {}
47 override get_override(
48 char const* name, PyTypeObject* class_object) const;
57 namespace wrapper_base_ // ADL disabler
61 owner_impl(T const volatile* x, detail::true_)
63 if (wrapper_base const volatile* w = dynamic_cast<wrapper_base const volatile*>(x))
65 return wrapper_base_::get_owner(*w);
70 inline PyObject* get_owner(wrapper_base const volatile& w)
76 inline void initialize_wrapper(PyObject* self, wrapper_base* w)
81 inline void initialize_wrapper(PyObject* /*self*/, ...) {}
87 }} // namespace boost::python
89 #endif // WRAPPER_BASE_DWA2004722_HPP