aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/pysideweakref.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/libpyside/pysideweakref.cpp')
-rw-r--r--sources/pyside6/libpyside/pysideweakref.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp
index 79a19fec8..5f3ca59e4 100644
--- a/sources/pyside6/libpyside/pysideweakref.cpp
+++ b/sources/pyside6/libpyside/pysideweakref.cpp
@@ -6,32 +6,37 @@
#include <sbkpython.h>
#include <shiboken.h>
-typedef struct {
+struct PySideCallableObject {
PyObject_HEAD
/* Type-specific fields go here. */
PySideWeakRefFunction weakref_func;
void *user_data;
-} 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;
}
@@ -44,7 +49,7 @@ static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args,
Py_RETURN_NONE;
}
-namespace PySide { namespace WeakRef {
+namespace PySide::WeakRef {
PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
{
@@ -74,5 +79,4 @@ PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
return reinterpret_cast<PyObject *>(weak);
}
-} } //namespace
-
+} // namespace PySide::WeakRef