]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Don't use template for gdbpy_ref_policy
authorTom Tromey <tom@tromey.com>
Sat, 21 Feb 2026 17:05:24 +0000 (10:05 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 4 Mar 2026 17:07:33 +0000 (10:07 -0700)
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>
gdb/python/py-ref.h

index 4ce7e29357d015b031acbdda6bf56e3f2ab58083..0a56436634dab5a25e21249dbe4b49eb92b3bfff 100644 (file)
 #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.