gdb/python: Make convert_values_to_python return gdbpy_ref<>
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 10 Sep 2018 11:05:22 +0000 (12:05 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 25 Oct 2018 11:20:18 +0000 (12:20 +0100)
Make convert_values_to_python return a gdbpy_ref<> directly rather
than building a gdbpy_ref<>, releasing it, and then having a new
gdbpy_ref<> created to hold the result.

I also added a header comment to convert_values_to_python.

gdb/ChangeLog:

* python/py-function.c (convert_values_to_python): Return
gdbpy_ref<>. Add header comment.
(fnpy_call): Adjust.

gdb/ChangeLog
gdb/python/py-function.c

index 6ab2ec8021853e5dcb4d3834e4e1dd698f72694a..61dc039d4fe963bf33a82b68350f8765a013da24 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-25  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * python/py-function.c (convert_values_to_python): Return
+       gdbpy_ref<>.  Add header comment.
+       (fnpy_call): Adjust.
+
 2018-10-25  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * python/py-cmd.c (cmdpy_completer_helper): Return gdbpy_ref<>.
index 1900f0ff0c0fde4c432b1e829887b6a945b9e877..cf5e68a0545718e55ea686af43b1bbc40952a742 100644 (file)
@@ -34,7 +34,10 @@ extern PyTypeObject fnpy_object_type
 
 \f
 
-static PyObject *
+/* Return a reference to a tuple ARGC elements long.  Each element of the
+   tuple is a PyObject converted from the corresponding element of ARGV.  */
+
+static gdbpy_ref<>
 convert_values_to_python (int argc, struct value **argv)
 {
   int i;
@@ -50,7 +53,7 @@ convert_values_to_python (int argc, struct value **argv)
        return NULL;
       PyTuple_SetItem (result.get (), i, elt.release ());
     }
-  return result.release ();
+  return result;
 }
 
 /* Call a Python function object's invoke method.  */
@@ -64,7 +67,7 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
   gdbpy_enter enter_py (gdbarch, language);
   struct value *value;
   gdbpy_ref<> result;
-  gdbpy_ref<> args (convert_values_to_python (argc, argv));
+  gdbpy_ref<> args = convert_values_to_python (argc, argv);
 
   /* convert_values_to_python can return NULL on error.  If we
      encounter this, do not call the function, but allow the Python ->
This page took 0.030698 seconds and 4 git commands to generate.