[PyQt] [SIP] Proposed patch for isPyOwned function
Alexis Boutillier
alexis.boutillier at arteris.com
Thu Sep 3 09:40:49 BST 2009
Hi,
Here is a patch we made in sip to have a function letting us know if a
sip wrapper is own by C++ or python from python.
This is only a call to the existing sip method sipIsPyOwned.
We use it to track wrapper that are owned by python whereas they should
be owned by C++ for garbage collecting problems.
Regards,
--
Boutillier Alexis
Methodology engineer
Arteris SA
The Network-on-Chip Company TM
www.arteris.net
6 par Ariane Immeuble Mercure
78284 Guyancourt Cedex
France
Office: (+33) 1 61 37 38 71
Fax: (+33) 1 61 37 38 41
Alexis.Boutillier at arteris.net
-------------- next part --------------
diff -ruN ../sip-4.8.1.orig/siplib/siplib.c ./siplib/siplib.c
--- ../sip-4.8.1.orig/siplib/siplib.c 2009-06-16 10:35:38.000000000 +0200
+++ ./siplib/siplib.c 2009-06-29 11:06:52.000000000 +0200
@@ -417,6 +417,7 @@
static PyObject *cast(PyObject *self, PyObject *args);
static PyObject *callDtor(PyObject *self, PyObject *args);
static PyObject *dumpWrapper(PyObject *self, PyObject *args);
+static PyObject *isPyOwned(PyObject *self, PyObject *args);
static PyObject *isDeleted(PyObject *self, PyObject *args);
static PyObject *setDeleted(PyObject *self, PyObject *args);
static PyObject *setTraceMask(PyObject *self, PyObject *args);
@@ -483,6 +484,7 @@
{"cast", cast, METH_VARARGS, NULL},
{"delete", callDtor, METH_VARARGS, NULL},
{"dump", dumpWrapper, METH_VARARGS, NULL},
+ {"ispyowned", isPyOwned, METH_VARARGS, NULL},
{"isdeleted", isDeleted, METH_VARARGS, NULL},
{"setdeleted", setDeleted, METH_VARARGS, NULL},
{"settracemask", setTraceMask, METH_VARARGS, NULL},
@@ -718,6 +720,24 @@
return NULL;
}
+/*
+ * Tells whether a sip wrapper is owned by python or C++
+ */
+
+static PyObject *isPyOwned(PyObject *self, PyObject *args)
+{
+ sipSimpleWrapper *sw;
+ PyObject *res;
+
+ if (!PyArg_ParseTuple(args, "O!:ispyowned", &sipSimpleWrapper_Type, &sw))
+ return NULL;
+
+ res = (sipIsPyOwned(sw) ? Py_True : Py_False);
+
+ Py_INCREF(res);
+ return res;
+}
+
/*
* Write a reference to a wrapper to stdout.
More information about the PyQt
mailing list