aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-09-23 13:14:25 +0200
committerChristian Tismer <tismer@stackless.com>2020-09-24 11:35:12 +0000
commit03b9069a7e408568e98cc826c0cb7ea2e5035f1c (patch)
tree0e072296b1a7c5a47a0d305b3a2111322b9e3605 /sources/shiboken2
parent9eee97b5e66c9771e428539eb340b2c2a3756968 (diff)
Signature: Revert SbkSpecial_Type_Ready to PyType_Ready
The early signature module tried to minimize the visible changes to the code base. It replaced the `PyType_Ready` call by a special version which did other things as well. We replace that special call by a more intuitive function `InitSignatureStrings` that does exactly that and nothing more. The functionality of the module is unchanged. Change-Id: Ic2f9cd29b0352f0a24daa55b01420c77d103c0b2 Task-number: PYSIDE-510 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp22
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp7
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.h1
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp5
-rw-r--r--sources/shiboken2/libshiboken/signature.h2
5 files changed, 13 insertions, 24 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 304a7ba4e..2f76b6dbf 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -595,7 +595,7 @@ void CppGenerator::generateClass(QTextStream &s, const GeneratorContext &classCo
sorter.sort();
s << '\n';
- s << "static const char *" << className << "_properties[] = {\n";
+ s << "static const char *" << className << "_PropertyStrings[] = {\n";
for (const auto &entry : qAsConst(sorter))
s << INDENT << entry << ",\n";
s << INDENT << NULL_PTR << " // Sentinel\n";
@@ -5171,10 +5171,7 @@ void CppGenerator::writeClassRegister(QTextStream &s,
// 4:typeSpec
s << INDENT << '&' << chopType(pyTypeName) << "_spec,\n";
- // 5:signatureStrings
- s << INDENT << initFunctionName << "_SignatureStrings,\n";
-
- // 6:cppObjDtor
+ // 5:cppObjDtor
s << INDENT;
if (!metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
QString dtorClassName = metaClass->qualifiedCppName();
@@ -5190,7 +5187,7 @@ void CppGenerator::writeClassRegister(QTextStream &s,
s << "0,\n";
}
- // 7:baseType
+ // 6:baseType
const auto base = metaClass->isNamespace()
? metaClass->extendedNamespace() : metaClass->baseClass();
if (base) {
@@ -5200,13 +5197,13 @@ void CppGenerator::writeClassRegister(QTextStream &s,
s << INDENT << "0,\n";
}
- // 8:baseTypes
+ // 7:baseTypes
if (metaClass->baseClassNames().size() > 1)
s << INDENT << pyTypeBasesVariable << ',' << Qt::endl;
else
s << INDENT << "0,\n";
- // 9:wrapperflags
+ // 8:wrapperflags
QByteArrayList wrapperFlags;
if (enc)
wrapperFlags.append(QByteArrayLiteral("Shiboken::ObjectType::WrapperFlags::InnerClass"));
@@ -5220,11 +5217,12 @@ void CppGenerator::writeClassRegister(QTextStream &s,
s << INDENT << ");\n";
s << INDENT << Qt::endl;
- if (usePySideExtensions()) {
- QString className = metaClass->qualifiedCppName();
+ s << INDENT << "auto pyType = reinterpret_cast<PyTypeObject *>(" << typePtr << ");\n";
+ s << INDENT << "InitSignatureStrings(pyType, " << initFunctionName << "_SignatureStrings);\n";
+
+ if (usePySideExtensions())
s << INDENT << "SbkObjectType_SetPropertyStrings(reinterpret_cast<PyTypeObject *>(" << typePtr << "), "
- << chopType(pyTypeName) << "_properties);\n";
- }
+ << chopType(pyTypeName) << "_PropertyStrings);\n";
if (!classContext.forSmartPointer())
s << INDENT << cpythonTypeNameExt(classTypeEntry) << Qt::endl;
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 6c4dea642..d866d133c 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -1102,7 +1102,6 @@ introduceWrapperType(PyObject *enclosingObject,
const char *typeName,
const char *originalName,
PyType_Spec *typeSpec,
- const char *signatureStrings[],
ObjectDestructor cppObjDtor,
SbkObjectType *baseType,
PyObject *baseTypes,
@@ -1127,12 +1126,8 @@ introduceWrapperType(PyObject *enclosingObject,
BindingManager::instance().addClassInheritance(baseType, type);
}
}
- // PYSIDE-510: Here is the single change to support signatures.
- if (SbkSpecial_Type_Ready(enclosingObject, reinterpret_cast<PyTypeObject *>(type), signatureStrings) < 0) {
- std::cerr << "Warning: " << __FUNCTION__ << " returns nullptr for "
- << typeName << '/' << originalName << " due to SbkSpecial_Type_Ready() failing\n";
+ if (PyType_Ready(reinterpret_cast<PyTypeObject *>(type)) < 0)
return nullptr;
- }
initPrivateData(type);
auto sotp = PepType_SOTP(type);
diff --git a/sources/shiboken2/libshiboken/basewrapper.h b/sources/shiboken2/libshiboken/basewrapper.h
index 1190f3187..31083522b 100644
--- a/sources/shiboken2/libshiboken/basewrapper.h
+++ b/sources/shiboken2/libshiboken/basewrapper.h
@@ -234,7 +234,6 @@ LIBSHIBOKEN_API SbkObjectType *introduceWrapperType(PyObject *enclosingObject,
const char *typeName,
const char *originalName,
PyType_Spec *typeSpec,
- const char *signatureStrings[],
ObjectDestructor cppObjDtor,
SbkObjectType *baseType,
PyObject *baseTypes,
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index 242fe18c1..3498829e7 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -1182,11 +1182,8 @@ static int _build_func_to_type(PyObject *obtype)
return 0;
}
-int SbkSpecial_Type_Ready(PyObject * /* module */, PyTypeObject *type,
- const char *signatures[])
+int InitSignatureStrings(PyTypeObject *type, const char *signatures[])
{
- if (PyType_Ready(type) < 0)
- return -1;
auto *ob_type = reinterpret_cast<PyObject *>(type);
int ret = PySide_BuildSignatureArgs(ob_type, signatures);
if (ret < 0) {
diff --git a/sources/shiboken2/libshiboken/signature.h b/sources/shiboken2/libshiboken/signature.h
index 2a69df9cf..c5f515a7f 100644
--- a/sources/shiboken2/libshiboken/signature.h
+++ b/sources/shiboken2/libshiboken/signature.h
@@ -45,7 +45,7 @@
extern "C"
{
-LIBSHIBOKEN_API int SbkSpecial_Type_Ready(PyObject *, PyTypeObject *, const char *[]);
+LIBSHIBOKEN_API int InitSignatureStrings(PyTypeObject *, const char *[]);
LIBSHIBOKEN_API void FinishSignatureInitialization(PyObject *, const char *[]);
LIBSHIBOKEN_API void SetError_Argument(PyObject *, const char *);
LIBSHIBOKEN_API PyObject *Sbk_TypeGet___signature__(PyObject *, PyObject *);