]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/include/boost/python/refcount.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / refcount.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 REFCOUNT_DWA2002615_HPP
6 # define REFCOUNT_DWA2002615_HPP
7
8 # include <boost/python/detail/prefix.hpp>
9 # include <boost/python/cast.hpp>
10
11 namespace boost { namespace python {
12
13 template <class T>
14 inline T* incref(T* p)
15 {
16 Py_INCREF(python::upcast<PyObject>(p));
17 return p;
18 }
19
20 template <class T>
21 inline T* xincref(T* p)
22 {
23 Py_XINCREF(python::upcast<PyObject>(p));
24 return p;
25 }
26
27 template <class T>
28 inline void decref(T* p)
29 {
30 assert( Py_REFCNT(python::upcast<PyObject>(p)) > 0 );
31 Py_DECREF(python::upcast<PyObject>(p));
32 }
33
34 template <class T>
35 inline void xdecref(T* p)
36 {
37 assert( !p || Py_REFCNT(python::upcast<PyObject>(p)) > 0 );
38 Py_XDECREF(python::upcast<PyObject>(p));
39 }
40
41 }} // namespace boost::python
42
43 #endif // REFCOUNT_DWA2002615_HPP