aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-07-08 17:05:21 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:07 -0300
commit9961a25273bd6ff59efdef4d482269eea8c069d0 (patch)
treefd98f7e73c5793c0ca894f5487a74ba1060dc0a4 /abstractmetabuilder.cpp
parent681f738fe473239d73172fdc979c208fdf434e2d (diff)
Fix bug#260 - "Can't modify argument name of a function added with add-function tag."
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 9b57e1e1..01c9e761 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1565,7 +1565,6 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
decideUsagePattern(type);
metaArg->setType(type);
metaArg->setArgumentIndex(i);
- metaArg->setName(typeInfo.name);
metaArg->setDefaultValueExpression(typeInfo.defaultValue);
metaArg->setOriginalDefaultValueExpression(typeInfo.defaultValue);
metaArguments.append(metaArg);
@@ -1595,9 +1594,32 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(const AddedFunction&
}
metaFunction->setOriginalAttributes(metaFunction->attributes());
+ fixArgumentNames(metaFunction);
return metaFunction;
}
+void AbstractMetaBuilder::fixArgumentNames(AbstractMetaFunction* func)
+{
+ if (func->arguments().isEmpty())
+ return;
+ foreach (FunctionModification mod, func->modifications(m_currentClass)) {
+ foreach (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);
+ }
+ }
+ }
+
+ int i = 1;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ if (arg->name().isEmpty())
+ arg->setName("arg__" + QString::number(i), false);
+ ++i;
+ }
+}
+
AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem functionItem)
{
QString functionName = functionItem->name();
@@ -1759,12 +1781,17 @@ AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
}
//Check for missing argument name
- if (hasDefaultValue && !metaArg->hasName() && !metaFunction->isOperatorOverload() && !metaFunction->isSignal() && metaFunction->argumentName(i+1, false, m_currentClass).isEmpty()) {
+ if (hasDefaultValue
+ && !metaArg->hasName()
+ && !metaFunction->isOperatorOverload()
+ && !metaFunction->isSignal()
+ && metaFunction->argumentName(i+1, false, m_currentClass).isEmpty()) {
ReportHandler::warning(QString("Argument %1 on function '%2::%3' has default expressiont but does not have name.").arg(i+1).arg(className).arg(metaFunction->minimalSignature()));
}
}
+ fixArgumentNames(metaFunction);
return metaFunction;
}