2013-12-12 Siva Chandra Reddy <sivachandra@google.com>

PR python/16113
	* NEWS (Python Scripting): Add entry for the new feature and the
	new attribute of gdb.Field objects.
	* python/py-type.c (gdbpy_is_field): New function
	(convert_field): Add 'parent_type' attribute to gdb.Field
	objects.
	* python/py-value.c (valpy_getitem): Allow subscript value to be
	a gdb.Field object.
	(value_has_field): New function
	(get_field_flag): New function
	* python/python-internal.h (gdbpy_is_field): Add declaration.

	testsuite/
	* gdb.python/py-value-cc.cc: Improve test case.
	* gdb.python/py-value-cc.exp: Add new tests to test usage of
	gdb.Field objects as subscripts on gdb.Value objects.

	doc/
	* gdb.texinfo (Values From Inferior): Add a note about using
	gdb.Field objects as subscripts on gdb.Value objects.
	(Types In Python): Add description about the new attribute
	"parent_type" of gdb.Field objects.
This commit is contained in:
Siva Chandra 2013-12-12 15:18:27 -08:00
parent ec0d6081a0
commit a16b0e220d
10 changed files with 251 additions and 3 deletions

View file

@ -146,6 +146,14 @@ field_new (void)
/* Return true if OBJ is of type gdb.Field, false otherwise. */
int
gdbpy_is_field (PyObject *obj)
{
return PyObject_TypeCheck (obj, &field_object_type);
}
/* Return the code for this type. */
static PyObject *
typy_get_code (PyObject *self, void *closure)
@ -167,6 +175,13 @@ convert_field (struct type *type, int field)
if (!result)
return NULL;
arg = type_to_type_object (type);
if (arg == NULL)
goto fail;
if (PyObject_SetAttrString (result, "parent_type", arg) < 0)
goto failarg;
Py_DECREF (arg);
if (!field_is_static (&TYPE_FIELD (type, field)))
{
const char *attrstring;