aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/CMakeLists.txt1
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetaargument.cpp192
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetaargument.h90
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp115
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp89
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h73
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h2
-rw-r--r--sources/shiboken2/ApiExtractor/doxygenparser.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/qtdocparser.cpp4
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp10
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp28
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp24
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testenum.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp4
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp2
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp2
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtemplates.cpp12
20 files changed, 435 insertions, 257 deletions
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt
index 062ccf808..e1b1f64e4 100644
--- a/sources/shiboken2/ApiExtractor/CMakeLists.txt
+++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt
@@ -7,6 +7,7 @@ set(CMAKE_AUTOMOC ON)
set(apiextractor_SRC
apiextractor.cpp
+abstractmetaargument.cpp
abstractmetabuilder.cpp
abstractmetatype.cpp
abstractmetalang.cpp
diff --git a/sources/shiboken2/ApiExtractor/abstractmetaargument.cpp b/sources/shiboken2/ApiExtractor/abstractmetaargument.cpp
new file mode 100644
index 000000000..366fc00a1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetaargument.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstractmetaargument.h"
+#include "documentation.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QSharedData>
+
+class AbstractMetaArgumentData : public QSharedData
+{
+public:
+ QString toString() const;
+
+ QString m_name;
+ AbstractMetaType m_type;
+ bool m_hasName = false;
+ Documentation m_doc;
+ QString m_expression;
+ QString m_originalExpression;
+ int m_argumentIndex = 0;
+};
+
+AbstractMetaArgument::AbstractMetaArgument() : d(new AbstractMetaArgumentData)
+{
+}
+
+AbstractMetaArgument::~AbstractMetaArgument() = default;
+
+AbstractMetaArgument::AbstractMetaArgument(const AbstractMetaArgument &) = default;
+
+AbstractMetaArgument &AbstractMetaArgument::operator=(const AbstractMetaArgument &) = default;
+
+AbstractMetaArgument::AbstractMetaArgument(AbstractMetaArgument &&) = default;
+
+AbstractMetaArgument &AbstractMetaArgument::operator=(AbstractMetaArgument &&) = default;
+
+const AbstractMetaType &AbstractMetaArgument::type() const
+{
+ return d->m_type;
+}
+
+void AbstractMetaArgument::setType(const AbstractMetaType &type)
+{
+ if (d->m_type != type)
+ d->m_type = type;
+}
+
+QString AbstractMetaArgument::name() const
+{
+ return d->m_name;
+}
+
+void AbstractMetaArgument::setName(const QString &name, bool realName)
+{
+ if (d->m_name != name || d->m_hasName != realName) {
+ d->m_name = name;
+ d->m_hasName = realName;
+ }
+}
+
+bool AbstractMetaArgument::hasName() const
+{
+ return d->m_hasName;
+}
+
+void AbstractMetaArgument::setDocumentation(const Documentation &doc)
+{
+ if (d->m_doc != doc)
+ d->m_doc = doc;
+}
+
+Documentation AbstractMetaArgument::documentation() const
+{
+ return d->m_doc;
+}
+
+QString AbstractMetaArgument::defaultValueExpression() const
+{
+ return d->m_expression;
+}
+
+void AbstractMetaArgument::setDefaultValueExpression(const QString &expr)
+{
+ if (d->m_expression != expr)
+ d->m_expression = expr;
+}
+
+QString AbstractMetaArgument::originalDefaultValueExpression() const
+{
+ return d->m_originalExpression;
+}
+
+void AbstractMetaArgument::setOriginalDefaultValueExpression(const QString &expr)
+{
+ if (d->m_originalExpression != expr)
+ d->m_originalExpression = expr;
+}
+
+bool AbstractMetaArgument::hasOriginalDefaultValueExpression() const
+{
+ return !d->m_originalExpression.isEmpty();
+}
+
+bool AbstractMetaArgument::hasDefaultValueExpression() const
+{
+ return !d->m_expression.isEmpty();
+}
+
+bool AbstractMetaArgument::hasUnmodifiedDefaultValueExpression() const
+{
+ return !d->m_originalExpression.isEmpty() && d->m_originalExpression == d->m_expression;
+}
+
+bool AbstractMetaArgument::hasModifiedDefaultValueExpression() const
+{
+ return !d->m_expression.isEmpty() && d->m_originalExpression != d->m_expression;
+}
+
+QString AbstractMetaArgumentData::toString() const
+{
+ QString result = m_type.name() + QLatin1Char(' ') + m_name;
+ if (!m_expression.isEmpty())
+ result += QLatin1String(" = ") + m_expression;
+ return result;
+}
+
+QString AbstractMetaArgument::toString() const
+{
+ return d->toString();
+}
+
+int AbstractMetaArgument::argumentIndex() const
+{
+ return d->m_argumentIndex;
+}
+
+void AbstractMetaArgument::setArgumentIndex(int argIndex)
+{
+ if (d->m_argumentIndex != argIndex)
+ d->m_argumentIndex = argIndex;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaArgument &aa)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaArgument(" << aa.toString() << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaArgument *aa)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaArgument(";
+ if (aa)
+ d << aa->toString();
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/abstractmetaargument.h b/sources/shiboken2/ApiExtractor/abstractmetaargument.h
new file mode 100644
index 000000000..b5fe22db7
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetaargument.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTMETAARGUMENT_H
+#define ABSTRACTMETAARGUMENT_H
+
+#include "abstractmetalang_typedefs.h"
+#include "abstractmetatype.h"
+#include "typesystem_enums.h"
+#include "typesystem_typedefs.h"
+
+#include <QtCore/QSharedDataPointer>
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+class AbstractMetaArgumentData;
+class Documentation;
+
+class AbstractMetaArgument
+{
+public:
+ AbstractMetaArgument();
+ ~AbstractMetaArgument();
+ AbstractMetaArgument(const AbstractMetaArgument &);
+ AbstractMetaArgument &operator=(const AbstractMetaArgument &);
+ AbstractMetaArgument(AbstractMetaArgument &&);
+ AbstractMetaArgument &operator=(AbstractMetaArgument &&);
+
+
+ const AbstractMetaType &type() const;
+ void setType(const AbstractMetaType &type);
+
+ QString name() const;
+ void setName(const QString &name, bool realName = true);
+ bool hasName() const;
+
+ void setDocumentation(const Documentation& doc);
+ Documentation documentation() const;
+
+ QString defaultValueExpression() const;
+ void setDefaultValueExpression(const QString &expr);
+
+ QString originalDefaultValueExpression() const;
+ void setOriginalDefaultValueExpression(const QString &expr);
+
+ bool hasDefaultValueExpression() const;
+ bool hasOriginalDefaultValueExpression() const;
+ bool hasUnmodifiedDefaultValueExpression() const;
+ bool hasModifiedDefaultValueExpression() const;
+
+ QString toString() const;
+
+ int argumentIndex() const;
+ void setArgumentIndex(int argIndex);
+
+private:
+ QSharedDataPointer<AbstractMetaArgumentData> d;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaArgument &aa);
+QDebug operator<<(QDebug d, const AbstractMetaArgument *aa);
+#endif
+
+#endif // ABSTRACTMETAARGUMENT_H
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index b176191c1..dd3e3fac0 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -311,10 +311,9 @@ void AbstractMetaBuilderPrivate::traverseOperatorFunction(const FunctionModelIte
// Strip away first argument, since that is the containing object
AbstractMetaArgumentList arguments = metaFunction->arguments();
if (firstArgumentIsSelf || unaryOperator) {
- AbstractMetaArgument *first = arguments.takeFirst();
- if (!unaryOperator && first->type().indirections())
+ AbstractMetaArgument first = arguments.takeFirst();
+ if (!unaryOperator && first.type().indirections())
metaFunction->setPointerOperator(true);
- delete first;
metaFunction->setArguments(arguments);
} else {
// If the operator method is not unary and the first operator is
@@ -322,10 +321,9 @@ void AbstractMetaBuilderPrivate::traverseOperatorFunction(const FunctionModelIte
// must be an reverse operator (e.g. CLASS::operator(TYPE, CLASS)).
// All operator overloads that operate over a class are already
// being added as member functions of that class by the API Extractor.
- AbstractMetaArgument *last = arguments.takeLast();
- if (last->type().indirections())
+ AbstractMetaArgument last = arguments.takeLast();
+ if (last.type().indirections())
metaFunction->setPointerOperator(true);
- delete last;
metaFunction->setArguments(arguments);
metaFunction->setReverseOperator(true);
@@ -358,9 +356,9 @@ void AbstractMetaBuilderPrivate::traverseStreamOperator(const FunctionModelItem
// Strip first argument, since that is the containing object
AbstractMetaArgumentList arguments = streamFunction->arguments();
if (!streamClass->typeEntry()->generateCode())
- delete arguments.takeLast();
+ arguments.takeLast();
else
- delete arguments.takeFirst();
+ arguments.takeFirst();
streamFunction->setArguments(arguments);
@@ -1328,7 +1326,7 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem,
// Make sure the function was created with all arguments; some argument can be
// missing during the parsing because of errors in the typesystem.
if (metaFunction->isVoid() && metaFunction->arguments().size() == 1
- && (write->typeEntry() == metaFunction->arguments().at(0)->type().typeEntry())) {
+ && (write->typeEntry() == metaFunction->arguments().at(0).type().typeEntry())) {
*metaFunction += AbstractMetaAttributes::PropertyWriter;
metaFunction->setPropertySpec(write);
}
@@ -1547,11 +1545,9 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
metaFunction->setType(returnType);
const auto &args = addedFunc->arguments();
- AbstractMetaArgumentList metaArguments;
for (int i = 0; i < args.count(); ++i) {
const AddedFunction::TypeInfo& typeInfo = args.at(i).typeInfo;
- auto *metaArg = new AbstractMetaArgument;
AbstractMetaType type = translateType(typeInfo, &errorMessage);
if (Q_UNLIKELY(!type)) {
qCWarning(lcShiboken, "%s",
@@ -1562,22 +1558,25 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
return nullptr;
}
type.decideUsagePattern();
+
+ AbstractMetaArgument metaArg;
if (!args.at(i).name.isEmpty())
- metaArg->setName(args.at(i).name);
- metaArg->setType(type);
- metaArg->setArgumentIndex(i);
- metaArg->setDefaultValueExpression(typeInfo.defaultValue);
- metaArg->setOriginalDefaultValueExpression(typeInfo.defaultValue);
- metaArguments.append(metaArg);
+ metaArg.setName(args.at(i).name);
+ metaArg.setType(type);
+ metaArg.setArgumentIndex(i);
+ metaArg.setDefaultValueExpression(typeInfo.defaultValue);
+ metaArg.setOriginalDefaultValueExpression(typeInfo.defaultValue);
+ metaFunction->addArgument(metaArg);
}
- metaFunction->setArguments(metaArguments);
+ AbstractMetaArgumentList &metaArguments = metaFunction->arguments();
+
if (metaFunction->isOperatorOverload() && !metaFunction->isCallOperator()) {
if (metaArguments.size() > 2) {
qCWarning(lcShiboken) << "An operator overload need to have 0, 1 or 2 arguments if it's reverse.";
} else if (metaArguments.size() == 2) {
// Check if it's a reverse operator
- if (metaArguments[1]->type().typeEntry() == metaClass->typeEntry()) {
+ if (metaArguments[1].type().typeEntry() == metaClass->typeEntry()) {
metaFunction->setReverseOperator(true);
// we need to call these two function to cache the old signature (with two args)
// we do this buggy behaviour to comply with the original apiextractor buggy behaviour.
@@ -1595,11 +1594,11 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
// Find the correct default values
const FunctionModificationList functionMods = metaFunction->modifications(metaClass);
for (int i = 0; i < metaArguments.size(); ++i) {
- AbstractMetaArgument* metaArg = metaArguments.at(i);
+ AbstractMetaArgument &metaArg = metaArguments[i];
// use replace-default-expression for set default value
- applyDefaultExpressionModifications(functionMods, i, metaArg);
- metaArg->setOriginalDefaultValueExpression(metaArg->defaultValueExpression()); // appear unmodified
+ applyDefaultExpressionModifications(functionMods, i, &metaArg);
+ metaArg.setOriginalDefaultValueExpression(metaArg.defaultValueExpression()); // appear unmodified
}
metaFunction->setOriginalAttributes(metaFunction->attributes());
@@ -1613,7 +1612,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
if (metaFunction->name() == metaClass->name()) {
metaFunction->setFunctionType(AbstractMetaFunction::ConstructorFunction);
if (fargs.size() == 1) {
- const TypeEntry *te = fargs.constFirst()->type().typeEntry();
+ const TypeEntry *te = fargs.constFirst().type().typeEntry();
if (te->isCustom())
metaFunction->setExplicit(true);
if (te->name() == metaFunction->name())
@@ -1639,20 +1638,18 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
void AbstractMetaBuilderPrivate::fixArgumentNames(AbstractMetaFunction *func, const FunctionModificationList &mods)
{
+ AbstractMetaArgumentList &arguments = func->arguments();
+
for (const FunctionModification &mod : mods) {
for (const ArgumentModification &argMod : mod.argument_mods) {
- if (!argMod.renamed_to.isEmpty()) {
- AbstractMetaArgument* arg = func->arguments().at(argMod.index - 1);
- arg->setOriginalName(arg->name());
- arg->setName(argMod.renamed_to, false);
- }
+ if (!argMod.renamed_to.isEmpty())
+ arguments[argMod.index - 1].setName(argMod.renamed_to, false);
}
}
- AbstractMetaArgumentList arguments = func->arguments();
for (int i = 0, size = arguments.size(); i < size; ++i) {
- if (arguments.at(i)->name().isEmpty())
- arguments[i]->setName(QLatin1String("arg__") + QString::number(i + 1), false);
+ if (arguments.at(i).name().isEmpty())
+ arguments[i].setName(QLatin1String("arg__") + QString::number(i + 1), false);
}
}
@@ -1716,12 +1713,12 @@ static bool applyArrayArgumentModifications(const FunctionModificationList &func
QLatin1String("Index out of range."));
return false;
}
- auto t = func->arguments().at(i)->type();
+ auto t = func->arguments().at(i).type();
if (!t.applyArrayModification(errorMessage)) {
*errorMessage = msgCannotSetArrayUsage(func->minimalSignature(), i, *errorMessage);
return false;
}
- func->arguments()[i]->setType(t);
+ func->arguments()[i].setType(t);
}
}
}
@@ -1863,8 +1860,6 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
arguments.pop_front();
}
- AbstractMetaArgumentList metaArguments;
-
for (int i = 0; i < arguments.size(); ++i) {
const ArgumentModelItem &arg = arguments.at(i);
@@ -1908,15 +1903,14 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
metaType.setViewOn(viewOn);
}
- auto *metaArgument = new AbstractMetaArgument;
-
- metaArgument->setType(metaType);
- metaArgument->setName(arg->name());
- metaArgument->setArgumentIndex(i);
- metaArguments << metaArgument;
+ AbstractMetaArgument metaArgument;
+ metaArgument.setType(metaType);
+ metaArgument.setName(arg->name());
+ metaArgument.setArgumentIndex(i);
+ metaFunction->addArgument(metaArgument);
}
- metaFunction->setArguments(metaArguments);
+ AbstractMetaArgumentList &metaArguments = metaFunction->arguments();
const FunctionModificationList functionMods = metaFunction->modifications(currentClass);
@@ -1930,19 +1924,19 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
// Find the correct default values
for (int i = 0, size = metaArguments.size(); i < size; ++i) {
const ArgumentModelItem &arg = arguments.at(i);
- AbstractMetaArgument* metaArg = metaArguments.at(i);
+ AbstractMetaArgument &metaArg = metaArguments[i];
const QString originalDefaultExpression =
- fixDefaultValue(arg, metaArg->type(), metaFunction, currentClass, i);
+ fixDefaultValue(arg, metaArg.type(), metaFunction, currentClass, i);
- metaArg->setOriginalDefaultValueExpression(originalDefaultExpression);
- metaArg->setDefaultValueExpression(originalDefaultExpression);
+ metaArg.setOriginalDefaultValueExpression(originalDefaultExpression);
+ metaArg.setDefaultValueExpression(originalDefaultExpression);
- applyDefaultExpressionModifications(functionMods, i, metaArg);
+ applyDefaultExpressionModifications(functionMods, i, &metaArg);
//Check for missing argument name
- if (!metaArg->defaultValueExpression().isEmpty()
- && !metaArg->hasName()
+ if (!metaArg.defaultValueExpression().isEmpty()
+ && !metaArg.hasName()
&& !metaFunction->isOperatorOverload()
&& !metaFunction->isSignal()
&& metaFunction->argumentName(i + 1, false, currentClass).isEmpty()) {
@@ -1964,7 +1958,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
// Determine class special functions
if (currentClass && metaFunction->arguments().size() == 1) {
- const AbstractMetaType &argType = metaFunction->arguments().constFirst()->type();
+ const AbstractMetaType &argType = metaFunction->arguments().constFirst().type();
if (argType.typeEntry() == currentClass->typeEntry() && argType.indirections() == 0) {
if (metaFunction->name() == QLatin1String("operator=")) {
switch (argType.referenceType()) {
@@ -2757,12 +2751,12 @@ void AbstractMetaBuilderPrivate::inheritTemplateFunctions(AbstractMetaClass *sub
}
const AbstractMetaArgumentList &arguments = function->arguments();
- for (AbstractMetaArgument *argument : arguments) {
- AbstractMetaType argType = inheritTemplateType(templateTypes, argument->type());
+ for (const AbstractMetaArgument &argument : arguments) {
+ AbstractMetaType argType = inheritTemplateType(templateTypes, argument.type());
if (!argType)
break;
- AbstractMetaArgument *arg = argument->copy();
- arg->setType(argType);
+ AbstractMetaArgument arg = argument;
+ arg.setType(argType);
f->addArgument(arg);
}
@@ -3079,12 +3073,12 @@ AbstractMetaClassList AbstractMetaBuilderPrivate::classesTopologicalSorted(const
const AbstractMetaFunctionList &functions = clazz->functions();
for (AbstractMetaFunction *func : functions) {
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
+ for (const AbstractMetaArgument &arg : arguments) {
// Check methods with default args: If a class is instantiated by value,
// ("QString s = QString()"), add a dependency.
- if (!arg->originalDefaultValueExpression().isEmpty()
- && arg->type().isValue()) {
- addClassDependency(arg->type().typeEntry(), clazz, classIndex,
+ if (!arg.originalDefaultValueExpression().isEmpty()
+ && arg.type().isValue()) {
+ addClassDependency(arg.type().typeEntry(), clazz, classIndex,
map, &graph);
}
}
@@ -3160,8 +3154,9 @@ AbstractMetaArgumentList AbstractMetaBuilderPrivate::reverseList(const AbstractM
AbstractMetaArgumentList ret;
int index = list.size();
- for (AbstractMetaArgument *arg : list) {
- arg->setArgumentIndex(index);
+ for (const AbstractMetaArgument &a : list) {
+ AbstractMetaArgument arg = a;
+ arg.setArgumentIndex(index);
ret.prepend(arg);
index--;
}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 217365d6c..d88775356 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -138,43 +138,6 @@ void AbstractMetaAttributes::assignMetaAttributes(const AbstractMetaAttributes &
}
/*******************************************************************************
- * AbstractMetaArgument
- */
-
-AbstractMetaArgument::AbstractMetaArgument() = default;
-
-void AbstractMetaArgument::assignMetaArgument(const AbstractMetaArgument &other)
-{
- assignMetaVariable(other);
- m_expression = other.m_expression;
- m_originalExpression = other.m_originalExpression;
- m_argumentIndex = other.m_argumentIndex;
-}
-
-AbstractMetaArgument *AbstractMetaArgument::copy() const
-{
- auto *copy = new AbstractMetaArgument;
- copy->assignMetaArgument(*this);
- return copy;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const AbstractMetaArgument *aa)
-{
- QDebugStateSaver saver(d);
- d.noquote();
- d.nospace();
- d << "AbstractMetaArgument(";
- if (aa)
- d << aa->toString();
- else
- d << '0';
- d << ')';
- return d;
-}
-#endif // !QT_NO_DEBUG_STREAM
-
-/*******************************************************************************
* AbstractMetaFunction
*/
@@ -210,10 +173,7 @@ AbstractMetaFunction::AbstractMetaFunction()
{
}
-AbstractMetaFunction::~AbstractMetaFunction()
-{
- qDeleteAll(m_arguments);
-}
+AbstractMetaFunction::~AbstractMetaFunction() = default;
/*******************************************************************************
* Indicates that this function has a modification that removes it
@@ -287,15 +247,15 @@ AbstractMetaFunction::CompareResult AbstractMetaFunction::compareTo(const Abstra
bool same = true;
for (int i = 0; i < maxCount; ++i) {
if (i < minCount) {
- const AbstractMetaArgument *min_arg = minArguments.at(i);
- const AbstractMetaArgument *max_arg = maxArguments.at(i);
- if (min_arg->type().name() != max_arg->type().name()
- && (min_arg->defaultValueExpression().isEmpty() || max_arg->defaultValueExpression().isEmpty())) {
+ const AbstractMetaArgument &min_arg = minArguments.at(i);
+ const AbstractMetaArgument &max_arg = maxArguments.at(i);
+ if (min_arg.type().name() != max_arg.type().name()
+ && (min_arg.defaultValueExpression().isEmpty() || max_arg.defaultValueExpression().isEmpty())) {
same = false;
break;
}
} else {
- if (maxArguments.at(i)->defaultValueExpression().isEmpty()) {
+ if (maxArguments.at(i).defaultValueExpression().isEmpty()) {
same = false;
break;
}
@@ -324,9 +284,8 @@ AbstractMetaFunction *AbstractMetaFunction::copy() const
cpy->setAllowThreadModification(m_allowThreadModification);
cpy->setExceptionHandlingModification(m_exceptionHandlingModification);
cpy->m_addedFunction = m_addedFunction;
+ cpy->m_arguments = m_arguments;
- for (AbstractMetaArgument *arg : m_arguments)
- cpy->addArgument(arg->copy());
return cpy;
}
@@ -336,8 +295,8 @@ bool AbstractMetaFunction::usesRValueReferences() const
return true;
if (m_type.referenceType() == RValueReference)
return true;
- for (const AbstractMetaArgument *a : m_arguments) {
- if (a->type().referenceType() == RValueReference)
+ for (const AbstractMetaArgument &a : m_arguments) {
+ if (a.type().referenceType() == RValueReference)
return true;
}
return false;
@@ -352,8 +311,8 @@ QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStrin
}
QStringList returned;
- AbstractMetaArgument *argument = arguments.at(resolvedArguments.size());
- QStringList minimalTypeSignature = argument->type().minimalSignature().split(QLatin1String("::"));
+ const AbstractMetaArgument &argument = arguments.at(resolvedArguments.size());
+ QStringList minimalTypeSignature = argument.type().minimalSignature().split(QLatin1String("::"));
for (int i = 0; i < minimalTypeSignature.size(); ++i) {
returned += introspectionCompatibleSignatures(QStringList(resolvedArguments)
<< QStringList(minimalTypeSignature.mid(minimalTypeSignature.size() - i - 1)).join(QLatin1String("::")));
@@ -370,20 +329,20 @@ QString AbstractMetaFunction::signature() const
m_cachedSignature += QLatin1Char('(');
for (int i = 0; i < m_arguments.count(); ++i) {
- AbstractMetaArgument *a = m_arguments.at(i);
- const AbstractMetaType &t = a->type();
+ const AbstractMetaArgument &a = m_arguments.at(i);
+ const AbstractMetaType &t = a.type();
if (!t.isVoid()) {
if (i > 0)
m_cachedSignature += QLatin1String(", ");
m_cachedSignature += t.cppSignature();
// We need to have the argument names in the qdoc files
m_cachedSignature += QLatin1Char(' ');
- m_cachedSignature += a->name();
+ m_cachedSignature += a.name();
} else {
qCWarning(lcShiboken).noquote().nospace()
<< QString::fromLatin1("No abstract meta type found for argument '%1' while"
"constructing signature for function '%2'.")
- .arg(a->name(), name());
+ .arg(a.name(), name());
}
}
m_cachedSignature += QLatin1Char(')');
@@ -402,7 +361,7 @@ int AbstractMetaFunction::actualMinimumArgumentCount() const
for (int i = 0; i < arguments.size(); ++i && ++count) {
if (argumentRemoved(i + 1))
--count;
- else if (!arguments.at(i)->defaultValueExpression().isEmpty())
+ else if (!arguments.at(i).defaultValueExpression().isEmpty())
break;
}
@@ -617,7 +576,7 @@ QString AbstractMetaFunction::minimalSignature() const
AbstractMetaArgumentList arguments = this->arguments();
for (int i = 0; i < arguments.count(); ++i) {
- const AbstractMetaType &t = arguments.at(i)->type();
+ const AbstractMetaType &t = arguments.at(i).type();
if (!t.isVoid()) {
if (i > 0)
minimalSignature += QLatin1Char(',');
@@ -626,7 +585,7 @@ QString AbstractMetaFunction::minimalSignature() const
qCWarning(lcShiboken).noquote().nospace()
<< QString::fromLatin1("No abstract meta type found for argument '%1' while constructing"
" minimal signature for function '%2'.")
- .arg(arguments.at(i)->name(), name());
+ .arg(arguments.at(i).name(), name());
}
}
minimalSignature += QLatin1Char(')');
@@ -680,7 +639,7 @@ QString AbstractMetaFunction::argumentName(int index,
bool /* create */,
const AbstractMetaClass * /* implementor */) const
{
- return m_arguments[--index]->name();
+ return m_arguments[--index].name();
}
bool AbstractMetaFunction::isCallOperator() const
@@ -1616,9 +1575,9 @@ void AbstractMetaClass::addDefaultCopyConstructor(bool isPrivate)
argType.setConstant(true);
argType.setTypeUsagePattern(AbstractMetaType::ValuePattern);
- auto arg = new AbstractMetaArgument;
- arg->setType(argType);
- arg->setName(name());
+ AbstractMetaArgument arg;
+ arg.setType(argType);
+ arg.setName(name());
f->addArgument(arg);
AbstractMetaAttributes::Attributes attr = FinalInTargetLang | AddedMethod;
@@ -1850,8 +1809,8 @@ static void addExtraIncludesForFunction(AbstractMetaClass *metaClass, const Abst
addExtraIncludeForType(metaClass, meta_function->type());
const AbstractMetaArgumentList &arguments = meta_function->arguments();
- for (AbstractMetaArgument *argument : arguments)
- addExtraIncludeForType(metaClass, argument->type());
+ for (const AbstractMetaArgument &argument : arguments)
+ addExtraIncludeForType(metaClass, argument.type());
}
void AbstractMetaClass::fixFunctions()
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 66331bbd9..9c52182ef 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -30,6 +30,7 @@
#define ABSTRACTMETALANG_H
#include "abstractmetalang_typedefs.h"
+#include "abstractmetaargument.h"
#include "abstractmetatype.h"
#include "documentation.h"
#include "sourcelocation.h"
@@ -306,66 +307,6 @@ private:
QDebug operator<<(QDebug d, const AbstractMetaVariable *av);
#endif
-class AbstractMetaArgument : public AbstractMetaVariable
-{
-public:
- AbstractMetaArgument();
-
- QString defaultValueExpression() const
- {
- return m_expression;
- }
- void setDefaultValueExpression(const QString &expr)
- {
- m_expression = expr;
- }
-
- QString originalDefaultValueExpression() const
- {
- return m_originalExpression;
- }
- void setOriginalDefaultValueExpression(const QString &expr)
- {
- m_originalExpression = expr;
- }
-
- bool hasDefaultValueExpression() const
- { return !m_expression.isEmpty(); }
- bool hasOriginalDefaultValueExpression() const
- { return !m_originalExpression.isEmpty(); }
- bool hasUnmodifiedDefaultValueExpression() const
- { return !m_originalExpression.isEmpty() && m_originalExpression == m_expression; }
- bool hasModifiedDefaultValueExpression() const
- { return !m_expression.isEmpty() && m_originalExpression != m_expression; }
-
- QString toString() const
- {
- return type().name() + QLatin1Char(' ') + AbstractMetaVariable::name() +
- (m_expression.isEmpty() ? QString() : QLatin1String(" = ") + m_expression);
- }
-
- int argumentIndex() const
- {
- return m_argumentIndex;
- }
- void setArgumentIndex(int argIndex)
- {
- m_argumentIndex = argIndex;
- }
-
- AbstractMetaArgument *copy() const;
-
-protected:
- void assignMetaArgument(const AbstractMetaArgument &other);
-
-private:
- QString m_expression;
- QString m_originalExpression;
- int m_argumentIndex = 0;
-
- friend class AbstractMetaClass;
-};
-
class EnclosingClassMixin {
public:
const AbstractMetaClass *enclosingClass() const { return m_enclosingClass; }
@@ -376,10 +317,6 @@ private:
const AbstractMetaClass *m_enclosingClass = nullptr;
};
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const AbstractMetaArgument *aa);
-#endif
-
class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes, public EnclosingClassMixin
{
public:
@@ -591,7 +528,11 @@ public:
m_implementingClass = cls;
}
- AbstractMetaArgumentList arguments() const
+ const AbstractMetaArgumentList &arguments() const
+ {
+ return m_arguments;
+ }
+ AbstractMetaArgumentList &arguments()
{
return m_arguments;
}
@@ -599,7 +540,7 @@ public:
{
m_arguments = arguments;
}
- void addArgument(AbstractMetaArgument *argument)
+ void addArgument(const AbstractMetaArgument &argument)
{
m_arguments << argument;
}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h
index 580af8170..c32a49348 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h
@@ -40,7 +40,7 @@ class AbstractMetaEnumValue;
class AbstractMetaFunction;
class AbstractMetaType;
-using AbstractMetaArgumentList = QVector<AbstractMetaArgument *>;
+using AbstractMetaArgumentList = QVector<AbstractMetaArgument>;
using AbstractMetaClassList = QVector<AbstractMetaClass *>;
using AbstractMetaEnumList = QVector<AbstractMetaEnum *>;
using AbstractMetaEnumValueList = QVector<AbstractMetaEnumValue *>;
diff --git a/sources/shiboken2/ApiExtractor/doxygenparser.cpp b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
index c6bc3b440..01b8fc012 100644
--- a/sources/shiboken2/ApiExtractor/doxygenparser.cpp
+++ b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
@@ -137,16 +137,16 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
} else {
int i = 1;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- if (!arg->type().isPrimitive()) {
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (!arg.type().isPrimitive()) {
query += QLatin1String("/../param[") + QString::number(i)
+ QLatin1String("]/type/ref[text()=\"")
- + arg->type().cppSignature().toHtmlEscaped()
+ + arg.type().cppSignature().toHtmlEscaped()
+ QLatin1String("\"]/../..");
} else {
query += QLatin1String("/../param[") + QString::number(i)
+ QLatin1String("]/type[text(), \"")
- + arg->type().cppSignature().toHtmlEscaped()
+ + arg.type().cppSignature().toHtmlEscaped()
+ QLatin1String("\"]/..");
}
++i;
diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
index 9318ef18b..6df37fa51 100644
--- a/sources/shiboken2/ApiExtractor/qtdocparser.cpp
+++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
@@ -46,9 +46,9 @@ Documentation QtDocParser::retrieveModuleDocumentation()
return retrieveModuleDocumentation(packageName());
}
-static void formatFunctionArgTypeQuery(QTextStream &str, const AbstractMetaArgument *arg)
+static void formatFunctionArgTypeQuery(QTextStream &str, const AbstractMetaArgument &arg)
{
- const AbstractMetaType &metaType = arg->type();
+ const AbstractMetaType &metaType = arg.type();
if (metaType.isConstant())
str << "const " ;
switch (metaType.typeUsagePattern()) {
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp
index 19bfb8464..c33296885 100644
--- a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp
@@ -242,8 +242,8 @@ void TestAbstractMetaClass::testDefaultValues()
AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
QCOMPARE(classA->queryFunctionsByName(QLatin1String("method")).count(), 1);
AbstractMetaFunction* method = classA->queryFunctionsByName(QLatin1String("method")).constFirst();
- AbstractMetaArgument* arg = method->arguments().constFirst();
- QCOMPARE(arg->defaultValueExpression(), arg->originalDefaultValueExpression());
+ const AbstractMetaArgument &arg = method->arguments().constFirst();
+ QCOMPARE(arg.defaultValueExpression(), arg.originalDefaultValueExpression());
}
void TestAbstractMetaClass::testModifiedDefaultValues()
@@ -271,9 +271,9 @@ void TestAbstractMetaClass::testModifiedDefaultValues()
AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
QCOMPARE(classA->queryFunctionsByName(QLatin1String("method")).count(), 1);
AbstractMetaFunction *method = classA->queryFunctionsByName(QLatin1String("method")).constFirst();
- AbstractMetaArgument *arg = method->arguments().constFirst();
- QCOMPARE(arg->defaultValueExpression(), QLatin1String("Hello"));
- QCOMPARE(arg->originalDefaultValueExpression(), QLatin1String("A::B()"));
+ const AbstractMetaArgument &arg = method->arguments().constFirst();
+ QCOMPARE(arg.defaultValueExpression(), QLatin1String("Hello"));
+ QCOMPARE(arg.originalDefaultValueExpression(), QLatin1String("A::B()"));
}
void TestAbstractMetaClass::testInnerClassOfAPolymorphicOne()
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp
index cbbda70b8..6fd25bc0b 100644
--- a/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp
@@ -209,8 +209,8 @@ void TestAbstractMetaType::testTypedefWithTemplates()
AbstractMetaFunction *function = functions.constFirst();
AbstractMetaArgumentList args = function->arguments();
QCOMPARE(args.count(), 1);
- AbstractMetaArgument *arg = args.constFirst();
- AbstractMetaType metaType = arg->type();
+ const AbstractMetaArgument &arg = args.constFirst();
+ AbstractMetaType metaType = arg.type();
QCOMPARE(metaType.cppSignature(), QLatin1String("A<B >"));
}
@@ -237,8 +237,8 @@ void TestAbstractMetaType::testObjectTypeUsedAsValue()
QVERIFY(method);
AbstractMetaArgumentList args = method->arguments();
QCOMPARE(args.count(), 1);
- AbstractMetaArgument* arg = args.constFirst();
- AbstractMetaType metaType = arg->type();
+ const AbstractMetaArgument &arg = args.constFirst();
+ AbstractMetaType metaType = arg.type();
QCOMPARE(metaType.cppSignature(), QLatin1String("A"));
QVERIFY(metaType.isValue());
QVERIFY(metaType.typeEntry()->isObject());
diff --git a/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
index 4289b4e49..51088a040 100644
--- a/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
@@ -114,11 +114,11 @@ struct A {
AbstractMetaType returnType = addedFunc->type();
QCOMPARE(returnType.typeEntry(), typeDb->findPrimitiveType(QLatin1String("int")));
- AbstractMetaArgumentList args = addedFunc->arguments();
+ const AbstractMetaArgumentList &args = addedFunc->arguments();
QCOMPARE(args.count(), 3);
- QCOMPARE(args[0]->type().typeEntry(), returnType.typeEntry());
- QCOMPARE(args[1]->defaultValueExpression(), QLatin1String("4.6"));
- QCOMPARE(args[2]->type().typeEntry(), typeDb->findType(QLatin1String("B")));
+ QCOMPARE(args.at(0).type().typeEntry(), returnType.typeEntry());
+ QCOMPARE(args.at(1).defaultValueExpression(), QLatin1String("4.6"));
+ QCOMPARE(args.at(2).type().typeEntry(), typeDb->findType(QLatin1String("B")));
auto addedCallOperator = classA->findFunction(QLatin1String("operator()"));
QVERIFY(addedCallOperator);
@@ -250,8 +250,8 @@ void TestAddFunction::testAddFunctionWithDefaultArgs()
QVERIFY(classA);
const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
QVERIFY(addedFunc);
- AbstractMetaArgument *arg = addedFunc->arguments()[1];
- QCOMPARE(arg->defaultValueExpression(), QLatin1String("2"));
+ const AbstractMetaArgument &arg = addedFunc->arguments().at(1);
+ QCOMPARE(arg.defaultValueExpression(), QLatin1String("2"));
}
void TestAddFunction::testAddFunctionAtModuleLevel()
@@ -312,9 +312,9 @@ void TestAddFunction::testAddFunctionWithVarargs()
QVERIFY(classA);
const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
QVERIFY(addedFunc);
- const AbstractMetaArgument *arg = addedFunc->arguments().constLast();
- QVERIFY(arg->type().isVarargs());
- QVERIFY(arg->type().typeEntry()->isVarargs());
+ const AbstractMetaArgument &arg = addedFunc->arguments().constLast();
+ QVERIFY(arg.type().isVarargs());
+ QVERIFY(arg.type().typeEntry()->isVarargs());
}
void TestAddFunction::testAddStaticFunction()
@@ -409,9 +409,9 @@ void TestAddFunction::testModifyAddedFunction()
AbstractMetaClass* foo = AbstractMetaClass::findClass(classes, QLatin1String("Foo"));
const AbstractMetaFunction* method = foo->findFunction(QLatin1String("method"));
QCOMPARE(method->arguments().size(), 2);
- AbstractMetaArgument* arg = method->arguments().at(1);
- QCOMPARE(arg->defaultValueExpression(), QLatin1String("0"));
- QCOMPARE(arg->name(), QLatin1String("varName"));
+ const AbstractMetaArgument &arg = method->arguments().at(1);
+ QCOMPARE(arg.defaultValueExpression(), QLatin1String("0"));
+ QCOMPARE(arg.name(), QLatin1String("varName"));
QCOMPARE(method->argumentName(2), QLatin1String("varName"));
}
@@ -459,8 +459,8 @@ void TestAddFunction::testAddFunctionWithTemplateArg()
QVERIFY(!builder.isNull());
QCOMPARE(builder->globalFunctions().size(), 1);
AbstractMetaFunction *func = builder->globalFunctions().constFirst();
- AbstractMetaArgument *arg = func->arguments().constFirst();
- QCOMPARE(arg->type().instantiations().count(), 1);
+ const AbstractMetaArgument &arg = func->arguments().constFirst();
+ QCOMPARE(arg.type().instantiations().count(), 1);
}
QTEST_APPLESS_MAIN(TestAddFunction)
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
index ab05802b3..1804ec61e 100644
--- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
@@ -52,10 +52,10 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByInteger()
const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
QVERIFY(classA);
- const AbstractMetaArgument *arg = classA->functions().constLast()->arguments().constFirst();
- QVERIFY(arg->type().isArray());
- QCOMPARE(arg->type().arrayElementCount(), 3);
- QCOMPARE(arg->type().arrayElementType()->name(), QLatin1String("double"));
+ const AbstractMetaArgument &arg = classA->functions().constLast()->arguments().constFirst();
+ QVERIFY(arg.type().isArray());
+ QCOMPARE(arg.type().arrayElementCount(), 3);
+ QCOMPARE(arg.type().arrayElementType()->name(), QLatin1String("double"));
}
static QString functionMinimalSignature(const AbstractMetaClass *c, const QString &name)
@@ -131,10 +131,10 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue()
AbstractMetaEnumValue *nvalues = classA->findEnumValue(QLatin1String("NValues"));
QVERIFY(nvalues);
- const AbstractMetaArgument *arg = classA->functions().constLast()->arguments().constFirst();
- QVERIFY(arg->type().isArray());
- QCOMPARE(arg->type().arrayElementCount(), nvalues->value().value());
- QCOMPARE(arg->type().arrayElementType()->name(), QLatin1String("double"));
+ const AbstractMetaArgument &arg = classA->functions().constLast()->arguments().constFirst();
+ QVERIFY(arg.type().isArray());
+ QCOMPARE(arg.type().arrayElementCount(), nvalues->value().value());
+ QCOMPARE(arg.type().arrayElementType()->name(), QLatin1String("double"));
};
void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnum()
@@ -162,10 +162,10 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnu
const AbstractMetaEnumValue *nvalues = someEnum->findEnumValue(QLatin1String("NValues"));
QVERIFY(nvalues);
- const AbstractMetaArgument *arg = classA->functions().constLast()->arguments().constFirst();
- QVERIFY(arg->type().isArray());
- QCOMPARE(arg->type().arrayElementCount(), nvalues->value().value());
- QCOMPARE(arg->type().arrayElementType()->name(), QLatin1String("double"));
+ const AbstractMetaArgument &arg = classA->functions().constLast()->arguments().constFirst();
+ QVERIFY(arg.type().isArray());
+ QCOMPARE(arg.type().arrayElementCount(), nvalues->value().value());
+ QCOMPARE(arg.type().arrayElementType()->name(), QLatin1String("double"));
};
QTEST_APPLESS_MAIN(TestArrayArgument)
diff --git a/sources/shiboken2/ApiExtractor/tests/testenum.cpp b/sources/shiboken2/ApiExtractor/tests/testenum.cpp
index 607a8f627..cc5f93ad5 100644
--- a/sources/shiboken2/ApiExtractor/tests/testenum.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testenum.cpp
@@ -64,7 +64,7 @@ void TestEnum::testEnumCppSignature()
AbstractMetaFunctionList functions = builder->globalFunctions();
QCOMPARE(functions.count(), 1);
QCOMPARE(functions.constFirst()->arguments().count(), 1);
- QCOMPARE(functions.constFirst()->arguments().constFirst()->type().cppSignature(),
+ QCOMPARE(functions.constFirst()->arguments().constFirst().type().cppSignature(),
QLatin1String("A::ClassEnum"));
// enum as parameter of a method
@@ -74,13 +74,13 @@ void TestEnum::testEnumCppSignature()
QVERIFY(!funcs.isEmpty());
AbstractMetaFunction *method = funcs.constFirst();
QVERIFY(method);
- AbstractMetaArgument *arg = method->arguments().constFirst();
- QCOMPARE(arg->type().name(), QLatin1String("ClassEnum"));
- QCOMPARE(arg->type().cppSignature(), QLatin1String("A::ClassEnum"));
+ AbstractMetaArgument arg = method->arguments().constFirst();
+ QCOMPARE(arg.type().name(), QLatin1String("ClassEnum"));
+ QCOMPARE(arg.type().cppSignature(), QLatin1String("A::ClassEnum"));
QCOMPARE(functions.constFirst()->arguments().count(), 1);
arg = functions.constFirst()->arguments().constFirst();
- QCOMPARE(arg->type().name(), QLatin1String("ClassEnum"));
- QCOMPARE(arg->type().cppSignature(), QLatin1String("A::ClassEnum"));
+ QCOMPARE(arg.type().name(), QLatin1String("ClassEnum"));
+ QCOMPARE(arg.type().cppSignature(), QLatin1String("A::ClassEnum"));
AbstractMetaEnumList classEnums = classA->enums();
QCOMPARE(classEnums.constFirst()->name(), QLatin1String("ClassEnum"));
diff --git a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp
index a48298bf7..309314445 100644
--- a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp
@@ -59,7 +59,7 @@ void TestImplicitConversions::testWithPrivateCtors()
const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
QCOMPARE(implicitConvs.count(), 1);
- QCOMPARE(implicitConvs.constFirst()->arguments().constFirst()->type().typeEntry(),
+ QCOMPARE(implicitConvs.constFirst()->arguments().constFirst().type().typeEntry(),
classC->typeEntry());
}
@@ -89,7 +89,7 @@ void TestImplicitConversions::testWithModifiedVisibility()
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
QCOMPARE(implicitConvs.count(), 1);
- QCOMPARE(implicitConvs.constFirst()->arguments().constFirst()->type().typeEntry(),
+ QCOMPARE(implicitConvs.constFirst()->arguments().constFirst().type().typeEntry(),
classB->typeEntry());
}
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
index cca0370e6..d88ad5397 100644
--- a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
@@ -311,10 +311,10 @@ void TestModifyFunction::testGlobalFunctionModification()
const AbstractMetaFunction *func = builder->globalFunctions().constFirst();
QVERIFY(func);
QCOMPARE(func->arguments().count(), 1);
- const AbstractMetaArgument *arg = func->arguments().constFirst();
- QCOMPARE(arg->type().cppSignature(), QLatin1String("A *"));
- QCOMPARE(arg->originalDefaultValueExpression(), QLatin1String("0"));
- QCOMPARE(arg->defaultValueExpression(), QLatin1String("A()"));
+ const AbstractMetaArgument &arg = func->arguments().constFirst();
+ QCOMPARE(arg.type().cppSignature(), QLatin1String("A *"));
+ QCOMPARE(arg.originalDefaultValueExpression(), QLatin1String("0"));
+ QCOMPARE(arg.defaultValueExpression(), QLatin1String("A()"));
}
// Tests modifications of exception handling and allow-thread
diff --git a/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp
index ab91e2c3b..f6f930679 100644
--- a/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp
@@ -60,13 +60,13 @@ void TestNumericalTypedef::testNumericalTypedef()
QCOMPARE(funcDouble->minimalSignature(), QLatin1String("funcDouble(double)"));
QCOMPARE(funcReal->minimalSignature(), QLatin1String("funcReal(real)"));
- const AbstractMetaType doubleType = funcDouble->arguments().constFirst()->type();
+ const AbstractMetaType doubleType = funcDouble->arguments().constFirst().type();
QVERIFY(doubleType);
QCOMPARE(doubleType.cppSignature(), QLatin1String("double"));
QVERIFY(doubleType.isPrimitive());
QVERIFY(doubleType.typeEntry()->isCppPrimitive());
- const AbstractMetaType realType = funcReal->arguments().constFirst()->type();
+ const AbstractMetaType realType = funcReal->arguments().constFirst().type();
QVERIFY(realType);
QCOMPARE(realType.cppSignature(), QLatin1String("real"));
QVERIFY(realType.isPrimitive());
@@ -102,13 +102,13 @@ void TestNumericalTypedef::testUnsignedNumericalTypedef()
QCOMPARE(funcUnsignedShort->minimalSignature(), QLatin1String("funcUnsignedShort(unsigned short)"));
QCOMPARE(funcUShort->minimalSignature(), QLatin1String("funcUShort(custom_ushort)"));
- const AbstractMetaType unsignedShortType = funcUnsignedShort->arguments().constFirst()->type();
+ const AbstractMetaType unsignedShortType = funcUnsignedShort->arguments().constFirst().type();
QVERIFY(unsignedShortType);
QCOMPARE(unsignedShortType.cppSignature(), QLatin1String("unsigned short"));
QVERIFY(unsignedShortType.isPrimitive());
QVERIFY(unsignedShortType.typeEntry()->isCppPrimitive());
- const AbstractMetaType ushortType = funcUShort->arguments().constFirst()->type();
+ const AbstractMetaType ushortType = funcUShort->arguments().constFirst().type();
QVERIFY(ushortType);
QCOMPARE(ushortType.cppSignature(), QLatin1String("custom_ushort"));
QVERIFY(ushortType.isPrimitive());
diff --git a/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp
index b9997b90e..545c47c61 100644
--- a/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp
@@ -51,7 +51,7 @@ void TestReferenceToPointer::testReferenceToPointerArgument()
QVERIFY(classB);
const AbstractMetaFunction* func = classB->findFunction(QLatin1String("dummy"));
QVERIFY(func);
- QCOMPARE(func->arguments().constFirst()->type().minimalSignature(), QLatin1String("A*&"));
+ QCOMPARE(func->arguments().constFirst().type().minimalSignature(), QLatin1String("A*&"));
}
QTEST_APPLESS_MAIN(TestReferenceToPointer)
diff --git a/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp
index e3ea3cbb0..2ae6b105f 100644
--- a/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp
@@ -63,7 +63,7 @@ void TestRemoveImplConv::testRemoveImplConv()
QVERIFY(classC);
AbstractMetaFunctionList implConv = classC->implicitConversions();
QCOMPARE(implConv.count(), 1);
- QCOMPARE(implConv.constFirst()->arguments().constFirst()->type().typeEntry(),
+ QCOMPARE(implConv.constFirst()->arguments().constFirst().type().typeEntry(),
classB->typeEntry());
}
diff --git a/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp
index 217b31256..807768236 100644
--- a/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp
@@ -115,7 +115,7 @@ namespace Namespace {
QVERIFY(!classB->baseClass());
QVERIFY(classB->baseClassName().isEmpty());
const AbstractMetaFunction* func = classB->findFunction(QLatin1String("foo"));
- AbstractMetaType argType = func->arguments().constFirst()->type();
+ AbstractMetaType argType = func->arguments().constFirst().type();
QCOMPARE(argType.instantiations().count(), 1);
QCOMPARE(argType.typeEntry()->qualifiedCppName(), QLatin1String("QList"));
@@ -149,7 +149,7 @@ void func(List<int> arg) {}
AbstractMetaFunction *func = globalFuncs.constFirst();
QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>)"));
- QCOMPARE(func->arguments().constFirst()->type().cppSignature(),
+ QCOMPARE(func->arguments().constFirst().type().cppSignature(),
QLatin1String("List<int >"));
}
@@ -174,7 +174,7 @@ void func(List<int>* arg) {}
AbstractMetaFunction* func = globalFuncs.constFirst();
QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>*)"));
- QCOMPARE(func->arguments().constFirst()->type().cppSignature(),
+ QCOMPARE(func->arguments().constFirst().type().cppSignature(),
QLatin1String("List<int > *"));
}
@@ -199,7 +199,7 @@ void func(List<int>& arg) {}
AbstractMetaFunction* func = globalFuncs.constFirst();
QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>&)"));
- QCOMPARE(func->arguments().constFirst()->type().cppSignature(),
+ QCOMPARE(func->arguments().constFirst().type().cppSignature(),
QLatin1String("List<int > &"));
}
@@ -231,13 +231,13 @@ struct List {
const AbstractMetaFunction *append = list->findFunction(QStringLiteral("append"));
QVERIFY(append);
QCOMPARE(append->arguments().size(), 1);
- QCOMPARE(append->arguments().at(0)->type().cppSignature(), QLatin1String("List<T >"));
+ QCOMPARE(append->arguments().at(0).type().cppSignature(), QLatin1String("List<T >"));
// Verify that the parameter of "void erase(Iterator)" is not modified
const AbstractMetaFunction *erase = list->findFunction(QStringLiteral("erase"));
QVERIFY(erase);
QCOMPARE(erase->arguments().size(), 1);
QEXPECT_FAIL("", "Clang: Some other code changes the parameter type", Abort);
- QCOMPARE(erase->arguments().at(0)->type().cppSignature(), QLatin1String("List::Iterator"));
+ QCOMPARE(erase->arguments().at(0).type().cppSignature(), QLatin1String("List::Iterator"));
}
void TestTemplates::testInheritanceFromContainterTemplate()