summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-18 16:10:13 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-23 15:44:28 +0200
commitb647762117f49a3e8d20ceba84c47d4fb2941722 (patch)
tree8c2d3570999aef7fabd7afddd4aabce6cac475a1
parentdd499bac5ce01abe730d47a84c7ad3e29bc3cf4d (diff)
downloadqt4-tools-b647762117f49a3e8d20ceba84c47d4fb2941722.tar.gz
do not record class forward declarations
they don't create useful namespaces and don't hold flags, so it is pointless to clutter the namespace maps with them.
-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 fce53af590..5dbb8e25e4 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();