[pygobject/gsoc2009: 71/160] Use pygobject_new_from_type



commit dcd211387417fc1b2cdef795a9a7f1ca82ebc491
Author: Simon van der Linden <svdlinden src gnome org>
Date:   Sun Jul 26 16:11:10 2009 +0200

    Use pygobject_new_from_type

 gi/pygiinfo.c |   26 +++-----------------------
 1 files changed, 3 insertions(+), 23 deletions(-)
---
diff --git a/gi/pygiinfo.c b/gi/pygiinfo.c
index fefe1f5..5c982f0 100644
--- a/gi/pygiinfo.c
+++ b/gi/pygiinfo.c
@@ -962,32 +962,12 @@ _wrap_g_function_info_invoke(PyGIBaseInfo *self, PyObject *args)
 
             g_assert(return_value != NULL);
         } else {
-            /* Instanciate the class passed as first argument and attach the GObject instance. */
-            PyTypeObject *py_type;
-            PyGObject *self;
+            PyTypeObject *type;
 
             g_assert(n_py_args > 0);
-            py_type = (PyTypeObject *)PyTuple_GetItem(args, 0);
-            g_assert(py_type != NULL);
+            type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0);
 
-            if (py_type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
-                Py_INCREF(py_type);
-            }
-            self = PyObject_GC_New(PyGObject, py_type);
-            self->inst_dict = NULL;
-            self->weakreflist = NULL;
-            self->private_flags.flags = 0;
-
-            self->obj = return_arg.v_pointer;
-
-            if (g_object_is_floating(self->obj)) {
-                g_object_ref_sink(self->obj);
-            }
-            pygobject_register_wrapper((PyObject *)self);
-
-            PyObject_GC_Track((PyObject *)self);
-
-            return_value = (PyObject *)self;
+            return_value = pygobject_new_from_type(return_arg.v_pointer, TRUE, type);
         }
     } else {
         return_value = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]