aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-09-10 12:48:06 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-11-25 23:55:11 +0200
commit1b63d41e5ed095ce7ff8a93935a917204dd4695c (patch)
tree351128ab73fc877b3cc4121c66e5a57f0a998f24 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parent6341e81149599e68bcd99b6b4f617fbe3b470e05 (diff)
shiboken: Refactor metatype comparison
Remove unused code left over from previous changes and add flags for matching value and const-ref as equivalent. Rename a few functions for improved clarity. Change-Id: Ifac1414e4977643b18d31dfc63a8e4a5f89a2ddc Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp45
1 files changed, 16 insertions, 29 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 0ecf2dce4..4566ed3bc 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1284,27 +1284,37 @@ void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(AbstractMetaF
metaFunction->replaceType(metaType);
}
-static bool _compareAbstractMetaTypes(const AbstractMetaType *type, const AbstractMetaType *other)
+static bool _compareAbstractMetaTypes(const AbstractMetaType *type,
+ const AbstractMetaType *other,
+ AbstractMetaType::ComparisonFlags flags = {})
{
return (type != nullptr) == (other != nullptr)
- && (type == nullptr || *type == *other);
+ && (type == nullptr || type->compare(*other, flags));
}
-static bool _compareAbstractMetaFunctions(const AbstractMetaFunction *func, const AbstractMetaFunction *other)
+static bool _compareAbstractMetaFunctions(const AbstractMetaFunction *func,
+ const AbstractMetaFunction *other,
+ AbstractMetaType::ComparisonFlags argumentFlags = {})
{
if (!func && !other)
return true;
if (!func || !other)
return false;
- if (func->arguments().count() != other->arguments().count()
+ if (func->name() != other->name())
+ return false;
+ const int argumentsCount = func->arguments().count();
+ if (argumentsCount != other->arguments().count()
|| func->isConstant() != other->isConstant()
|| func->isStatic() != other->isStatic()
|| !_compareAbstractMetaTypes(func->type(), other->type())) {
return false;
}
- for (int i = 0; i < func->arguments().count(); ++i) {
- if (!_compareAbstractMetaTypes(func->arguments().at(i)->type(), other->arguments().at(i)->type()))
+ for (int i = 0; i < argumentsCount; ++i) {
+ if (!_compareAbstractMetaTypes(func->arguments().at(i)->type(),
+ other->arguments().at(i)->type(),
+ argumentFlags)) {
return false;
+ }
}
return true;
}
@@ -1330,29 +1340,6 @@ AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const Sco
return result;
}
-// For template classes, entries with more specific types may exist from out-of-
-// line definitions. If there is a declaration which matches it after fixing
-// the parameters, remove it as duplicate. For example:
-// template class<T> Vector { public:
-// Vector(const Vector &rhs);
-// };
-// template class<T>
-// Vector<T>::Vector(const Vector<T>&) {} // More specific, remove declaration.
-
-class DuplicatingFunctionPredicate : public std::unary_function<bool, const AbstractMetaFunction *> {
-public:
- explicit DuplicatingFunctionPredicate(const AbstractMetaFunction *f) : m_function(f) {}
-
- bool operator()(const AbstractMetaFunction *rhs) const
- {
- return rhs != m_function && rhs->name() == m_function->name()
- && _compareAbstractMetaFunctions(m_function, rhs);
- }
-
-private:
- const AbstractMetaFunction *m_function;
-};
-
void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem,
AbstractMetaClass *metaClass)
{