summaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideslot.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-12-17 19:12:56 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-05-30 18:13:41 +0000
commit18dc31becdd994c53a9f894087cf1ef99fbd0232 (patch)
tree3021cfa473f20102bfb63a26117776615b91b526 /sources/pyside2/libpyside/pysideslot.cpp
parent50dd4ae202d7afb3556335c056db003f5ef50532 (diff)
PEP 384-squash: Implement PEP 384
This is the condensed checkin of 18 commits which created the implementation of PEP 384. Task-number: PYSIDE-560 Change-Id: I834c659af4c2b55b268f8e8dc4cfa53f02502409 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/pyside2/libpyside/pysideslot.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideslot.cpp80
1 files changed, 27 insertions, 53 deletions
diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp
index 8f307260..db1a7d9e 100644
--- a/sources/pyside2/libpyside/pysideslot.cpp
+++ b/sources/pyside2/libpyside/pysideslot.cpp
@@ -62,55 +62,29 @@ static int slotTpInit(PyObject*, PyObject*, PyObject*);
static PyObject* slotCall(PyObject*, PyObject*, PyObject*);
// Class Definition -----------------------------------------------
-static PyTypeObject PySideSlotType = {
- PyVarObject_HEAD_INIT(0, 0)
- "PySide2.QtCore." SLOT_DEC_NAME, /*tp_name*/
- sizeof(PySideSlot), /*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 */
- slotCall, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- SLOT_DEC_NAME, /*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 */
- slotTpInit, /*tp_init */
- 0, /*tp_alloc */
- PyType_GenericNew, /*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*/
+static PyType_Slot PySideSlotType_slots[] = {
+ {Py_tp_call, (void *)slotCall},
+ {Py_tp_init, (void *)slotTpInit},
+ {Py_tp_new, (void *)PyType_GenericNew},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec PySideSlotType_spec = {
+ "PySide2.QtCore." SLOT_DEC_NAME,
+ sizeof(PySideSlot),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSlotType_slots,
+};
+
+
+static PyTypeObject *PySideSlotTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&PySideSlotType_spec);
+ return type;
+}
int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
{
@@ -139,7 +113,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
data->args = typeName;
}
} else {
- PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", argType->ob_type->tp_name);
+ PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", PepType((Py_TYPE(argType)))->tp_name);
return -1;
}
}
@@ -166,7 +140,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
PySideSlot *data = reinterpret_cast<PySideSlot*>(self);
if (!data->slotName) {
- PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
+ PyObject *funcName = PepFunction_GetName(callback);
data->slotName = strdup(Shiboken::String::toCString(funcName));
}
@@ -209,11 +183,11 @@ namespace PySide { namespace Slot {
void init(PyObject* module)
{
- if (PyType_Ready(&PySideSlotType) < 0)
+ if (PyType_Ready(PySideSlotTypeF()) < 0)
return;
- Py_INCREF(&PySideSlotType);
- PyModule_AddObject(module, SLOT_DEC_NAME, reinterpret_cast<PyObject *>(&PySideSlotType));
+ Py_INCREF(PySideSlotTypeF());
+ PyModule_AddObject(module, SLOT_DEC_NAME, reinterpret_cast<PyObject *>(PySideSlotTypeF()));
}
} // namespace Slot