]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/converter/pytype_function.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / converter / pytype_function.hpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2002, Nikolay Mladenov 2007.
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 WRAP_PYTYPE_NM20070606_HPP
6# define WRAP_PYTYPE_NM20070606_HPP
7
8# include <boost/python/detail/prefix.hpp>
9# include <boost/python/converter/registered.hpp>
10# include <boost/python/detail/unwind_type.hpp>
11
12
13namespace boost { namespace python {
14
15namespace converter
16{
17template <PyTypeObject const* python_type>
18struct wrap_pytype
19{
20 static PyTypeObject const* get_pytype()
21 {
22 return python_type;
23 }
24};
25
26typedef PyTypeObject const* (*pytype_function)();
27
28#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
29
30
31
32namespace detail
33{
34struct unwind_type_id_helper{
35 typedef python::type_info result_type;
36 template <class U>
37 static result_type execute(U* ){
38 return python::type_id<U>();
39 }
40};
41
42template <class T>
43inline python::type_info unwind_type_id_(boost::type<T>* = 0, mpl::false_ * =0)
44{
45 return boost::python::detail::unwind_type<unwind_type_id_helper, T> ();
46}
47
48inline python::type_info unwind_type_id_(boost::type<void>* = 0, mpl::true_* =0)
49{
50 return type_id<void>();
51}
52
53template <class T>
54inline python::type_info unwind_type_id(boost::type<T>* p= 0)
55{
56 return unwind_type_id_(p, (mpl::bool_<boost::is_void<T>::value >*)0 );
57}
58}
59
60
61template <class T>
62struct expected_pytype_for_arg
63{
64 static PyTypeObject const *get_pytype()
65 {
66 const converter::registration *r=converter::registry::query(
67 detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::is_void<T>::value >*)0 )
68 );
69 return r ? r->expected_from_python_type(): 0;
70 }
71};
72
73
74template <class T>
75struct registered_pytype
76{
77 static PyTypeObject const *get_pytype()
78 {
79 const converter::registration *r=converter::registry::query(
80 detail::unwind_type_id_((boost::type<T>*) 0, (mpl::bool_<boost::is_void<T>::value >*)0 )
81 );
82 return r ? r->m_class_object: 0;
83 }
84};
85
86
87template <class T>
88struct registered_pytype_direct
89{
90 static PyTypeObject const* get_pytype()
91 {
92 return registered<T>::converters.m_class_object;
93 }
94};
95
96template <class T>
97struct expected_from_python_type : expected_pytype_for_arg<T>{};
98
99template <class T>
100struct expected_from_python_type_direct
101{
102 static PyTypeObject const* get_pytype()
103 {
104 return registered<T>::converters.expected_from_python_type();
105 }
106};
107
108template <class T>
109struct to_python_target_type
110{
111 static PyTypeObject const *get_pytype()
112 {
113 const converter::registration *r=converter::registry::query(
114 detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::is_void<T>::value >*)0 )
115 );
116 return r ? r->to_python_target_type(): 0;
117 }
118};
119
120template <class T>
121struct to_python_target_type_direct
122{
123 static PyTypeObject const *get_pytype()
124 {
125 return registered<T>::converters.to_python_target_type();
126 }
127};
128#endif
129
130}}} // namespace boost::python
131
132#endif // WRAP_PYTYPE_NM20070606_HPP