diff options
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/generator.cpp | 20 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 29 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.h | 1 |
3 files changed, 32 insertions, 18 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ccc6d795d7..fc1bafc7a7 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -515,7 +515,7 @@ void Generator::generateCode() for (int i = 0; i < extraList.count(); ++i) { fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); } - fprintf(out, " Q_NULLPTR\n};\n\n"); + fprintf(out, " nullptr\n};\n\n"); } // @@ -527,24 +527,24 @@ void Generator::generateCode() fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData()); if (isQObject) - fprintf(out, " { Q_NULLPTR, "); + fprintf(out, " { nullptr, "); else if (cdef->superclassList.size() && (!cdef->hasQGadget || knownGadgets.contains(purestSuperClass))) fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); else - fprintf(out, " { Q_NULLPTR, "); + fprintf(out, " { nullptr, "); fprintf(out, "qt_meta_stringdata_%s.data,\n" " qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (hasStaticMetaCall) fprintf(out, " qt_static_metacall, "); else - fprintf(out, " Q_NULLPTR, "); + fprintf(out, " nullptr, "); if (extraList.isEmpty()) - fprintf(out, "Q_NULLPTR, "); + fprintf(out, "nullptr, "); else fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); - fprintf(out, "Q_NULLPTR}\n};\n\n"); + fprintf(out, "nullptr}\n};\n\n"); if(isQt) return; @@ -559,7 +559,7 @@ void Generator::generateCode() // Generate smart cast function // fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData()); - fprintf(out, " if (!_clname) return Q_NULLPTR;\n"); + fprintf(out, " if (!_clname) return nullptr;\n"); fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata0))\n" " return static_cast<void*>(const_cast< %s*>(this));\n", qualifiedClassNameIdentifier.constData(), cdef->classname.constData()); @@ -584,7 +584,7 @@ void Generator::generateCode() QByteArray superClass = purestSuperClass; fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData()); } else { - fprintf(out, " return Q_NULLPTR;\n"); + fprintf(out, " return nullptr;\n"); } fprintf(out, "}\n"); @@ -1481,7 +1481,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, "QPrivateSignal"); fprintf(out, ")%s\n{\n" - " QMetaObject::activate(%s, &staticMetaObject, %d, Q_NULLPTR);\n" + " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n" "}\n", constQualifier, thisPtr.constData(), index); return; } @@ -1511,7 +1511,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, " void *_a[] = { "); if (def->normalizedType == "void") { - fprintf(out, "Q_NULLPTR"); + fprintf(out, "nullptr"); } else { if (def->returnTypeIsVolatile) fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))"); diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 11bf8d7937..f5639ffe31 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -1005,22 +1005,20 @@ static void mergeStringLiterals(Symbols *_symbols) } } -QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepaths, + const QByteArray &include) { - // #### stringery QFileInfo fi; - if (!relativeTo.isEmpty()) - fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo.constData())).dir(), QString::fromLocal8Bit(include.constData())); - for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) { - const IncludePath &p = Preprocessor::includes.at(j); + for (int j = 0; j < includepaths.size() && !fi.exists(); ++j) { + const Parser::IncludePath &p = includepaths.at(j); if (p.isFrameworkPath) { const int slashPos = include.indexOf('/'); if (slashPos == -1) continue; fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"), - QString::fromLocal8Bit(include.mid(slashPos + 1).constData())); + QString::fromLocal8Bit(include.mid(slashPos + 1))); } else { - fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData())); + fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include)); } // try again, maybe there's a file later in the include paths with the same name // (186067) @@ -1035,6 +1033,21 @@ QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteAr return fi.canonicalFilePath().toLocal8Bit(); } +QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +{ + if (!relativeTo.isEmpty()) { + QFileInfo fi; + fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo)).dir(), QString::fromLocal8Bit(include)); + if (fi.exists() && !fi.isDir()) + return fi.canonicalFilePath().toLocal8Bit(); + } + + auto it = nonlocalIncludePathResolutionCache.find(include); + if (it == nonlocalIncludePathResolutionCache.end()) + it = nonlocalIncludePathResolutionCache.insert(include, searchIncludePaths(includes, include)); + return it.value(); +} + void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) { currentFilenames.push(filename); diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index a7eb1a19e1..39f56d6e92 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -61,6 +61,7 @@ public: static bool preprocessOnly; QList<QByteArray> frameworks; QSet<QByteArray> preprocessedIncludes; + QHash<QByteArray, QByteArray> nonlocalIncludePathResolutionCache; Macros macros; QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo); Symbols preprocessed(const QByteArray &filename, QFile *device); |