Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 2/2] gdb/python: Make a function return gdbpy_ref<>
Date: Wed, 24 Oct 2018 19:12:00 -0000	[thread overview]
Message-ID: <3d0d7723dc6b3116efc41a05b573938defee801c.1540407540.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1540407540.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1540407540.git.andrew.burgess@embecosm.com>

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            | 6 ++++++
 gdb/python/py-function.c | 9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 1900f0ff0c0..cf5e68a0545 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -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 ->
-- 
2.14.5


  parent reply	other threads:[~2018-10-24 19:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24 19:12 [PATCH 0/2] Return gdbpy_ref in a couple more places Andrew Burgess
2018-10-24 19:12 ` [PATCH 1/2] gdb/python: Make a function return gdbpy_ref<> Andrew Burgess
2018-10-24 19:12 ` Andrew Burgess [this message]
2018-10-24 20:03 ` [PATCH 0/2] Return gdbpy_ref in a couple more places Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d0d7723dc6b3116efc41a05b573938defee801c.1540407540.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox