From d74dca257111f82a7eb661791dafd360c3225bac Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 20 Oct 2023 13:04:13 +0200 Subject: 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 Reviewed-by: Qt CI Bot --- .../PySide6/QtQml/pysideqmlvolatilebool.cpp | 38 +++++++++++++--------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp') diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp index d498f5bb0..e92e13aaf 100644 --- a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp +++ b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp @@ -113,25 +113,31 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self) return s; } -static PyType_Slot QtQml_VolatileBoolType_slots[] = { - {Py_tp_repr, reinterpret_cast(QtQml_VolatileBoolObject_repr)}, - {Py_tp_str, reinterpret_cast(QtQml_VolatileBoolObject_str)}, - {Py_tp_methods, reinterpret_cast(QtQml_VolatileBoolObject_methods)}, - {Py_tp_new, reinterpret_cast(QtQml_VolatileBoolObject_new)}, - {Py_tp_dealloc, reinterpret_cast(QtQml_VolatileBoolObject_dealloc)}, - {0, 0} -}; -static PyType_Spec QtQml_VolatileBoolType_spec = { - "2:PySide6.QtQml.VolatileBool", - sizeof(QtQml_VolatileBoolObject), - 0, - Py_TPFLAGS_DEFAULT, - QtQml_VolatileBoolType_slots, -}; +static PyTypeObject *createVolatileBoolType() +{ + PyType_Slot QtQml_VolatileBoolType_slots[] = { + {Py_tp_repr, reinterpret_cast(QtQml_VolatileBoolObject_repr)}, + {Py_tp_str, reinterpret_cast(QtQml_VolatileBoolObject_str)}, + {Py_tp_methods, reinterpret_cast(QtQml_VolatileBoolObject_methods)}, + {Py_tp_new, reinterpret_cast(QtQml_VolatileBoolObject_new)}, + {Py_tp_dealloc, reinterpret_cast(QtQml_VolatileBoolObject_dealloc)}, + {0, 0} + }; + + PyType_Spec QtQml_VolatileBoolType_spec = { + "2:PySide6.QtQml.VolatileBool", + sizeof(QtQml_VolatileBoolObject), + 0, + Py_TPFLAGS_DEFAULT, + QtQml_VolatileBoolType_slots, + }; + + return SbkType_FromSpec(&QtQml_VolatileBoolType_spec); +} PyTypeObject *QtQml_VolatileBool_TypeF(void) { - static auto *type = SbkType_FromSpec(&QtQml_VolatileBoolType_spec); + static auto *type = createVolatileBoolType(); return type; } -- cgit v1.2.3