aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/libpyside')
-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
6 files changed, 182 insertions, 146 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;
}
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;
}