summaryrefslogtreecommitdiffstats
path: root/gobject/pygpointer.c
diff options
context:
space:
mode:
authorSimon van der Linden <svdlinden@src.gnome.org>2009-11-07 16:43:35 +0100
committerSimon van der Linden <svdlinden@src.gnome.org>2009-11-09 13:41:14 +0100
commit000f7c36e667c6e078e3370769ea868e56a1b4ee (patch)
tree87663b933462f0a376ed686b430141659f0f2bc1 /gobject/pygpointer.c
parentbfd3100a580b8bea9db25b8bb7443fb8c3dbe1cc (diff)
downloadpygobject-000f7c36e667c6e078e3370769ea868e56a1b4ee.tar.gz
pygobject-000f7c36e667c6e078e3370769ea868e56a1b4ee.tar.xz
pygobject-000f7c36e667c6e078e3370769ea868e56a1b4ee.zip
Add capabilities to import wrappers from pygi
At instance creation for boxed and pointers, at lookup for objects, when the gtype has no wrapper yet, a wrapper may be imported from pygi. The feature is turned on at configure time by --enable-pygi. Because we couldn't create a circular build dependency, PyGI's import function and API definition had to be copied in this tree.
Diffstat (limited to 'gobject/pygpointer.c')
-rw-r--r--gobject/pygpointer.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c
index ee0a8da..449b80c 100644
--- a/gobject/pygpointer.c
+++ b/gobject/pygpointer.c
@@ -28,6 +28,9 @@
#include "pygobject-private.h"
#include "pygpointer.h"
+#include "pygi-external.h"
+
+
GQuark pygpointer_class_key;
PYGLIB_DEFINE_TYPE("gobject.GPointer", PyGPointer_Type, PyGPointer);
@@ -155,6 +158,14 @@ pyg_pointer_new(GType pointer_type, gpointer pointer)
}
tp = g_type_get_qdata(pointer_type, pygpointer_class_key);
+
+ if (tp == NULL) {
+ tp = (PyTypeObject *)pygi_type_import_by_g_type(pointer_type);
+ if (tp == NULL) {
+ PyErr_Clear();
+ }
+ }
+
if (!tp)
tp = (PyTypeObject *)&PyGPointer_Type; /* fallback */
self = PyObject_NEW(PyGPointer, tp);