aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideqml
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2023-10-20 13:04:13 +0200
committerChristian Tismer <tismer@stackless.com>2023-10-25 10:45:54 +0200
commitd74dca257111f82a7eb661791dafd360c3225bac (patch)
tree97e990f5e2584f552c160a21bba2712006a28ec7 /sources/pyside6/libpysideqml
parent897eaa60525099f2c3667148955732db7fed7271 (diff)
shiboken: Unify the structure of type creation functions
It is the better concept to use the same structure for all type creation functions. We move the type slots and type specs into these functions. The calling function then always has the same structure of one static expression and returning the type. This might also save some space for shatic structures. Task-number: PYSIDE-2230 Change-Id: Ib972f210f44422eb1ebe47a0d92ac18a8377ac87 Pick-to: 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/libpysideqml')
-rw-r--r--sources/pyside6/libpysideqml/pysideqmllistproperty.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
index 648761a54..a6f9f0193 100644
--- a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
@@ -101,29 +101,31 @@ static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds)
return 0;
}
-static PyType_Slot PropertyListType_slots[] = {
- {Py_tp_new, reinterpret_cast<void *>(propList_tp_new)},
- {Py_tp_init, reinterpret_cast<void *>(propListTpInit)},
- {0, nullptr}
-};
-static PyType_Spec PropertyListType_spec = {
- "2:PySide6.QtQml.ListProperty",
- sizeof(PySideProperty),
- 0,
- Py_TPFLAGS_DEFAULT,
- PropertyListType_slots,
-};
-
+static PyTypeObject *createPropertyListType()
+{
+ PyType_Slot PropertyListType_slots[] = {
+ {Py_tp_new, reinterpret_cast<void *>(propList_tp_new)},
+ {Py_tp_init, reinterpret_cast<void *>(propListTpInit)},
+ {0, nullptr}
+ };
+
+ PyType_Spec PropertyListType_spec = {
+ "2:PySide6.QtQml.ListProperty",
+ sizeof(PySideProperty),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PropertyListType_slots,
+ };
+
+ Shiboken::AutoDecRef bases(Py_BuildValue("(O)", PySideProperty_TypeF()));
+ return SbkType_FromSpecWithBases(&PropertyListType_spec, bases.object());
+}
PyTypeObject *PropertyList_TypeF(void)
{
// PYSIDE-2230: This was a wrong replacement by static AutoDecref.
// Never do that, deletes things way too late.
- static PyTypeObject *type{};
- if (!type) {
- Shiboken::AutoDecRef bases(Py_BuildValue("(O)", PySideProperty_TypeF()));
- type = (PyTypeObject *)SbkType_FromSpecWithBases(&PropertyListType_spec, bases.object());
- }
+ static PyTypeObject *type = createPropertyListType();
return type;
}