diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-03-08 11:52:37 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-03-08 17:34:38 +0000 |
commit | 5675334b6e22786195fe69a1fc1f40c49aaea37c (patch) | |
tree | 9e9d493d05d894255fe32e7d825e6a769395a7af /src | |
parent | 11d60dcad62b53d20f12c6f548eea3df412a43cc (diff) |
moc: Add support for C++17 nested namespaces (N4230)
[ChangeLog][moc] Added Support for C++17 nested namespaces
Change-Id: Ib83fc5bf48f66546fa97b49710582fbf9c984503
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/moc/moc.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index e2987f1be4..36d84a61d8 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -549,12 +549,20 @@ void Moc::parse() case NAMESPACE: { int rewind = index; if (test(IDENTIFIER)) { + QByteArray nsName = lexem(); + QByteArrayList nested; + while (test(SCOPE)) { + next(IDENTIFIER); + nested.append(nsName); + nsName = lexem(); + } if (test(EQ)) { // namespace Foo = Bar::Baz; until(SEMIC); } else if (!test(SEMIC)) { NamespaceDef def; - def.classname = lexem(); + def.classname = nsName; + next(LBRACE); def.begin = index - 1; until(RBRACE); @@ -568,11 +576,23 @@ void Moc::parse() def.qualified.prepend(namespaceList.at(i).classname + "::"); } } + for (const QByteArray &ns : nested) { + NamespaceDef parentNs; + parentNs.classname = ns; + parentNs.qualified = def.qualified; + def.qualified += ns + "::"; + parentNs.begin = def.begin; + parentNs.end = def.end; + namespaceList += parentNs; + } } + while (parseNamespace && inNamespace(&def) && hasNext()) { switch (next()) { case NAMESPACE: if (test(IDENTIFIER)) { + while (test(SCOPE)) + next(IDENTIFIER); if (test(EQ)) { // namespace Foo = Bar::Baz; until(SEMIC); |