diff options
author | Christian Tismer <tismer@stackless.com> | 2018-07-19 21:00:30 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2018-07-23 16:32:01 +0000 |
commit | e24392c76e5cfdd2d6d51bd853b106db2bc4cb80 (patch) | |
tree | 985048135d3a6a81da2f5a72b667ff59ed4d0b44 /sources/shiboken2/libshiboken/pep384impl.h | |
parent | 5d21980ba4bd605ccbf4278e75177ae2c144bdd8 (diff) |
Pep 384 Final Cut: Remove PepType
While trying to document the Limited API Project,
it suddenly struck me:
We can make the patch much much simpler and implement it
without the necessity to have an extra PepType!
Now I am happy to continue the documentation, because
it is now no more improvable.
This version will last as long as the layout of
PyTypeObject does not change substantially. When that
happens, then we need to rewrite stuff with the according
PyType_GetSlot() access functions.
These access functions will until then be complete enough
so that we can live without the tricks like inventing a reduced
PyTypeObject as was done in the current implementation.
Task-number: PYSIDE-560
Change-Id: I49849cc377baa6794a5b53292691e21d6e2853ab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/pep384impl.h')
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.h | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index 8f14c853a..643714f04 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -69,14 +69,9 @@ LIBSHIBOKEN_API void _PyObject_Dump(PyObject *); /* * There are a few structures that are needed, but cannot be used without * breaking the API. We use some heuristics to get those fields anyway - * and validate that we really found them, see Pepresolve.cpp . + * and validate that we really found them, see pep384impl.cpp . */ -// PepType is just a typecast that allows direct access. This is -// often better to read than the reversal via the former macro -// functions PepType_tp_xxx. -#define PepType(o) (reinterpret_cast<PepTypeObject*>(o)) - #ifdef Py_LIMITED_API /* @@ -87,7 +82,7 @@ LIBSHIBOKEN_API void _PyObject_Dump(PyObject *); * When we need more fields, we replace it back and add it to the * validation. */ -typedef struct _peptypeobject { +typedef struct _typeobject { PyVarObject ob_base; const char *tp_name; Py_ssize_t tp_basicsize; @@ -131,7 +126,7 @@ typedef struct _peptypeobject { PyObject *tp_bases; PyObject *tp_mro; /* method resolution order */ -} PepTypeObject; +} PyTypeObject; // This was a macro error in the limited API from the beginning. // It was fixed in Python master, but did make it only in Python 3.8 . @@ -143,11 +138,9 @@ LIBSHIBOKEN_API int PyIndex_Check(PyObject *obj); #undef PyObject_IS_GC #define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ - ( PepType(Py_TYPE(o))->tp_is_gc == NULL || \ - PepType(Py_TYPE(o))->tp_is_gc(o) )) + ( Py_TYPE(o)->tp_is_gc == NULL || \ + Py_TYPE(o)->tp_is_gc(o) )) -#else -#define PepTypeObject PyTypeObject #endif // Py_LIMITED_API struct SbkObjectTypePrivate; @@ -155,7 +148,7 @@ struct PySideQFlagsTypePrivate; struct _SbkGenericTypePrivate; #define PepHeapType_SIZE \ - (reinterpret_cast<PepTypeObject*>(&PyType_Type)->tp_basicsize) + (reinterpret_cast<PyTypeObject*>(&PyType_Type)->tp_basicsize) #define _genericTypeExtender(etype) \ (reinterpret_cast<char*>(etype) + PepHeapType_SIZE) |