From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111930 invoked by alias); 7 Jan 2018 14:27:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 111919 invoked by uid 89); 7 Jan 2018 14:27:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=ify, getter, owning, act X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 07 Jan 2018 14:27:12 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w07ER5SQ003987 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 7 Jan 2018 09:27:10 -0500 Received: by simark.ca (Postfix, from userid 112) id 61E301E5B7; Sun, 7 Jan 2018 09:27:05 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 67BB41E093; Sun, 7 Jan 2018 09:26:54 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 07 Jan 2018 14:27:00 -0000 From: Simon Marchi To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] C++ify xmethod_worker, get rid of VEC(xmethod_worker_ptr) In-Reply-To: <1511790817-27382-1-git-send-email-simon.marchi@ericsson.com> References: <1511790817-27382-1-git-send-email-simon.marchi@ericsson.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.2 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sun, 7 Jan 2018 14:27:05 +0000 X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00138.txt.bz2 On 2017-11-27 08:53, Simon Marchi wrote: > From: Simon Marchi > > The initial goal of this patch was to remove the usage of > VEC(xmethod_worker_ptr) and corresponding cleanups. I ended up having > to C++ify the xmethod_worker code, to be able to have xmethod_workers > free their data in destructors, and therefore be able to use vectors of > xmethod_worker unique_ptr. > > The operations in extension_language_ops that act on one instance of > xmethod_worker (get result type, get args type, invoke) are transformed > to methods of xmethod_worker. xmethod_worker becomes an abstract base > class with virtual pure methods which python_xmethod_worker implements. > The only xmethod-related operation left in extension_language_ops is > get_matching_xmethod_workers, which returns a list of xmethod_workers. > > The changes are relatively straightforward, but here are some notes on > things that may raise eyebrows: > > - I was not really comfortable with the value_of_xmethod function. > At > first it looks like a simple getter, so I considered making it a > method of xmethod_worker. But actually it creates a value and > transfers the ownership of the xmethod_worker to it. It would be a > bit weird and error-prone if calling a method on an object silently > removed the ownership of the object from the caller. To reflect the > behavior more accurately, I renamed it to value_from_xmethod and made > it accept an rvalue-reference (so the caller knows it gives away the > ownership). I noticed the backlink from xmethod_worker to its owning > value was not used, so I removed it. > > - Some code, like get_matching_xmethod_workers, made each callee fill > a new vector, which was then merged in the result vector. I think > it's safe if we always pass the same vector around, and each > implementation just appends to it. > > - The clone operation does not seem particularly useful, it is > removed > in the following patch. I pushed these two patches in. Simon