File indexing completed on 2025-01-18 09:50:38
0001
0002
0003
0004 #ifndef WRAPPER_BASE_DWA2004722_HPP
0005 # define WRAPPER_BASE_DWA2004722_HPP
0006
0007 # include <boost/python/detail/prefix.hpp>
0008 # include <boost/python/detail/type_traits.hpp>
0009
0010 namespace boost { namespace python {
0011
0012 class override;
0013
0014 namespace detail
0015 {
0016 class wrapper_base;
0017
0018 namespace wrapper_base_
0019 {
0020 inline PyObject* get_owner(wrapper_base const volatile& w);
0021
0022 inline PyObject*
0023 owner_impl(void const volatile* , detail::false_)
0024 {
0025 return 0;
0026 }
0027
0028 template <class T>
0029 inline PyObject*
0030 owner_impl(T const volatile* x, detail::true_);
0031
0032 template <class T>
0033 inline PyObject*
0034 owner(T const volatile* x)
0035 {
0036 return wrapper_base_::owner_impl(x,is_polymorphic<T>());
0037 }
0038 }
0039
0040 class BOOST_PYTHON_DECL wrapper_base
0041 {
0042 friend void initialize_wrapper(PyObject* self, wrapper_base* w);
0043 friend PyObject* wrapper_base_::get_owner(wrapper_base const volatile& w);
0044 protected:
0045 wrapper_base() : m_self(0) {}
0046
0047 override get_override(
0048 char const* name, PyTypeObject* class_object) const;
0049
0050 private:
0051 void detach();
0052
0053 private:
0054 PyObject* m_self;
0055 };
0056
0057 namespace wrapper_base_
0058 {
0059 template <class T>
0060 inline PyObject*
0061 owner_impl(T const volatile* x, detail::true_)
0062 {
0063 if (wrapper_base const volatile* w = dynamic_cast<wrapper_base const volatile*>(x))
0064 {
0065 return wrapper_base_::get_owner(*w);
0066 }
0067 return 0;
0068 }
0069
0070 inline PyObject* get_owner(wrapper_base const volatile& w)
0071 {
0072 return w.m_self;
0073 }
0074 }
0075
0076 inline void initialize_wrapper(PyObject* self, wrapper_base* w)
0077 {
0078 w->m_self = self;
0079 }
0080
0081 inline void initialize_wrapper(PyObject* , ...) {}
0082
0083
0084
0085 }
0086
0087 }}
0088
0089 #endif