aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/basewrapper.h
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-12-17 19:12:56 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-05-30 18:13:41 +0000
commit18dc31becdd994c53a9f894087cf1ef99fbd0232 (patch)
tree3021cfa473f20102bfb63a26117776615b91b526 /sources/shiboken2/libshiboken/basewrapper.h
parent50dd4ae202d7afb3556335c056db003f5ef50532 (diff)
PEP 384-squash: Implement PEP 384
This is the condensed checkin of 18 commits which created the implementation of PEP 384. Task-number: PYSIDE-560 Change-Id: I834c659af4c2b55b268f8e8dc4cfa53f02502409 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper.h')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.h38
1 files changed, 26 insertions, 12 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.h b/sources/shiboken2/libshiboken/basewrapper.h
index fc553cf8c..755058e8b 100644
--- a/sources/shiboken2/libshiboken/basewrapper.h
+++ b/sources/shiboken2/libshiboken/basewrapper.h
@@ -93,22 +93,34 @@ typedef void (*ObjectDestructor)(void*);
typedef void (*SubTypeInitHook)(SbkObjectType*, PyObject*, PyObject*);
-extern LIBSHIBOKEN_API PyTypeObject SbkObjectType_Type;
-extern LIBSHIBOKEN_API SbkObjectType SbkObject_Type;
+extern LIBSHIBOKEN_API PyTypeObject *SbkObjectType_TypeF(void);
+extern LIBSHIBOKEN_API SbkObjectType *SbkObject_TypeF(void);
struct SbkObjectTypePrivate;
/// PyTypeObject extended with C++ multiple inheritance information.
struct LIBSHIBOKEN_API SbkObjectType
{
- PyHeapTypeObject super;
- SbkObjectTypePrivate* d;
+ PepTypeObject type;
};
LIBSHIBOKEN_API PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*);
// the special case of a switchable singleton
LIBSHIBOKEN_API PyObject* SbkQAppTpNew(PyTypeObject *subtype, PyObject *args, PyObject *kwds);
+/**
+ * PYSIDE-595: Use a null deallocator instead of nullptr.
+ *
+ * When moving to heaptypes, we were struck by a special default behavior of
+ * PyType_FromSpecWithBases that inserts subtype_dealloc when tp_dealloc is
+ * nullptr. To prevent inserting this, we use a null deallocator that is there
+ * as a placeholder.
+ *
+ * The same holds for a null tp_new. We use one that raises the right error.
+ */
+LIBSHIBOKEN_API void SbkDummyDealloc(PyObject*);
+LIBSHIBOKEN_API PyObject *SbkDummyNew(PyTypeObject *type, PyObject*, PyObject*);
+
} // extern "C"
namespace Shiboken
@@ -173,7 +185,7 @@ LIBSHIBOKEN_API const char* getOriginalName(SbkObjectType* self);
LIBSHIBOKEN_API void setTypeDiscoveryFunctionV2(SbkObjectType* self, TypeDiscoveryFuncV2 func);
LIBSHIBOKEN_API void copyMultimpleheritance(SbkObjectType* self, SbkObjectType* other);
-LIBSHIBOKEN_API void setMultipleIheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction func);
+LIBSHIBOKEN_API void setMultipleInheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction func);
LIBSHIBOKEN_API MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkObjectType* self);
LIBSHIBOKEN_API void setDestructorFunction(SbkObjectType* self, ObjectDestructor func);
@@ -197,13 +209,15 @@ LIBSHIBOKEN_API void initPrivateData(SbkObjectType* self);
* wrapper type.
* \returns true if the initialization went fine, false otherwise.
*/
-LIBSHIBOKEN_API bool introduceWrapperType(PyObject* enclosingObject,
- const char* typeName, const char* originalName,
- SbkObjectType* type,
- const char* signaturesString,
- ObjectDestructor cppObjDtor = 0,
- SbkObjectType* baseType = 0, PyObject* baseTypes = 0,
- bool isInnerClass = false);
+LIBSHIBOKEN_API SbkObjectType *introduceWrapperType(PyObject *enclosingObject,
+ const char *typeName,
+ const char *originalName,
+ PyType_Spec *typeSpec,
+ const char *signaturesString,
+ ObjectDestructor cppObjDtor,
+ SbkObjectType *baseType,
+ PyObject *baseTypes,
+ bool isInnerClass);
/**
* Set the subtype init hook for a type.