This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Python] Allow attribute references to gdb.Value objects


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]