aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-xmethods.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-08 15:35:24 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:49 -0700
commitbf1ca3b9476185fb6e301d85e646f5d2af95e257 (patch)
tree29b674244b9f558411470a9949aa8ec434006374 /gdb/python/py-xmethods.c
parent572a5524c1eb50d8064a44108fd0ef22a0e63bf8 (diff)
downloadgdb-bf1ca3b9476185fb6e301d85e646f5d2af95e257.zip
gdb-bf1ca3b9476185fb6e301d85e646f5d2af95e257.tar.gz
gdb-bf1ca3b9476185fb6e301d85e646f5d2af95e257.tar.bz2
Use gdbpy_ref in invoke_match_method
Change invoke_match_method to use gdbpy_ref. I neglected to convert this function in my earlier series. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-xmethods.c (invoke_match_method): Use gdbpy_ref.
Diffstat (limited to 'gdb/python/py-xmethods.c')
-rw-r--r--gdb/python/py-xmethods.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index 2bac9da..939cff3 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -94,59 +94,33 @@ 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_ref 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_ref 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_ref 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. */