From: Pedro Alves <palves@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
gdb-patches@sourceware.org
Subject: Re: [RFA 1/5] Add class scoped_switch_auto_to_sym_language.
Date: Fri, 16 Nov 2018 18:27:00 -0000 [thread overview]
Message-ID: <516744d6-6186-23ee-7e23-ad59a51acf5d@redhat.com> (raw)
In-Reply-To: <20181028144614.14149-2-philippe.waroquiers@skynet.be>
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 <philippe.waroquiers@skynet.be>
>
> * 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
next prev parent reply other threads:[~2018-11-16 18:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-28 14:46 [RFA 0/5] Use language mode in 'info [functions|variables|types]|rbreak' Philippe Waroquiers
2018-10-28 14:46 ` [RFA 3/5] Add a test to verify info [functions|variables|types]|rbreak respect language_mode Philippe Waroquiers
2018-11-16 18:30 ` Pedro Alves
2018-10-28 14:46 ` [RFA 4/5] Document language choice in 'info [functions|variables|types]|rbreak' commands Philippe Waroquiers
2018-10-28 15:33 ` Eli Zaretskii
2018-10-28 14:46 ` [RFA 1/5] Add class scoped_switch_auto_to_sym_language Philippe Waroquiers
2018-11-16 18:27 ` Pedro Alves [this message]
2018-10-28 14:46 ` [RFA 2/5] Use scoped_switch_auto_to_sym_language in symtab.c to switch language Philippe Waroquiers
2018-11-16 18:28 ` Pedro Alves
2018-11-17 12:24 ` Philippe Waroquiers
2018-10-28 14:46 ` [RFA 5/5] NEWS: Document the language choice by 'info [types|functions|variables]|rbreak' Philippe Waroquiers
2018-10-28 15:31 ` Eli Zaretskii
2018-11-13 19:15 ` PING Re: [RFA 0/5] Use language mode in 'info [functions|variables|types]|rbreak' Philippe Waroquiers
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=516744d6-6186-23ee-7e23-ad59a51acf5d@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=philippe.waroquiers@skynet.be \
/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