aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abstractmetabuilder.cpp4
-rw-r--r--abstractmetalang.cpp18
-rw-r--r--abstractmetalang.h12
-rw-r--r--tests/testmodifyfunction.cpp7
4 files changed, 35 insertions, 6 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index d40e07cb0..5c326abb9 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1633,6 +1633,10 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
}
AbstractMetaArgument* metaArgument = createMetaArgument();
metaArgument->setType(metaType);
+
+ if (arg->name().isEmpty() && metaFunction->argumentName(i).isEmpty())
+ ReportHandler::warning(QString("Argument %1 on function '%2::%3' declared without name.").arg(i).arg(className).arg(functionItem->name()));
+
metaArgument->setName(arg->name());
metaArgument->setArgumentIndex(i);
metaArguments << metaArgument;
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index 068256528..4a7571359 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -699,6 +699,24 @@ bool AbstractMetaFunction::hasModifications(const AbstractMetaClass *implementor
return !modifications(implementor).isEmpty();
}
+QString AbstractMetaFunction::argumentName(int index, bool create, const AbstractMetaClass *implementor) const
+{
+ foreach (FunctionModification mod, modifications(implementor)) {
+ foreach (ArgumentModification argMod, mod.argument_mods) {
+ if ((argMod.index == index) && !argMod.renamed_to.isEmpty())
+ return argMod.renamed_to;
+ }
+ }
+
+ AbstractMetaArgumentList args = arguments();
+ if ((index > 0) && (args.size() > index)) {
+ if (create || args[index]->hasName())
+ return args[index]->argumentName();
+ }
+
+ return QString();
+}
+
bool AbstractMetaFunction::hasInjectedCode() const
{
foreach (const FunctionModification mod, modifications(ownerClass())) {
diff --git a/abstractmetalang.h b/abstractmetalang.h
index 6609eb936..ba72b35cb 100644
--- a/abstractmetalang.h
+++ b/abstractmetalang.h
@@ -687,6 +687,11 @@ public:
AbstractMetaArgument *copy() const;
+ bool hasName() const
+ {
+ return !AbstractMetaVariable::name().isEmpty();
+ }
+
private:
// Just to force people to call argumentName() And indexedName();
QString name() const;
@@ -694,6 +699,8 @@ private:
QString m_expression;
QString m_originalExpression;
int m_argumentIndex;
+
+ friend class AbstractMetaClass;
};
@@ -1068,6 +1075,11 @@ public:
bool hasSignatureModifications() const;
FunctionModificationList modifications(const AbstractMetaClass* implementor = 0) const;
+ /**
+ * Return the argument name if there is a modification the renamed value will be returned
+ */
+ QString argumentName(int index, bool create = true, const AbstractMetaClass *cl = 0) const;
+
// If this function stems from an interface, this returns the
// interface that declares it.
const AbstractMetaClass *interfaceClass() const
diff --git a/tests/testmodifyfunction.cpp b/tests/testmodifyfunction.cpp
index 7fa8833f1..930ccdca8 100644
--- a/tests/testmodifyfunction.cpp
+++ b/tests/testmodifyfunction.cpp
@@ -49,12 +49,7 @@ void TestModifyFunction::testRenameArgument()
const AbstractMetaFunction* func = classA->findFunction("method");
Q_ASSERT(func);
- FunctionModificationList modList = func->modifications(classA);
- QVERIFY(modList.size() == 1);
- FunctionModification mod = modList.at(0);
- QVERIFY(mod.argument_mods.size() == 1);
-
- QCOMPARE(mod.argument_mods.at(0).renamed_to, QString("otherArg"));
+ QCOMPARE(func->argumentName(1), QString("otherArg"));
}
void TestModifyFunction::testOwnershipTransfer()