aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideweakref.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/libpyside/pysideweakref.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideweakref.cpp74
1 files changed, 23 insertions, 51 deletions
diff --git a/sources/pyside2/libpyside/pysideweakref.cpp b/sources/pyside2/libpyside/pysideweakref.cpp
index c31334ee5..906aafd7c 100644
--- a/sources/pyside2/libpyside/pysideweakref.cpp
+++ b/sources/pyside2/libpyside/pysideweakref.cpp
@@ -40,6 +40,7 @@
#include "pysideweakref.h"
#include <sbkpython.h>
+#include <shiboken.h>
typedef struct {
PyObject_HEAD
@@ -50,56 +51,27 @@ typedef struct {
static PyObject* CallableObject_call(PyObject* callable_object, PyObject* args, PyObject* kw);
-static PyTypeObject PySideCallableObjectType = {
- PyVarObject_HEAD_INIT(0, 0)
+static PyType_Slot PySideCallableObjectType_slots[] = {
+ {Py_tp_call, (void *)CallableObject_call},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+};
+static PyType_Spec PySideCallableObjectType_spec = {
const_cast<char*>("PySide.Callable"),
- sizeof(PySideCallableObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- CallableObject_call, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
- 0, /* tp_del */
- 0 /* tp_version_tag */
+ sizeof(PySideCallableObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideCallableObjectType_slots,
};
+
+static PyTypeObject *PySideCallableObjectTypeF(void)
+{
+ static PyTypeObject *type =
+ (PyTypeObject *)PyType_FromSpec(&PySideCallableObjectType_spec);
+ return type;
+}
+
static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject * /* kw */)
{
PySideCallableObject* obj = reinterpret_cast<PySideCallableObject *>(callable_object);
@@ -116,13 +88,13 @@ PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData)
if (obj == Py_None)
return 0;
- if (Py_TYPE(&PySideCallableObjectType) == 0)
+ if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
{
- Py_TYPE(&PySideCallableObjectType) = &PyType_Type;
- PyType_Ready(&PySideCallableObjectType);
+ Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
+ PyType_Ready(PySideCallableObjectTypeF());
}
- PySideCallableObject* callable = PyObject_New(PySideCallableObject, &PySideCallableObjectType);
+ PySideCallableObject* callable = PyObject_New(PySideCallableObject, PySideCallableObjectTypeF());
if (!callable || PyErr_Occurred())
return 0;