diff --git a/sip/siplib/sip.h b/sip/siplib/sip.h index f0cad4cc..ae26a315 100644 --- a/sip/siplib/sip.h +++ b/sip/siplib/sip.h @@ -55,7 +55,7 @@ extern "C" { * Define the SIP version number. */ #define SIP_VERSION 0x040c01 -#define SIP_VERSION_STR "4.12.1-snapshot-1c2692d2bb29" +#define SIP_VERSION_STR "4.12.1-snapshot-baf837919f74" /* diff --git a/sip/siplib/siplib.c b/sip/siplib/siplib.c index c1c811b0..8419d137 100644 --- a/sip/siplib/siplib.c +++ b/sip/siplib/siplib.c @@ -605,6 +605,7 @@ static PyObject *cast(PyObject *self, PyObject *args); static PyObject *callDtor(PyObject *self, PyObject *args); static PyObject *dumpWrapper(PyObject *self, PyObject *args); static PyObject *isDeleted(PyObject *self, PyObject *args); +static PyObject *isPyCreated(PyObject *self, PyObject *args); static PyObject *isPyOwned(PyObject *self, PyObject *args); static PyObject *setDeleted(PyObject *self, PyObject *args); static PyObject *setTraceMask(PyObject *self, PyObject *args); @@ -691,6 +692,7 @@ PyMODINIT_FUNC SIP_MODULE_ENTRY(void) {"dump", dumpWrapper, METH_VARARGS, NULL}, {"getapi", sipGetAPI, METH_VARARGS, NULL}, {"isdeleted", isDeleted, METH_VARARGS, NULL}, + {"ispycreated", isPyCreated, METH_VARARGS, NULL}, {"ispyowned", isPyOwned, METH_VARARGS, NULL}, {"setapi", sipSetAPI, METH_VARARGS, NULL}, {"setdeleted", setDeleted, METH_VARARGS, NULL}, @@ -912,8 +914,8 @@ static PyObject *dumpWrapper(PyObject *self, PyObject *args) printf(" Reference count: %d\n", Py_REFCNT(sw)); #endif printf(" Address of wrapped object: %p\n", sip_api_get_address(sw)); + printf(" Created by: %s\n", (sipIsDerived(sw) ? "Python" : "C/C++")); printf(" To be destroyed by: %s\n", (sipIsPyOwned(sw) ? "Python" : "C/C++")); - printf(" Derived class?: %s\n", (sipIsDerived(sw) ? "yes" : "no")); if (PyObject_TypeCheck((PyObject *)sw, (PyTypeObject *)&sipWrapper_Type)) { @@ -1088,6 +1090,25 @@ static PyObject *isDeleted(PyObject *self, PyObject *args) } +/* + * Check if an instance was created by Python. + */ +static PyObject *isPyCreated(PyObject *self, PyObject *args) +{ + sipSimpleWrapper *sw; + PyObject *res; + + if (!PyArg_ParseTuple(args, "O!:ispycreated", &sipSimpleWrapper_Type, &sw)) + return NULL; + + /* sipIsDerived() is a misnomer. */ + res = (sipIsDerived(sw) ? Py_True : Py_False); + + Py_INCREF(res); + return res; +} + + /* * Check if an instance is owned by Python or C/C++. */