summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-01 12:46:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-01 18:32:52 +0000
commit4e468d77de10c7bd6e76b59a37cecb5151a80626 (patch)
treea09b020224a933a5ef88bbadc991af9a2ad0afba
parentee8e7117c79f6820cb228e0f0da522ce7d3c1dce (diff)
shiboken/ClangBuilder: Fix nested qualified names
The qualified name was obtained by splitting by "::", which would result in "std::list<std::string>" -> ("std", "list<std", string>"). Fix by splitting up to first '<' or '(' only. Task-number: PYSIDE-672 Change-Id: I9d790535e877da251a5b6c352dc550e4077877bd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
index a6b6f2af..5192e9e7 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::string>" -> ("std", "list<std::string>")
+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;
}