From patchwork Wed Oct 24 19:12:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 29874 Received: (qmail 53527 invoked by alias); 24 Oct 2018 19:12:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53421 invoked by uid 89); 24 Oct 2018 19:12:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Calling, Hx-languages-length:2441, our X-HELO: mail-wm1-f43.google.com Received: from mail-wm1-f43.google.com (HELO mail-wm1-f43.google.com) (209.85.128.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Oct 2018 19:12:14 +0000 Received: by mail-wm1-f43.google.com with SMTP id 143-v6so6492686wmf.1 for ; Wed, 24 Oct 2018 12:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6FEIsYQ4BOdV5OU/r5ayKep7192I+/MGUYZe6wEC4gk=; b=MTMIhtzF3FHOgr0vK6xDGrvyi/bsSwaAlb8WRPkdbjuRyTTHQjlTr9E/dBWImh+DPy smFadpztYlblPTTCFLYDQOc+fAtVFUYgcJtkn3KtBNKjgmvx1tsXG+HW+iZLGDevzqgX ttg+9vBXSkdpSn7yAH3j9wkoeDzGbgl8P2KyGvPRpRRVnr05dexfoloBt35OB6py4zWP iEm7pb+hasPAjDk6Mtd4YB9pwAjBsGQk9E/FUKT7u+bNkxPs+JnDfH4ZotJ9qAmdPvdj hNFL9EUXH7KcK6lUVitLueeHBxKloWyLRyW6iAV5y2kJi2p7RFr+uuXkCwg2bE83JiA5 oZQw== Return-Path: Received: from localhost (host86-164-85-193.range86-164.btcentralplus.com. [86.164.85.193]) by smtp.gmail.com with ESMTPSA id 203-v6sm7860362wmn.34.2018.10.24.12.12.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Oct 2018 12:12:11 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/2] gdb/python: Make a function return gdbpy_ref<> Date: Wed, 24 Oct 2018 20:12:02 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 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. */