diff options
| author | Christian Tismer <tismer@stackless.com> | 2023-10-20 13:04:13 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2023-10-25 10:45:54 +0200 |
| commit | d74dca257111f82a7eb661791dafd360c3225bac (patch) | |
| tree | 97e990f5e2584f552c160a21bba2712006a28ec7 /sources/pyside6/libpyside/pysideweakref.cpp | |
| parent | 897eaa60525099f2c3667148955732db7fed7271 (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/pysideweakref.cpp')
| -rw-r--r-- | sources/pyside6/libpyside/pysideweakref.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp index c0ef2586f..5f3ca59e4 100644 --- a/sources/pyside6/libpyside/pysideweakref.cpp +++ b/sources/pyside6/libpyside/pysideweakref.cpp @@ -15,23 +15,28 @@ struct PySideCallableObject { static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject *kw); -static PyType_Slot PySideCallableObjectType_slots[] = { - {Py_tp_call, reinterpret_cast<void *>(CallableObject_call)}, - {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)}, - {0, nullptr} -}; -static PyType_Spec PySideCallableObjectType_spec = { - "1:PySide.Callable", - sizeof(PySideCallableObject), - 0, - Py_TPFLAGS_DEFAULT, - PySideCallableObjectType_slots, -}; - +static PyTypeObject *createCallableObjectType() +{ + PyType_Slot PySideCallableObjectType_slots[] = { + {Py_tp_call, reinterpret_cast<void *>(CallableObject_call)}, + {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)}, + {0, nullptr} + }; + + PyType_Spec PySideCallableObjectType_spec = { + "1:PySide.Callable", + sizeof(PySideCallableObject), + 0, + Py_TPFLAGS_DEFAULT, + PySideCallableObjectType_slots, + }; + + return SbkType_FromSpec(&PySideCallableObjectType_spec); +} static PyTypeObject *PySideCallableObject_TypeF() { - static auto *type = SbkType_FromSpec(&PySideCallableObjectType_spec); + static auto *type = createCallableObjectType(); return type; } |
