aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor')
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp16
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafunction.cpp30
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.cpp210
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.h76
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp16
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp43
7 files changed, 292 insertions, 105 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
index efe2f5ec8..a3c2d3731 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
@@ -1497,13 +1497,13 @@ static void applyDefaultExpressionModifications(const FunctionModificationList &
// use replace/remove-default-expression for set default value
for (const auto &modification : functionMods) {
for (const auto &argumentModification : modification.argument_mods()) {
- if (argumentModification.index == i + 1) {
- if (argumentModification.removedDefaultExpression) {
+ if (argumentModification.index() == i + 1) {
+ if (argumentModification.removedDefaultExpression()) {
metaArg->setDefaultValueExpression(QString());
break;
}
- if (!argumentModification.replacedDefaultExpression.isEmpty()) {
- metaArg->setDefaultValueExpression(argumentModification.replacedDefaultExpression);
+ if (!argumentModification.replacedDefaultExpression().isEmpty()) {
+ metaArg->setDefaultValueExpression(argumentModification.replacedDefaultExpression());
break;
}
}
@@ -1646,8 +1646,8 @@ void AbstractMetaBuilderPrivate::fixArgumentNames(AbstractMetaFunction *func, co
for (const FunctionModification &mod : mods) {
for (const ArgumentModification &argMod : mod.argument_mods()) {
- if (!argMod.renamed_to.isEmpty())
- arguments[argMod.index - 1].setName(argMod.renamed_to, false);
+ if (!argMod.renamedToName().isEmpty())
+ arguments[argMod.index() - 1].setName(argMod.renamedToName(), false);
}
}
@@ -1710,8 +1710,8 @@ static bool applyArrayArgumentModifications(const FunctionModificationList &func
{
for (const FunctionModification &mod : functionMods) {
for (const ArgumentModification &argMod : mod.argument_mods()) {
- if (argMod.array) {
- const int i = argMod.index - 1;
+ if (argMod.isArray()) {
+ const int i = argMod.index() - 1;
if (i < 0 || i >= func->arguments().size()) {
*errorMessage = msgCannotSetArrayUsage(func->minimalSignature(), i,
QLatin1String("Index out of range."));
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
index 79ca961f6..e2d0fb9dc 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
@@ -431,9 +431,9 @@ QList<ReferenceCount> AbstractMetaFunction::referenceCounts(const AbstractMetaCl
for (const auto &mod : modifications(cls)) {
for (const ArgumentModification &argumentMod : mod.argument_mods()) {
- if (argumentMod.index != idx && idx != -2)
+ if (argumentMod.index() != idx && idx != -2)
continue;
- returned += argumentMod.referenceCounts;
+ returned += argumentMod.referenceCounts();
}
}
@@ -444,9 +444,9 @@ ArgumentOwner AbstractMetaFunction::argumentOwner(const AbstractMetaClass *cls,
{
for (const auto &mod : modifications(cls)) {
for (const ArgumentModification &argumentMod : mod.argument_mods()) {
- if (argumentMod.index != idx)
+ if (argumentMod.index() != idx)
continue;
- return argumentMod.owner;
+ return argumentMod.owner();
}
}
return ArgumentOwner();
@@ -456,10 +456,10 @@ QString AbstractMetaFunction::conversionRule(TypeSystem::Language language, int
{
for (const auto &modification : modifications(declaringClass())) {
for (const ArgumentModification &argumentModification : modification.argument_mods()) {
- if (argumentModification.index != key)
+ if (argumentModification.index() != key)
continue;
- for (const CodeSnip &snip : argumentModification.conversion_rules) {
+ for (const CodeSnip &snip : argumentModification.conversionRules()) {
if (snip.language == language && !snip.code().isEmpty())
return snip.code();
}
@@ -474,8 +474,8 @@ bool AbstractMetaFunction::argumentRemoved(int key) const
{
for (const auto &modification : modifications(declaringClass())) {
for (const ArgumentModification &argumentModification : modification.argument_mods()) {
- if (argumentModification.index == key) {
- if (argumentModification.removed)
+ if (argumentModification.index() == key) {
+ if (argumentModification.isRemoved())
return true;
}
}
@@ -625,8 +625,8 @@ TypeSystem::Ownership AbstractMetaFunction::ownership(const AbstractMetaClass *c
{
for (const auto &modification : modifications(cls)) {
for (const ArgumentModification &argumentModification : modification.argument_mods()) {
- if (argumentModification.index == key)
- return argumentModification.ownerships.value(language, TypeSystem::InvalidOwnership);
+ if (argumentModification.index() == key)
+ return argumentModification.ownerships().value(language, TypeSystem::InvalidOwnership);
}
}
@@ -637,9 +637,9 @@ QString AbstractMetaFunction::typeReplaced(int key) const
{
for (const auto &modification : modifications(declaringClass())) {
for (const ArgumentModification &argumentModification : modification.argument_mods()) {
- if (argumentModification.index == key
- && !argumentModification.modified_type.isEmpty()) {
- return argumentModification.modified_type;
+ if (argumentModification.index() == key
+ && !argumentModification.modifiedType().isEmpty()) {
+ return argumentModification.modifiedType();
}
}
}
@@ -651,7 +651,7 @@ bool AbstractMetaFunction::isModifiedToArray(int argumentIndex) const
{
for (const auto &modification : modifications(declaringClass())) {
for (const ArgumentModification &argumentModification : modification.argument_mods()) {
- if (argumentModification.index == argumentIndex && argumentModification.array != 0)
+ if (argumentModification.index() == argumentIndex && argumentModification.isArray())
return true;
}
}
@@ -853,7 +853,7 @@ bool AbstractMetaFunction::hasSignatureModifications() const
// since zero represents the return type and we're
// interested only in checking the function arguments,
// it will be ignored.
- if (argmod.index > 0)
+ if (argmod.index() > 0)
return true;
}
}
diff --git a/sources/shiboken6/ApiExtractor/modifications.cpp b/sources/shiboken6/ApiExtractor/modifications.cpp
index e70c7f7d8..eba1437dc 100644
--- a/sources/shiboken6/ApiExtractor/modifications.cpp
+++ b/sources/shiboken6/ApiExtractor/modifications.cpp
@@ -454,6 +454,182 @@ QDebug operator<<(QDebug d, const CodeSnip &s)
return d;
}
+class ArgumentModificationData : public QSharedData
+{
+public:
+ ArgumentModificationData(int idx = -1) : index(idx),
+ removedDefaultExpression(false), removed(false),
+ noNullPointers(false), resetAfterUse(false), array(false)
+ {}
+
+ QList<ReferenceCount> referenceCounts;
+ QString modified_type;
+ QString replacedDefaultExpression;
+ QHash<TypeSystem::Language, TypeSystem::Ownership> ownerships;
+ CodeSnipList conversion_rules;
+ ArgumentOwner owner;
+ QString renamed_to;
+ int index = -1;
+ uint removedDefaultExpression : 1;
+ uint removed : 1;
+ uint noNullPointers : 1;
+ uint resetAfterUse : 1;
+ uint array : 1;
+};
+
+ArgumentModification::ArgumentModification() : d(new ArgumentModificationData)
+{
+}
+
+ArgumentModification::ArgumentModification(int idx) : d(new ArgumentModificationData(idx))
+{
+}
+
+ArgumentModification::ArgumentModification(const ArgumentModification &) = default;
+ArgumentModification &ArgumentModification::operator=(const ArgumentModification &) = default;
+ArgumentModification::ArgumentModification(ArgumentModification &&) = default;
+ArgumentModification &ArgumentModification::operator=(ArgumentModification &&) = default;
+ArgumentModification::~ArgumentModification() = default;
+
+QString ArgumentModification::modifiedType() const
+{
+ return d->modified_type;
+}
+
+void ArgumentModification::setModifiedType(const QString &value)
+{
+ if (d->modified_type != value)
+ d->modified_type = value;
+}
+
+QString ArgumentModification::replacedDefaultExpression() const
+{
+ return d->replacedDefaultExpression;
+}
+
+void ArgumentModification::setReplacedDefaultExpression(const QString &value)
+{
+ if (d->replacedDefaultExpression != value)
+ d->replacedDefaultExpression = value;
+}
+
+const QHash<TypeSystem::Language, TypeSystem::Ownership> &ArgumentModification::ownerships() const
+{
+ return d->ownerships;
+}
+
+void ArgumentModification::insertOwnership(TypeSystem::Language l, TypeSystem::Ownership o)
+{
+ d->ownerships.insert(l, o);
+}
+
+const CodeSnipList &ArgumentModification::conversionRules() const
+{
+ return d->conversion_rules;
+}
+
+CodeSnipList &ArgumentModification::conversionRules()
+{
+ return d->conversion_rules;
+}
+
+ArgumentOwner ArgumentModification::owner() const
+{
+ return d->owner;
+}
+
+void ArgumentModification::setOwner(const ArgumentOwner &value)
+{
+ d->owner = value;
+}
+
+QString ArgumentModification::renamedToName() const
+{
+ return d->renamed_to;
+}
+
+void ArgumentModification::setRenamedToName(const QString &value)
+{
+ if (d->renamed_to != value)
+ d->renamed_to = value;
+}
+
+int ArgumentModification::index() const
+{
+ return d->index;
+}
+
+void ArgumentModification::setIndex(int value)
+{
+ if (d->index != value)
+ d->index = value;
+}
+
+bool ArgumentModification::removedDefaultExpression() const
+{
+ return d->removedDefaultExpression;
+}
+
+void ArgumentModification::setRemovedDefaultExpression(const uint &value)
+{
+ if (d->removedDefaultExpression != value)
+ d->removedDefaultExpression = value;
+}
+
+bool ArgumentModification::isRemoved() const
+{
+ return d->removed;
+}
+
+void ArgumentModification::setRemoved(bool value)
+{
+ if (d->removed != value)
+ d->removed = value;
+}
+
+bool ArgumentModification::noNullPointers() const
+{
+ return d->noNullPointers;
+}
+
+void ArgumentModification::setNoNullPointers(bool value)
+{
+ if (d->noNullPointers != value)
+ d->noNullPointers = value;
+}
+
+bool ArgumentModification::resetAfterUse() const
+{
+ return d->resetAfterUse;
+}
+
+void ArgumentModification::setResetAfterUse(bool value)
+{
+ if (d->resetAfterUse != value)
+ d->resetAfterUse = value;
+}
+
+bool ArgumentModification::isArray() const
+{
+ return d->array;
+}
+
+void ArgumentModification::setArray(bool value)
+{
+ if (d->array != value)
+ d->array = value;
+}
+
+const QList<ReferenceCount> &ArgumentModification::referenceCounts() const
+{
+ return d->referenceCounts;
+}
+
+void ArgumentModification::addReferenceCount(const ReferenceCount &value)
+{
+ d->referenceCounts.append(value);
+}
+
class ModificationData : public QSharedData
{
public:
@@ -705,28 +881,26 @@ QDebug operator<<(QDebug d, const ArgumentModification &a)
QDebugStateSaver saver(d);
d.noquote();
d.nospace();
- d << "ArgumentModification(index=" << a.index;
- if (a.removedDefaultExpression)
+ d << "ArgumentModification(index=" << a.index();
+ if (a.removedDefaultExpression())
d << ", removedDefaultExpression";
- if (a.removed)
+ if (a.isRemoved())
d << ", removed";
- if (a.noNullPointers)
+ if (a.noNullPointers())
d << ", noNullPointers";
- if (a.array)
+ if (a.isArray())
d << ", array";
- if (!a.referenceCounts.isEmpty())
- d << ", referenceCounts=" << a.referenceCounts;
- if (!a.modified_type.isEmpty())
- d << ", modified_type=\"" << a.modified_type << '"';
- if (!a.replace_value.isEmpty())
- d << ", replace_value=\"" << a.replace_value << '"';
- if (!a.replacedDefaultExpression.isEmpty())
- d << ", replacedDefaultExpression=\"" << a.replacedDefaultExpression << '"';
- if (!a.ownerships.isEmpty())
- d << ", ownerships=" << a.ownerships;
- if (!a.renamed_to.isEmpty())
- d << ", renamed_to=\"" << a.renamed_to << '"';
- d << ", owner=" << a.owner << ')';
+ if (!a.referenceCounts().isEmpty())
+ d << ", referenceCounts=" << a.referenceCounts();
+ if (!a.modifiedType().isEmpty())
+ d << ", modified_type=\"" << a.modifiedType() << '"';
+ if (!a.replacedDefaultExpression().isEmpty())
+ d << ", replacedDefaultExpression=\"" << a.replacedDefaultExpression() << '"';
+ if (!a.ownerships().isEmpty())
+ d << ", ownerships=" << a.ownerships();
+ if (!a.renamedToName().isEmpty())
+ d << ", renamed_to=\"" << a.renamedToName() << '"';
+ d << ", owner=" << a.owner() << ')';
return d;
}
diff --git a/sources/shiboken6/ApiExtractor/modifications.h b/sources/shiboken6/ApiExtractor/modifications.h
index 1dc66cf74..1d217d0cb 100644
--- a/sources/shiboken6/ApiExtractor/modifications.h
+++ b/sources/shiboken6/ApiExtractor/modifications.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -39,6 +39,7 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
+class ArgumentModificationData;
class FunctionModificationData;
class ModificationData;
class FieldModificationData;
@@ -174,47 +175,66 @@ public:
TypeSystem::CodeSnipPosition position = TypeSystem::CodeSnipPositionAny;
};
-struct ArgumentModification
+class ArgumentModification
{
- ArgumentModification() : removedDefaultExpression(false), removed(false),
- noNullPointers(false), resetAfterUse(false), array(false) {}
- explicit ArgumentModification(int idx) : index(idx), removedDefaultExpression(false), removed(false),
- noNullPointers(false), resetAfterUse(false), array(false) {}
-
- // Should the default expression be removed?
-
+public:
+ ArgumentModification();
+ explicit ArgumentModification(int idx);
+ ArgumentModification(const ArgumentModification &);
+ ArgumentModification &operator=(const ArgumentModification &);
+ ArgumentModification(ArgumentModification &&);
+ ArgumentModification &operator=(ArgumentModification &&);
+ ~ArgumentModification();
// Reference count flags for this argument
- QList<ReferenceCount> referenceCounts;
+ const QList<ReferenceCount> &referenceCounts() const;
+ void addReferenceCount(const ReferenceCount &value);
// The text given for the new type of the argument
- QString modified_type;
-
- QString replace_value;
+ QString modifiedType() const;
+ void setModifiedType(const QString &value);
- // The text of the new default expression of the argument
- QString replacedDefaultExpression;
+ // The text of the new default expression of the argument
+ QString replacedDefaultExpression() const;
+ void setReplacedDefaultExpression(const QString &value);
// The new definition of ownership for a specific argument
- QHash<TypeSystem::Language, TypeSystem::Ownership> ownerships;
+ const QHash<TypeSystem::Language, TypeSystem::Ownership> &ownerships() const;
+ void insertOwnership(TypeSystem::Language l, TypeSystem::Ownership o);
// Different conversion rules
- CodeSnipList conversion_rules;
+ const CodeSnipList &conversionRules() const;
+ CodeSnipList &conversionRules();
- //QObject parent(owner) of this argument
- ArgumentOwner owner;
+ // QObject parent(owner) of this argument
+ ArgumentOwner owner() const;
+ void setOwner(const ArgumentOwner &value);
+
+ // New name
+ QString renamedToName() const;
+ void setRenamedToName(const QString &value);
- //New name
- QString renamed_to;
+ int index() const;
+ void setIndex(int value);
- // The index of this argument
- int index = -1;
+ bool removedDefaultExpression() const;
+ void setRemovedDefaultExpression(const uint &value);
- uint removedDefaultExpression : 1;
- uint removed : 1;
- uint noNullPointers : 1;
- uint resetAfterUse : 1;
- uint array : 1; // consider "int*" to be "int[]"
+ bool isRemoved() const;
+ void setRemoved(bool value);
+
+ bool noNullPointers() const;
+ void setNoNullPointers(bool value);
+
+ bool resetAfterUse() const;
+ void setResetAfterUse(bool value);
+
+ // consider "int*" to be "int[]"
+ bool isArray() const;
+ void setArray(bool value);
+
+private:
+ QSharedDataPointer<ArgumentModificationData> d;
};
class Modification
diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
index ebee345a0..7c7bb6115 100644
--- a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
@@ -146,31 +146,31 @@ void TestModifyFunction::invalidateAfterUse()
auto func = classB->findFunction(QLatin1String("call"));
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
QVERIFY(classC);
func = classC->findFunction(QLatin1String("call"));
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
func = classC->findFunction(QLatin1String("call2"));
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
const AbstractMetaClass *classD = AbstractMetaClass::findClass(classes, QLatin1String("D"));
QVERIFY(classD);
func = classD->findFunction(QLatin1String("call"));
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
func = classD->findFunction(QLatin1String("call2"));
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
const AbstractMetaClass *classE = AbstractMetaClass::findClass(classes, QLatin1String("E"));
QVERIFY(classE);
@@ -178,13 +178,13 @@ void TestModifyFunction::invalidateAfterUse()
QVERIFY(func);
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
func = classE->findFunction(QLatin1String("call2"));
QVERIFY(func);
QCOMPARE(func->modifications().size(), 1);
QCOMPARE(func->modifications().at(0).argument_mods().size(), 1);
- QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse);
+ QVERIFY(func->modifications().at(0).argument_mods().at(0).resetAfterUse());
}
void TestModifyFunction::testWithApiVersion()
@@ -308,7 +308,7 @@ void TestModifyFunction::testGlobalFunctionModification()
const QList<ArgumentModification> &argMods = mods.constFirst().argument_mods();
QCOMPARE(argMods.count(), 1);
ArgumentModification argMod = argMods.constFirst();
- QCOMPARE(argMod.replacedDefaultExpression, QLatin1String("A()"));
+ QCOMPARE(argMod.replacedDefaultExpression(), QLatin1String("A()"));
QVERIFY(!builder->globalFunctions().isEmpty());
const auto func = builder->globalFunctions().constFirst();
diff --git a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
index a589827e4..f3ffd0edf 100644
--- a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
@@ -57,7 +57,8 @@ void TestRefCountTag::testReferenceCountTag()
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
const auto func = classB->findFunction(QLatin1String("keepObject"));
QVERIFY(!func.isNull());
- ReferenceCount refCount = func->modifications().constFirst().argument_mods().constFirst().referenceCounts.constFirst();
+ const auto refCount =
+ func->modifications().constFirst().argument_mods().constFirst().referenceCounts().constFirst();
QCOMPARE(refCount.action, ReferenceCount::Add);
}
@@ -90,7 +91,8 @@ void TestRefCountTag::testWithApiVersion()
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
const auto func = classB->findFunction(QLatin1String("keepObject"));
QVERIFY(!func.isNull());
- ReferenceCount refCount = func->modifications().constFirst().argument_mods().constFirst().referenceCounts.constFirst();
+ const auto refCount =
+ func->modifications().constFirst().argument_mods().constFirst().referenceCounts().constFirst();
QCOMPARE(refCount.action, ReferenceCount::Add);
QCOMPARE(func->modifications().size(), 1);
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index 1b7864e30..4c754f680 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -887,7 +887,7 @@ bool TypeSystemParser::endElement(QStringView localName)
m_current->parent->value.customFunction->addTemplateInstance(m_current->value.templateInstance);
break;
case StackElement::ConversionRule:
- m_contextStack.top()->functionMods.last().argument_mods().last().conversion_rules.last().addTemplateInstance(m_current->value.templateInstance);
+ m_contextStack.top()->functionMods.last().argument_mods().last().conversionRules().last().addTemplateInstance(m_current->value.templateInstance);
break;
case StackElement::InjectCodeInFunction:
m_contextStack.top()->functionMods.last().snips().last().addTemplateInstance(m_current->value.templateInstance);
@@ -940,7 +940,7 @@ bool TypeSystemParser::characters(const String &ch)
if (m_current->type == StackElement::ConversionRule
&& m_current->parent->type == StackElement::ModifyArgument) {
- m_contextStack.top()->functionMods.last().argument_mods().last().conversion_rules.last().addCode(ch);
+ m_contextStack.top()->functionMods.last().argument_mods().last().conversionRules().last().addCode(ch);
return true;
}
@@ -1798,8 +1798,8 @@ bool TypeSystemParser::parseReplaceArgumentType(const QXmlStreamReader &,
m_error = QLatin1String("Type replacement requires 'modified-type' attribute");
return false;
}
- m_contextStack.top()->functionMods.last().argument_mods().last().modified_type =
- attributes->takeAt(modifiedTypeIndex).value().toString();
+ m_contextStack.top()->functionMods.last().argument_mods().last().setModifiedType(
+ attributes->takeAt(modifiedTypeIndex).value().toString());
return true;
}
@@ -1838,7 +1838,7 @@ bool TypeSystemParser::parseCustomConversion(const QXmlStreamReader &,
if (topElement.type == StackElement::ModifyArgument) {
CodeSnip snip;
snip.language = lang;
- m_contextStack.top()->functionMods.last().argument_mods().last().conversion_rules.append(snip);
+ m_contextStack.top()->functionMods.last().argument_mods().last().conversionRules().append(snip);
return true;
}
@@ -1954,15 +1954,12 @@ bool TypeSystemParser::parseModifyArgument(const QXmlStreamReader &,
}
QString index;
- QString replaceValue;
QString renameTo;
bool resetAfterUse = false;
for (int i = attributes->size() - 1; i >= 0; --i) {
const auto name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
index = attributes->takeAt(i).value().toString();
- } else if (name == QLatin1String("replace-value")) {
- replaceValue = attributes->takeAt(i).value().toString();
} else if (name == invalidateAfterUseAttribute()) {
resetAfterUse = convertBoolean(attributes->takeAt(i).value(),
invalidateAfterUseAttribute(), false);
@@ -1980,15 +1977,9 @@ bool TypeSystemParser::parseModifyArgument(const QXmlStreamReader &,
if (!parseArgumentIndex(index, &idx, &m_error))
return false;
- if (!replaceValue.isEmpty() && idx) {
- m_error = QLatin1String("replace-value is only supported for return values (index=0).");
- return false;
- }
-
ArgumentModification argumentModification = ArgumentModification(idx);
- argumentModification.replace_value = replaceValue;
- argumentModification.resetAfterUse = resetAfterUse;
- argumentModification.renamed_to = renameTo;
+ argumentModification.setResetAfterUse(resetAfterUse);
+ argumentModification.setRenamedToName(renameTo);
m_contextStack.top()->functionMods.last().argument_mods().append(argumentModification);
return true;
}
@@ -2002,7 +1993,7 @@ bool TypeSystemParser::parseNoNullPointer(const QXmlStreamReader &reader,
}
ArgumentModification &lastArgMod = m_contextStack.top()->functionMods.last().argument_mods().last();
- lastArgMod.noNullPointers = true;
+ lastArgMod.setNoNullPointers(true);
const int defaultValueIndex =
indexOfAttribute(*attributes, u"default-value");
@@ -2043,7 +2034,7 @@ bool TypeSystemParser::parseDefineOwnership(const QXmlStreamReader &,
m_error = QStringLiteral("unsupported owner attribute: '%1'").arg(ownership);
return false;
}
- m_contextStack.top()->functionMods.last().argument_mods().last().ownerships[lang] = owner;
+ m_contextStack.top()->functionMods.last().argument_mods().last().insertOwnership(lang, owner);
return true;
}
@@ -2063,7 +2054,7 @@ bool TypeSystemParser::parseRename(const QXmlStreamReader &,
return false;
}
const QString renamed_to = attributes->takeAt(toIndex).value().toString();
- m_contextStack.top()->functionMods.last().argument_mods().last().renamed_to = renamed_to;
+ m_contextStack.top()->functionMods.last().argument_mods().last().setRenamedToName(renamed_to);
return true;
}
@@ -2352,8 +2343,8 @@ bool TypeSystemParser::parseReplaceDefaultExpression(const QXmlStreamReader &,
return false;
}
- m_contextStack.top()->functionMods.last().argument_mods().last().replacedDefaultExpression =
- attributes->takeAt(withIndex).value().toString();
+ m_contextStack.top()->functionMods.last().argument_mods().last().setReplacedDefaultExpression(
+ attributes->takeAt(withIndex).value().toString());
return true;
}
@@ -2413,7 +2404,7 @@ bool TypeSystemParser::parseReferenceCount(const QXmlStreamReader &reader,
}
}
- m_contextStack.top()->functionMods.last().argument_mods().last().referenceCounts.append(rc);
+ m_contextStack.top()->functionMods.last().argument_mods().last().addReferenceCount(rc);
return true;
}
@@ -2443,7 +2434,7 @@ bool TypeSystemParser::parseParentOwner(const QXmlStreamReader &,
}
}
}
- m_contextStack.top()->functionMods.last().argument_mods().last().owner = ao;
+ m_contextStack.top()->functionMods.last().argument_mods().last().setOwner(ao);
return true;
}
@@ -2966,7 +2957,7 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
return false;
}
- m_contextStack.top()->functionMods.last().argument_mods().last().removed = true;
+ m_contextStack.top()->functionMods.last().argument_mods().last().setRemoved(true);
break;
case StackElement::ModifyField:
@@ -2991,7 +2982,7 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
return false;
break;
case StackElement::RemoveDefaultExpression:
- m_contextStack.top()->functionMods.last().argument_mods().last().removedDefaultExpression = true;
+ m_contextStack.top()->functionMods.last().argument_mods().last().setRemovedDefaultExpression(true);
break;
case StackElement::CustomMetaConstructor:
case StackElement::CustomMetaDestructor:
@@ -3011,7 +3002,7 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
m_error = QLatin1String("array must be child of modify-argument");
return false;
}
- m_contextStack.top()->functionMods.last().argument_mods().last().array = true;
+ m_contextStack.top()->functionMods.last().argument_mods().last().setArray(true);
break;
case StackElement::InjectCode:
if (!parseInjectCode(reader, topElement, element, &attributes))