aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp38
-rw-r--r--sources/pyside6/libpyside/class_property.cpp49
-rw-r--r--sources/pyside6/libpyside/pysidemetafunction.cpp37
-rw-r--r--sources/pyside6/libpyside/pysideproperty.cpp48
-rw-r--r--sources/pyside6/libpyside/pysidesignal.cpp125
-rw-r--r--sources/pyside6/libpyside/pysideslot.cpp36
-rw-r--r--sources/pyside6/libpyside/pysideweakref.cpp33
-rw-r--r--sources/pyside6/libpysideqml/pysideqmllistproperty.cpp38
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp123
-rw-r--r--sources/shiboken6/libshiboken/voidptr.cpp54
10 files changed, 320 insertions, 261 deletions
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<void *>(QtQml_VolatileBoolObject_repr)},
- {Py_tp_str, reinterpret_cast<void *>(QtQml_VolatileBoolObject_str)},
- {Py_tp_methods, reinterpret_cast<void *>(QtQml_VolatileBoolObject_methods)},
- {Py_tp_new, reinterpret_cast<void *>(QtQml_VolatileBoolObject_new)},
- {Py_tp_dealloc, reinterpret_cast<void *>(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<void *>(QtQml_VolatileBoolObject_repr)},
+ {Py_tp_str, reinterpret_cast<void *>(QtQml_VolatileBoolObject_str)},
+ {Py_tp_methods, reinterpret_cast<void *>(QtQml_VolatileBoolObject_methods)},
+ {Py_tp_new, reinterpret_cast<void *>(QtQml_VolatileBoolObject_new)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(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;
}
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;
}
diff --git a/sources/pyside6/libpyside/pysidemetafunction.cpp b/sources/pyside6/libpyside/pysidemetafunction.cpp
index eb2943ecf..e8173b97d 100644
--- a/sources/pyside6/libpyside/pysidemetafunction.cpp
+++ b/sources/pyside6/libpyside/pysidemetafunction.cpp
@@ -22,25 +22,30 @@ struct PySideMetaFunctionPrivate
static void functionFree(void *);
static PyObject *functionCall(PyObject *, PyObject *, PyObject *);
-static PyType_Slot PySideMetaFunctionType_slots[] = {
- {Py_tp_call, reinterpret_cast<void *>(functionCall)},
- {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
- {Py_tp_free, reinterpret_cast<void *>(functionFree)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, nullptr}
-};
-static PyType_Spec PySideMetaFunctionType_spec = {
- "2:PySide6.QtCore.MetaFunction",
- sizeof(PySideMetaFunction),
- 0,
- Py_TPFLAGS_DEFAULT,
- PySideMetaFunctionType_slots,
-};
-
+static PyTypeObject *createMetaFunctionType()
+{
+ PyType_Slot PySideMetaFunctionType_slots[] = {
+ {Py_tp_call, reinterpret_cast<void *>(functionCall)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_free, reinterpret_cast<void *>(functionFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
+ };
+
+ PyType_Spec PySideMetaFunctionType_spec = {
+ "2:PySide6.QtCore.MetaFunction",
+ sizeof(PySideMetaFunction),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideMetaFunctionType_slots,
+ };
+
+ return SbkType_FromSpec(&PySideMetaFunctionType_spec);
+}
PyTypeObject *PySideMetaFunction_TypeF(void)
{
- static auto *type = SbkType_FromSpec(&PySideMetaFunctionType_spec);
+ static auto *type = createMetaFunctionType();
return type;
}
diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp
index d68185667..2648ca43c 100644
--- a/sources/pyside6/libpyside/pysideproperty.cpp
+++ b/sources/pyside6/libpyside/pysideproperty.cpp
@@ -58,31 +58,35 @@ static PyGetSetDef PySidePropertyType_getset[] = {
{nullptr, nullptr, nullptr, nullptr, nullptr}
};
-static PyType_Slot PySidePropertyType_slots[] = {
- {Py_tp_dealloc, reinterpret_cast<void *>(qpropertyDeAlloc)},
- {Py_tp_call, reinterpret_cast<void *>(qPropertyCall)},
- {Py_tp_traverse, reinterpret_cast<void *>(qpropertyTraverse)},
- {Py_tp_clear, reinterpret_cast<void *>(qpropertyClear)},
- {Py_tp_methods, reinterpret_cast<void *>(PySidePropertyMethods)},
- {Py_tp_init, reinterpret_cast<void *>(qpropertyTpInit)},
- {Py_tp_new, reinterpret_cast<void *>(qpropertyTpNew)},
- {Py_tp_getset, PySidePropertyType_getset},
- {Py_tp_del, reinterpret_cast<void *>(PyObject_GC_Del)},
- {0, nullptr}
-};
-
-static PyType_Spec PySidePropertyType_spec = {
- "2:PySide6.QtCore.Property",
- sizeof(PySideProperty),
- 0,
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE,
- PySidePropertyType_slots,
-};
-
+static PyTypeObject *createPropertyType()
+{
+ PyType_Slot PySidePropertyType_slots[] = {
+ {Py_tp_dealloc, reinterpret_cast<void *>(qpropertyDeAlloc)},
+ {Py_tp_call, reinterpret_cast<void *>(qPropertyCall)},
+ {Py_tp_traverse, reinterpret_cast<void *>(qpropertyTraverse)},
+ {Py_tp_clear, reinterpret_cast<void *>(qpropertyClear)},
+ {Py_tp_methods, reinterpret_cast<void *>(PySidePropertyMethods)},
+ {Py_tp_init, reinterpret_cast<void *>(qpropertyTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(qpropertyTpNew)},
+ {Py_tp_getset, PySidePropertyType_getset},
+ {Py_tp_del, reinterpret_cast<void *>(PyObject_GC_Del)},
+ {0, nullptr}
+ };
+
+ PyType_Spec PySidePropertyType_spec = {
+ "2:PySide6.QtCore.Property",
+ sizeof(PySideProperty),
+ 0,
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE,
+ PySidePropertyType_slots,
+ };
+
+ return SbkType_FromSpec(&PySidePropertyType_spec);
+}
PyTypeObject *PySideProperty_TypeF(void)
{
- static auto *type = SbkType_FromSpec(&PySidePropertyType_spec);
+ static auto *type = createPropertyType();
return type;
}
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp
index 59b7ae551..86736c381 100644
--- a/sources/pyside6/libpyside/pysidesignal.cpp
+++ b/sources/pyside6/libpyside/pysidesignal.cpp
@@ -154,54 +154,64 @@ static PyMethodDef MetaSignal_tp_methods[] = {
{nullptr, nullptr, 0, nullptr}
};
-static PyType_Slot PySideMetaSignalType_slots[] = {
- {Py_tp_methods, reinterpret_cast<void *>(MetaSignal_tp_methods)},
- {Py_tp_base, reinterpret_cast<void *>(&PyType_Type)},
- {Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, nullptr}
-};
-static PyType_Spec PySideMetaSignalType_spec = {
- "2:PySide6.QtCore.MetaSignal",
- 0,
- // sizeof(PyHeapTypeObject) is filled in by SbkType_FromSpec
- // which calls PyType_Ready which calls inherit_special.
- 0,
- Py_TPFLAGS_DEFAULT,
- PySideMetaSignalType_slots,
-};
+static PyTypeObject *createMetaSignalType()
+{
+ PyType_Slot PySideMetaSignalType_slots[] = {
+ {Py_tp_methods, reinterpret_cast<void *>(MetaSignal_tp_methods)},
+ {Py_tp_base, reinterpret_cast<void *>(&PyType_Type)},
+ {Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
+ };
+ PyType_Spec PySideMetaSignalType_spec = {
+ "2:PySide6.QtCore.MetaSignal",
+ 0,
+ // sizeof(PyHeapTypeObject) is filled in by SbkType_FromSpec
+ // which calls PyType_Ready which calls inherit_special.
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideMetaSignalType_slots,
+ };
+
+ return SbkType_FromSpec(&PySideMetaSignalType_spec);
+}
static PyTypeObject *PySideMetaSignal_TypeF(void)
{
- static auto *type = SbkType_FromSpec(&PySideMetaSignalType_spec);
+ static auto *type = createMetaSignalType();
return type;
}
-static PyType_Slot PySideSignalType_slots[] = {
- {Py_mp_subscript, reinterpret_cast<void *>(signalGetItem)},
- {Py_tp_getattro, reinterpret_cast<void *>(signalGetAttr)},
- {Py_tp_descr_get, reinterpret_cast<void *>(signalDescrGet)},
- {Py_tp_call, reinterpret_cast<void *>(signalCall)},
- {Py_tp_str, reinterpret_cast<void *>(signalToString)},
- {Py_tp_init, reinterpret_cast<void *>(signalTpInit)},
- {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
- {Py_tp_free, reinterpret_cast<void *>(signalFree)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, nullptr}
-};
-static PyType_Spec PySideSignalType_spec = {
- "2:PySide6.QtCore.Signal",
- sizeof(PySideSignal),
- 0,
- Py_TPFLAGS_DEFAULT,
- PySideSignalType_slots,
-};
+static PyTypeObject *createSignalType()
+{
+ PyType_Slot PySideSignalType_slots[] = {
+ {Py_mp_subscript, reinterpret_cast<void *>(signalGetItem)},
+ {Py_tp_getattro, reinterpret_cast<void *>(signalGetAttr)},
+ {Py_tp_descr_get, reinterpret_cast<void *>(signalDescrGet)},
+ {Py_tp_call, reinterpret_cast<void *>(signalCall)},
+ {Py_tp_str, reinterpret_cast<void *>(signalToString)},
+ {Py_tp_init, reinterpret_cast<void *>(signalTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_free, reinterpret_cast<void *>(signalFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
+ };
+ PyType_Spec PySideSignalType_spec = {
+ "2:PySide6.QtCore.Signal",
+ sizeof(PySideSignal),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSignalType_slots,
+ };
+
+ return SbkType_FromSpecWithMeta(&PySideSignalType_spec, PySideMetaSignal_TypeF());
+}
PyTypeObject *PySideSignal_TypeF(void)
{
- static auto *type = SbkType_FromSpecWithMeta(&PySideSignalType_spec, PySideMetaSignal_TypeF());
+ static auto *type = createSignalType();
return type;
}
@@ -222,28 +232,33 @@ static PyMethodDef SignalInstance_methods[] = {
{nullptr, nullptr, 0, nullptr} /* Sentinel */
};
-static PyType_Slot PySideSignalInstanceType_slots[] = {
- {Py_mp_subscript, reinterpret_cast<void *>(signalInstanceGetItem)},
- {Py_tp_call, reinterpret_cast<void *>(signalInstanceCall)},
- {Py_tp_methods, reinterpret_cast<void *>(SignalInstance_methods)},
- {Py_tp_repr, reinterpret_cast<void *>(signalInstanceRepr)},
- {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
- {Py_tp_free, reinterpret_cast<void *>(signalInstanceFree)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, nullptr}
-};
-static PyType_Spec PySideSignalInstanceType_spec = {
- "2:PySide6.QtCore.SignalInstance",
- sizeof(PySideSignalInstance),
- 0,
- Py_TPFLAGS_DEFAULT,
- PySideSignalInstanceType_slots,
-};
+static PyTypeObject *createSignalInstanceType()
+{
+ PyType_Slot PySideSignalInstanceType_slots[] = {
+ {Py_mp_subscript, reinterpret_cast<void *>(signalInstanceGetItem)},
+ {Py_tp_call, reinterpret_cast<void *>(signalInstanceCall)},
+ {Py_tp_methods, reinterpret_cast<void *>(SignalInstance_methods)},
+ {Py_tp_repr, reinterpret_cast<void *>(signalInstanceRepr)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_free, reinterpret_cast<void *>(signalInstanceFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
+ };
+ PyType_Spec PySideSignalInstanceType_spec = {
+ "2:PySide6.QtCore.SignalInstance",
+ sizeof(PySideSignalInstance),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSignalInstanceType_slots,
+ };
+
+ return SbkType_FromSpec(&PySideSignalInstanceType_spec);
+}
PyTypeObject *PySideSignalInstance_TypeF(void)
{
- static auto *type = SbkType_FromSpec(&PySideSignalInstanceType_spec);
+ static auto *type = createSignalInstanceType();
return type;
}
diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp
index 676a0bb16..fa7e89f42 100644
--- a/sources/pyside6/libpyside/pysideslot.cpp
+++ b/sources/pyside6/libpyside/pysideslot.cpp
@@ -39,25 +39,31 @@ static int slotTpInit(PyObject *, PyObject *, PyObject *);
static PyObject *slotCall(PyObject *, PyObject *, PyObject *);
// Class Definition -----------------------------------------------
-static PyType_Slot PySideSlotType_slots[] = {
- {Py_tp_call, reinterpret_cast<void *>(slotCall)},
- {Py_tp_init, reinterpret_cast<void *>(slotTpInit)},
- {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, nullptr}
-};
-static PyType_Spec PySideSlotType_spec = {
- "2:PySide6.QtCore.Slot",
- sizeof(PySideSlot),
- 0,
- Py_TPFLAGS_DEFAULT,
- PySideSlotType_slots,
-};
+static PyTypeObject *createSlotType()
+{
+ PyType_Slot PySideSlotType_slots[] = {
+ {Py_tp_call, reinterpret_cast<void *>(slotCall)},
+ {Py_tp_init, reinterpret_cast<void *>(slotTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
+ };
+
+ PyType_Spec PySideSlotType_spec = {
+ "2:PySide6.QtCore.Slot",
+ sizeof(PySideSlot),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSlotType_slots,
+ };
+
+ return SbkType_FromSpec(&PySideSlotType_spec);
+}
static PyTypeObject *PySideSlot_TypeF()
{
- static auto *type = SbkType_FromSpec(&PySideSlotType_spec);
+ static auto *type = createSlotType();
return type;
}
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;
}
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;
}
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 4e93fa192..8bd5b7d37 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -125,31 +125,36 @@ static PyGetSetDef SbkObjectType_tp_getset[] = {
{nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel
};
-static PyType_Slot SbkObjectType_Type_slots[] = {
- {Py_tp_dealloc, reinterpret_cast<void *>(SbkObjectType_tp_dealloc)},
- {Py_tp_getattro, reinterpret_cast<void *>(mangled_type_getattro)},
- {Py_tp_base, static_cast<void *>(&PyType_Type)},
- {Py_tp_alloc, reinterpret_cast<void *>(PyType_GenericAlloc)},
- {Py_tp_new, reinterpret_cast<void *>(SbkObjectType_tp_new)},
- {Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
- {Py_tp_getset, reinterpret_cast<void *>(SbkObjectType_tp_getset)},
- {0, nullptr}
-};
-
-// PYSIDE-535: The tp_itemsize field is inherited and does not need to be set.
-// In PyPy, it _must_ not be set, because it would have the meaning that a
-// `__len__` field must be defined. Not doing so creates a hard-to-find crash.
-static PyType_Spec SbkObjectType_Type_spec = {
- "1:Shiboken.ObjectType",
- 0,
- 0, // sizeof(PyMemberDef), not for PyPy without a __len__ defined
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- SbkObjectType_Type_slots,
-};
+static PyTypeObject *createObjectTypeType()
+{
+ PyType_Slot SbkObjectType_Type_slots[] = {
+ {Py_tp_dealloc, reinterpret_cast<void *>(SbkObjectType_tp_dealloc)},
+ {Py_tp_getattro, reinterpret_cast<void *>(mangled_type_getattro)},
+ {Py_tp_base, static_cast<void *>(&PyType_Type)},
+ {Py_tp_alloc, reinterpret_cast<void *>(PyType_GenericAlloc)},
+ {Py_tp_new, reinterpret_cast<void *>(SbkObjectType_tp_new)},
+ {Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
+ {Py_tp_getset, reinterpret_cast<void *>(SbkObjectType_tp_getset)},
+ {0, nullptr}
+ };
+
+ // PYSIDE-535: The tp_itemsize field is inherited and does not need to be set.
+ // In PyPy, it _must_ not be set, because it would have the meaning that a
+ // `__len__` field must be defined. Not doing so creates a hard-to-find crash.
+ PyType_Spec SbkObjectType_Type_spec = {
+ "1:Shiboken.ObjectType",
+ 0,
+ 0, // sizeof(PyMemberDef), not for PyPy without a __len__ defined
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ SbkObjectType_Type_slots,
+ };
+
+ return SbkType_FromSpec(&SbkObjectType_Type_spec);
+}
PyTypeObject *SbkObjectType_TypeF(void)
{
- static auto *type = SbkType_FromSpec(&SbkObjectType_Type_spec);
+ static auto *type = createObjectTypeType();
return type;
}
@@ -186,10 +191,10 @@ static int SbkObject_tp_traverse(PyObject *self, visitproc visit, void *arg)
if (sbkSelf->ob_dict)
Py_VISIT(sbkSelf->ob_dict);
- if (_PepRuntimeVersion() >= 0x030900) {
- // This was not needed before Python 3.9 (Python issue 35810 and 40217)
- Py_VISIT(Py_TYPE(self));
- }
+#if PY_VERSION_HEX >= 0x03090000
+ // This was not needed before Python 3.9 (Python issue 35810 and 40217)
+ Py_VISIT(Py_TYPE(self));
+#endif
return 0;
}
@@ -209,46 +214,52 @@ static int SbkObject_tp_clear(PyObject *self)
return 0;
}
-static PyType_Slot SbkObject_Type_slots[] = {
- {Py_tp_getattro, reinterpret_cast<void *>(SbkObject_GenericGetAttr)},
- {Py_tp_setattro, reinterpret_cast<void *>(SbkObject_GenericSetAttr)},
- {Py_tp_dealloc, reinterpret_cast<void *>(SbkDeallocWrapperWithPrivateDtor)},
- {Py_tp_traverse, reinterpret_cast<void *>(SbkObject_tp_traverse)},
- {Py_tp_clear, reinterpret_cast<void *>(SbkObject_tp_clear)},
- // unsupported: {Py_tp_weaklistoffset, (void *)offsetof(SbkObject, weakreflist)},
- {Py_tp_getset, reinterpret_cast<void *>(SbkObject_tp_getset)},
- // unsupported: {Py_tp_dictoffset, (void *)offsetof(SbkObject, ob_dict)},
- {0, nullptr}
-};
-static PyType_Spec SbkObject_Type_spec = {
- "1:Shiboken.Object",
- sizeof(SbkObject),
- 0,
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
- SbkObject_Type_slots,
-};
-
-static const char *SbkObject_SignatureStrings[] = {
- "Shiboken.Object(self)",
- nullptr}; // Sentinel
+static PyTypeObject *createObjectType()
+{
+ PyType_Slot SbkObject_Type_slots[] = {
+ {Py_tp_getattro, reinterpret_cast<void *>(SbkObject_GenericGetAttr)},
+ {Py_tp_setattro, reinterpret_cast<void *>(SbkObject_GenericSetAttr)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(SbkDeallocWrapperWithPrivateDtor)},
+ {Py_tp_traverse, reinterpret_cast<void *>(SbkObject_tp_traverse)},
+ {Py_tp_clear, reinterpret_cast<void *>(SbkObject_tp_clear)},
+ // unsupported: {Py_tp_weaklistoffset, (void *)offsetof(SbkObject, weakreflist)},
+ {Py_tp_getset, reinterpret_cast<void *>(SbkObject_tp_getset)},
+ // unsupported: {Py_tp_dictoffset, (void *)offsetof(SbkObject, ob_dict)},
+ {0, nullptr}
+ };
+
+ PyType_Spec SbkObject_Type_spec = {
+ "1:Shiboken.Object",
+ sizeof(SbkObject),
+ 0,
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
+ SbkObject_Type_slots,
+ };
-PyTypeObject *SbkObject_TypeF(void)
-{
// PYSIDE-2230: When creating this type, we cannot easily handle the metaclass.
// In versions < Python 3.12, the metaclass can only be set
// indirectly by a base which has that metaclass.
// But before 3.12 is the minimum version, we cannot use the new
// function, although we would need this for 3.12 :-D
// We do a special patching here that is triggered through Py_None.
- static auto *type = SbkType_FromSpec_BMDWB(&SbkObject_Type_spec,
- Py_None, // bases, special flag!
- SbkObjectType_TypeF(),
- offsetof(SbkObject, ob_dict),
- offsetof(SbkObject, weakreflist),
- nullptr); // bufferprocs
+ return SbkType_FromSpec_BMDWB(&SbkObject_Type_spec,
+ Py_None, // bases, special flag!
+ SbkObjectType_TypeF(),
+ offsetof(SbkObject, ob_dict),
+ offsetof(SbkObject, weakreflist),
+ nullptr); // bufferprocs
+}
+
+PyTypeObject *SbkObject_TypeF(void)
+{
+ static auto *type = createObjectType(); // bufferprocs
return type;
}
+static const char *SbkObject_SignatureStrings[] = {
+ "Shiboken.Object(self)",
+ nullptr}; // Sentinel
+
static int mainThreadDeletionHandler(void *)
{
if (Py_IsInitialized())
diff --git a/sources/shiboken6/libshiboken/voidptr.cpp b/sources/shiboken6/libshiboken/voidptr.cpp
index abfff5831..ed4f88ad1 100644
--- a/sources/shiboken6/libshiboken/voidptr.cpp
+++ b/sources/shiboken6/libshiboken/voidptr.cpp
@@ -256,38 +256,42 @@ static PyBufferProcs SbkVoidPtrObjectBufferProc = {
(releasebufferproc)nullptr // bf_releasebuffer
};
-// Void pointer type definition.
-static PyType_Slot SbkVoidPtrType_slots[] = {
- {Py_tp_repr, reinterpret_cast<void *>(SbkVoidPtrObject_repr)},
- {Py_nb_int, reinterpret_cast<void *>(SbkVoidPtrObject_int)},
- {Py_sq_length, reinterpret_cast<void *>(SbkVoidPtrObject_length)},
- {Py_tp_str, reinterpret_cast<void *>(SbkVoidPtrObject_str)},
- {Py_tp_richcompare, reinterpret_cast<void *>(SbkVoidPtrObject_richcmp)},
- {Py_tp_init, reinterpret_cast<void *>(SbkVoidPtrObject_init)},
- {Py_tp_new, reinterpret_cast<void *>(SbkVoidPtrObject_new)},
- {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {Py_tp_methods, reinterpret_cast<void *>(SbkVoidPtrObject_methods)},
- {0, nullptr}
-};
-static PyType_Spec SbkVoidPtrType_spec = {
- "2:shiboken6.Shiboken.VoidPtr",
- sizeof(SbkVoidPtrObject),
- 0,
- Py_TPFLAGS_DEFAULT,
- SbkVoidPtrType_slots,
-};
-
-
+static PyTypeObject *createVoidPtrType()
+{
+ PyType_Slot SbkVoidPtrType_slots[] = {
+ {Py_tp_repr, reinterpret_cast<void *>(SbkVoidPtrObject_repr)},
+ {Py_nb_int, reinterpret_cast<void *>(SbkVoidPtrObject_int)},
+ {Py_sq_length, reinterpret_cast<void *>(SbkVoidPtrObject_length)},
+ {Py_tp_str, reinterpret_cast<void *>(SbkVoidPtrObject_str)},
+ {Py_tp_richcompare, reinterpret_cast<void *>(SbkVoidPtrObject_richcmp)},
+ {Py_tp_init, reinterpret_cast<void *>(SbkVoidPtrObject_init)},
+ {Py_tp_new, reinterpret_cast<void *>(SbkVoidPtrObject_new)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {Py_tp_methods, reinterpret_cast<void *>(SbkVoidPtrObject_methods)},
+ {0, nullptr}
+ };
+
+ PyType_Spec SbkVoidPtrType_spec = {
+ "2:shiboken6.Shiboken.VoidPtr",
+ sizeof(SbkVoidPtrObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ SbkVoidPtrType_slots,
+ };
+
+ return SbkType_FromSpec_BMDWB(&SbkVoidPtrType_spec,
+ nullptr, nullptr, 0, 0,
+ &SbkVoidPtrObjectBufferProc);
}
PyTypeObject *SbkVoidPtr_TypeF(void)
{
- static PyTypeObject *type = SbkType_FromSpec_BMDWB(&SbkVoidPtrType_spec,
- nullptr, nullptr, 0, 0,
- &SbkVoidPtrObjectBufferProc);
+ static auto *type = createVoidPtrType();
return type;
}
+} // extern "C"
+
namespace VoidPtr {
static int voidPointerInitialized = false;