From 71592420892dd8f4bb4602bb307de3fc6f95cf72 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 Jun 2018 09:35:14 +0200 Subject: shiboken: Remove code fixing template arguments Pre-dating the Clang-parser, there is code that tries to fix template parameter in template class declarations, for example copy constructors like: "QList(const QList &)" -> "QList(const QList &)" The code no longer triggers since Clang always provides the parameters, so, remove it. Task-number: PYSIDE-672 Change-Id: I15949d71fa4391e7088fe0e29a1821487ced2105 Reviewed-by: Christian Tismer --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 80 +--------------------- 1 file changed, 2 insertions(+), 78 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp') diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 493e37754..c879727c3 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -1356,45 +1356,6 @@ static bool _compareAbstractMetaFunctions(const AbstractMetaFunction* func, cons return true; } -// Fix the arguments of template classes that take the class itself, for example: -// "QList(const QList &)" to "QList(const QList &)". -static bool _fixFunctionModelItemTypes(FunctionModelItem& function, const AbstractMetaClass* metaClass) -{ - const QVector &templateTypes = metaClass->templateArguments(); - if (templateTypes.isEmpty()) - return false; - - const QStringList classType = metaClass->typeEntry()->qualifiedCppName().split(colonColon()); - QStringList fixedClassType = classType; - fixedClassType.last().append(QLatin1Char('<')); - for (int i = 0, count = templateTypes.size(); i < count; ++i) { - if (i) - fixedClassType.last().append(QLatin1String(", ")); - fixedClassType.last().append(templateTypes.at(i)->qualifiedCppName()); - } - fixedClassType.last().append(QLatin1String(" >")); - - bool templateTypeFixed = false; - TypeInfo functionType = function->type(); - if (functionType.qualifiedName() == classType) { - templateTypeFixed = true; - functionType.setQualifiedName(fixedClassType); - function->setType(functionType); - } - - ArgumentList arguments = function->arguments(); - for (int i = 0; i < arguments.size(); ++i) { - ArgumentModelItem arg = arguments.at(i); - TypeInfo type = arg->type(); - if (type.qualifiedName() == classType) { - type.setQualifiedName(fixedClassType); - arg->setType(type); - templateTypeFixed = true; - } - } - return templateTypeFixed; -} - AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const ScopeModelItem &scopeItem, bool *constructorRejected) { @@ -1434,49 +1395,12 @@ private: const AbstractMetaFunction *m_function; }; -AbstractMetaFunctionList AbstractMetaBuilderPrivate::templateClassFunctionList(const ScopeModelItem &scopeItem, - AbstractMetaClass *metaClass, - bool *constructorRejected) -{ - AbstractMetaFunctionList result; - AbstractMetaFunctionList unchangedFunctions; - - *constructorRejected = false; - const FunctionList &scopeFunctionList = scopeItem->functions(); - result.reserve(scopeFunctionList.size()); - unchangedFunctions.reserve(scopeFunctionList.size()); - for (FunctionModelItem function : scopeFunctionList) { - // This fixes method's arguments and return types that are templates - // but the template variable wasn't declared in the C++ header. - const bool templateTypeFixed =_fixFunctionModelItemTypes(function, metaClass); - if (AbstractMetaFunction *metaFunction = traverseFunction(function)) { - result.append(metaFunction); - if (!templateTypeFixed) - unchangedFunctions.append(metaFunction); - } else if (function->functionType() == CodeModel::Constructor) { - *constructorRejected = true; - } - } - - const AbstractMetaFunctionList::ConstIterator unchangedBegin = unchangedFunctions.cbegin(); - const AbstractMetaFunctionList::ConstIterator unchangedEnd = unchangedFunctions.cend(); - for (int i = result.size() - 1; i >= 0; --i) { - AbstractMetaFunction *function = result.at(i); - if (!unchangedFunctions.contains(function) - && unchangedEnd != std::find_if(unchangedBegin, unchangedEnd, DuplicatingFunctionPredicate(function))) { - delete result.takeAt(i); - } - } - return result; -} - void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, AbstractMetaClass *metaClass) { bool constructorRejected = false; - const AbstractMetaFunctionList functions = metaClass->templateArguments().isEmpty() - ? classFunctionList(scopeItem, &constructorRejected) - : templateClassFunctionList(scopeItem, metaClass, &constructorRejected); + const AbstractMetaFunctionList functions = + classFunctionList(scopeItem, &constructorRejected); if (constructorRejected) *metaClass += AbstractMetaAttributes::HasRejectedConstructor; -- cgit v1.2.3