This is the mail archive of the
mailing list for the GDB project.
Re: [users/palves/cxx-target_ops] Convert struct target_ops to C++
- From: Tom Tromey <tom at tromey dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Thu, 15 Sep 2016 13:43:50 -0600
- Subject: Re: [users/palves/cxx-target_ops] Convert struct target_ops to C++
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
>>>>> "Pedro" == Pedro Alves <firstname.lastname@example.org> writes:
Pedro> The other week I started converting struct target_ops to
Pedro> use C++ virtual methods and inheritance instead of tables
Pedro> of function pointers.
This is great.
I took a look at it. It's much cleaner than the approach I took on my
old multi-target branch. Removing to_xclose and converting everything
is more ambitious but, IMO, really paid off.
I wonder how you plan to handle target life cycles. In my approach, I
made to_xclose a sentinel, meaning that an "xclose" target could be
"delete"d when popped.
One idea would be not to have any singleton targets. However, then
there's another issue, namely that sometimes targets do a kind of
"instanceof" check -- see the (few remaining) target_is_pushed calls.
Maybe you can just use RTTI. How nice to have C++ now :)
Getting rid of singletons would mean removing all the things like
A couple minor notes --
I still saw a reference to "to_data" in a comment.
Naming a method "wait" may trip up on platforms where this is a #define.