aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-29 09:35:14 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-30 06:58:33 +0000
commit71592420892dd8f4bb4602bb307de3fc6f95cf72 (patch)
tree1b179e979bca2eb2d9f08d053840c690173c3529 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parent73fd61d556735c9781847620c511bb43ccae9a95 (diff)
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<T> &)" 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 <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp80
1 files changed, 2 insertions, 78 deletions
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<T> &)".
-static bool _fixFunctionModelItemTypes(FunctionModelItem& function, const AbstractMetaClass* metaClass)
-{
- const QVector<TypeEntry *> &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;