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 <daniel.teske@nokia.com>
This commit is contained in:
Oswald Buddenhagen
2011-05-31 19:19:34 +02:00
parent 7572718ace
commit b0d764cf95
5 changed files with 24 additions and 0 deletions

View File

@@ -275,7 +275,11 @@ public:
int m_skipLevel; int m_skipLevel;
int m_loopLevel; // To report unexpected break() and next()s int m_loopLevel; // To report unexpected break() and next()s
#ifdef PROEVALUATOR_CUMULATIVE
bool m_cumulative; bool m_cumulative;
#else
enum { m_cumulative = 0 };
#endif
struct Location { struct Location {
Location() : pro(0), line(0) {} Location() : pro(0), line(0) {}
@@ -502,7 +506,9 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_, ProFileOption *option,
initStatics(); initStatics();
// Configuration, more or less // Configuration, more or less
#ifdef PROEVALUATOR_CUMULATIVE
m_cumulative = true; m_cumulative = true;
#endif
// Evaluator state // Evaluator state
m_skipLevel = 0; m_skipLevel = 0;
@@ -1218,8 +1224,10 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
locker.unlock(); locker.unlock();
#endif #endif
#ifdef PROEVALUATOR_CUMULATIVE
bool cumulative = m_cumulative; bool cumulative = m_cumulative;
m_cumulative = false; m_cumulative = false;
#endif
// ### init QMAKE_QMAKE, QMAKE_SH // ### init QMAKE_QMAKE, QMAKE_SH
// ### init QMAKE_EXT_{C,H,CPP,OBJ} // ### 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_valuemap = m_valuemapStack.top();
m_option->base_functions = m_functionDefs; m_option->base_functions = m_functionDefs;
#ifdef PROEVALUATOR_CUMULATIVE
m_cumulative = cumulative; m_cumulative = cumulative;
#endif
#ifdef PROEVALUATOR_THREAD_SAFE #ifdef PROEVALUATOR_THREAD_SAFE
locker.relock(); locker.relock();
@@ -3237,14 +3247,18 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName)
fn = resolvePath(fn); fn = resolvePath(fn);
} }
#ifdef PROEVALUATOR_CUMULATIVE
bool cumulative = m_cumulative; bool cumulative = m_cumulative;
m_cumulative = false; m_cumulative = false;
#endif
// The path is fully normalized already. // The path is fully normalized already.
bool ok = evaluateFileDirect(fn, ProFileEvaluatorHandler::EvalFeatureFile, bool ok = evaluateFileDirect(fn, ProFileEvaluatorHandler::EvalFeatureFile,
ProFileEvaluator::LoadProOnly); ProFileEvaluator::LoadProOnly);
#ifdef PROEVALUATOR_CUMULATIVE
m_cumulative = cumulative; m_cumulative = cumulative;
#endif
return ok; return ok;
} }
@@ -3253,7 +3267,9 @@ bool ProFileEvaluator::Private::evaluateFileInto(
QHash<ProString, ProStringList> *values, FunctionDefs *funcs, EvalIntoMode mode) QHash<ProString, ProStringList> *values, FunctionDefs *funcs, EvalIntoMode mode)
{ {
ProFileEvaluator visitor(m_option, m_parser, m_handler); ProFileEvaluator visitor(m_option, m_parser, m_handler);
#ifdef PROEVALUATOR_CUMULATIVE
visitor.d->m_cumulative = false; visitor.d->m_cumulative = false;
#endif
visitor.d->m_outputDir = m_outputDir; visitor.d->m_outputDir = m_outputDir;
// visitor.d->m_valuemapStack.top() = *values; // visitor.d->m_valuemapStack.top() = *values;
if (funcs) if (funcs)
@@ -3424,10 +3440,12 @@ QString ProFileEvaluator::propertyValue(const QString &name) const
return d->propertyValue(name, false); return d->propertyValue(name, false);
} }
#ifdef PROEVALUATOR_CUMULATIVE
void ProFileEvaluator::setCumulative(bool on) void ProFileEvaluator::setCumulative(bool on)
{ {
d->m_cumulative = on; d->m_cumulative = on;
} }
#endif
void ProFileEvaluator::setOutputDir(const QString &dir) void ProFileEvaluator::setOutputDir(const QString &dir)
{ {

View File

@@ -115,7 +115,9 @@ public:
~ProFileEvaluator(); ~ProFileEvaluator();
ProFileEvaluator::TemplateType templateType() const; ProFileEvaluator::TemplateType templateType() const;
#ifdef PROEVALUATOR_CUMULATIVE
void setCumulative(bool on); // Default is true! void setCumulative(bool on); // Default is true!
#endif
void setOutputDir(const QString &dir); // Default is empty void setOutputDir(const QString &dir); // Default is empty
enum LoadFlag { enum LoadFlag {

View File

@@ -1,5 +1,6 @@
VPATH += $$PWD VPATH += $$PWD
QT += xml QT += xml
DEFINES += PROEVALUATOR_CUMULATIVE
INCLUDEPATH *= $$PWD $$PWD/.. INCLUDEPATH *= $$PWD $$PWD/..
DEPENDPATH *= $$PWD $$PWD/.. DEPENDPATH *= $$PWD $$PWD/..

View File

@@ -91,7 +91,9 @@ static int evaluate(const QString &fileName, const QString &in_pwd, const QStrin
visited.insert(fileName); visited.insert(fileName);
ProFileEvaluator visitor(option, parser, &evalHandler); ProFileEvaluator visitor(option, parser, &evalHandler);
#ifdef PROEVALUATOR_CUMULATIVE
visitor.setCumulative(cumulative); visitor.setCumulative(cumulative);
#endif
visitor.setOutputDir(out_pwd); visitor.setOutputDir(out_pwd);
ProFile *pro; ProFile *pro;

View File

@@ -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_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
DEFINES += PROEVALUATOR_CUMULATIVE