Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Joel Brobecker <brobecker@adacore.com>,
	gdb-patches@sourceware.org,
	        Tobias Burnus <burnus@net-b.de>,
	Ulrich Weigand <uweigand@de.ibm.com>,
	        Jim Blandy <jimb@red-bean.com>
Subject: Re: Accessor macro wrappers removal  [Re: [patch] static_kind -> 	bit0,  bit1]
Date: Thu, 02 Oct 2008 20:59:00 -0000	[thread overview]
Message-ID: <20081002205722.GA12134@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <20080926125422.GB21287@caradoc.them.org>

On Fri, 26 Sep 2008 14:54:22 +0200, Daniel Jacobowitz wrote:
> On Fri, Sep 26, 2008 at 06:43:09AM +0200, Jan Kratochvil wrote:
> > On Sat, 20 Sep 2008 00:12:21 +0200, Joel Brobecker wrote:
> > > > Also I do not understand why exist all the macros like this one at all:
> > > > #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
> > > > Why we cannot use it expanded?  This way it is always one (or more)
> > > > "tags"-jump (VIM ctrl-]) indirections while navigating the source files.
> > > 
> > > Personally, I find them to be very useful to quickly find who is using
> > > field "main_type" in struct type.
> > 
> > How does it differ from
> >   grep -- '->main_type\>' *.[ch]
> > ?
> 
> "in struct type" is the difference.

* Either to use static getters/setters (Gnome):
  struct main_type *type_main_type_get (struct type *type);

* or in the C++ way (optional get/set prefixes instead of the overloading):
  class type {
    private: struct main_type *_main_type;
    public: struct main_type *main_type () { return _main_type; }
    public: void main_type (struct main_type *v) { _main_type = v; }
  };
  One can get here even the automatic reference counting / memory management.

* or to use semiunique fields prefix:
  struct type { struct main_type *tp_main_type; ... };


> For main_type it's not too bad.  But for e.g. TYPE_FIELD_TYPE you can
> see the problem; there's lots of things that have a type.  If you're
> looking just for the ones that come from a "struct field", it can be
> pretty awful to locate them all.

There is not the mess of mixed prefix (macros) vs. postfix (fields):
xml-tdesc.c:
if (TYPE_VECTOR (TYPE_FIELD_TYPE (data->current_union, i)))

It gets expanded to:
if ((((((data->current_union)->main_type->fields[i]).type))->main_type->flag_vector))
if (data->current_union->main_type->fields[i].type->main_type->flag_vector)

Which could be simplified with C++ (do you also find it more clear?):
if (data->current_union->fields()[i]->type()->flag_vector())


Regards,
Jan


  reply	other threads:[~2008-10-02 20:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-15 15:06 [gdb] Fortran dynamic arrays Tobias Burnus
2008-08-18 11:12 ` Joel Brobecker
2008-08-18 15:54   ` Ulrich Weigand
2008-09-07 11:59 ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Jan Kratochvil
2008-09-08 15:32   ` Tom Tromey
2008-09-08 17:27     ` Jan Kratochvil
2008-09-19 22:29       ` Joel Brobecker
2008-09-26 23:04         ` Tom Tromey
2008-09-27 14:53           ` Joel Brobecker
2008-09-19  6:04   ` Joel Brobecker
2008-09-22 15:25     ` Jan Kratochvil
2008-09-24 19:15       ` Joel Brobecker
2008-09-26  5:03         ` Jan Kratochvil
2008-09-26 22:12           ` Joel Brobecker
2008-10-02 22:13             ` [patch] Fortran obsolete bounds type [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-09-26 12:52         ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Daniel Jacobowitz
2008-09-26 22:15           ` Joel Brobecker
2008-09-26 22:20             ` Daniel Jacobowitz
2008-09-19 22:13   ` Joel Brobecker
2008-09-26  5:06     ` Accessor macro wrappers removal [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-09-26 12:55       ` Daniel Jacobowitz
2008-10-02 20:59         ` Jan Kratochvil [this message]
2008-10-02 21:05           ` Daniel Jacobowitz
2008-09-26 23:15       ` Tom Tromey
2008-09-26 12:58     ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Daniel Jacobowitz
     [not found]       ` <20081006200928.GD3588@adacore.com>
2008-10-06 20:26         ` Jan Kratochvil
2008-10-07 23:22         ` type/main_type/field size [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-10-08  3:32           ` Joel Brobecker
2008-10-08 23:56             ` Tom Tromey
2008-10-04 20:28     ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Jan Kratochvil
2008-10-06 20:00       ` Joel Brobecker
2008-10-07 23:18         ` Jan Kratochvil
2008-10-08  3:28           ` Joel Brobecker
2008-10-08 12:54             ` Jan Kratochvil

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=20081002205722.GA12134@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=burnus@net-b.de \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jimb@red-bean.com \
    --cc=uweigand@de.ibm.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