diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-05 12:54:25 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-11 19:01:58 +0000 |
| commit | 612bfd01e1e7698cb3a06d619cc7d7c7acd3d273 (patch) | |
| tree | dd9aa2aacd81e9045ba6708a4117e503cf3f9bca /sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp | |
| parent | f2443b02fce5dd4182e80ed0e5343586cbd72a31 (diff) | |
shiboken: Move detection of template arguments to ClangBuilder
Obtain the template arguments from Clang and fall back to parsing
the type name where this is not possible (which may be the case
inside a template declaration).
The string-based formatting and re-parsing of the type in
AbstractMetaBuilder::translateType() can then be removed, opening
the way to passing up more complex types from Clang into the
MetaBuilder.
Task-number: PYSIDE-672
Change-Id: I43ff285c5f3720319bf40c65b1c27302ef1b934e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp')
| -rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp index 2ff18b23b..a68c5b5ee 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp @@ -160,6 +160,43 @@ QVector<Diagnostic> getDiagnostics(CXTranslationUnit tu) return result; } +QPair<int, int> parseTemplateArgumentList(const QString &l, + const TemplateArgumentHandler &handler, + int from) +{ + const int ltPos = l.indexOf(QLatin1Char('<'), from); + if (ltPos == - 1) + return qMakePair(-1, -1); + int startPos = ltPos + 1; + int level = 1; + for (int p = startPos, end = l.size(); p < end; ) { + const char c = l.at(p).toLatin1(); + switch (c) { + case ',': + case '>': + handler(level, l.midRef(startPos, p - startPos).trimmed()); + ++p; + if (c == '>') { + if (--level == 0) + return qMakePair(ltPos, p); + // Skip over next ',': "a<b<c,d>,e>" + for (; p < end && (l.at(p).isSpace() || l.at(p) == QLatin1Char(',')); ++p) {} + } + startPos = p; + break; + case '<': + handler(level, l.midRef(startPos, p - startPos).trimmed()); + ++level; + startPos = ++p; + break; + default: + ++p; + break; + } + } + return qMakePair(-1, -1); +} + CXDiagnosticSeverity maxSeverity(const QVector<Diagnostic> &ds) { CXDiagnosticSeverity result = CXDiagnostic_Ignored; |
