]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/python/object/class_wrapper.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / python / object / class_wrapper.hpp
1 // Copyright David Abrahams 2001.
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 CLASS_WRAPPER_DWA20011221_HPP
6 # define CLASS_WRAPPER_DWA20011221_HPP
7
8 # include <boost/python/to_python_converter.hpp>
9 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
10 # include <boost/python/converter/pytype_function.hpp>
11 #endif
12 # include <boost/ref.hpp>
13
14 namespace boost { namespace python { namespace objects {
15
16 //
17 // These two classes adapt the static execute function of a class
18 // MakeInstance execute() function returning a new PyObject*
19 // reference. The first one is used for class copy constructors, and
20 // the second one is used to handle smart pointers.
21 //
22
23 template <class Src, class MakeInstance>
24 struct class_cref_wrapper
25 : to_python_converter<Src,class_cref_wrapper<Src,MakeInstance> ,true>
26 {
27 static PyObject* convert(Src const& x)
28 {
29 return MakeInstance::execute(boost::ref(x));
30 }
31 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
32 static PyTypeObject const *get_pytype() { return converter::registered_pytype_direct<Src>::get_pytype(); }
33 #endif
34 };
35
36 template <class Src, class MakeInstance>
37 struct class_value_wrapper
38 : to_python_converter<Src,class_value_wrapper<Src,MakeInstance> ,true>
39 {
40 static PyObject* convert(Src x)
41 {
42 return MakeInstance::execute(x);
43 }
44 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
45 static PyTypeObject const *get_pytype() { return MakeInstance::get_pytype(); }
46 #endif
47 };
48
49 }}} // namespace boost::python::objects
50
51 #endif // CLASS_WRAPPER_DWA20011221_HPP