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) <ogoffart@woboq.com>
This commit is contained in:
parent
23ef3b04eb
commit
21b7661a79
@ -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;
|
||||
|
||||
|
@ -560,7 +560,8 @@ void Moc::parse()
|
||||
until(RBRACE);
|
||||
def.end = index;
|
||||
index = def.begin + 1;
|
||||
while (inNamespace(&def) && hasNext()) {
|
||||
const bool parseNamespace = currentFilenames.size() <= 1;
|
||||
while (parseNamespace && inNamespace(&def) && hasNext()) {
|
||||
switch (next()) {
|
||||
case Q_NAMESPACE_TOKEN:
|
||||
def.hasQNamespace = true;
|
||||
|
@ -28,7 +28,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
|
||||
qtbug-35657-gadget.h \
|
||||
non-gadget-parent-class.h grand-parent-gadget-class.h \
|
||||
related-metaobjects-in-gadget.h \
|
||||
related-metaobjects-name-conflict.h
|
||||
related-metaobjects-name-conflict.h \
|
||||
namespace.h
|
||||
|
||||
|
||||
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
|
||||
|
7
tests/auto/tools/moc/namespace.h
Normal file
7
tests/auto/tools/moc/namespace.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace FooNamespace {
|
||||
Q_NAMESPACE
|
||||
}
|
@ -69,6 +69,7 @@
|
||||
|
||||
#include "non-gadget-parent-class.h"
|
||||
#include "grand-parent-gadget-class.h"
|
||||
#include "namespace.h"
|
||||
|
||||
#ifdef Q_MOC_RUN
|
||||
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
|
||||
|
Loading…
x
Reference in New Issue
Block a user