From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 2/5] Introduce ui_file_up and use it to remove cleanups
Date: Mon, 16 Jan 2017 17:58:00 -0000 [thread overview]
Message-ID: <8396005b-762c-7fb6-5151-3d0b11a1f642@redhat.com> (raw)
In-Reply-To: <20170115134253.24018-3-tom@tromey.com>
On 01/15/2017 01:42 PM, Tom Tromey wrote:
> This introduces a new ui_file_up typedef, which is a specialization of
> unique_ptr that calls ui_file_delete. This patch also changes
> mem_fileopen to return a ui_file_up, and fixes the users. It also
> updates a few other spots in the Python code to use this rather than
> cleanups.
>
> If at some point ui_file_delete is removed in favor of a destructor, I
> think the typedef could be changed and the default deletion policy
> used instead.
Urgh, guess you forgot/missed my
palves/cxx-eliminate-cleanups branch ... :-(
The top commit does:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eliminate make_cleanup_ui_file_delete
And now that ui_file_as_string is in, let's eliminate it. :-)
Makes ui_file a real C++ hierarchy. mem_fileopen is replaced with a
new string_file class that is treated as a value class created on the
stack. This alone eliminates most make_cleanup_ui_file_delete calls,
and, simplifies code a whole lot (diffstat shows almost 1k loc
dropped.)
string_file has a string() method that gives you a direct reference to
the internal std::string. This is what replaces old (well, new)
ui_file_as_string, which used to alway return a new copy of the same
data the stream had inside.. With direct access via a writable
reference, we can instead move the string out of the string_stream.
Note I needed a tweak on scoped_restore. That one should probably be
split out to a separate patch.
This exposed the need to make use of gnulib namespace support.
Otherwise, making use of read/write/printf/puts/etc symbol names will
clash on systems where gnulib replaces those functions, due to
'#define foo rpl_foo'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I've been working on fixing that gnulib namespace issue since,
thinking that I'd fix it before posting that patch, but looks
like that was the wrong decision... :-/ Simon's ui_out series
also had the same problem, but since common-defs.h includes
the system headers that might cause the problem before
any other header, it ends up not being such a bad problem
in practice...
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-01-16 17:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 13:43 [RFA 0/5] more cleanup removal in Python Tom Tromey
2017-01-15 13:43 ` [RFA 4/5] Change one more spot to use gdbpy_ref Tom Tromey
2017-02-09 12:52 ` Pedro Alves
2017-01-15 13:43 ` [RFA 3/5] Introduce gdbpy_subclass and use it to simplify some logic Tom Tromey
2017-01-24 20:21 ` Simon Marchi
2017-02-09 11:44 ` Pedro Alves
2017-02-09 18:52 ` Tom Tromey
2017-02-09 13:00 ` Pedro Alves
2017-01-15 13:43 ` [RFA 1/5] Remove some ui_out-related cleanups from Python Tom Tromey
2017-01-15 21:52 ` Simon Marchi
2017-01-16 16:13 ` Tom Tromey
2017-01-16 11:19 ` Trevor Saunders
2017-02-08 17:28 ` Pedro Alves
2017-02-08 22:27 ` Pedro Alves
2017-02-08 23:05 ` Tom Tromey
2017-02-08 23:52 ` Pedro Alves
2017-02-09 4:34 ` Matt Rice
2017-02-09 12:48 ` Pedro Alves
2017-02-09 12:51 ` Pedro Alves
2017-02-09 15:46 ` Matt Rice
2017-02-09 16:04 ` Simon Marchi
2017-02-10 6:47 ` Trevor Saunders
2017-01-15 13:43 ` [RFA 2/5] Introduce ui_file_up and use it to remove cleanups Tom Tromey
2017-01-16 9:59 ` Trevor Saunders
2017-01-16 17:58 ` Pedro Alves [this message]
2017-01-16 19:08 ` Tom Tromey
2017-01-17 1:40 ` Pedro Alves
2017-01-17 19:05 ` Tom Tromey
2017-01-15 13:43 ` [RFA 5/5] Remove some gotos from Python Tom Tromey
2017-02-09 13:03 ` Pedro Alves
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=8396005b-762c-7fb6-5151-3d0b11a1f642@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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