Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] New python module gdb.types
Date: Wed, 06 Oct 2010 21:12:00 -0000	[thread overview]
Message-ID: <20101006211158.GB2784@adacore.com> (raw)
In-Reply-To: <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


  parent reply	other threads:[~2010-10-06 21:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 20:49 Doug Evans
2010-10-06 21:04 ` Eli Zaretskii
2010-10-08 22:19   ` Doug Evans
2010-10-08 22:21     ` Doug Evans
2010-10-09  9:14     ` Eli Zaretskii
2010-10-13 18:42       ` Doug Evans
2010-10-13 18:49         ` Eli Zaretskii
2010-10-06 21:12 ` Joel Brobecker [this message]
2010-10-06 22:12 ` Tom Tromey
2010-10-06 23:44   ` Doug Evans
2010-10-08 23:08 ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101006211158.GB2784@adacore.com \
    --to=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox