summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodeparser.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2016-03-11 15:35:55 +0100
committerMartin Smith <martin.smith@qt.io>2017-08-10 07:32:05 +0000
commit21ca107f47600d729431828f562c6baca5ad4fb0 (patch)
tree97987b671f035b9bc3d14f90b5e1dc2001b3c909 /src/qdoc/cppcodeparser.cpp
parentb032aee53c8fb6807485186f276ca25b86ac1251 (diff)
downloadqttools-21ca107f47600d729431828f562c6baca5ad4fb0.tar.gz
Parse function pointer types the same way clang does
When an argument to a function is itself a function, use the same representation of its type that clang uses. - Omit spaces adjacent to parentheses - The argument name is not part of the argument type. This is required so types parsed with our parser lead to the same string as libclang gives us. The only function affected in QtCore is qRegisterAnimationInterpolator. Before: void qRegisterAnimationInterpolator(QVariant(* ) ( const T & from, const T & to, qreal progress ) func) After: void qRegisterAnimationInterpolator(QVariant (*)(const T &, const T &, qreal) func) Unfortunately, this means the documentation does not contain the parameter names in the function type. We will probably have to adapt the documentation of qRegisterAnimationInterpolator() to mention the meaning explicitly. Change-Id: I00ba1854869c061fb54c6a53e6eb02b934c20459 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r--src/qdoc/cppcodeparser.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 7ec6ed805..3c21c8b1b 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -1154,22 +1154,29 @@ bool CppCodeParser::matchDataType(CodeChunk *dataType, QString *var, bool qProp)
in some cases (e.g., 'operator int()'). The tokenizer recognizes '(*'
as a single token.
*/
+ dataType->append(" "); // force a space after the type
dataType->append(previousLexeme());
dataType->appendHotspot();
if (var != 0 && match(Tok_Ident))
*var = previousLexeme();
- if (!match(Tok_RightParen) || tok != Tok_LeftParen) {
+ if (!match(Tok_RightParen))
+ return false;
+ dataType->append(previousLexeme());
+ if (!match(Tok_LeftParen))
return false;
- }
dataType->append(previousLexeme());
- int parenDepth0 = tokenizer->parenDepth();
- while (tokenizer->parenDepth() >= parenDepth0 && tok != Tok_Eoi) {
- dataType->append(lexeme());
- readToken();
+ /* parse the parameters. Ignore the parameter name from the type */
+ while (tok != Tok_RightParen && tok != Tok_Eoi) {
+ QString dummy;
+ if (!matchDataType(dataType, &dummy))
+ return false;
+ if (match(Tok_Comma))
+ dataType->append(previousLexeme());
}
- if (match(Tok_RightParen))
- dataType->append(previousLexeme());
+ if (!match(Tok_RightParen))
+ return false;
+ dataType->append(previousLexeme());
}
else {
/*