From e24392c76e5cfdd2d6d51bd853b106db2bc4cb80 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 19 Jul 2018 21:00:30 +0200 Subject: 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 Reviewed-by: Friedemann Kleint Reviewed-by: Alexandru Croitor --- sources/shiboken2/libshiboken/pep384impl.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sources/shiboken2/libshiboken/pep384impl.cpp') diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index f0e8f3457..b648330d8 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -190,9 +190,9 @@ extern "C" struct LIBSHIBOKEN_API SbkObject { PyObject_HEAD - PyObject* ob_dict; - PyObject* weakreflist; - SbkObjectPrivate* d; + PyObject *ob_dict; + PyObject *weakreflist; + SbkObjectPrivate *d; }; The first step was to rename the SbkObjectTypePrivate from "d" to @@ -217,7 +217,7 @@ extern "C" #define _genericTypeExtender(etype) \ (reinterpret_cast(etype) + \ - (reinterpret_cast(&PyType_Type))->tp_basicsize) + (reinterpret_cast(&PyType_Type))->tp_basicsize) #define PepType_SOTP(etype) \ (*reinterpret_cast(_genericTypeExtender(etype))) @@ -404,13 +404,13 @@ static PyType_Spec typeprobe_spec = { static void check_PepTypeObject_valid(void) { - PyObject *obtype = reinterpret_cast(&PyType_Type); - PyTypeObject *probe_tp_base = reinterpret_cast( + PyObject *obtype = reinterpret_cast(&PyType_Type); + PyTypeObject *probe_tp_base = reinterpret_cast( PyObject_GetAttrString(obtype, "__base__")); PyObject *probe_tp_bases = PyObject_GetAttrString(obtype, "__bases__"); - PepTypeObject *check = reinterpret_cast( + PyTypeObject *check = reinterpret_cast( PyType_FromSpecWithBases(&typeprobe_spec, probe_tp_bases)); - PepTypeObject *typetype = reinterpret_cast(obtype); + PyTypeObject *typetype = reinterpret_cast(obtype); PyObject *w = PyObject_GetAttrString(obtype, "__weakrefoffset__"); long probe_tp_weakrefoffset = PyLong_AsLong(w); PyObject *d = PyObject_GetAttrString(obtype, "__dictoffset__"); @@ -675,8 +675,8 @@ PyTime_FromTime(int hour, int min, int sec, int usec) PyObject * PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) { - PyObject* code = Py_CompileString(str, "pyscript", start); - PyObject* ret = NULL; + PyObject *code = Py_CompileString(str, "pyscript", start); + PyObject *ret = NULL; if (code != NULL) { ret = PyEval_EvalCode(code, globals, locals); @@ -811,7 +811,7 @@ static PyTypeObject *getStaticMethodType(void) const char * PepType_GetNameStr(PyTypeObject *type) { - const char *ret = PepType(type)->tp_name; + const char *ret = type->tp_name; const char *nodots = strrchr(ret, '.'); if (nodots) ret = nodots + 1; -- cgit v1.2.3