From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84423 invoked by alias); 16 Nov 2018 18:27:53 -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 84392 invoked by uid 89); 16 Nov 2018 18:27:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_STOCKGEN,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Feel, admit X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Nov 2018 18:27:52 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D19430012E0; Fri, 16 Nov 2018 18:27:50 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B8660BE5; Fri, 16 Nov 2018 18:27:49 +0000 (UTC) Subject: Re: [RFA 1/5] Add class scoped_switch_auto_to_sym_language. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20181028144614.14149-1-philippe.waroquiers@skynet.be> <20181028144614.14149-2-philippe.waroquiers@skynet.be> From: Pedro Alves Message-ID: <516744d6-6186-23ee-7e23-ad59a51acf5d@redhat.com> Date: Fri, 16 Nov 2018 18:27:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181028144614.14149-2-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-11/txt/msg00256.txt.bz2 On 10/28/2018 02:46 PM, Philippe Waroquiers wrote: > The class scoped_switch_auto_to_sym_language allows to switch in a scope > the current language to the language of a symbol when language mode is > set to auto. > > 2018-10-27 Philippe Waroquiers > > * language.h (scoped_switch_auto_to_sym_language): new class. s/new/New/ > --- > gdb/language.h | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/gdb/language.h b/gdb/language.h > index 02a84ff9a2..47a88de756 100644 > --- a/gdb/language.h > +++ b/gdb/language.h > @@ -707,4 +707,43 @@ private: > enum language m_lang; > }; > > +/* If language_mode is language_mode_auto, > + then switches current language to the language of SYM > + and restore current language upon destruction. > + > + Else does nothing. */ Either s/switches/switch/ s/does/do/ or s/restore/restores/ I'd go with the former. > + > +class scoped_switch_auto_to_sym_language I have to admit that I had trouble grokking the class's name for a bit. I don't have a much better suggestion, though this would read a bit better to me: scoped_switch_to_sym_language_if_auto scoped_switch_to_sym_lang_if_auto But may well be just me. Feel free to ignore. > +{ > +public: > + > + explicit scoped_switch_auto_to_sym_language (const struct symbol *sym) > + { > + if (language_mode == language_mode_auto) > + { > + m_lang = current_language->la_language; > + m_switched = true; > + set_language (SYMBOL_LANGUAGE (sym)); > + } > + else > + m_switched = false; > + } > + > + ~scoped_switch_auto_to_sym_language () > + { > + if (m_switched) > + set_language (m_lang); > + } > + > + scoped_switch_auto_to_sym_language > + (const scoped_switch_auto_to_sym_language &) > + = delete; > + scoped_switch_auto_to_sym_language &operator= > + (const scoped_switch_auto_to_sym_language &) = delete; Use DISABLE_COPY_AND_ASSIGN instead. Otherwise OK. > + > +private: > + bool m_switched; > + enum language m_lang; > +}; > + > #endif /* defined (LANGUAGE_H) */ > Thanks, Pedro Alves