diff options
| author | Tom Tromey <tom@tromey.com> | 2026-02-21 10:05:24 -0700 |
|---|---|---|
| committer | Tom Tromey <tom@tromey.com> | 2026-03-04 10:07:33 -0700 |
| commit | 0d9faae86e6fadd0cae08fc29424551de458fefc (patch) | |
| tree | c107782f6851640ef49dbc902b6ca4c3f72c0ced /gdb/python | |
| parent | 071381ae0dcaff09139e8cd1e5a4623ecc4b5a36 (diff) | |
| download | binutils-0d9faae86e6fadd0cae08fc29424551de458fefc.tar.gz binutils-0d9faae86e6fadd0cae08fc29424551de458fefc.tar.bz2 binutils-0d9faae86e6fadd0cae08fc29424551de458fefc.zip | |
Don't use template for gdbpy_ref_policy
Now that gdb's Python types derive from PyObject, there's no need to
use a template for gdbpy_ref_policy. This simplifies the code a tiny
bit.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/python')
| -rw-r--r-- | gdb/python/py-ref.h | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h index 4ce7e29357d..0a56436634d 100644 --- a/gdb/python/py-ref.h +++ b/gdb/python/py-ref.h @@ -23,27 +23,23 @@ #include "gdbsupport/gdb_ref_ptr.h" /* A policy class for gdb::ref_ptr for Python reference counting. */ -template<typename T> struct gdbpy_ref_policy { - static_assert(std::is_base_of<PyObject, T>::value, - "T must be a subclass of PyObject"); - - static void incref (T *ptr) + static void incref (PyObject *ptr) { - Py_INCREF (static_cast<PyObject *> (ptr)); + Py_INCREF (ptr); } - static void decref (T *ptr) + static void decref (PyObject *ptr) { - Py_DECREF (static_cast<PyObject *> (ptr)); + Py_DECREF (ptr); } }; /* A gdb::ref_ptr that has been specialized for Python objects or their "subclasses". */ template<typename T = PyObject> using gdbpy_ref - = gdb::ref_ptr<T, gdbpy_ref_policy<T>>; + = gdb::ref_ptr<T, gdbpy_ref_policy>; /* A wrapper class for Python extension objects that have a __dict__ attribute. |
