[pygobject/gsoc2009: 96/160] Refactor _wrap_g_object_info_get_methods
- From: Simon van der Linden <svdlinden src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject/gsoc2009: 96/160] Refactor _wrap_g_object_info_get_methods
- Date: Fri, 14 Aug 2009 21:31:09 +0000 (UTC)
commit a80036816ea9cf9ff88133ebfff58d36f2160ceb
Author: Simon van der Linden <svdlinden src gnome org>
Date: Mon Aug 3 15:47:27 2009 +0200
Refactor _wrap_g_object_info_get_methods
gi/pygiinfo.c | 41 ++++++++++++++++++++++++++++-------------
1 files changed, 28 insertions(+), 13 deletions(-)
---
diff --git a/gi/pygiinfo.c b/gi/pygiinfo.c
index 5a8df13..31bf86e 100644
--- a/gi/pygiinfo.c
+++ b/gi/pygiinfo.c
@@ -1219,22 +1219,37 @@ _wrap_g_object_info_get_parent(PyGIBaseInfo *self)
static PyObject *
_wrap_g_object_info_get_methods(PyGIBaseInfo *self)
{
- int i, length;
- PyObject *retval;
+ gssize n_infos;
+ PyObject *infos;
+ gssize i;
- g_base_info_ref(self->info);
- length = g_object_info_get_n_methods((GIObjectInfo*)self->info);
- retval = PyTuple_New(length);
+ n_infos = g_object_info_get_n_methods((GIObjectInfo *)self->info);
- for (i = 0; i < length; i++) {
- GIFunctionInfo *function;
- function = g_object_info_get_method((GIObjectInfo*)self->info, i);
- PyTuple_SetItem(retval, i, pyg_info_new(function));
- g_base_info_unref((GIBaseInfo*)function);
+ infos = PyTuple_New(n_infos);
+ if (infos == NULL) {
+ return NULL;
}
- g_base_info_unref(self->info);
- return retval;
+ for (i = 0; i < n_infos; i++) {
+ GIBaseInfo *info;
+ PyObject *py_info;
+
+ info = (GIBaseInfo *)g_object_info_get_method((GIObjectInfo *)self->info, i);
+ g_assert(info != NULL);
+
+ py_info = pyg_info_new(info);
+
+ g_base_info_unref(info);
+
+ if (py_info == NULL) {
+ Py_CLEAR(infos);
+ break;
+ }
+
+ PyTuple_SET_ITEM(infos, i, py_info);
+ }
+
+ return infos;
}
static PyObject *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]