This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Python] Allow attribute references to gdb.Value objects
- From: Tom Tromey <tromey at redhat dot com>
- To: Paul Koning <paulkoning at comcast dot net>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 15 Aug 2011 13:09:33 -0600
- Subject: Re: [Python] Allow attribute references to gdb.Value objects
- References: <3A56CC74-0A48-47E8-BBA2-6E2BEB2FB588@comcast.net>
>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> writes:
Paul> It would be more natural to be able to reference fields of a
Paul> gdb.Value by the standard field (attribute) syntax, e.g.,
Paul> "val1.field2" as opposed to "val1['field2']". The attached patch
Paul> does this. It acts like the Python standard method __getattr__ in
Paul> that it first looks for a predefined attribute (such as "type"),
Paul> and only if that fails will it look for a value field with the
Paul> given name. So val1.type means what it always did (and if you
Paul> want the "type" field of some structure value, you'd need to use
Paul> val1['type'] as before).
We considered this initially, but decided on the current approach
instead. The current approach lets us add attributes to Value without
breaking any existing code.
Tom