Line | |
---|
1 | // Copyright David Abrahams 2003.
|
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
3 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
4 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
5 | #ifndef SHARED_PTR_TO_PYTHON_DWA2003224_HPP
|
---|
6 | # define SHARED_PTR_TO_PYTHON_DWA2003224_HPP
|
---|
7 |
|
---|
8 | # include <boost/python/refcount.hpp>
|
---|
9 | # include <boost/python/converter/shared_ptr_deleter.hpp>
|
---|
10 | # include <boost/shared_ptr.hpp>
|
---|
11 | # include <boost/get_pointer.hpp>
|
---|
12 |
|
---|
13 | namespace boost { namespace python { namespace converter {
|
---|
14 |
|
---|
15 | template <class T>
|
---|
16 | PyObject* shared_ptr_to_python(shared_ptr<T> const& x)
|
---|
17 | {
|
---|
18 | if (!x)
|
---|
19 | return python::detail::none();
|
---|
20 | else if (shared_ptr_deleter* d = boost::get_deleter<shared_ptr_deleter>(x))
|
---|
21 | return incref( get_pointer( d->owner ) );
|
---|
22 | else
|
---|
23 | return converter::registered<shared_ptr<T> const&>::converters.to_python(&x);
|
---|
24 | }
|
---|
25 |
|
---|
26 | }}} // namespace boost::python::converter
|
---|
27 |
|
---|
28 | #endif // SHARED_PTR_TO_PYTHON_DWA2003224_HPP
|
---|
Note: See
TracBrowser
for help on using the repository browser.