aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/class_property.cpp
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/libpyside/class_property.cpp
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/libpyside/class_property.cpp')
-rw-r--r--sources/pyside6/libpyside/class_property.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/sources/pyside6/libpyside/class_property.cpp b/sources/pyside6/libpyside/class_property.cpp
index 39f536061..140956035 100644
--- a/sources/pyside6/libpyside/class_property.cpp
+++ b/sources/pyside6/libpyside/class_property.cpp
@@ -45,33 +45,34 @@ static int PyClassProperty_tp_init(PyObject *self, PyObject *args, PyObject *kwa
return ret;
}
-static PyType_Slot PyClassProperty_slots[] = {
- {Py_tp_getset, nullptr}, // will be set below
- {Py_tp_base, reinterpret_cast<void *>(&PyProperty_Type)},
- {Py_tp_descr_get, reinterpret_cast<void *>(PyClassProperty_descr_get)},
- {Py_tp_descr_set, reinterpret_cast<void *>(PyClassProperty_descr_set)},
- {Py_tp_init, reinterpret_cast<void *>(PyClassProperty_tp_init)},
- {0, nullptr}
-};
-
-static PyType_Spec PyClassProperty_spec = {
- "2:PySide6.QtCore.PyClassProperty",
- sizeof(propertyobject),
- 0,
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- PyClassProperty_slots,
-};
+static PyTypeObject *createPyClassPropertyType()
+{
+ PyType_Slot PyClassProperty_slots[] = {
+ {Py_tp_getset, nullptr}, // will be set below
+ {Py_tp_base, reinterpret_cast<void *>(&PyProperty_Type)},
+ {Py_tp_descr_get, reinterpret_cast<void *>(PyClassProperty_descr_get)},
+ {Py_tp_descr_set, reinterpret_cast<void *>(PyClassProperty_descr_set)},
+ {Py_tp_init, reinterpret_cast<void *>(PyClassProperty_tp_init)},
+ {0, nullptr}
+ };
+
+ PyType_Spec PyClassProperty_spec = {
+ "2:PySide6.QtCore.PyClassProperty",
+ sizeof(propertyobject),
+ 0,
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ PyClassProperty_slots,
+ };
+
+ PyClassProperty_slots[0].pfunc = PyProperty_Type.tp_getset;
+ if (_PepRuntimeVersion() >= 0x030A00)
+ PyClassProperty_spec.basicsize = sizeof(propertyobject310);
+ return SbkType_FromSpec(&PyClassProperty_spec);
+}
PyTypeObject *PyClassProperty_TypeF()
{
- static PyTypeObject *type = nullptr;
- if (type == nullptr) {
- // Provide the same `tp_getset`, which is not inherited.
- PyClassProperty_slots[0].pfunc = PyProperty_Type.tp_getset;
- if (_PepRuntimeVersion() >= 0x030A00)
- PyClassProperty_spec.basicsize = sizeof(propertyobject310);
- type = SbkType_FromSpec(&PyClassProperty_spec);
- }
+ static auto *type = createPyClassPropertyType();
return type;
}