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: [RFA] New python module gdb.types


> 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


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