moc: Cleanup handling of default arguments in functions
Change-Id: I0a381525b92ce5f0b51296a02d9ab98c7a204efc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7415e53a8b
commit
e1abacfdf7
@ -578,6 +578,17 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void handleDefaultArguments(QList<FunctionDef> *functionList, FunctionDef &function)
|
||||||
|
{
|
||||||
|
// support a function with a default argument by pretending there is an
|
||||||
|
// overload without the argument (the original function is the overload with
|
||||||
|
// all arguments present)
|
||||||
|
while (function.arguments.size() > 0 && function.arguments.constLast().isDefault) {
|
||||||
|
function.wasCloned = true;
|
||||||
|
function.arguments.removeLast();
|
||||||
|
*functionList += function;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Moc::parse()
|
void Moc::parse()
|
||||||
{
|
{
|
||||||
@ -895,11 +906,7 @@ void Moc::parse()
|
|||||||
if (funcDef.isConstructor) {
|
if (funcDef.isConstructor) {
|
||||||
if ((access == FunctionDef::Public) && funcDef.isInvokable) {
|
if ((access == FunctionDef::Public) && funcDef.isInvokable) {
|
||||||
def.constructorList += funcDef;
|
def.constructorList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def.constructorList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def.constructorList += funcDef;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (funcDef.isDestructor) {
|
} else if (funcDef.isDestructor) {
|
||||||
// don't care about destructors
|
// don't care about destructors
|
||||||
@ -908,29 +915,17 @@ void Moc::parse()
|
|||||||
def.publicList += funcDef;
|
def.publicList += funcDef;
|
||||||
if (funcDef.isSlot) {
|
if (funcDef.isSlot) {
|
||||||
def.slotList += funcDef;
|
def.slotList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def.slotList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def.slotList += funcDef;
|
|
||||||
}
|
|
||||||
if (funcDef.revision > 0)
|
if (funcDef.revision > 0)
|
||||||
++def.revisionedMethods;
|
++def.revisionedMethods;
|
||||||
} else if (funcDef.isSignal) {
|
} else if (funcDef.isSignal) {
|
||||||
def.signalList += funcDef;
|
def.signalList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def.signalList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def.signalList += funcDef;
|
|
||||||
}
|
|
||||||
if (funcDef.revision > 0)
|
if (funcDef.revision > 0)
|
||||||
++def.revisionedMethods;
|
++def.revisionedMethods;
|
||||||
} else if (funcDef.isInvokable) {
|
} else if (funcDef.isInvokable) {
|
||||||
def.methodList += funcDef;
|
def.methodList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def.methodList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def.methodList += funcDef;
|
|
||||||
}
|
|
||||||
if (funcDef.revision > 0)
|
if (funcDef.revision > 0)
|
||||||
++def.revisionedMethods;
|
++def.revisionedMethods;
|
||||||
}
|
}
|
||||||
@ -1180,11 +1175,7 @@ void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
|
|||||||
++def->revisionedMethods;
|
++def->revisionedMethods;
|
||||||
}
|
}
|
||||||
def->slotList += funcDef;
|
def->slotList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def->slotList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def->slotList += funcDef;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,11 +1219,7 @@ void Moc::parseSignals(ClassDef *def)
|
|||||||
++def->revisionedMethods;
|
++def->revisionedMethods;
|
||||||
}
|
}
|
||||||
def->signalList += funcDef;
|
def->signalList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def->signalList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def->signalList += funcDef;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1667,11 +1654,7 @@ void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
|
|||||||
funcDef.access = access;
|
funcDef.access = access;
|
||||||
parseFunction(&funcDef, true);
|
parseFunction(&funcDef, true);
|
||||||
def->slotList += funcDef;
|
def->slotList += funcDef;
|
||||||
while (funcDef.arguments.size() > 0 && funcDef.arguments.constLast().isDefault) {
|
handleDefaultArguments(&def->slotList, funcDef);
|
||||||
funcDef.wasCloned = true;
|
|
||||||
funcDef.arguments.removeLast();
|
|
||||||
def->slotList += funcDef;
|
|
||||||
}
|
|
||||||
if (funcDef.revision > 0)
|
if (funcDef.revision > 0)
|
||||||
++def->revisionedMethods;
|
++def->revisionedMethods;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user