aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/basewrapper.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2018-07-19 21:00:30 +0200
committerChristian Tismer <tismer@stackless.com>2018-07-23 16:32:01 +0000
commite24392c76e5cfdd2d6d51bd853b106db2bc4cb80 (patch)
tree985048135d3a6a81da2f5a72b667ff59ed4d0b44 /sources/shiboken2/libshiboken/basewrapper.cpp
parent5d21980ba4bd605ccbf4278e75177ae2c144bdd8 (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/basewrapper.cpp')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 43c162dec..ec705a421 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -180,8 +180,8 @@ SbkObjectType *SbkObject_TypeF(void)
type = reinterpret_cast<PyTypeObject *>(PyType_FromSpec(&SbkObject_Type_spec));
Py_TYPE(type) = SbkObjectType_TypeF();
Py_INCREF(Py_TYPE(type));
- PepType(type)->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
- PepType(type)->tp_dictoffset = offsetof(SbkObject, ob_dict);
+ type->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
+ type->tp_dictoffset = offsetof(SbkObject, ob_dict);
}
return reinterpret_cast<SbkObjectType *>(type);
}
@@ -306,18 +306,18 @@ PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* k
#ifndef IS_PY3K
if (PyClass_Check(baseType)) {
PyErr_Format(PyExc_TypeError, "Invalid base class used in type %s. "
- "PySide only support multiple inheritance from python new style class.", PepType(metatype)->tp_name);
+ "PySide only support multiple inheritance from python new style class.", metatype->tp_name);
return 0;
}
#endif
- if (PepType(reinterpret_cast<PyTypeObject*>(baseType))->tp_new == SbkDummyNew) {
+ if (reinterpret_cast<PyTypeObject *>(baseType)->tp_new == SbkDummyNew) {
// PYSIDE-595: A base class does not allow inheritance.
return SbkDummyNew(metatype, args, kwds);
}
}
// The meta type creates a new type when the Python programmer extends a wrapped C++ class.
- newfunc type_new = reinterpret_cast<newfunc>(PepType(&PyType_Type)->tp_new);
+ newfunc type_new = reinterpret_cast<newfunc>(PyType_Type.tp_new);
SbkObjectType *newType = reinterpret_cast<SbkObjectType*>(type_new(metatype, args, kwds));
if (!newType)
return 0;
@@ -425,7 +425,7 @@ SbkDummyNew(PyTypeObject *type, PyObject*, PyObject*)
// PYSIDE-595: Give the same error as type_call does when tp_new is NULL.
PyErr_Format(PyExc_TypeError,
"cannot create '%.100s' instances ¯\\_(ツ)_/¯",
- PepType(type)->tp_name);
+ type->tp_name);
return nullptr;
}
@@ -458,7 +458,7 @@ static void decRefPyObjectList(const std::list<PyObject*> &pyObj, PyObject* skip
static void _walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visitor)
{
- PyObject* bases = PepType(currentType)->tp_bases;
+ PyObject* bases = currentType->tp_bases;
Py_ssize_t numBases = PyTuple_GET_SIZE(bases);
for (int i = 0; i < numBases; ++i) {
PyTypeObject* type = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(bases, i));
@@ -577,10 +577,10 @@ void setErrorAboutWrongArguments(PyObject* args, const char* funcName, const cha
if (i)
params += ", ";
PyObject* arg = PyTuple_GET_ITEM(args, i);
- params += PepType((Py_TYPE(arg)))->tp_name;
+ params += Py_TYPE(arg)->tp_name;
}
} else {
- params = PepType((Py_TYPE(args)))->tp_name;
+ params = Py_TYPE(args)->tp_name;
}
}
@@ -669,7 +669,7 @@ bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType)
FindBaseTypeVisitor visitor(ctorType);
walkThroughClassHierarchy(myType, &visitor);
if (!visitor.found()) {
- PyErr_Format(PyExc_TypeError, "%s isn't a direct base class of %s", PepType(ctorType)->tp_name, PepType(myType)->tp_name);
+ PyErr_Format(PyExc_TypeError, "%s isn't a direct base class of %s", ctorType->tp_name, myType->tp_name);
return false;
}
return true;
@@ -1105,13 +1105,13 @@ bool isValid(PyObject* pyObj)
if (!priv->cppObjectCreated && isUserType(pyObj)) {
PyErr_Format(PyExc_RuntimeError, "'__init__' method of object's base class (%s) not called.",
- PepType((Py_TYPE(pyObj)))->tp_name);
+ Py_TYPE(pyObj)->tp_name);
return false;
}
if (!priv->validCppObject) {
PyErr_Format(PyExc_RuntimeError, "Internal C++ object (%s) already deleted.",
- PepType((Py_TYPE(pyObj)))->tp_name);
+ Py_TYPE(pyObj)->tp_name);
return false;
}
@@ -1127,14 +1127,14 @@ bool isValid(SbkObject* pyObj, bool throwPyError)
if (!priv->cppObjectCreated && isUserType(reinterpret_cast<PyObject*>(pyObj))) {
if (throwPyError)
PyErr_Format(PyExc_RuntimeError, "Base constructor of the object (%s) not called.",
- PepType((Py_TYPE(pyObj)))->tp_name);
+ Py_TYPE(pyObj)->tp_name);
return false;
}
if (!priv->validCppObject) {
if (throwPyError)
PyErr_Format(PyExc_RuntimeError, "Internal C++ object (%s) already deleted.",
- PepType((Py_TYPE(pyObj)))->tp_name);
+ (Py_TYPE(pyObj))->tp_name);
return false;
}
@@ -1415,7 +1415,7 @@ void deallocData(SbkObject* self, bool cleanup)
// PYSIDE-571: qApp is no longer allocated.
if (PyObject_IS_GC(reinterpret_cast<PyObject*>(self)))
- PepType(Py_TYPE(self))->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
void setTypeUserData(SbkObject* wrapper, void* userData, DeleteUserDataFunc d_func)
@@ -1512,7 +1512,7 @@ std::string info(SbkObject* self)
s << "C++ address....... ";
std::list<SbkObjectType*>::const_iterator it = bases.begin();
for (int i = 0; it != bases.end(); ++it, ++i)
- s << PepType((reinterpret_cast<PyTypeObject*>(*it)))->tp_name << '/' << self->d->cptr[i] << ' ';
+ s << reinterpret_cast<PyTypeObject *>(*it)->tp_name << '/' << self->d->cptr[i] << ' ';
s << "\n";
}
else {