]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/include/boost/python/converter/registrations.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / converter / registrations.hpp
1 // Copyright David Abrahams 2002.
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 REGISTRATIONS_DWA2002223_HPP
6 # define REGISTRATIONS_DWA2002223_HPP
7
8 # include <boost/python/detail/prefix.hpp>
9
10 # include <boost/python/type_id.hpp>
11
12 # include <boost/python/converter/convertible_function.hpp>
13 # include <boost/python/converter/constructor_function.hpp>
14 # include <boost/python/converter/to_python_function_type.hpp>
15
16 # include <boost/detail/workaround.hpp>
17
18 namespace boost { namespace python { namespace converter {
19
20 struct lvalue_from_python_chain
21 {
22 convertible_function convert;
23 lvalue_from_python_chain* next;
24 };
25
26 struct rvalue_from_python_chain
27 {
28 convertible_function convertible;
29 constructor_function construct;
30 PyTypeObject const* (*expected_pytype)();
31 rvalue_from_python_chain* next;
32 };
33
34 struct BOOST_PYTHON_DECL registration
35 {
36 public: // member functions
37 explicit registration(type_info target, bool is_shared_ptr = false);
38 ~registration();
39
40 // Convert the appropriately-typed data to Python
41 PyObject* to_python(void const volatile*) const;
42
43 // Return the class object, or raise an appropriate Python
44 // exception if no class has been registered.
45 PyTypeObject* get_class_object() const;
46
47 // Return common denominator of the python class objects,
48 // convertable to target. Inspects the m_class_object and the value_chains.
49 PyTypeObject const* expected_from_python_type() const;
50 PyTypeObject const* to_python_target_type() const;
51
52 public: // data members. So sue me.
53 const python::type_info target_type;
54
55 // The chain of eligible from_python converters when an lvalue is required
56 lvalue_from_python_chain* lvalue_chain;
57
58 // The chain of eligible from_python converters when an rvalue is acceptable
59 rvalue_from_python_chain* rvalue_chain;
60
61 // The class object associated with this type
62 PyTypeObject* m_class_object;
63
64 // The unique to_python converter for the associated C++ type.
65 to_python_function_t m_to_python;
66 PyTypeObject const* (*m_to_python_target_type)();
67
68
69 // True iff this type is a shared_ptr. Needed for special rvalue
70 // from_python handling.
71 const bool is_shared_ptr;
72
73 # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
74 private:
75 void operator=(registration); // This is not defined, and just keeps MWCW happy.
76 # endif
77 };
78
79 //
80 // implementations
81 //
82 inline registration::registration(type_info target_type, bool is_shared_ptr)
83 : target_type(target_type)
84 , lvalue_chain(0)
85 , rvalue_chain(0)
86 , m_class_object(0)
87 , m_to_python(0)
88 , m_to_python_target_type(0)
89 , is_shared_ptr(is_shared_ptr)
90 {}
91
92 inline bool operator<(registration const& lhs, registration const& rhs)
93 {
94 return lhs.target_type < rhs.target_type;
95 }
96
97 }}} // namespace boost::python::converter
98
99 #endif // REGISTRATIONS_DWA2002223_HPP