From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7827 invoked by alias); 2 Oct 2008 20:59:24 -0000 Received: (qmail 7819 invoked by uid 22791); 2 Oct 2008 20:59:23 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 02 Oct 2008 20:58:48 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m92KvX5N013856; Thu, 2 Oct 2008 16:57:33 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m92KvVOs011557; Thu, 2 Oct 2008 16:57:32 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m92KvOGl006926; Thu, 2 Oct 2008 16:57:25 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.2) with ESMTP id m92KvON4016550; Thu, 2 Oct 2008 22:57:24 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id m92KvMVF016545; Thu, 2 Oct 2008 22:57:22 +0200 Date: Thu, 02 Oct 2008 20:59:00 -0000 From: Jan Kratochvil To: Daniel Jacobowitz Cc: Joel Brobecker , gdb-patches@sourceware.org, Tobias Burnus , Ulrich Weigand , Jim Blandy Subject: Re: Accessor macro wrappers removal [Re: [patch] static_kind -> bit0, bit1] Message-ID: <20081002205722.GA12134@host0.dyn.jankratochvil.net> References: <20080818111120.GE16894@adacore.com> <200808181553.m7IFrG3w005270@d12av02.megacenter.de.ibm.com> <48A59B3C.9050801@net-b.de> <20080818111120.GE16894@adacore.com> <20080907115637.GA12939@host0.dyn.jankratochvil.net> <20080919221221.GA23372@adacore.com> <20080926044309.GA3803@host0.dyn.jankratochvil.net> <20080926125422.GB21287@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080926125422.GB21287@caradoc.them.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00062.txt.bz2 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