From c982d275edc1d364c8becdf69fb0ad8d4cd32cb7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 21 May 2010 21:18:17 +0200 Subject: [PATCH] factor out evaluateBoolFunction() --- src/shared/proparser/profileevaluator.cpp | 57 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 2fcac8fcca..d11819a5ca 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -284,6 +284,8 @@ public: QList prepareFunctionArgs(const ProString &arguments); ProStringList evaluateFunction(const FunctionDef &func, const QList &argumentsList, bool *ok); + VisitReturn evaluateBoolFunction(const FunctionDef &func, const QList &argumentsList, + const ProString &function); QStringList qmakeMkspecPaths() const; QStringList qmakeFeaturePaths() const; @@ -2307,6 +2309,32 @@ ProStringList ProFileEvaluator::Private::evaluateFunction( return ProStringList(); } +ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateBoolFunction( + const FunctionDef &func, const QList &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( const ProString &func, const ProString &arguments) { @@ -2701,33 +2729,8 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit { QHash::ConstIterator it = m_functionDefs.testFunctions.constFind(function); - if (it != m_functionDefs.testFunctions.constEnd()) { - bool ok; - 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; - } + if (it != m_functionDefs.testFunctions.constEnd()) + return evaluateBoolFunction(*it, prepareFunctionArgs(arguments), function); //why don't the builtin functions just use args_list? --Sam int pos = 0; -- 2.11.0