This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] New python module gdb.types
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 6 Oct 2010 14:11:58 -0700
- Subject: Re: [RFA] New python module gdb.types
- References: <20101006204434.DCD842461B2@ruffy.mtv.corp.google.com>
> 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