| 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 | |
|---|
| 5 | #include <boost/python/wrapper.hpp> |
|---|
| 6 | |
|---|
| 7 | namespace boost { namespace python { |
|---|
| 8 | |
|---|
| 9 | namespace detail |
|---|
| 10 | { |
|---|
| 11 | override wrapper_base::get_override( |
|---|
| 12 | char const* name |
|---|
| 13 | , PyTypeObject* class_object |
|---|
| 14 | ) const |
|---|
| 15 | { |
|---|
| 16 | if (this->m_self) |
|---|
| 17 | { |
|---|
| 18 | if (handle<> m = handle<>( |
|---|
| 19 | python::allow_null( |
|---|
| 20 | ::PyObject_GetAttrString( |
|---|
| 21 | this->m_self, const_cast<char*>(name)))) |
|---|
| 22 | ) |
|---|
| 23 | { |
|---|
| 24 | PyObject* borrowed_f = 0; |
|---|
| 25 | |
|---|
| 26 | if ( |
|---|
| 27 | PyMethod_Check(m.get()) |
|---|
| 28 | && ((PyMethodObject*)m.get())->im_self == this->m_self |
|---|
| 29 | && class_object->tp_dict != 0 |
|---|
| 30 | ) |
|---|
| 31 | { |
|---|
| 32 | borrowed_f = ::PyDict_GetItemString( |
|---|
| 33 | class_object->tp_dict, const_cast<char*>(name)); |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | } |
|---|
| 37 | if (borrowed_f != ((PyMethodObject*)m.get())->im_func) |
|---|
| 38 | return override(m); |
|---|
| 39 | } |
|---|
| 40 | } |
|---|
| 41 | return override(handle<>(detail::none())); |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | #if 0 |
|---|
| 46 | namespace converter |
|---|
| 47 | { |
|---|
| 48 | PyObject* BOOST_PYTHON_DECL do_polymorphic_ref_to_python( |
|---|
| 49 | python::detail::wrapper_base const volatile* x, type_info src |
|---|
| 50 | ) |
|---|
| 51 | { |
|---|
| 52 | if (x == 0) |
|---|
| 53 | { |
|---|
| 54 | ::PyErr_Format( |
|---|
| 55 | PyExc_TypeError |
|---|
| 56 | , "Attempting to returning pointer or reference to instance of %s\n" |
|---|
| 57 | "for which no corresponding Python object exists. Wrap this function" |
|---|
| 58 | "with a return return value policy" |
|---|
| 59 | ) |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | } |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | }} // namespace boost::python::detail |
|---|