From 21b7661a797ecf77fbcad4380e6dcb2ade929a18 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 23 Aug 2016 22:32:11 +0300 Subject: Parse namespaces only for current file, add Q_NAMESPACE support to qmake Parsing the other files will (re)generate the same metaobject info in two places Change-Id: I8984ed30751a7587de870f55dd427f067d1b2495 Reviewed-by: Olivier Goffart (Woboq GmbH) --- qmake/generators/makefiledeps.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 57cb0ea854..67c8219d4b 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -911,9 +911,10 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) debug_msg(2, "findMocs: %s", file->file.local().toLatin1().constData()); int line_count = 1; - bool ignore[2] = { false, false }; // [0] for Q_OBJECT, [1] for Q_GADGET + bool ignore[3] = { false, false, false }; // [0] for Q_OBJECT, [1] for Q_GADGET, [2] for Q_NAMESPACE /* qmake ignore Q_GADGET */ /* qmake ignore Q_OBJECT */ + /* qmake ignore Q_NAMESPACE */ for(int x = 0; x < buffer_len; x++) { #define SKIP_BSNL(pos) skipEscapedLineEnds(buffer, buffer_len, (pos), &line_count) x = SKIP_BSNL(x); @@ -946,6 +947,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) file->file.real().toLatin1().constData(), line_count); x += 20; ignore[1] = true; + } else if (buffer_len >= (x + 23) && + !strncmp(buffer + x + 1, "make ignore Q_NAMESPACE", 23)) { + debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_NAMESPACE\"", + file->file.real().toLatin1().constData(), line_count); + x += 23; + ignore[2] = true; } } else if (buffer[x] == '*') { extralines = 0; @@ -973,8 +980,8 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) int morelines = 0; int y = skipEscapedLineEnds(buffer, buffer_len, x + 1, &morelines); if (buffer[y] == 'Q') { - static const char interesting[][9] = { "Q_OBJECT", "Q_GADGET" }; - for (int interest = 0; interest < 2; ++interest) { + static const char interesting[][12] = { "Q_OBJECT", "Q_GADGET", "Q_NAMESPACE"}; + for (int interest = 0; interest < 3; ++interest) { if (ignore[interest]) continue; -- cgit v1.2.3