From b0d764cf95e96cbf3676a5c5f76ab04cfa8cead5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 May 2011 19:19:34 +0200 Subject: [PATCH] make cumulative mode support in ProFileEvaluator optional just in case it gets used for something "real" ... making exact mode optional would make no sense, as feature files always need to be evaluated exactly for meaningful results. Change-Id: I568ab751cf74790e0f79b54248202412c39a68ea Reviewed-on: http://codereview.qt.nokia.com/306 Reviewed-by: Daniel Teske --- src/shared/proparser/profileevaluator.cpp | 18 ++++++++++++++++++ src/shared/proparser/profileevaluator.h | 2 ++ src/shared/proparser/proparser.pri | 1 + tests/manual/proparser/main.cpp | 2 ++ tests/manual/proparser/testreader.pro | 1 + 5 files changed, 24 insertions(+) diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 890bc7dd121..9bae8f43a21 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -275,7 +275,11 @@ public: int m_skipLevel; int m_loopLevel; // To report unexpected break() and next()s +#ifdef PROEVALUATOR_CUMULATIVE bool m_cumulative; +#else + enum { m_cumulative = 0 }; +#endif struct Location { Location() : pro(0), line(0) {} @@ -502,7 +506,9 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_, ProFileOption *option, initStatics(); // Configuration, more or less +#ifdef PROEVALUATOR_CUMULATIVE m_cumulative = true; +#endif // Evaluator state m_skipLevel = 0; @@ -1218,8 +1224,10 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile( locker.unlock(); #endif +#ifdef PROEVALUATOR_CUMULATIVE bool cumulative = m_cumulative; m_cumulative = false; +#endif // ### init QMAKE_QMAKE, QMAKE_SH // ### init QMAKE_EXT_{C,H,CPP,OBJ} @@ -1333,7 +1341,9 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile( m_option->base_valuemap = m_valuemapStack.top(); m_option->base_functions = m_functionDefs; +#ifdef PROEVALUATOR_CUMULATIVE m_cumulative = cumulative; +#endif #ifdef PROEVALUATOR_THREAD_SAFE locker.relock(); @@ -3237,14 +3247,18 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName) fn = resolvePath(fn); } +#ifdef PROEVALUATOR_CUMULATIVE bool cumulative = m_cumulative; m_cumulative = false; +#endif // The path is fully normalized already. bool ok = evaluateFileDirect(fn, ProFileEvaluatorHandler::EvalFeatureFile, ProFileEvaluator::LoadProOnly); +#ifdef PROEVALUATOR_CUMULATIVE m_cumulative = cumulative; +#endif return ok; } @@ -3253,7 +3267,9 @@ bool ProFileEvaluator::Private::evaluateFileInto( QHash *values, FunctionDefs *funcs, EvalIntoMode mode) { ProFileEvaluator visitor(m_option, m_parser, m_handler); +#ifdef PROEVALUATOR_CUMULATIVE visitor.d->m_cumulative = false; +#endif visitor.d->m_outputDir = m_outputDir; // visitor.d->m_valuemapStack.top() = *values; if (funcs) @@ -3424,10 +3440,12 @@ QString ProFileEvaluator::propertyValue(const QString &name) const return d->propertyValue(name, false); } +#ifdef PROEVALUATOR_CUMULATIVE void ProFileEvaluator::setCumulative(bool on) { d->m_cumulative = on; } +#endif void ProFileEvaluator::setOutputDir(const QString &dir) { diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 9a782269d63..3f73de4ca1a 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -115,7 +115,9 @@ public: ~ProFileEvaluator(); ProFileEvaluator::TemplateType templateType() const; +#ifdef PROEVALUATOR_CUMULATIVE void setCumulative(bool on); // Default is true! +#endif void setOutputDir(const QString &dir); // Default is empty enum LoadFlag { diff --git a/src/shared/proparser/proparser.pri b/src/shared/proparser/proparser.pri index 19d93e04a8b..907f1b425e3 100644 --- a/src/shared/proparser/proparser.pri +++ b/src/shared/proparser/proparser.pri @@ -1,5 +1,6 @@ VPATH += $$PWD QT += xml +DEFINES += PROEVALUATOR_CUMULATIVE INCLUDEPATH *= $$PWD $$PWD/.. DEPENDPATH *= $$PWD $$PWD/.. diff --git a/tests/manual/proparser/main.cpp b/tests/manual/proparser/main.cpp index 3ef012dd0af..6f70e513f1e 100644 --- a/tests/manual/proparser/main.cpp +++ b/tests/manual/proparser/main.cpp @@ -91,7 +91,9 @@ static int evaluate(const QString &fileName, const QString &in_pwd, const QStrin visited.insert(fileName); ProFileEvaluator visitor(option, parser, &evalHandler); +#ifdef PROEVALUATOR_CUMULATIVE visitor.setCumulative(cumulative); +#endif visitor.setOutputDir(out_pwd); ProFile *pro; diff --git a/tests/manual/proparser/testreader.pro b/tests/manual/proparser/testreader.pro index 43aaa8e3be9..521e2b73ffb 100644 --- a/tests/manual/proparser/testreader.pro +++ b/tests/manual/proparser/testreader.pro @@ -20,3 +20,4 @@ HEADERS = profileparser.h profileevaluator.h proitems.h ioutils.h DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION +DEFINES += PROEVALUATOR_CUMULATIVE