annotate DEPENDENCIES/generic/include/boost/python/converter/registrations.hpp @ 125:34e428693f5d vext

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