aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPaul Koning <pkoning@equallogic.com>2011-10-04 16:20:03 +0000
committerPaul Koning <pkoning@equallogic.com>2011-10-04 16:20:03 +0000
commit0dab82e9b3346035364369b2a2cdd15fb929ab54 (patch)
tree65ba1fcbc29225405199c0fdf32097f9fb267e06 /gdb
parent84ad80e63a333efa71a9a9658ee7f0a9e00f58ae (diff)
downloadgdb-0dab82e9b3346035364369b2a2cdd15fb929ab54.zip
gdb-0dab82e9b3346035364369b2a2cdd15fb929ab54.tar.gz
gdb-0dab82e9b3346035364369b2a2cdd15fb929ab54.tar.bz2
* python/py-type.c (typy_make_iter): Add forward declaration.
(typy_fields_items): Use the gdb.Type iterator.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/python/py-type.c42
2 files changed, 15 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6c92b9e..29a61fe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2011-10-04 Paul Koning <paul_koning@dell.com>
+ * python/py-type.c (typy_make_iter): Add forward declaration.
+ (typy_fields_items): Use the gdb.Type iterator.
+
+2011-10-04 Paul Koning <paul_koning@dell.com>
+
* NEWS: Add entry for Python gdb.Type mapping methods.
2011-10-04 Kevin Pouget <kevin.pouget@st.com>
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 76415b3..c7fd25b 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -77,6 +77,9 @@ struct pyty_code
const char *name;
};
+/* Forward declarations. */
+static PyObject *typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind);
+
#define ENTRY(X) { X, #X }
static struct pyty_code pyty_codes[] =
@@ -290,40 +293,15 @@ make_fielditem (struct type *type, int i, enum gdbpy_iter_kind kind)
static PyObject *
typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
{
- PyObject *result = NULL, *item = NULL;
- int i;
- struct type *type = ((type_object *) self)->type;
- volatile struct gdb_exception except;
-
- TRY_CATCH (except, RETURN_MASK_ALL)
- {
- CHECK_TYPEDEF (type);
- }
- GDB_PY_HANDLE_EXCEPTION (except);
-
- /* We would like to make a tuple here, make fields immutable, and
- then memoize the result (and perhaps make Field.type() lazy).
- However, that can lead to cycles. */
- result = PyList_New (0);
- if (result == NULL)
- return NULL;
+ PyObject *result = NULL, *iter = NULL;
- for (i = 0; i < TYPE_NFIELDS (type); ++i)
- {
- item = make_fielditem (type, i, kind);
- if (!item)
- goto fail;
- if (PyList_Append (result, item))
- goto fail;
- Py_DECREF (item);
- }
-
+ iter = typy_make_iter (self, kind);
+ if (iter == NULL)
+ return NULL;
+
+ result = PySequence_List (iter);
+ Py_DECREF (iter);
return result;
-
- fail:
- Py_XDECREF (item);
- Py_XDECREF (result);
- return NULL;
}
/* Return a sequence of all fields. Each field is a gdb.Field object. */