gdbtypes.h #defined field accessors
Jan Kratochvil
jan.kratochvil@redhat.com
Thu Jun 24 19:57:00 GMT 2010
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
More information about the Gdb
mailing list