From 4e468d77de10c7bd6e76b59a37cecb5151a80626 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Jun 2018 12:46:07 +0200 Subject: shiboken/ClangBuilder: Fix nested qualified names The qualified name was obtained by splitting by "::", which would result in "std::list" -> ("std", "list"). Fix by splitting up to first '<' or '(' only. Task-number: PYSIDE-672 Change-Id: I9d790535e877da251a5b6c352dc550e4077877bd Reviewed-by: Alexandru Croitor --- .../ApiExtractor/clangparser/clangbuilder.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index a6b6f2af3..5192e9e76 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -379,6 +379,27 @@ static QStringList parseArrayArgs(const CXType &type, QString *typeName) return result; } +// Create qualified name "std::list" -> ("std", "list") +static QStringList qualifiedName(const QString &t) +{ + QStringList result; + int end = t.indexOf(QLatin1Char('<')); + if (end == -1) + end = t.indexOf(QLatin1Char('(')); + if (end == -1) + end = t.size(); + int lastPos = 0; + while (true) { + const int nextPos = t.indexOf(colonColon(), lastPos); + if (nextPos < 0 || nextPos >= end) + break; + result.append(t.mid(lastPos, nextPos - lastPos)); + lastPos = nextPos + 2; + } + result.append(t.right(t.size() - lastPos)); + return result; +} + TypeInfo BuilderPrivate::createTypeInfo(const CXType &type) const { if (type.kind == CXType_Pointer) { // Check for function pointers, first. @@ -439,7 +460,7 @@ TypeInfo BuilderPrivate::createTypeInfo(const CXType &type) const typeName = typeName.trimmed(); - typeInfo.setQualifiedName(typeName.split(colonColon())); + typeInfo.setQualifiedName(qualifiedName(typeName)); // 3320:CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); function ptr types? return typeInfo; } -- cgit v1.2.3