gdb/python: add Type.is_scalar property

Add a new read-only property which is True for scalar types,
otherwise, it's False.
This commit is contained in:
Andrew Burgess 2022-02-25 10:54:04 +00:00
parent 6fd90137e7
commit ee6a3d9e94
5 changed files with 65 additions and 1 deletions

View file

@ -433,6 +433,19 @@ typy_get_objfile (PyObject *self, void *closure)
return objfile_to_objfile_object (objfile).release ();
}
/* Return true if this is a scalar type, otherwise, returns false. */
static PyObject *
typy_is_scalar (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
if (is_scalar_type (type))
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
/* Return the type, stripped of typedefs. */
static PyObject *
typy_strip_typedefs (PyObject *self, PyObject *args)
@ -1487,6 +1500,8 @@ static gdb_PyGetSetDef type_object_getset[] =
"The tag name for this type, or None.", NULL },
{ "objfile", typy_get_objfile, NULL,
"The objfile this type was defined in, or None.", NULL },
{ "is_scalar", typy_is_scalar, nullptr,
"Is this a scalar type?", nullptr },
{ NULL }
};