This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 17/20] Use gdbpy_reference in invoke_match_method
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Thu, 10 Nov 2016 15:19:44 -0700
- Subject: [RFA 17/20] Use gdbpy_reference in invoke_match_method
- Authentication-results: sourceware.org; auth=none
- References: <1478816387-27064-1-git-send-email-tom@tromey.com>
Change invoke_match_method to use gdbpy_reference.
I neglected to convert this function in my earlier series.
2016-11-10 Tom Tromey <tom@tromey.com>
* python/py-xmethods.c (invoke_match_method): Use
gdbpy_reference.
---
gdb/ChangeLog | 5 +++++
gdb/python/py-xmethods.c | 51 ++++++++++++------------------------------------
2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fef6a71..cb0492d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-11-10 Tom Tromey <tom@tromey.com>
+ * python/py-xmethods.c (invoke_match_method): Use
+ gdbpy_reference.
+
+2016-11-10 Tom Tromey <tom@tromey.com>
+
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): use
gdbpy_enter, gdbpy_reference.
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index ca83b0b..a5319cc 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -94,59 +94,34 @@ static PyObject *
invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
const char *xmethod_name)
{
- PyObject *py_xmethod_name;
- PyObject *match_method, *enabled_field, *match_result;
- struct cleanup *cleanups;
int enabled;
- cleanups = make_cleanup (null_cleanup, NULL);
-
- enabled_field = PyObject_GetAttrString (matcher, enabled_field_name);
+ gdbpy_reference enabled_field (PyObject_GetAttrString (matcher,
+ enabled_field_name));
if (enabled_field == NULL)
- {
- do_cleanups (cleanups);
- return NULL;
- }
- make_cleanup_py_decref (enabled_field);
+ return NULL;
- enabled = PyObject_IsTrue (enabled_field);
+ enabled = PyObject_IsTrue (enabled_field.get ());
if (enabled == -1)
- {
- do_cleanups (cleanups);
- return NULL;
- }
+ return NULL;
if (enabled == 0)
{
/* Return 'None' if the matcher is not enabled. */
- do_cleanups (cleanups);
Py_RETURN_NONE;
}
- match_method = PyObject_GetAttrString (matcher, match_method_name);
+ gdbpy_reference match_method (PyObject_GetAttrString (matcher,
+ match_method_name));
if (match_method == NULL)
- {
- do_cleanups (cleanups);
- return NULL;
- }
- make_cleanup_py_decref (match_method);
+ return NULL;
- py_xmethod_name = PyString_FromString (xmethod_name);
+ gdbpy_reference py_xmethod_name (PyString_FromString (xmethod_name));
if (py_xmethod_name == NULL)
- {
- do_cleanups (cleanups);
- return NULL;
- }
- make_cleanup_py_decref (py_xmethod_name);
-
- match_result = PyObject_CallMethodObjArgs (matcher,
- py_match_method_name,
- py_obj_type,
- py_xmethod_name,
- NULL);
-
- do_cleanups (cleanups);
+ return NULL;
- return match_result;
+ return PyObject_CallMethodObjArgs (matcher, py_match_method_name,
+ py_obj_type, py_xmethod_name.get (),
+ NULL);
}
/* Implementation of get_matching_xmethod_workers for Python. */
--
2.7.4