From 21ca107f47600d729431828f562c6baca5ad4fb0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 11 Mar 2016 15:35:55 +0100 Subject: Parse function pointer types the same way clang does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ƶ --- src/qdoc/cppcodeparser.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/qdoc/cppcodeparser.cpp') 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 { /* -- cgit v1.2.1