Chris@16
|
1 // Copyright David Abrahams 2001.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
3 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 #ifndef CLASS_WRAPPER_DWA20011221_HPP
|
Chris@16
|
6 # define CLASS_WRAPPER_DWA20011221_HPP
|
Chris@16
|
7
|
Chris@16
|
8 # include <boost/python/to_python_converter.hpp>
|
Chris@16
|
9 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
Chris@16
|
10 # include <boost/python/converter/pytype_function.hpp>
|
Chris@16
|
11 #endif
|
Chris@16
|
12 # include <boost/ref.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost { namespace python { namespace objects {
|
Chris@16
|
15
|
Chris@16
|
16 //
|
Chris@16
|
17 // These two classes adapt the static execute function of a class
|
Chris@16
|
18 // MakeInstance execute() function returning a new PyObject*
|
Chris@16
|
19 // reference. The first one is used for class copy constructors, and
|
Chris@16
|
20 // the second one is used to handle smart pointers.
|
Chris@16
|
21 //
|
Chris@16
|
22
|
Chris@16
|
23 template <class Src, class MakeInstance>
|
Chris@16
|
24 struct class_cref_wrapper
|
Chris@16
|
25 : to_python_converter<Src,class_cref_wrapper<Src,MakeInstance> ,true>
|
Chris@16
|
26 {
|
Chris@16
|
27 static PyObject* convert(Src const& x)
|
Chris@16
|
28 {
|
Chris@16
|
29 return MakeInstance::execute(boost::ref(x));
|
Chris@16
|
30 }
|
Chris@16
|
31 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
Chris@16
|
32 static PyTypeObject const *get_pytype() { return converter::registered_pytype_direct<Src>::get_pytype(); }
|
Chris@16
|
33 #endif
|
Chris@16
|
34 };
|
Chris@16
|
35
|
Chris@16
|
36 template <class Src, class MakeInstance>
|
Chris@16
|
37 struct class_value_wrapper
|
Chris@16
|
38 : to_python_converter<Src,class_value_wrapper<Src,MakeInstance> ,true>
|
Chris@16
|
39 {
|
Chris@16
|
40 static PyObject* convert(Src x)
|
Chris@16
|
41 {
|
Chris@16
|
42 return MakeInstance::execute(x);
|
Chris@16
|
43 }
|
Chris@16
|
44 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
Chris@16
|
45 static PyTypeObject const *get_pytype() { return MakeInstance::get_pytype(); }
|
Chris@16
|
46 #endif
|
Chris@16
|
47 };
|
Chris@16
|
48
|
Chris@16
|
49 }}} // namespace boost::python::objects
|
Chris@16
|
50
|
Chris@16
|
51 #endif // CLASS_WRAPPER_DWA20011221_HPP
|