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 1/2] gdb/python: Make a function return gdbpy_ref<>
Date: Wed, 24 Oct 2018 19:12:00 -0000	[thread overview]
Message-ID: <e6ff4c8277bfedffe393e709887c42e309d2688a.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 cmdpy_completer_helper 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.

gdb/ChangeLog:

	* python/py-cmd.c (cmdpy_completer_helper): Return gdbpy_ref<>.
	(cmdpy_completer_handle_brkchars): Adjust.
	(cmdpy_completer): Adjust.
---
 gdb/ChangeLog       |  6 ++++++
 gdb/python/py-cmd.c | 16 ++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index e7eb66f515c..d560b3a44e3 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -174,10 +174,10 @@ cmdpy_function (struct cmd_list_element *command,
    and then a "complete"-completion sequentially.  Therefore, we just
    recalculate everything twice for TAB-completions.
 
-   This function returns the PyObject representing the Python method
-   call.  */
+   This function returns a reference to the PyObject representing the
+   Python method call.  */
 
-static PyObject *
+static gdbpy_ref<>
 cmdpy_completer_helper (struct cmd_list_element *command,
 			const char *text, const char *word)
 {
@@ -220,7 +220,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
       PyErr_Clear ();
     }
 
-  return resultobj.release ();
+  return resultobj;
 }
 
 /* Python function called to determine the break characters of a
@@ -235,9 +235,9 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
 {
   gdbpy_enter enter_py (get_current_arch (), current_language);
 
-  /* Calling our helper to obtain the PyObject of the Python
+  /* Calling our helper to obtain a reference to the PyObject of the Python
      function.  */
-  gdbpy_ref<> resultobj (cmdpy_completer_helper (command, text, word));
+  gdbpy_ref<> resultobj = cmdpy_completer_helper (command, text, word);
 
   /* Check if there was an error.  */
   if (resultobj == NULL)
@@ -278,9 +278,9 @@ cmdpy_completer (struct cmd_list_element *command,
 {
   gdbpy_enter enter_py (get_current_arch (), current_language);
 
-  /* Calling our helper to obtain the PyObject of the Python
+  /* Calling our helper to obtain a reference to the PyObject of the Python
      function.  */
-  gdbpy_ref<> resultobj (cmdpy_completer_helper (command, text, word));
+  gdbpy_ref<> resultobj = cmdpy_completer_helper (command, text, word);
 
   /* If the result object of calling the Python function is NULL, it
      means that there was an error.  In this case, just give up.  */
-- 
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 2/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=e6ff4c8277bfedffe393e709887c42e309d2688a.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