1 | // Copyright Gottfried Ganßauge 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 | /* |
6 | * Generic Return value converter generator for opaque C++-pointers |
7 | */ |
8 | # ifndef RETURN_OPAQUE_POINTER_HPP_ |
9 | # define RETURN_OPAQUE_POINTER_HPP_ |
10 | |
11 | # include <boost/python/detail/prefix.hpp> |
12 | # include <boost/python/opaque_pointer_converter.hpp> |
13 | # include <boost/python/detail/force_instantiate.hpp> |
14 | # include <boost/python/to_python_value.hpp> |
15 | # include <boost/python/detail/value_arg.hpp> |
16 | # include <boost/mpl/assert.hpp> |
17 | |
18 | namespace boost { namespace python { |
19 | |
20 | namespace detail |
21 | { |
22 | template <class Pointee> |
23 | static void opaque_pointee(Pointee const volatile*) |
24 | { |
25 | force_instantiate(opaque<Pointee>::instance); |
26 | } |
27 | } |
28 | |
29 | struct return_opaque_pointer |
30 | { |
31 | template <class R> |
32 | struct apply |
33 | { |
34 | BOOST_MPL_ASSERT_MSG( is_pointer<R>::value, RETURN_OPAQUE_POINTER_EXPECTS_A_POINTER_TYPE, (R)); |
35 | |
36 | struct type : |
37 | boost::python::to_python_value< |
38 | typename detail::value_arg<R>::type |
39 | > |
40 | { |
41 | type() { detail::opaque_pointee(R()); } |
42 | }; |
43 | }; |
44 | }; |
45 | |
46 | }} // namespace boost::python |
47 | # endif // RETURN_OPAQUE_POINTER_HPP_ |
48 |