public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdbtypes.h #defined field accessors
@ 2010-06-24 19:57 Jan Kratochvil
  2010-06-28 20:37 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2010-06-24 19:57 UTC (permalink / raw)
  To: gdb

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-30 21:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-24 19:57 gdbtypes.h #defined field accessors Jan Kratochvil
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

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).