gdb/python: add Type.is_signed property

Add a new read-only property, Type.is_signed, which is True for signed
types, and False otherwise.

This property should only be read on types for which Type.is_scalar is
true, attempting to read this property for non-scalar types will raise
a ValueError.

I chose 'is_signed' rather than 'is_unsigned' in order to match the
existing Architecture.integer_type method, which takes a 'signed'
parameter.  As far as I could find, that was the only existing
signed/unsigned selector in the Python API, so it seemed reasonable to
stay consistent.
This commit is contained in:
Andrew Burgess 2021-11-30 14:35:44 +00:00
parent ee6a3d9e94
commit 551b380fbd
5 changed files with 80 additions and 1 deletions

View file

@ -1269,6 +1269,16 @@ this property is @code{False}. Examples of non-scalar types include
structures, unions, and classes.
@end defvar
@defvar Type.is_signed
For scalar types (those for which @code{Type.is_scalar} is
@code{True}), this property is @code{True} if the type is signed,
otherwise this property is @code{False}.
Attempting to read this property for a non-scalar type (a type for
which @code{Type.is_scalar} is @code{False}), will raise a
@code{ValueError}.
@end defvar
The following methods are provided:
@defun Type.fields ()