summaryrefslogtreecommitdiffstats
path: root/tools/linguist/lupdate
diff options
context:
space:
mode:
Diffstat (limited to 'tools/linguist/lupdate')
-rw-r--r--tools/linguist/lupdate/cpp.cpp55
1 files changed, 27 insertions, 28 deletions
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index fce53af..5dbb8e2 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -1394,8 +1394,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
}
case Tok_friend:
yyTok = getToken();
- // Ensure that these don't end up being interpreted as forward declarations
- // (they are forwards, but with different namespacing).
+ // These are forward declarations, so ignore them.
if (yyTok == Tok_class)
yyTok = getToken();
break;
@@ -1406,7 +1405,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
*/
yyTok = getToken();
if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) {
- QStringList fct;
+ QStringList quali;
+ QString fct;
do {
/*
This code should execute only once, but we play
@@ -1414,52 +1414,51 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
'class Q_EXPORT QMessageBox', in which case
'QMessageBox' is the class name, not 'Q_EXPORT'.
*/
- text = yyWord;
- text.detach();
- fct = QStringList(text);
+ fct = yyWord;
+ fct.detach();
yyTok = getToken();
} while (yyTok == Tok_Ident);
while (yyTok == Tok_ColonColon) {
yyTok = getToken();
if (yyTok != Tok_Ident)
break; // Oops ...
- text = yyWord;
- text.detach();
- fct += text;
+ quali << fct;
+ fct = yyWord;
+ fct.detach();
yyTok = getToken();
}
- if (fct.count() > 1) {
- // Forward-declared class definitions can be namespaced
- NamespaceList nsl;
- if (!fullyQualify(namespaces, fct, true, &nsl, 0)) {
- qWarning("%s:%d: Ignoring definition of undeclared qualified class\n",
- qPrintable(yyFileName), yyLineNo);
- break;
- }
- namespaceDepths.push(namespaces.count());
- namespaces = nsl;
- } else {
- namespaceDepths.push(namespaces.count());
- enterNamespace(&namespaces, fct.first());
- }
- namespaces.last()->isClass = true;
-
while (yyTok == Tok_Comment)
yyTok = getToken();
if (yyTok == Tok_Colon) {
- // Skip any token until '{' since lupdate might do things wrong if it finds
+ // Skip any token until '{' since we might do things wrong if we find
// a '::' token here.
do {
yyTok = getToken();
} while (yyTok != Tok_LeftBrace && yyTok != Tok_Eof);
} else {
if (yyTok != Tok_LeftBrace) {
- // Obviously a forward decl
- truncateNamespaces(&namespaces, namespaceDepths.pop());
+ // Obviously a forward declaration. We skip those, as they
+ // don't create actually usable namespaces.
break;
}
}
+ if (!quali.isEmpty()) {
+ // Forward-declared class definitions can be namespaced.
+ NamespaceList nsl;
+ if (!fullyQualify(namespaces, quali, true, &nsl, 0)) {
+ qWarning("%s:%d: Ignoring definition of undeclared qualified class\n",
+ qPrintable(yyFileName), yyLineNo);
+ break;
+ }
+ namespaceDepths.push(namespaces.count());
+ namespaces = nsl;
+ } else {
+ namespaceDepths.push(namespaces.count());
+ }
+ enterNamespace(&namespaces, fct);
+ namespaces.last()->isClass = true;
+
functionContext = namespaces;
functionContextUnresolved.clear(); // Pointless
prospectiveContext.clear();