From 38fc08ae9d52c2332c28a6dcf5d6498cdfe14f56 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 Nov 2019 11:33:29 +0100 Subject: shiboken: Fix usage of Qt's endl, preparing for Qt 6 Cherry-pick the part of 870b7f4c849ebbc5f39f1f2398e39a3b7dfd9562 from 5.15 that joins "bla" << endl into "bla\n" to reduce further merge conflicts between 5.14 and 5.15 while preserving the ability of 5.14 to compile against Qt 5.12. Change-Id: Id9632973b253557c99b2f4e0a84c3db12c55f5b4 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 870b7f4c849ebbc5f39f1f2398e39a3b7dfd9562) --- .../generator/shiboken2/headergenerator.cpp | 96 +++++++++++----------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'sources/shiboken2/generator/shiboken2/headergenerator.cpp') diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp index e47c37523..6ae00f75b 100644 --- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp @@ -61,9 +61,9 @@ QString HeaderGenerator::fileNameForContext(GeneratorContext &context) const void HeaderGenerator::writeCopyCtor(QTextStream &s, const AbstractMetaClass *metaClass) const { s << INDENT << wrapperName(metaClass) << "(const " << metaClass->qualifiedCppName() << "& self)"; - s << " : " << metaClass->qualifiedCppName() << "(self)" << endl; - s << INDENT << "{" << endl; - s << INDENT << "}" << endl << endl; + s << " : " << metaClass->qualifiedCppName() << "(self)\n"; + s << INDENT << "{\n"; + s << INDENT << "}\n\n"; } void HeaderGenerator::writeProtectedFieldAccessors(QTextStream &s, const AbstractMetaField *field) const @@ -84,11 +84,11 @@ void HeaderGenerator::writeProtectedFieldAccessors(QTextStream &s, const Abstrac << (useReference ? " *" : " ") << ' ' << protectedFieldGetterName(field) << "()" << " { return " - << (useReference ? " &" : " ") << "this->" << fieldName << "; }" << endl; + << (useReference ? " &" : " ") << "this->" << fieldName << "; }\n"; // Set function s << INDENT << "inline void " << protectedFieldSetterName(field) << '(' << fieldType << " value)" - << " { " << fieldName << " = value; }" << endl; + << " { " << fieldName << " = value; }\n"; } void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) @@ -112,11 +112,11 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte QString innerHeaderGuard; // Header - s << "#ifndef SBK_" << outerHeaderGuard << "_H" << endl; - s << "#define SBK_" << outerHeaderGuard << "_H" << endl << endl; + s << "#ifndef SBK_" << outerHeaderGuard << "_H\n"; + s << "#define SBK_" << outerHeaderGuard << "_H\n\n"; if (!avoidProtectedHack()) - s << "#define protected public" << endl << endl; + s << "#define protected public\n\n"; //Includes s << metaClass->typeEntry()->include() << endl; @@ -127,16 +127,16 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte while (shouldGenerateCppWrapper(metaClass)) { if (!innerHeaderGuard.isEmpty()) { - s << "# ifndef SBK_" << innerHeaderGuard << "_H" << endl; - s << "# define SBK_" << innerHeaderGuard << "_H" << endl << endl; - s << "// Inherited base class:" << endl; + s << "# ifndef SBK_" << innerHeaderGuard << "_H\n"; + s << "# define SBK_" << innerHeaderGuard << "_H\n\n"; + s << "// Inherited base class:\n"; } // Class s << "class " << wrapperName; s << " : public " << metaClass->qualifiedCppName(); - s << endl << '{' << endl << "public:" << endl; + s << "\n{\npublic:\n"; const AbstractMetaFunctionList &funcs = filterFunctions(metaClass); for (AbstractMetaFunction *func : funcs) { @@ -160,8 +160,8 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte s << INDENT; if (avoidProtectedHack() && metaClass->hasPrivateDestructor()) s << "// C++11: need to declare (unimplemented) destructor because " - "the base class destructor is private." << endl; - s << '~' << wrapperName << "();" << endl; + "the base class destructor is private.\n"; + s << '~' << wrapperName << "();\n"; } writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), TypeSystem::CodeSnipPositionDeclaration, TypeSystem::NativeCode); @@ -169,22 +169,22 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte if ((!avoidProtectedHack() || !metaClass->hasPrivateDestructor()) && usePySideExtensions() && metaClass->isQObject()) { s << "public:\n"; - s << INDENT << "int qt_metacall(QMetaObject::Call call, int id, void **args) override;" << endl; - s << INDENT << "void *qt_metacast(const char *_clname) override;" << endl; + s << INDENT << "int qt_metacall(QMetaObject::Call call, int id, void **args) override;\n"; + s << INDENT << "void *qt_metacast(const char *_clname) override;\n"; } if (!m_inheritedOverloads.isEmpty()) { - s << INDENT << "// Inherited overloads, because the using keyword sux" << endl; + s << INDENT << "// Inherited overloads, because the using keyword sux\n"; writeInheritedOverloads(s); m_inheritedOverloads.clear(); } if (usePySideExtensions()) - s << INDENT << "static void pysideInitQtMetaTypes();" << endl; + s << INDENT << "static void pysideInitQtMetaTypes();\n"; - s << "};" << endl << endl; + s << "};\n\n"; if (!innerHeaderGuard.isEmpty()) - s << "# endif // SBK_" << innerHeaderGuard << "_H" << endl << endl; + s << "# endif // SBK_" << innerHeaderGuard << "_H\n\n"; // PYSIDE-500: Use also includes for inherited wrapper classes, because // without the protected hack, we sometimes need to cast inherited wrappers. @@ -202,7 +202,7 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte innerHeaderGuard = getFilteredCppSignatureString(wrapperName).toUpper(); } - s << "#endif // SBK_" << outerHeaderGuard << "_H" << endl << endl; + s << "#endif // SBK_" << outerHeaderGuard << "_H\n\n"; } void HeaderGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction *func) @@ -238,7 +238,7 @@ void HeaderGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction * args << argName; } s << args.join(QLatin1String(", ")) << ')'; - s << "; }" << endl; + s << "; }\n"; } // pure virtual functions need a default implementation @@ -263,7 +263,7 @@ void HeaderGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction * if (virtualFunc) s << " override"; - s << ';' << endl; + s << ";\n"; // Check if this method hide other methods in base classes const AbstractMetaFunctionList &ownerFuncs = func->ownerClass()->functions(); for (const AbstractMetaFunction *f : ownerFuncs) { @@ -412,12 +412,12 @@ bool HeaderGenerator::finishGeneration() getMaxTypeIndex() + smartPointerCount); macrosStream << "\n};\n"; - macrosStream << "// This variable stores all Python types exported by this module." << endl; - macrosStream << "extern PyTypeObject **" << cppApiVariableName() << ';' << endl << endl; - macrosStream << "// This variable stores the Python module object exported by this module." << endl; - macrosStream << "extern PyObject *" << pythonModuleObjectName() << ';' << endl << endl; - macrosStream << "// This variable stores all type converters exported by this module." << endl; - macrosStream << "extern SbkConverter **" << convertersVariableName() << ';' << endl << endl; + macrosStream << "// This variable stores all Python types exported by this module.\n"; + macrosStream << "extern PyTypeObject **" << cppApiVariableName() << ";\n\n"; + macrosStream << "// This variable stores the Python module object exported by this module.\n"; + macrosStream << "extern PyObject *" << pythonModuleObjectName() << ";\n\n"; + macrosStream << "// This variable stores all type converters exported by this module.\n"; + macrosStream << "extern SbkConverter **" << convertersVariableName() << ";\n\n"; // TODO-CONVERTER ------------------------------------------------------------------------------ // Using a counter would not do, a fix must be made to APIExtractor's getTypeIndex(). @@ -453,11 +453,11 @@ bool HeaderGenerator::finishGeneration() // TODO-CONVERTER ------------------------------------------------------------------------------ - macrosStream << "// Macros for type check" << endl; + macrosStream << "// Macros for type check\n"; if (usePySideExtensions()) { - typeFunctions << "QT_WARNING_PUSH" << endl; - typeFunctions << "QT_WARNING_DISABLE_DEPRECATED" << endl; + typeFunctions << "QT_WARNING_PUSH\n"; + typeFunctions << "QT_WARNING_DISABLE_DEPRECATED\n"; } for (const AbstractMetaEnum *cppEnum : qAsConst(globalEnums)) { if (cppEnum->isAnonymous() || cppEnum->isPrivate()) @@ -495,7 +495,7 @@ bool HeaderGenerator::finishGeneration() writeSbkTypeFunction(typeFunctions, metaType); } if (usePySideExtensions()) - typeFunctions << "QT_WARNING_POP" << endl; + typeFunctions << "QT_WARNING_POP\n"; QString moduleHeaderFileName(outputDirectory() + QDir::separator() + subDirectoryForPackage(packageName()) @@ -509,29 +509,29 @@ bool HeaderGenerator::finishGeneration() s << licenseComment() << endl << endl; s << "#ifndef " << includeShield << endl; - s << "#define " << includeShield << endl<< endl; + s << "#define " << includeShield << endl << endl; if (!avoidProtectedHack()) { - s << "//workaround to access protected functions" << endl; - s << "#define protected public" << endl << endl; + s << "//workaround to access protected functions\n"; + s << "#define protected public\n\n"; } - s << "#include " << endl; - s << "#include " << endl; + s << "#include \n"; + s << "#include \n"; QStringList requiredTargetImports = TypeDatabase::instance()->requiredTargetImports(); if (!requiredTargetImports.isEmpty()) { - s << "// Module Includes" << endl; + s << "// Module Includes\n"; for (const QString &requiredModule : qAsConst(requiredTargetImports)) - s << "#include <" << getModuleHeaderFileName(requiredModule) << ">" << endl; + s << "#include <" << getModuleHeaderFileName(requiredModule) << ">\n"; s << endl; } - s << "// Binded library includes" << endl; + s << "// Bound library includes\n"; for (const Include &include : qAsConst(includes)) s << include; if (!primitiveTypes().isEmpty()) { - s << "// Conversion Includes - Primitive Types" << endl; + s << "// Conversion Includes - Primitive Types\n"; const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *ptype : primitiveTypeList) s << ptype->include(); @@ -539,7 +539,7 @@ bool HeaderGenerator::finishGeneration() } if (!containerTypes().isEmpty()) { - s << "// Conversion Includes - Container Types" << endl; + s << "// Conversion Includes - Container Types\n"; const ContainerTypeEntryList &containerTypeList = containerTypes(); for (const ContainerTypeEntry *ctype : containerTypeList) s << ctype->include(); @@ -549,16 +549,16 @@ bool HeaderGenerator::finishGeneration() s << macros << endl; if (!protectedEnumSurrogates.isEmpty()) { - s << "// Protected enum surrogates" << endl; + s << "// Protected enum surrogates\n"; s << protectedEnumSurrogates << endl; } - s << "namespace Shiboken" << endl << '{' << endl << endl; + s << "namespace Shiboken\n{\n\n"; s << "// PyType functions, to get the PyObjectType for a type T\n"; s << sbkTypeFunctions << endl; - s << "} // namespace Shiboken" << endl << endl; + s << "} // namespace Shiboken\n\n"; s << "#endif // " << includeShield << endl << endl; @@ -568,7 +568,7 @@ bool HeaderGenerator::finishGeneration() void HeaderGenerator::writeProtectedEnumSurrogate(QTextStream &s, const AbstractMetaEnum *cppEnum) { if (avoidProtectedHack() && cppEnum->isProtected()) - s << "enum " << protectedEnumSurrogateName(cppEnum) << " {};" << endl; + s << "enum " << protectedEnumSurrogateName(cppEnum) << " {};\n"; } void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaEnum *cppEnum) @@ -625,6 +625,6 @@ void HeaderGenerator::writeInheritedOverloads(QTextStream &s) args << argName; } s << args.join(QLatin1String(", ")) << ')'; - s << "; }" << endl; + s << "; }\n"; } } -- cgit v1.2.3