aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-22 08:59:03 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-27 10:01:34 +0000
commit8b88410f9f9589235738bb26739d40af4447cc05 (patch)
tree19276bec219bf2a3c728fdced77b8fb3a45063fc /sources
parent49bd2b28d4a666107d4d124b9a5cc9fbe88d8fe8 (diff)
shiboken2: AbstractMetaArgument: use QSharedData[Pointer]
Similar to AbstractMetaType, AbstractMetaArgument was previously kept as a raw pointer. The data were copied numerous times by AbstractMetaArgument::copy() when adding the inherited functions to a AbstractMetaClass. Similar to what was done for AbstractMetaType in 6cad0686101b252cfdbd1a6768a2b02c39aa1d8a, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. * Remove inheritance from AbstractMetaVariable by moving the fields over. * Remove the unused field m_originalName. Change-Id: Ic9e476ca71e163de131fbecc267d0a4e336cb0b9 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-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
-rw-r--r--sources/shiboken2/generator/generator.cpp28
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp37
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.h3
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp135
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp28
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp38
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.h2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp128
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h14
29 files changed, 647 insertions, 458 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()
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index 94b0f93b2..72a5b9a2e 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -298,8 +298,8 @@ void Generator::collectInstantiatedContainersAndSmartPointers(const AbstractMeta
{
addInstantiatedContainersAndSmartPointers(func->type(), func->signature());
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments)
- addInstantiatedContainersAndSmartPointers(arg->type(), func->signature());
+ for (const AbstractMetaArgument &arg : arguments)
+ addInstantiatedContainersAndSmartPointers(arg.type(), func->signature());
}
void Generator::collectInstantiatedContainersAndSmartPointers(const AbstractMetaClass *metaClass)
@@ -525,8 +525,8 @@ void Generator::replaceTemplateVariables(QString &code, const AbstractMetaFuncti
code.replace(QLatin1String("%TYPE"), cpp_class->name());
const AbstractMetaArgumentList &argument = func->arguments();
- for (AbstractMetaArgument *arg : argument)
- code.replace(QLatin1Char('%') + QString::number(arg->argumentIndex() + 1), arg->name());
+ for (const AbstractMetaArgument &arg : argument)
+ code.replace(QLatin1Char('%') + QString::number(arg.argumentIndex() + 1), arg.name());
//template values
code.replace(QLatin1String("%RETURN_TYPE"), translateType(func->type(), cpp_class));
@@ -790,7 +790,7 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaClass *metaClass) c
QLatin1String("::") + qualifiedCppName);
}
// First argument has unmodified default: Default constructible with values
- if (arguments.constFirst()->hasUnmodifiedDefaultValueExpression()) {
+ if (arguments.constFirst().hasUnmodifiedDefaultValueExpression()) {
return DefaultValue(DefaultValue::DefaultConstructorWithDefaultValues,
QLatin1String("::") + qualifiedCppName);
}
@@ -798,11 +798,11 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaClass *metaClass) c
bool simple = true;
bool suitable = true;
for (int i = 0, size = arguments.size();
- suitable && i < size && !arguments.at(i)->hasOriginalDefaultValueExpression(); ++i) {
- const AbstractMetaArgument *arg = arguments.at(i);
- const TypeEntry *aType = arg->type().typeEntry();
+ suitable && i < size && !arguments.at(i).hasOriginalDefaultValueExpression(); ++i) {
+ const AbstractMetaArgument &arg = arguments.at(i);
+ const TypeEntry *aType = arg.type().typeEntry();
suitable &= aType != cType;
- simple &= aType->isCppPrimitive() || aType->isEnum() || isPointer(arg->type());
+ simple &= aType->isCppPrimitive() || aType->isEnum() || isPointer(arg.type());
}
if (suitable)
candidates.insert(arguments.size() + (simple ? 0 : 100), ctor);
@@ -814,14 +814,14 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaClass *metaClass) c
QStringList args;
bool ok = true;
for (int i =0, size = arguments.size(); ok && i < size; ++i) {
- const AbstractMetaArgument *arg = arguments.at(i);
- if (arg->hasModifiedDefaultValueExpression()) {
- args << arg->defaultValueExpression(); // Spell out modified values
+ const AbstractMetaArgument &arg = arguments.at(i);
+ if (arg.hasModifiedDefaultValueExpression()) {
+ args << arg.defaultValueExpression(); // Spell out modified values
break;
}
- if (arg->hasOriginalDefaultValueExpression())
+ if (arg.hasOriginalDefaultValueExpression())
break;
- auto argValue = minimalConstructor(arg->type());
+ auto argValue = minimalConstructor(arg.type());
ok &= argValue.isValid();
args << argValue.constructorParameter();
}
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index f091860ca..53b403022 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -88,7 +88,7 @@ static bool shouldSkip(const AbstractMetaFunction* func)
const AbstractMetaArgumentList fargs = f->arguments();
for (int i = 0, max = funcArgs.count(); i < max; ++i) {
- if (funcArgs.at(i)->type().typeEntry() != fargs.at(i)->type().typeEntry()) {
+ if (funcArgs.at(i).type().typeEntry() != fargs.at(i).type().typeEntry()) {
cloneFound = false;
break;
}
@@ -1795,7 +1795,7 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass*
}
bool first = true;
- QHash<QString, AbstractMetaArgument*> arg_map;
+ QHash<QString, AbstractMetaArgument> arg_map;
IndentorBase<1> indent1;
indent1.indent = INDENT.total();
@@ -1818,9 +1818,9 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass*
s << indent1 << rstDeprecationNote("constructor");
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- if (!arg_map.contains(arg->name())) {
- arg_map.insert(arg->name(), arg);
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (!arg_map.contains(arg.name())) {
+ arg_map.insert(arg.name(), arg);
}
}
}
@@ -1828,7 +1828,7 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass*
s << Qt::endl;
- for (QHash<QString, AbstractMetaArgument*>::const_iterator it = arg_map.cbegin(), end = arg_map.cend(); it != end; ++it) {
+ for (auto it = arg_map.cbegin(), end = arg_map.cend(); it != end; ++it) {
Indentation indentation(INDENT, 2);
writeParameterType(s, cppClass, it.value());
}
@@ -1846,24 +1846,24 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */
int optArgs = 0;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
+ for (const AbstractMetaArgument &arg : arguments) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
- bool thisIsoptional = !arg->defaultValueExpression().isEmpty();
+ bool thisIsoptional = !arg.defaultValueExpression().isEmpty();
if (optArgs || thisIsoptional) {
ret += QLatin1Char('[');
optArgs++;
}
- if (arg->argumentIndex() > 0)
+ if (arg.argumentIndex() > 0)
ret += QLatin1String(", ");
- ret += arg->name();
+ ret += arg.name();
if (thisIsoptional) {
- QString defValue = arg->defaultValueExpression();
+ QString defValue = arg.defaultValueExpression();
if (defValue == QLatin1String("QString()")) {
defValue = QLatin1String("\"\"");
} else if (defValue == QLatin1String("QStringList()")
@@ -1876,7 +1876,7 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */
defValue.replace(QLatin1String("::"), QLatin1String("."));
if (defValue == QLatin1String("nullptr"))
defValue = none();
- else if (defValue == QLatin1String("0") && arg->type().isObject())
+ else if (defValue == QLatin1String("0") && arg.type().isObject())
defValue = none();
}
ret += QLatin1Char('=') + defValue;
@@ -2063,10 +2063,11 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
return strType;
}
-void QtDocGenerator::writeParameterType(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaArgument* arg)
+void QtDocGenerator::writeParameterType(QTextStream& s, const AbstractMetaClass* cppClass,
+ const AbstractMetaArgument &arg)
{
- s << INDENT << ":param " << arg->name() << ": "
- << translateToPythonType(arg->type(), cppClass) << Qt::endl;
+ s << INDENT << ":param " << arg.name() << ": "
+ << translateToPythonType(arg.type(), cppClass) << Qt::endl;
}
void QtDocGenerator::writeFunctionParametersType(QTextStream &s, const AbstractMetaClass *cppClass,
@@ -2074,9 +2075,9 @@ void QtDocGenerator::writeFunctionParametersType(QTextStream &s, const AbstractM
{
s << Qt::endl;
const AbstractMetaArgumentList &funcArgs = func->arguments();
- for (AbstractMetaArgument *arg : funcArgs) {
+ for (const AbstractMetaArgument &arg : funcArgs) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
writeParameterType(s, cppClass, arg);
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
index a562fe6be..70f6c7c26 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
@@ -258,7 +258,8 @@ private:
const AbstractMetaFunction* func);
void writeFunctionList(QTextStream& s, const AbstractMetaClass* cppClass);
void writeFunctionBlock(QTextStream& s, const QString& title, QStringList& functions);
- void writeParameterType(QTextStream &s, const AbstractMetaClass *cppClass, const AbstractMetaArgument *arg);
+ void writeParameterType(QTextStream &s, const AbstractMetaClass *cppClass,
+ const AbstractMetaArgument &arg);
void writeConstructors(QTextStream &s, const AbstractMetaClass *cppClass);
void writeFormattedText(QTextStream &s, const Documentation &doc,
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 5d1924818..4409e0fa0 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -793,7 +793,7 @@ void CppGenerator::writeConstructorNative(QTextStream &s, const GeneratorContext
s << "\n{\n";
if (wrapperDiagnostics())
s << INDENT << R"(std::cerr << __FUNCTION__ << ' ' << this << '\n';)" << '\n';
- const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : &func->arguments().constLast();
s << INDENT << "resetPyMethodCache();\n";
writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
s << INDENT << "// ... middle\n";
@@ -819,8 +819,8 @@ static bool allArgumentsRemoved(const AbstractMetaFunction *func)
if (func->arguments().isEmpty())
return false;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (!func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (!func->argumentRemoved(arg.argumentIndex() + 1))
return false;
}
return true;
@@ -918,7 +918,7 @@ QString CppGenerator::virtualMethodReturn(QTextStream &s,
qCWarning(lcShiboken, "The expression used in return value contains an invalid index.");
break;
}
- expr.replace(match.captured(0), func->arguments().at(argId)->name());
+ expr.replace(match.captured(0), func->arguments().at(argId).name());
offset = match.capturedStart(1);
}
DefaultValue defaultReturnExpr(DefaultValue::Custom, expr);
@@ -980,7 +980,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s,
const CodeSnipList snips = func->hasInjectedCode()
? func->injectedCodeSnips() : CodeSnipList();
const AbstractMetaArgument *lastArg = func->arguments().isEmpty()
- ? nullptr : func->arguments().constLast();
+ ? nullptr : &func->arguments().constLast();
//Write declaration/native injected code
if (!snips.isEmpty()) {
@@ -1049,13 +1049,13 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s,
} else {
QStringList argConversions;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
QString argConv;
QTextStream ac(&argConv);
- const auto &argType = arg->type();
+ const auto &argType = arg.type();
auto argTypeEntry = static_cast<const PrimitiveTypeEntry *>(argType.typeEntry());
bool convert = argTypeEntry->isObject()
|| argTypeEntry->isValue()
@@ -1075,13 +1075,13 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s,
Indentor nested;
Indentation indentation(nested);
ac << nested;
- if (!func->conversionRule(TypeSystem::TargetLangCode, arg->argumentIndex() + 1).isEmpty()) {
+ if (!func->conversionRule(TypeSystem::TargetLangCode, arg.argumentIndex() + 1).isEmpty()) {
// Has conversion rule.
- ac << arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ ac << arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
} else {
- QString argName = arg->name();
+ QString argName = arg.name();
if (convert)
- writeToPythonConversion(ac, arg->type(), func->ownerClass(), argName);
+ writeToPythonConversion(ac, arg.type(), func->ownerClass(), argName);
else
ac << argName;
}
@@ -1113,7 +1113,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s,
if (injectedCodeUsesPySelf(func))
s << INDENT << "PyObject *pySelf = BindingManager::instance().retrieveWrapper(this);\n";
- const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : &func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
}
@@ -1212,7 +1212,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s,
if (func->hasInjectedCode()) {
s << Qt::endl;
- const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : &func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg);
}
@@ -1542,7 +1542,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
// Constructor that does implicit conversion.
if (!conv->typeReplaced(1).isEmpty() || conv->isModifiedToArray(1))
continue;
- const AbstractMetaType sourceType = conv->arguments().constFirst()->type();
+ const AbstractMetaType sourceType = conv->arguments().constFirst().type();
typeCheck = cpythonCheckFunction(sourceType);
bool isUserPrimitiveWithoutTargetLangName = isUserPrimitive(sourceType)
&& sourceType.typeEntry()->targetLangApiName() == sourceType.typeEntry()->name();
@@ -1586,7 +1586,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
}
const AbstractMetaType sourceType = conv->isConversionOperator()
? buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass())
- : conv->arguments().constFirst()->type();
+ : conv->arguments().constFirst().type();
writePythonToCppConversionFunctions(s, sourceType, targetType, typeCheck, toCppConv, toCppPreConv);
}
@@ -1722,7 +1722,7 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
// Constructor that does implicit conversion.
if (!conv->typeReplaced(1).isEmpty() || conv->isModifiedToArray(1))
continue;
- sourceType = conv->arguments().constFirst()->type();
+ sourceType = conv->arguments().constFirst().type();
}
QString toCpp = pythonToCppFunctionName(sourceType, targetType);
QString isConv = convertibleToCppFunctionName(sourceType, targetType);
@@ -1872,10 +1872,10 @@ void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFun
const OverloadData::MetaFunctionList &overloads = overloadData.overloads();
for (const AbstractMetaFunction *func : overloads) {
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (arg->defaultValueExpression().isEmpty() || func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (arg.defaultValueExpression().isEmpty() || func->argumentRemoved(arg.argumentIndex() + 1))
continue;
- argNamesSet << arg->name();
+ argNamesSet << arg.name();
}
}
QStringList argNamesList = argNamesSet.values();
@@ -2410,7 +2410,7 @@ static void checkTypeViability(const AbstractMetaFunction *func)
return;
checkTypeViability(func, func->type(), 0);
for (int i = 0; i < func->arguments().count(); ++i)
- checkTypeViability(func, func->arguments().at(i)->type(), i + 1);
+ checkTypeViability(func, func->arguments().at(i).type(), i + 1);
}
void CppGenerator::writeTypeCheck(QTextStream &s, const OverloadData *overloadData, QString argumentName)
@@ -2468,7 +2468,7 @@ const AbstractMetaType CppGenerator::getArgumentType(const AbstractMetaFunction
if (typeReplaced.isEmpty()) {
if (argPos == 0)
return func->type();
- auto argType = func->arguments().at(argPos - 1)->type();
+ auto argType = func->arguments().at(argPos - 1).type();
return argType.viewOn() ? *argType.viewOn() : argType;
}
@@ -2632,10 +2632,10 @@ void CppGenerator::writeConversionRule(QTextStream &s, const AbstractMetaFunctio
{
CodeSnipList snippets;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- QString rule = func->conversionRule(language, arg->argumentIndex() + 1);
+ for (const AbstractMetaArgument &arg : arguments) {
+ QString rule = func->conversionRule(language, arg.argumentIndex() + 1);
addConversionRuleCodeSnippet(snippets, rule, language, TypeSystem::TargetLangCode,
- arg->name(), arg->name());
+ arg.name(), arg.name());
}
writeCodeSnips(s, snippets, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func);
}
@@ -2792,7 +2792,8 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream &s, const Ov
if (func->isConstructor() && func->arguments().count() == 1) {
const AbstractMetaClass *ownerClass = func->ownerClass();
const ComplexTypeEntry *baseContainerType = ownerClass->typeEntry()->baseContainerType();
- if (baseContainerType && baseContainerType == func->arguments().constFirst()->type().typeEntry() && isCopyable(ownerClass)) {
+ if (baseContainerType && baseContainerType == func->arguments().constFirst().type().typeEntry()
+ && isCopyable(ownerClass)) {
tck << '!' << cpythonCheckFunction(ownerClass->typeEntry()) << pyArgName << ")\n";
Indentation indent(INDENT);
tck << INDENT << "&& ";
@@ -2817,7 +2818,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream &s, const Ov
if (usePyArgs && signatureFound) {
AbstractMetaArgumentList args = refFunc->arguments();
- const bool isVarargs = args.size() > 1 && args.constLast()->type().isVarargs();
+ const bool isVarargs = args.size() > 1 && args.constLast().type().isVarargs();
int numArgs = args.size() - OverloadData::numberOfRemovedArguments(refFunc);
if (isVarargs)
--numArgs;
@@ -2916,12 +2917,12 @@ void CppGenerator::writeSingleFunctionCall(QTextStream &s,
int removedArgs = 0;
for (int argIdx = 0; argIdx < func->arguments().count(); ++argIdx) {
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, argIdx + 1).isEmpty();
- const AbstractMetaArgument *arg = func->arguments().at(argIdx);
+ const AbstractMetaArgument &arg = func->arguments().at(argIdx);
if (func->argumentRemoved(argIdx + 1)) {
- if (!arg->defaultValueExpression().isEmpty()) {
+ if (!arg.defaultValueExpression().isEmpty()) {
const QString cppArgRemoved = QLatin1String(CPP_ARG_REMOVED)
+ QString::number(argIdx);
- s << INDENT << getFullTypeName(arg->type()) << ' ' << cppArgRemoved;
+ s << INDENT << getFullTypeName(arg.type()) << ' ' << cppArgRemoved;
s << " = " << guessScopeForDefaultValue(func, arg) << ";\n";
writeUnusedVariableCast(s, cppArgRemoved);
} else if (!injectCodeCallsFunc && !func->isUserAdded() && !hasConversionRule) {
@@ -3248,10 +3249,11 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe
Indentation indent(INDENT);
s << INDENT << "PyObject *keyName = nullptr;\n";
s << INDENT << "PyObject *value = nullptr;\n";
- for (const AbstractMetaArgument *arg : args) {
- int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex());
+ for (const AbstractMetaArgument &arg : args) {
+ const int pyArgIndex = arg.argumentIndex()
+ - OverloadData::numberOfRemovedArguments(func, arg.argumentIndex());
QString pyArgName = usePyArgs ? pythonArgsAt(pyArgIndex) : QLatin1String(PYTHON_ARG);
- s << INDENT << "keyName = Py_BuildValue(\"s\",\"" << arg->name() << "\");\n";
+ s << INDENT << "keyName = Py_BuildValue(\"s\",\"" << arg.name() << "\");\n";
s << INDENT << "if (PyDict_Contains(kwds, keyName)) {\n";
{
Indentation indent(INDENT);
@@ -3259,7 +3261,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe
s << INDENT << "if (value && " << pyArgName << ") {\n";
{
Indentation indent(INDENT);
- s << INDENT << pyErrString.arg(arg->name()) << Qt::endl;
+ s << INDENT << pyErrString.arg(arg.name()) << Qt::endl;
s << INDENT << returnStatement(m_currentErrorCode) << Qt::endl;
}
s << INDENT << "}\n";
@@ -3268,7 +3270,8 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe
Indentation indent(INDENT);
s << INDENT << pyArgName << " = value;\n";
s << INDENT << "if (!";
- writeTypeCheck(s, arg->type(), pyArgName, isNumber(arg->type().typeEntry()), func->typeReplaced(arg->argumentIndex() + 1));
+ writeTypeCheck(s, arg.type(), pyArgName, isNumber(arg.type().typeEntry()),
+ func->typeReplaced(arg.argumentIndex() + 1));
s << ")\n";
{
Indentation indent(INDENT);
@@ -3306,7 +3309,7 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction *func, in
}
} else {
int realIndex = argIndex - 1 - OverloadData::numberOfRemovedArguments(func, argIndex - 1);
- AbstractMetaType argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type());
+ AbstractMetaType argType = getTypeWithoutContainer(func->arguments().at(realIndex).type());
if (argType) {
*wrappedClass = AbstractMetaClass::findClass(classes(), argType.typeEntry());
@@ -3373,12 +3376,12 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
if (maxArgs > 0 && maxArgs < func->arguments().size() - OverloadData::numberOfRemovedArguments(func)) {
int removedArgs = 0;
for (int i = 0; i < maxArgs + removedArgs; i++) {
- lastArg = func->arguments().at(i);
+ lastArg = &func->arguments().at(i);
if (func->argumentRemoved(i + 1))
removedArgs++;
}
} else if (maxArgs != 0 && !func->arguments().isEmpty()) {
- lastArg = func->arguments().constLast();
+ lastArg = &func->arguments().constLast();
}
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func, lastArg);
@@ -3391,8 +3394,9 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
if (func->functionType() != AbstractMetaFunction::CopyConstructorFunction) {
int removedArgs = 0;
for (int i = 0; i < maxArgs + removedArgs; i++) {
- const AbstractMetaArgument *arg = func->arguments().at(i);
- bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
+ const AbstractMetaArgument &arg = func->arguments().at(i);
+ bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode,
+ arg.argumentIndex() + 1).isEmpty();
if (func->argumentRemoved(i + 1)) {
// If some argument with default value is removed from a
// method signature, the said value must be explicitly
@@ -3401,16 +3405,17 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
// If have conversion rules I will use this for removed args
if (hasConversionRule)
- userArgs << arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
- else if (!arg->defaultValueExpression().isEmpty())
+ userArgs << arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ else if (!arg.defaultValueExpression().isEmpty())
userArgs.append(QLatin1String(CPP_ARG_REMOVED) + QString::number(i));
} else {
- int idx = arg->argumentIndex() - removedArgs;
- bool deRef = isValueTypeWithCopyConstructorOnly(arg->type())
- || isObjectTypeUsedAsValueType(arg->type())
- || (arg->type().referenceType() == LValueReference && isWrapperType(arg->type()) && !isPointer(arg->type()));
+ int idx = arg.argumentIndex() - removedArgs;
+ bool deRef = isValueTypeWithCopyConstructorOnly(arg.type())
+ || isObjectTypeUsedAsValueType(arg.type())
+ || (arg.type().referenceType() == LValueReference
+ && isWrapperType(arg.type()) && !isPointer(arg.type()));
if (hasConversionRule) {
- userArgs.append(arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
+ userArgs.append(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
} else {
QString argName;
if (deRef)
@@ -3429,15 +3434,16 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
bool otherArgsModified = false;
bool argsClear = true;
for (int i = func->arguments().size() - 1; i >= maxArgs + removedArgs; i--) {
- const AbstractMetaArgument *arg = func->arguments().at(i);
- const bool defValModified = arg->hasModifiedDefaultValueExpression();
- bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
+ const AbstractMetaArgument &arg = func->arguments().at(i);
+ const bool defValModified = arg.hasModifiedDefaultValueExpression();
+ bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode,
+ arg.argumentIndex() + 1).isEmpty();
if (argsClear && !defValModified && !hasConversionRule)
continue;
argsClear = false;
otherArgsModified |= defValModified || hasConversionRule || func->argumentRemoved(i + 1);
if (hasConversionRule)
- otherArgs.prepend(arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
+ otherArgs.prepend(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
else
otherArgs.prepend(QLatin1String(CPP_ARG_REMOVED) + QString::number(i));
}
@@ -4297,7 +4303,8 @@ void CppGenerator::writeMappingMethods(QTextStream &s,
writeCppSelfDefinition(s, func, context);
- const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty()
+ ? nullptr : &func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
s<< "}\n\n";
}
@@ -4324,7 +4331,7 @@ void CppGenerator::writeSequenceMethods(QTextStream &s,
writeCppSelfDefinition(s, func, context);
- const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : &func->arguments().constLast();
writeCodeSnips(s, snips,TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
s<< "}\n\n";
}
@@ -4734,7 +4741,7 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, const GeneratorConte
int alternativeNumericTypes = 0;
for (const AbstractMetaFunction *func : overloads) {
if (!func->isStatic() &&
- ShibokenGenerator::isNumber(func->arguments().at(0)->type().typeEntry()))
+ ShibokenGenerator::isNumber(func->arguments().at(0).type().typeEntry()))
alternativeNumericTypes++;
}
@@ -4771,7 +4778,7 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, const GeneratorConte
if (!snips.isEmpty()) {
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny,
TypeSystem::TargetLangCode, func,
- func->arguments().constLast());
+ &func->arguments().constLast());
generateOperatorCode = false;
}
}
@@ -4897,18 +4904,18 @@ void CppGenerator::writeSignatureInfo(QTextStream &s, const AbstractMetaFunction
if (!(f->isStatic()) && f->ownerClass())
args << QLatin1String("self");
const AbstractMetaArgumentList &arguments = f->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- auto metaType = arg->type();
+ for (const AbstractMetaArgument &arg : arguments) {
+ auto metaType = arg.type();
if (auto viewOn = metaType.viewOn())
metaType = *viewOn;
QString strArg = metaType.pythonSignature();
- if (!arg->defaultValueExpression().isEmpty()) {
+ if (!arg.defaultValueExpression().isEmpty()) {
strArg += QLatin1Char('=');
- QString e = arg->defaultValueExpression();
+ QString e = arg.defaultValueExpression();
e.replace(QLatin1String("::"), QLatin1String("."));
strArg += e;
}
- args << arg->name() + QLatin1Char(':') + strArg;
+ args << arg.name() + QLatin1Char(':') + strArg;
}
// mark the multiple signatures as such, to make it easier to generate different code
if (multiple)
@@ -5075,8 +5082,8 @@ void CppGenerator::writeSignalInitialization(QTextStream &s, const AbstractMetaC
if (cppSignal->declaringClass() != metaClass)
continue;
const AbstractMetaArgumentList &arguments = cppSignal->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- AbstractMetaType metaType = arg->type();
+ for (const AbstractMetaArgument &arg : arguments) {
+ AbstractMetaType metaType = arg.type();
const QByteArray origType =
QMetaObject::normalizedType(qPrintable(metaType.originalTypeDescription()));
const QByteArray cppSig =
@@ -6231,8 +6238,8 @@ bool CppGenerator::writeParentChildManagement(QTextStream &s, const AbstractMeta
int parentIndex = argOwner.index;
int childIndex = argIndex;
if (ctorHeuristicEnabled && argIndex > 0 && numArgs) {
- AbstractMetaArgument *arg = func->arguments().at(argIndex-1);
- if (arg->name() == QLatin1String("parent") && isObjectType(arg->type())) {
+ const AbstractMetaArgument &arg = func->arguments().at(argIndex-1);
+ if (arg.name() == QLatin1String("parent") && isObjectType(arg.type())) {
action = ArgumentOwner::Add;
parentIndex = argIndex;
childIndex = -1;
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
index 89f02f0b2..d607ed643 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -245,15 +245,15 @@ void HeaderGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction *
s << func->originalName() << '(';
QStringList args;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- QString argName = arg->name();
+ for (const AbstractMetaArgument &arg : arguments) {
+ QString argName = arg.name();
const TypeEntry *enumTypeEntry = nullptr;
- if (arg->type().isFlags())
- enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg->type().typeEntry())->originator();
- else if (arg->type().isEnum())
- enumTypeEntry = arg->type().typeEntry();
+ if (arg.type().isFlags())
+ enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg.type().typeEntry())->originator();
+ else if (arg.type().isEnum())
+ enumTypeEntry = arg.type().typeEntry();
if (enumTypeEntry)
- argName = QString::fromLatin1("%1(%2)").arg(arg->type().cppSignature(), argName);
+ argName = QString::fromLatin1("%1(%2)").arg(arg.type().cppSignature(), argName);
args << argName;
}
s << args.join(QLatin1String(", ")) << ')';
@@ -644,15 +644,15 @@ void HeaderGenerator::writeInheritedOverloads(QTextStream &s)
s << func->ownerClass()->qualifiedCppName() << "::" << func->originalName() << '(';
QStringList args;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- QString argName = arg->name();
+ for (const AbstractMetaArgument &arg : arguments) {
+ QString argName = arg.name();
const TypeEntry *enumTypeEntry = nullptr;
- if (arg->type().isFlags())
- enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg->type().typeEntry())->originator();
- else if (arg->type().isEnum())
- enumTypeEntry = arg->type().typeEntry();
+ if (arg.type().isFlags())
+ enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg.type().typeEntry())->originator();
+ else if (arg.type().isEnum())
+ enumTypeEntry = arg.type().typeEntry();
if (enumTypeEntry)
- argName = arg->type().cppSignature() + QLatin1Char('(') + argName + QLatin1Char(')');
+ argName = arg.type().cppSignature() + QLatin1Char('(') + argName + QLatin1Char(')');
args << argName;
}
s << args.join(QLatin1String(", ")) << ')';
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
index dd0cb39eb..53fff9f25 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -143,7 +143,7 @@ static QString getImplicitConversionTypeName(const AbstractMetaType &containerTy
else if (function->isConversionOperator())
impConv = function->ownerClass()->typeEntry()->name();
else
- impConv = getTypeName(function->arguments().constFirst()->type());
+ impConv = getTypeName(function->arguments().constFirst().type());
QStringList types;
for (const auto &otherType : containerType.instantiations())
@@ -314,7 +314,7 @@ void OverloadData::sortNextOverloads()
if (function->isConversionOperator())
convertibleType = function->ownerClass()->typeEntry()->name();
else
- convertibleType = getTypeName(function->arguments().constFirst()->type());
+ convertibleType = getTypeName(function->arguments().constFirst().type());
if (convertibleType == intT() || convertibleType == unsignedIntT())
classesWithIntegerImplicitConversion << targetTypeEntryName;
@@ -489,8 +489,8 @@ OverloadData::OverloadData(const AbstractMetaFunctionList &overloads, const Shib
m_maxArgs = argSize;
OverloadData *currentOverloadData = this;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
currentOverloadData = currentOverloadData->addOverloadData(func, arg);
}
@@ -530,7 +530,7 @@ void OverloadData::addOverload(const AbstractMetaFunction *func)
for (int i = 0; m_headOverloadData->m_minArgs > 0 && i < origNumArgs; i++) {
if (func->argumentRemoved(i + 1))
continue;
- if (func->arguments().at(i)->hasDefaultValueExpression()) {
+ if (func->arguments().at(i).hasDefaultValueExpression()) {
int fixedArgIndex = i - removed;
if (fixedArgIndex < m_headOverloadData->m_minArgs)
m_headOverloadData->m_minArgs = fixedArgIndex;
@@ -541,9 +541,9 @@ void OverloadData::addOverload(const AbstractMetaFunction *func)
}
OverloadData *OverloadData::addOverloadData(const AbstractMetaFunction *func,
- const AbstractMetaArgument *arg)
+ const AbstractMetaArgument &arg)
{
- const AbstractMetaType &argType = arg->type();
+ const AbstractMetaType &argType = arg.type();
OverloadData *overloadData = nullptr;
if (!func->isOperatorOverload()) {
for (OverloadData *tmp : qAsConst(m_nextOverloadData)) {
@@ -565,7 +565,7 @@ OverloadData *OverloadData::addOverloadData(const AbstractMetaFunction *func,
overloadData = new OverloadData(m_headOverloadData, func, argType, m_argPos + 1);
overloadData->m_previousOverloadData = this;
overloadData->m_generator = this->m_generator;
- QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+ QString typeReplaced = func->typeReplaced(arg.argumentIndex() + 1);
if (!typeReplaced.isEmpty())
overloadData->m_argTypeReplaced = typeReplaced;
@@ -597,7 +597,7 @@ bool OverloadData::hasVarargs() const
{
for (const AbstractMetaFunction *func : m_overloads) {
AbstractMetaArgumentList args = func->arguments();
- if (args.size() > 1 && args.constLast()->type().isVarargs())
+ if (args.size() > 1 && args.constLast().type().isVarargs())
return true;
}
return false;
@@ -677,7 +677,7 @@ const AbstractMetaArgument *OverloadData::argument(const AbstractMetaFunction *f
argPos++;
}
- return func->arguments().at(m_argPos + removed);
+ return &func->arguments().at(m_argPos + removed);
}
OverloadDataList OverloadData::overloadDataOnPosition(OverloadData *overloadData, int argPos) const
@@ -762,7 +762,7 @@ const AbstractMetaFunction *OverloadData::getFunctionWithDefaultValue() const
if (func->argumentRemoved(i + 1))
removedArgs++;
}
- if (func->arguments().at(m_argPos + removedArgs)->hasDefaultValueExpression())
+ if (func->arguments().at(m_argPos + removedArgs).hasDefaultValueExpression())
return func;
}
return nullptr;
@@ -779,7 +779,7 @@ QVector<int> OverloadData::invalidArgumentLengths() const
if (func->argumentRemoved(i+1)) {
offset++;
} else {
- if (args.at(i)->hasDefaultValueExpression())
+ if (args.at(i).hasDefaultValueExpression())
validArgLengths << i-offset;
}
}
@@ -828,7 +828,7 @@ QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList
if (func->argumentRemoved(j + 1))
continue;
int fixedArgIndex = j - removed;
- if (fixedArgIndex < minArgs && func->arguments().at(j)->hasDefaultValueExpression())
+ if (fixedArgIndex < minArgs && func->arguments().at(j).hasDefaultValueExpression())
minArgs = fixedArgIndex;
}
}
@@ -1037,10 +1037,10 @@ bool OverloadData::hasArgumentWithDefaultValue() const
bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction *func)
{
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
- if (arg->hasDefaultValueExpression())
+ if (arg.hasDefaultValueExpression())
return true;
}
return false;
@@ -1050,9 +1050,9 @@ AbstractMetaArgumentList OverloadData::getArgumentsWithDefaultValues(const Abstr
{
AbstractMetaArgumentList args;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- if (!arg->hasDefaultValueExpression()
- || func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (!arg.hasDefaultValueExpression()
+ || func->argumentRemoved(arg.argumentIndex() + 1))
continue;
args << arg;
}
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.h b/sources/shiboken2/generator/shiboken2/overloaddata.h
index 8c165a0be..2507c3213 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.h
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.h
@@ -136,7 +136,7 @@ private:
const AbstractMetaType &argType, int argPos);
void addOverload(const AbstractMetaFunction *func);
- OverloadData *addOverloadData(const AbstractMetaFunction *func, const AbstractMetaArgument *arg);
+ OverloadData *addOverloadData(const AbstractMetaFunction *func, const AbstractMetaArgument &arg);
void sortNextOverloads();
bool sortByOverloadNumberModification();
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index efbb81194..c097f4355 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -499,17 +499,17 @@ static QString searchForEnumScope(const AbstractMetaClass *metaClass, const QStr
// Handle QFlags<> for guessScopeForDefaultValue()
QString ShibokenGenerator::guessScopeForDefaultFlagsValue(const AbstractMetaFunction *func,
- const AbstractMetaArgument *arg,
+ const AbstractMetaArgument &arg,
const QString &value) const
{
// Numeric values -> "Options(42)"
static const QRegularExpression numberRegEx(QStringLiteral("^\\d+$")); // Numbers to flags
Q_ASSERT(numberRegEx.isValid());
if (numberRegEx.match(value).hasMatch()) {
- QString typeName = translateTypeForWrapperMethod(arg->type(), func->implementingClass());
- if (arg->type().isConstant())
+ QString typeName = translateTypeForWrapperMethod(arg.type(), func->implementingClass());
+ if (arg.type().isConstant())
typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
- switch (arg->type().referenceType()) {
+ switch (arg.type().referenceType()) {
case NoReference:
break;
case LValueReference:
@@ -564,13 +564,13 @@ QString ShibokenGenerator::guessScopeForDefaultFlagsValue(const AbstractMetaFunc
* this method should be updated, do it with care.
*/
QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction *func,
- const AbstractMetaArgument *arg) const
+ const AbstractMetaArgument &arg) const
{
- QString value = arg->defaultValueExpression();
+ QString value = arg.defaultValueExpression();
if (value.isEmpty() || value == QLatin1String("{}")
- || arg->hasModifiedDefaultValueExpression()
- || isPointer(arg->type())) {
+ || arg.hasModifiedDefaultValueExpression()
+ || isPointer(arg.type())) {
return value;
}
@@ -579,23 +579,24 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction
// Do not qualify macros by class name, eg QSGGeometry(..., int t = GL_UNSIGNED_SHORT);
static const QRegularExpression macroRegEx(QStringLiteral("^[A-Z_][A-Z0-9_]*$"));
Q_ASSERT(macroRegEx.isValid());
- if (arg->type().isPrimitive() && macroRegEx.match(value).hasMatch())
+ if (arg.type().isPrimitive() && macroRegEx.match(value).hasMatch())
return value;
QString prefix;
- if (arg->type().isEnum()) {
- if (const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(arg->type()))
+ if (arg.type().isEnum()) {
+ if (const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(arg.type()))
prefix = resolveScopePrefix(metaEnum, value);
- } else if (arg->type().isFlags()) {
+ } else if (arg.type().isFlags()) {
value = guessScopeForDefaultFlagsValue(func, arg, value);
- } else if (arg->type().typeEntry()->isValue()) {
- const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), arg->type().typeEntry());
+ } else if (arg.type().typeEntry()->isValue()) {
+ const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(),
+ arg.type().typeEntry());
if (enumValueRegEx.match(value).hasMatch() && value != QLatin1String("NULL"))
prefix = resolveScopePrefix(metaClass, value);
- } else if (arg->type().isPrimitive() && arg->type().name() == intT()) {
+ } else if (arg.type().isPrimitive() && arg.type().name() == intT()) {
if (enumValueRegEx.match(value).hasMatch() && func->implementingClass())
prefix = resolveScopePrefix(func->implementingClass(), value);
- } else if (arg->type().isPrimitive()) {
+ } else if (arg.type().isPrimitive()) {
static const QRegularExpression unknowArgumentRegEx(QStringLiteral("^(?:[A-Za-z_][\\w:]*\\()?([A-Za-z_]\\w*)(?:\\))?$")); // [PrimitiveType(] DESIREDNAME [)]
Q_ASSERT(unknowArgumentRegEx.isValid());
const QRegularExpressionMatch match = unknowArgumentRegEx.match(value);
@@ -705,13 +706,13 @@ bool ShibokenGenerator::shouldRejectNullPointerArgument(const AbstractMetaFuncti
if (argIndex < 0 || argIndex >= func->arguments().count())
return false;
- const AbstractMetaArgument *arg = func->arguments().at(argIndex);
- if (isValueTypeWithCopyConstructorOnly(arg->type()))
+ const AbstractMetaArgument &arg = func->arguments().at(argIndex);
+ if (isValueTypeWithCopyConstructorOnly(arg.type()))
return true;
// Argument type is not a pointer, a None rejection should not be
// necessary because the type checking would handle that already.
- if (!isPointer(arg->type()))
+ if (!isPointer(arg.type()))
return false;
if (func->argumentRemoved(argIndex + 1))
return false;
@@ -730,38 +731,39 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction *func,
QString result;
const char objType = (incRef ? 'O' : 'N');
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- if (func->argumentRemoved(arg->argumentIndex() + 1))
+ for (const AbstractMetaArgument &arg : arguments) {
+ if (func->argumentRemoved(arg.argumentIndex() + 1))
continue;
- if (!func->typeReplaced(arg->argumentIndex() + 1).isEmpty()) {
+ const auto &type = arg.type();
+ if (!func->typeReplaced(arg.argumentIndex() + 1).isEmpty()) {
result += QLatin1Char(objType);
- } else if (arg->type().isObject()
- || arg->type().isValue()
- || arg->type().isValuePointer()
- || arg->type().isNativePointer()
- || arg->type().isEnum()
- || arg->type().isFlags()
- || arg->type().isContainer()
- || arg->type().isSmartPointer()
- || arg->type().referenceType() == LValueReference) {
+ } else if (arg.type().isObject()
+ || type.isValue()
+ || type.isValuePointer()
+ || type.isNativePointer()
+ || type.isEnum()
+ || type.isFlags()
+ || type.isContainer()
+ || type.isSmartPointer()
+ || type.referenceType() == LValueReference) {
result += QLatin1Char(objType);
- } else if (arg->type().isPrimitive()) {
+ } else if (type.isPrimitive()) {
const auto *ptype =
- static_cast<const PrimitiveTypeEntry *>(arg->type().typeEntry());
+ static_cast<const PrimitiveTypeEntry *>(type.typeEntry());
if (ptype->basicReferencedTypeEntry())
ptype = ptype->basicReferencedTypeEntry();
if (m_formatUnits.contains(ptype->name()))
result += m_formatUnits[ptype->name()];
else
result += QLatin1Char(objType);
- } else if (isCString(arg->type())) {
+ } else if (isCString(type)) {
result += QLatin1Char('z');
} else {
qCWarning(lcShiboken).noquote().nospace()
<< "Method: " << func->ownerClass()->qualifiedCppName()
<< "::" << func->signature() << " => Arg:"
- << arg->name() << "index: " << arg->argumentIndex()
+ << arg.name() << "index: " << arg.argumentIndex()
<< " - cannot be handled properly. Use an inject-code to fix it!";
result += QLatin1Char('?');
}
@@ -1137,9 +1139,9 @@ bool ShibokenGenerator::isCppPrimitive(const AbstractMetaType &type)
return isCppPrimitive(type.typeEntry());
}
-bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument *arg)
+bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument &arg)
{
- return shouldDereferenceAbstractMetaTypePointer(arg->type());
+ return shouldDereferenceAbstractMetaTypePointer(arg.type());
}
bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType &metaType)
@@ -1336,9 +1338,9 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(AbstractMetaType metaTyp
return result;
}
-QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaArgument *metaArg, bool genericNumberType)
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaArgument &metaArg, bool genericNumberType)
{
- return cpythonIsConvertibleFunction(metaArg->type(), genericNumberType);
+ return cpythonIsConvertibleFunction(metaArg.type(), genericNumberType);
}
QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaClass *metaClass)
@@ -1404,16 +1406,16 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry *ty
}
QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func,
- const AbstractMetaArgument *argument,
+ const AbstractMetaArgument &argument,
Options options) const
{
QString modified_type;
if (!(options & OriginalTypeDescription))
- modified_type = func->typeReplaced(argument->argumentIndex() + 1);
+ modified_type = func->typeReplaced(argument.argumentIndex() + 1);
QString arg;
if (modified_type.isEmpty())
- arg = translateType(argument->type(), func->implementingClass(), options);
+ arg = translateType(argument.type(), func->implementingClass(), options);
else
arg = modified_type.replace(QLatin1Char('$'), QLatin1Char('.'));
@@ -1421,15 +1423,15 @@ QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func,
// "int a", "int a[]"
const int arrayPos = arg.indexOf(QLatin1Char('['));
if (arrayPos != -1)
- arg.insert(arrayPos, QLatin1Char(' ') + argument->name());
+ arg.insert(arrayPos, QLatin1Char(' ') + argument.name());
else
- arg.append(QLatin1Char(' ') + argument->name());
+ arg.append(QLatin1Char(' ') + argument.name());
}
if ((options & Generator::SkipDefaultValues) != Generator::SkipDefaultValues &&
- !argument->originalDefaultValueExpression().isEmpty())
+ !argument.originalDefaultValueExpression().isEmpty())
{
- QString default_value = argument->originalDefaultValueExpression();
+ QString default_value = argument.originalDefaultValueExpression();
if (default_value == QLatin1String("NULL"))
default_value = QLatin1String(NULL_PTR);
@@ -1445,7 +1447,7 @@ QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func,
void ShibokenGenerator::writeArgument(QTextStream &s,
const AbstractMetaFunction *func,
- const AbstractMetaArgument *argument,
+ const AbstractMetaArgument &argument,
Options options) const
{
s << argumentString(func, argument, options);
@@ -1535,11 +1537,11 @@ void ShibokenGenerator::writeArgumentNames(QTextStream &s,
const AbstractMetaArgumentList arguments = func->arguments();
int argCount = 0;
for (auto argument : arguments) {
- const int index = argument->argumentIndex() + 1;
+ const int index = argument.argumentIndex() + 1;
if ((options & Generator::SkipRemovedArguments) && (func->argumentRemoved(index)))
continue;
- s << ((argCount > 0) ? ", " : "") << argument->name();
+ s << ((argCount > 0) ? ", " : "") << argument.name();
if (((options & Generator::VirtualCall) == 0)
&& (!func->conversionRule(TypeSystem::NativeCode, index).isEmpty()
@@ -1718,7 +1720,7 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
? TypeSystem::NativeCode : TypeSystem::TargetLangCode;
int removed = 0;
for (int i = 0; i < func->arguments().size(); ++i) {
- const AbstractMetaArgument *arg = func->arguments().at(i);
+ const AbstractMetaArgument &arg = func->arguments().at(i);
QString argValue;
if (language == TypeSystem::TargetLangCode) {
bool hasConversionRule = !func->conversionRule(convLang, i+1).isEmpty();
@@ -1726,13 +1728,13 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
if (argRemoved)
++removed;
if (argRemoved && hasConversionRule)
- argValue = arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
- else if (argRemoved || (lastArg && arg->argumentIndex() > lastArg->argumentIndex()))
+ argValue = arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ else if (argRemoved || (lastArg && arg.argumentIndex() > lastArg->argumentIndex()))
argValue = QLatin1String(CPP_ARG_REMOVED) + QString::number(i);
if (!argRemoved && argValue.isEmpty()) {
int argPos = i - removed;
- AbstractMetaType type = arg->type();
- QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+ AbstractMetaType type = arg.type();
+ QString typeReplaced = func->typeReplaced(arg.argumentIndex() + 1);
if (!typeReplaced.isEmpty()) {
AbstractMetaType builtType = buildAbstractMetaTypeFromString(typeReplaced);
if (builtType)
@@ -1743,7 +1745,7 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
? pythonArgsAt(argPos) : QLatin1String(PYTHON_ARG);
} else {
argValue = hasConversionRule
- ? arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX)
+ ? arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX)
: QLatin1String(CPP_ARG) + QString::number(argPos);
if (isWrapperType(type)) {
if (type.referenceType() == LValueReference && !isPointer(type))
@@ -1752,7 +1754,7 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
}
}
} else {
- argValue = arg->name();
+ argValue = arg.name();
}
if (!argValue.isEmpty())
argReplacements << ArgumentVarReplacementPair(arg, argValue);
@@ -1846,9 +1848,9 @@ void ShibokenGenerator::writeCodeSnips(QTextStream &s,
// Replace %ARG#_TYPE variables.
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument *arg : arguments) {
- QString argTypeVar = QStringLiteral("%ARG%1_TYPE").arg(arg->argumentIndex() + 1);
- QString argTypeVal = arg->type().cppSignature();
+ for (const AbstractMetaArgument &arg : arguments) {
+ QString argTypeVar = QStringLiteral("%ARG%1_TYPE").arg(arg.argumentIndex() + 1);
+ QString argTypeVal = arg.type().cppSignature();
code.replace(argTypeVar, argTypeVal);
}
@@ -1951,10 +1953,10 @@ void ShibokenGenerator::writeCodeSnips(QTextStream &s,
code.replace(QLatin1String("%ARGUMENT_NAMES"), args.join(QLatin1String(", ")));
for (const ArgumentVarReplacementPair &pair : argReplacements) {
- const AbstractMetaArgument *arg = pair.first;
- int idx = arg->argumentIndex() + 1;
- AbstractMetaType type = arg->type();
- QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+ const AbstractMetaArgument &arg = pair.first;
+ int idx = arg.argumentIndex() + 1;
+ AbstractMetaType type = arg.type();
+ QString typeReplaced = func->typeReplaced(arg.argumentIndex() + 1);
if (!typeReplaced.isEmpty()) {
AbstractMetaType builtType = buildAbstractMetaTypeFromString(typeReplaced);
if (builtType)
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index 7b2f0cb39..0d49764ab 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -297,7 +297,7 @@ protected:
static bool isCppIntegralPrimitive(const AbstractMetaType &type);
/// Checks if an argument type should be dereferenced by the Python method wrapper before calling the C++ method.
- static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument *arg);
+ static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument &arg);
/// Checks if a meta type should be dereferenced by the Python method wrapper passing it to C++.
static bool shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType &metaType);
@@ -330,7 +330,7 @@ protected:
QString guessCPythonCheckFunction(const QString &type, AbstractMetaType *metaType);
QString cpythonIsConvertibleFunction(const TypeEntry *type, bool genericNumberType = false, bool checkExact = false);
QString cpythonIsConvertibleFunction(AbstractMetaType metaType, bool genericNumberType = false);
- QString cpythonIsConvertibleFunction(const AbstractMetaArgument *metaArg, bool genericNumberType = false);
+ QString cpythonIsConvertibleFunction(const AbstractMetaArgument &metaArg, bool genericNumberType = false);
QString cpythonToCppConversionFunction(const AbstractMetaClass *metaClass);
QString cpythonToCppConversionFunction(const AbstractMetaType &type, const AbstractMetaClass *context = nullptr);
@@ -356,9 +356,9 @@ protected:
/// Guesses the scope to where belongs an argument's default value.
QString guessScopeForDefaultValue(const AbstractMetaFunction *func,
- const AbstractMetaArgument *arg) const;
+ const AbstractMetaArgument &arg) const;
QString guessScopeForDefaultFlagsValue(const AbstractMetaFunction *func,
- const AbstractMetaArgument *arg,
+ const AbstractMetaArgument &arg,
const QString &value) const;
static QString cpythonEnumName(const EnumTypeEntry *enumEntry);
@@ -505,7 +505,7 @@ private:
*/
void writeArgument(QTextStream &s,
const AbstractMetaFunction *func,
- const AbstractMetaArgument *argument,
+ const AbstractMetaArgument &argument,
Options options = NoOption) const;
/**
* Create a QString in the C++ format to an function argument.
@@ -514,13 +514,13 @@ private:
* \param options some extra options.
*/
QString argumentString(const AbstractMetaFunction *func,
- const AbstractMetaArgument *argument,
+ const AbstractMetaArgument &argument,
Options options = NoOption) const;
QString functionReturnType(const AbstractMetaFunction *func, Options options = NoOption) const;
/// Utility function for writeCodeSnips.
- using ArgumentVarReplacementPair = QPair<const AbstractMetaArgument *, QString>;
+ using ArgumentVarReplacementPair = QPair<AbstractMetaArgument, QString>;
using ArgumentVarReplacementList = QVector<ArgumentVarReplacementPair>;
ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction* func,
bool usePyArgs, TypeSystem::Language language,