aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-06-04 19:53:50 +0200
committerChristian Tismer <tismer@stackless.com>2017-06-09 12:46:43 +0000
commit5ff239ac4f1b34e2b3317f0968a61658d8c586d6 (patch)
treea21c090bf607467126740d475e7eedb3a7b402bf /sources
parente25ed8d09b67a0b67dee4239513c00a6b7e701a4 (diff)
Fix missing headers in PySide custom build
PySide itself built fine after the additional includes were added for inheritance. But when a smaller project is built, suddenly header files are not found, because the inherited names are not expected by the deployment. Therefore, we do no longer add more includes, but insert recursive headers for the few relevant cases. So the includes become a little longer, but the names of the include files are those as before the enhanced inheritance. Task-number: PYSIDE-500 Change-Id: Iab456307a3c2365dfe1964dbe222b7d0efac7878 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp11
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp39
2 files changed, 32 insertions, 18 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 68b62477..06300fc0 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -251,17 +251,6 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
headerfile.replace(QLatin1String(".cpp"), QLatin1String(".h"));
s << endl << "// main header" << endl << "#include \"" << headerfile << '"' << endl;
- // PYSIDE-500: Use also includes for inherited wrapper classes, because
- // without the protected hack, we sometimes need to cast inherited wrappers.
- s << endl << "// inherited wrapper classes" << endl;
- AbstractMetaClass *basis = metaClass->baseClass();
- for (; basis; basis = basis->baseClass()) {
- GeneratorContext basisContext(basis);
- QString headerfile = fileNameForContext(basisContext);
- headerfile.replace(QLatin1String(".cpp"), QLatin1String(".h"));
- s << "#include \"" << headerfile << '"' << endl;
- }
-
s << endl << "// inner classes" << endl;
foreach (AbstractMetaClass* innerClass, metaClass->innerClasses()) {
GeneratorContext innerClassContext(innerClass);
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
index 5ef5d561..27a84f6a 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -107,11 +107,12 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte
} else {
wrapperName = HeaderGenerator::wrapperName(classContext.preciseType());
}
- QString headerGuard = getFilteredCppSignatureString(wrapperName).toUpper();
+ QString outerHeaderGuard = getFilteredCppSignatureString(wrapperName).toUpper();
+ QString innerHeaderGuard;
// Header
- s << "#ifndef SBK_" << headerGuard << "_H" << endl;
- s << "#define SBK_" << headerGuard << "_H" << endl<< endl;
+ s << "#ifndef SBK_" << outerHeaderGuard << "_H" << endl;
+ s << "#define SBK_" << outerHeaderGuard << "_H" << endl << endl;
if (!avoidProtectedHack())
s << "#define protected public" << endl << endl;
@@ -121,10 +122,16 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte
//Includes
s << metaClass->typeEntry()->include() << endl;
- if (shouldGenerateCppWrapper(metaClass)) {
+ if (shouldGenerateCppWrapper(metaClass) &&
+ usePySideExtensions() && metaClass->isQObject())
+ s << "namespace PySide { class DynamicQMetaObject; }\n\n";
- if (usePySideExtensions() && metaClass->isQObject())
- s << "namespace PySide { class DynamicQMetaObject; }\n\n";
+ while (shouldGenerateCppWrapper(metaClass)) {
+ if (!innerHeaderGuard.isEmpty()) {
+ s << "# ifndef SBK_" << innerHeaderGuard << "_H" << endl;
+ s << "# define SBK_" << innerHeaderGuard << "_H" << endl << endl;
+ s << "// Inherited base class:" << endl;
+ }
// Class
s << "class " << wrapperName;
@@ -172,15 +179,33 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte
if (m_inheritedOverloads.size()) {
s << INDENT << "// Inherited overloads, because the using keyword sux" << endl;
writeInheritedOverloads(s);
+ m_inheritedOverloads.clear();
}
if (usePySideExtensions())
s << INDENT << "static void pysideInitQtMetaTypes();" << endl;
s << "};" << endl << endl;
+ if (!innerHeaderGuard.isEmpty())
+ s << "# endif // SBK_" << innerHeaderGuard << "_H" << endl << endl;
+
+ // PYSIDE-500: Use also includes for inherited wrapper classes, because
+ // without the protected hack, we sometimes need to cast inherited wrappers.
+ // But we don't use multiple include files. Instead, they are inserted as recursive
+ // headers. This keeps the file structure as simple as before the enhanced inheritance.
+ metaClass = metaClass->baseClass();
+ if (!metaClass || !avoidProtectedHack())
+ break;
+ classContext = GeneratorContext(metaClass);
+ if (!classContext.forSmartPointer()) {
+ wrapperName = HeaderGenerator::wrapperName(metaClass);
+ } else {
+ wrapperName = HeaderGenerator::wrapperName(classContext.preciseType());
+ }
+ innerHeaderGuard = getFilteredCppSignatureString(wrapperName).toUpper();
}
- s << "#endif // SBK_" << headerGuard << "_H" << endl << endl;
+ s << "#endif // SBK_" << outerHeaderGuard << "_H" << endl << endl;
}
void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func)