forked from qt-creator/qt-creator
factor out evaluateBoolFunction()
This commit is contained in:
@@ -284,6 +284,8 @@ public:
|
|||||||
|
|
||||||
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
||||||
ProStringList evaluateFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList, bool *ok);
|
ProStringList evaluateFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList, bool *ok);
|
||||||
|
VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
||||||
|
const ProString &function);
|
||||||
|
|
||||||
QStringList qmakeMkspecPaths() const;
|
QStringList qmakeMkspecPaths() const;
|
||||||
QStringList qmakeFeaturePaths() const;
|
QStringList qmakeFeaturePaths() const;
|
||||||
@@ -2307,6 +2309,32 @@ ProStringList ProFileEvaluator::Private::evaluateFunction(
|
|||||||
return ProStringList();
|
return ProStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateBoolFunction(
|
||||||
|
const FunctionDef &func, const QList<ProStringList> &argumentsList,
|
||||||
|
const ProString &function)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
ProStringList ret = evaluateFunction(func, argumentsList, &ok);
|
||||||
|
if (ok) {
|
||||||
|
if (ret.isEmpty())
|
||||||
|
return ReturnTrue;
|
||||||
|
if (ret.at(0) != statics.strfalse) {
|
||||||
|
if (ret.at(0) == statics.strtrue)
|
||||||
|
return ReturnTrue;
|
||||||
|
int val = ret.at(0).toQString(m_tmp1).toInt(&ok);
|
||||||
|
if (ok) {
|
||||||
|
if (val)
|
||||||
|
return ReturnTrue;
|
||||||
|
} else {
|
||||||
|
logMessage(format("Unexpected return value from test '%1': %2")
|
||||||
|
.arg(function.toQString(m_tmp1))
|
||||||
|
.arg(ret.join(QLatin1String(" :: "))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ReturnFalse;
|
||||||
|
}
|
||||||
|
|
||||||
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
|
||||||
const ProString &func, const ProString &arguments)
|
const ProString &func, const ProString &arguments)
|
||||||
{
|
{
|
||||||
@@ -2701,33 +2729,8 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
|
|||||||
{
|
{
|
||||||
QHash<ProString, FunctionDef>::ConstIterator it =
|
QHash<ProString, FunctionDef>::ConstIterator it =
|
||||||
m_functionDefs.testFunctions.constFind(function);
|
m_functionDefs.testFunctions.constFind(function);
|
||||||
if (it != m_functionDefs.testFunctions.constEnd()) {
|
if (it != m_functionDefs.testFunctions.constEnd())
|
||||||
bool ok;
|
return evaluateBoolFunction(*it, prepareFunctionArgs(arguments), function);
|
||||||
ProStringList ret = evaluateFunction(*it, prepareFunctionArgs(arguments), &ok);
|
|
||||||
if (ok) {
|
|
||||||
if (ret.isEmpty()) {
|
|
||||||
return ReturnTrue;
|
|
||||||
} else {
|
|
||||||
if (ret.at(0) != statics.strfalse) {
|
|
||||||
if (ret.at(0) == statics.strtrue) {
|
|
||||||
return ReturnTrue;
|
|
||||||
} else {
|
|
||||||
bool ok;
|
|
||||||
int val = ret.at(0).toQString(m_tmp1).toInt(&ok);
|
|
||||||
if (ok) {
|
|
||||||
if (val)
|
|
||||||
return ReturnTrue;
|
|
||||||
} else {
|
|
||||||
logMessage(format("Unexpected return value from test '%1': %2")
|
|
||||||
.arg(function.toQString(m_tmp1))
|
|
||||||
.arg(ret.join(QLatin1String(" :: "))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ReturnFalse;
|
|
||||||
}
|
|
||||||
|
|
||||||
//why don't the builtin functions just use args_list? --Sam
|
//why don't the builtin functions just use args_list? --Sam
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user