From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6239 invoked by alias); 6 Oct 2010 21:12:08 -0000 Received: (qmail 6231 invoked by uid 22791); 6 Oct 2010 21:12:07 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Oct 2010 21:12:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6978B2BAC16; Wed, 6 Oct 2010 17:12:01 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ZHJH10IoD8SU; Wed, 6 Oct 2010 17:12:01 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 311F02BAC01; Wed, 6 Oct 2010 17:12:01 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 09B5AF5895; Wed, 6 Oct 2010 14:11:58 -0700 (PDT) Date: Wed, 06 Oct 2010 21:12:00 -0000 From: Joel Brobecker To: Doug Evans Cc: gdb-patches@sourceware.org Subject: Re: [RFA] New python module gdb.types Message-ID: <20101006211158.GB2784@adacore.com> References: <20101006204434.DCD842461B2@ruffy.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101006204434.DCD842461B2@ruffy.mtv.corp.google.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2010-10/txt/msg00087.txt.bz2 > This patch adds a new python module to gdb, gdb.types. > It contains a small collection of utilities that I've been using. I'm excited to seem more Python stuff being contributed! > +def get_basic_type (typ): > + """Return the 'basic' type of type TYP.""" > + > + if typ.code == gdb.TYPE_CODE_REF: > + typ = typ.target () > + return typ.unqualified ().strip_typedefs () The python style is to not have a space before the opening parenthesis. For instance: def get_basic_type(typ): """Return the 'basic' type of type TYP.""" if typ.code == gdb.TYPE_CODE_REF: typ = typ.target() return typ.unqualified().strip_typedefs() It looks really ugly at first, but it's not so bad after a while. I think we should try to follow the Python style because it makes it easier for Python users to read our code. > +# Return True if FIELD is in type TYP (spelled this way to avoid collision > +# with python's "type"), with extra handling so references, typedefs, and > +# subclasses "just work". Just a thought - I think it would useful to mention how we handle the case where the type has no fields (we return False, if I read the code right). And should we mention that, unlike module `gdb' which is already imported, module `gdb.types' isn't? -- Joel