]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/converter/pyobject_type.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / converter / pyobject_type.hpp
CommitLineData
7c673cae
FG
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 PYOBJECT_TYPE_DWA2002720_HPP
6# define PYOBJECT_TYPE_DWA2002720_HPP
7
8# include <boost/python/cast.hpp>
9
10namespace boost { namespace python { namespace converter {
11
12BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
13
14// Used as a base class for specializations which need to provide
15// Python type checking capability.
16template <class Object, PyTypeObject* pytype>
17struct pyobject_type
18{
19 static bool check(PyObject* x)
20 {
21 return ::PyObject_IsInstance(x, (PyObject*)pytype);
22 }
23
24 static Object* checked_downcast(PyObject* x)
25 {
26 return python::downcast<Object>(
27 (checked_downcast_impl)(x, pytype)
28 );
29 }
30#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
31 static PyTypeObject const* get_pytype() { return pytype; }
32#endif
33};
34
35}}} // namespace boost::python::converter
36
37#endif // PYOBJECT_TYPE_DWA2002720_HPP