From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24208 invoked by alias); 16 Sep 2011 06:49:02 -0000 Received: (qmail 24200 invoked by uid 22791); 16 Sep 2011 06:49:01 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Sep 2011 06:48:47 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LRL00300S95OS00@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Fri, 16 Sep 2011 09:48:44 +0300 (IDT) Received: from HOME-C4E4A596F7 ([77.126.9.62]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LRL003X9S976T90@a-mtaout20.012.net.il>; Fri, 16 Sep 2011 09:48:44 +0300 (IDT) Date: Fri, 16 Sep 2011 07:36:00 -0000 From: Eli Zaretskii Subject: Re: Python: add field access by name and standard python mapping methods to gdb.Type In-reply-to: To: Paul Koning Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83ty8dugmp.fsf@gnu.org> References: 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: 2011-09/txt/msg00284.txt.bz2 > From: Paul Koning > Date: Thu, 15 Sep 2011 16:38:33 -0400 > > The attached proposed patch adds access to struct and enum fields by their name, just as field names can be used on gdb.Value objects. It also adds the standard Python methods for mappings (dictionary-like objects), so that the kind of things that Python programmers would expect to work on objects that can be indexed by name indeed do work. For example, you can iterate through the fields, or query if a field name exists. Comments for the documentation part: > +If the type is a structure or class type, or an enum type, the fields > +of that type can be accessed using the Python @dfn{dictionary syntax}. > +For example, if @code{some_type} is a @code{gdb.Type} instance holding > +a structure type, you can access its @code{foo} element with: ^^^^^^^ For consistency with preceding text, I suggest to use "field" here. > +@code{bar} will be a @code{gdb.Field} object; see below under the > +description of the @code{fields()} method for a description of the "@code{fields}", without the parens. If you use the parentheses, it looks like a call to `fields' with no arguments, which is not what you want. In general, good Texinfo usage and GNU standards frown on the man-page tradition of using "()" to indicate that the symbol is a function. > +gdb.Field class. Forgot @code here. > +Each field is an @code{gdb.Field} object, with some pre-defined attributes: ^^ "a" Okay with those changes. Thanks.