diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-13 08:46:19 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-13 13:54:09 +0000 |
commit | 28199f5870b4c7d45f5db54444a6cf597cfdd700 (patch) | |
tree | 31128a3535667c800d582602404fc0bde9293515 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | |
parent | 07f58274a72cbdfcc2176fa68d0f78d96d2df121 (diff) |
shiboken: Improve handling of non-type template integer parameters
When trying to specify the base class
template<int R, int C> QGenericMatrix of the QMatrixRxN classes,
clashes of the SBK..IDX enumeration values occurred since
the integers were not part of the type name.
Fix that by dynamically adding dummy entries of
EnumValueTypeEntry for the integer values encountered on the fly.
Task-number: PYSIDE-725
Change-Id: Ie6b4489b5293e04b7c2c76861341c99b136cd558
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index c8ff41d91..979ac010e 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -2755,20 +2755,35 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass, for (const TypeInfo &i : qAsConst(targs)) { QString typeName = i.qualifiedName().join(colonColon()); - QStringList possibleNames; - possibleNames << subclass->qualifiedCppName() + colonColon() + typeName; - possibleNames << templateClass->qualifiedCppName() + colonColon() + typeName; - if (subclass->enclosingClass()) - possibleNames << subclass->enclosingClass()->qualifiedCppName() + colonColon() + typeName; - possibleNames << typeName; - - TypeDatabase* typeDb = TypeDatabase::instance(); - TypeEntry* t = 0; - QString templateParamName; - for (const QString &possibleName : qAsConst(possibleNames)) { - t = typeDb->findType(possibleName); - if (t) - break; + TypeDatabase *typeDb = TypeDatabase::instance(); + TypeEntry *t = nullptr; + // Check for a non-type template integer parameter, that is, for a base + // "template <int R, int C> Matrix<R, C>" and subclass + // "typedef Matrix<2,3> Matrix2x3;". If so, create dummy entries of + // EnumValueTypeEntry for the integer values encountered on the fly. + const bool isNumber = std::all_of(typeName.cbegin(), typeName.cend(), + [](QChar c) { return c.isDigit(); }); + if (isNumber) { + t = typeDb->findType(typeName); + if (!t) { + t = new EnumValueTypeEntry(typeName, typeName, nullptr, + QVersionNumber(0, 0)); + t->setCodeGeneration(0); + typeDb->addType(t); + } + } else { + QStringList possibleNames; + possibleNames << subclass->qualifiedCppName() + colonColon() + typeName; + possibleNames << templateClass->qualifiedCppName() + colonColon() + typeName; + if (subclass->enclosingClass()) + possibleNames << subclass->enclosingClass()->qualifiedCppName() + colonColon() + typeName; + possibleNames << typeName; + + for (const QString &possibleName : qAsConst(possibleNames)) { + t = typeDb->findType(possibleName); + if (t) + break; + } } if (t) { @@ -2781,7 +2796,7 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass, templateTypes << temporaryType; } else { qCWarning(lcShiboken).noquote().nospace() - << "Ignoring template parameter " << templateParamName << " from " + << "Ignoring template parameter " << typeName << " from " << info.toString() << ". The corresponding type was not found in the typesystem."; } } |