public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb@sourceware.org
Subject: gdbtypes.h #defined field accessors
Date: Thu, 24 Jun 2010 19:57:00 -0000	[thread overview]
Message-ID: <20100624195656.GA19643@host0.dyn.jankratochvil.net> (raw)

Hi,

I have a longterm question.  gdbtypes.h contains definitions like:

#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
#define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic

Why the code does not use directly the right hand side?  It would even have
the same (in some cases shorter, in some cases longer) statements length:

  f (TYPE_N_BASECLASSES (type), TYPE_CPLUS_DYNAMIC (type);
->
  struct cplus_struct_type *cplus = TYPE_CPLUS_SPECIFIC (type);
  f (cplus->n_baseclasses, cplus->is_dynamic);

I have only an idea to permit turning direct field into a getter such as is:

#define TYPE_CPLUS_SPECIFIC(thistype) \
   (!HAVE_CPLUS_STRUCT(thistype) \
    ? (struct cplus_struct_type*)&cplus_struct_default \
    : TYPE_RAW_CPLUS_SPECIFIC(thistype))

Coccinelle makes such later transformation automatic even without any macros.
Should new fields still follow this paradigm?

On Thu, 17 Jun 2010 04:31:57 +0200, Tom Tromey wrote:
# It is customary to make new wrapper macros for new fields here.
# I'm not sure that adds much benefit, but maybe just consistency is a
# good enough reason.


Thanks,
Jan

             reply	other threads:[~2010-06-24 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24 19:57 Jan Kratochvil [this message]
2010-06-28 20:37 ` Tom Tromey
2010-06-28 20:57   ` Joel Brobecker
2010-06-30 21:51     ` Tom Tromey
2010-06-29 23:15   ` 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=20100624195656.GA19643@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).