diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-05-13 10:32:24 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-07-20 12:30:34 (GMT) |
commit | a76c1d097f14e93517f27debde806da4fd7498b9 (patch) | |
tree | 5ce74e84616f907aad6d76d4b498686e9f47cb5a /tools | |
parent | c22f9b0ab5446b229cdf998187f063077432b288 (diff) | |
download | Qt-a76c1d097f14e93517f27debde806da4fd7498b9.zip Qt-a76c1d097f14e93517f27debde806da4fd7498b9.tar.gz Qt-a76c1d097f14e93517f27debde806da4fd7498b9.tar.bz2 |
put condition state variables into a structure
to enable cleaner save/restore - for later
cherry-picked 51f5ee959f58ee198e0fc51e2ad0161c612bf8d1 and
3104e4c121f3209890823db69a7c09d644b90951 from creator
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/shared/profileevaluator.cpp | 52 | ||||
-rw-r--r-- | tools/linguist/shared/profileevaluator.h | 3 |
2 files changed, 32 insertions, 23 deletions
diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index 92f588f..d4c4df8 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -204,11 +204,13 @@ public: QStringList qmakeFeaturePaths(); - enum { ConditionTrue, ConditionFalse, ConditionElse }; - int m_condition; - int m_prevCondition; - bool m_updateCondition; - bool m_invertNext; + enum Condition { ConditionFalse, ConditionTrue, ConditionElse }; + struct State { + Condition condition; + Condition prevCondition; + bool updateCondition; // == !(enclosingBlock()->kind() & ScopeContents) + } m_sts; + bool m_invertNext; // Short-lived, so not in State int m_skipLevel; bool m_cumulative; bool m_isFirstVariableValue; @@ -232,6 +234,10 @@ public: ProFile *m_prevProFile; // See m_prevLineNo }; +#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) +Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::State, Q_PRIMITIVE_TYPE); +#endif + ProFileEvaluator::Private::Private(ProFileEvaluator *q_) : q(q_) { @@ -244,8 +250,8 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_) m_cumulative = true; // Evaluator state - m_updateCondition = false; - m_condition = ConditionFalse; + m_sts.updateCondition = false; + m_sts.condition = ConditionFalse; m_invertNext = false; m_skipLevel = 0; m_isFirstVariableValue = true; @@ -563,16 +569,16 @@ void ProFileEvaluator::Private::updateItem() bool ProFileEvaluator::Private::visitBeginProBlock(ProBlock *block) { if (block->blockKind() == ProBlock::ScopeKind) { - m_updateCondition = true; + m_sts.updateCondition = true; if (!m_skipLevel) { - m_prevCondition = m_condition; - m_condition = ConditionFalse; + m_sts.prevCondition = m_sts.condition; + m_sts.condition = ConditionFalse; } else { - Q_ASSERT(m_condition != ConditionTrue); + Q_ASSERT(m_sts.condition != ConditionTrue); } } else if (block->blockKind() & ProBlock::ScopeContentsKind) { - m_updateCondition = false; - if (m_condition != ConditionTrue) + m_sts.updateCondition = false; + if (m_sts.condition != ConditionTrue) ++m_skipLevel; else Q_ASSERT(!m_skipLevel); @@ -584,12 +590,12 @@ bool ProFileEvaluator::Private::visitEndProBlock(ProBlock *block) { if (block->blockKind() & ProBlock::ScopeContentsKind) { if (m_skipLevel) { - Q_ASSERT(m_condition != ConditionTrue); + Q_ASSERT(m_sts.condition != ConditionTrue); --m_skipLevel; } else { // Conditionals contained inside this block may have changed the state. // So we reset it here to make an else following us do the right thing. - m_condition = ConditionTrue; + m_sts.condition = ConditionTrue; } } return true; @@ -626,13 +632,13 @@ bool ProFileEvaluator::Private::visitProCondition(ProCondition *cond) if (cond->text().toLower() == QLatin1String("else")) { // The state ConditionElse makes sure that subsequential elses are ignored. // That's braindead, but qmake is like that. - if (m_prevCondition == ConditionTrue) - m_condition = ConditionElse; - else if (m_prevCondition == ConditionFalse) - m_condition = ConditionTrue; - } else if (m_condition == ConditionFalse) { + if (m_sts.prevCondition == ConditionTrue) + m_sts.condition = ConditionElse; + else if (m_sts.prevCondition == ConditionFalse) + m_sts.condition = ConditionTrue; + } else if (m_sts.condition == ConditionFalse) { if (isActiveConfig(cond->text(), true) ^ m_invertNext) - m_condition = ConditionTrue; + m_sts.condition = ConditionTrue; } } m_invertNext = false; @@ -843,7 +849,7 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value) bool ProFileEvaluator::Private::visitProFunction(ProFunction *func) { - if (!m_updateCondition || m_condition == ConditionFalse) { + if (!m_sts.updateCondition || m_sts.condition == ConditionFalse) { QString text = func->text(); int lparen = text.indexOf(QLatin1Char('(')); int rparen = text.lastIndexOf(QLatin1Char(')')); @@ -853,7 +859,7 @@ bool ProFileEvaluator::Private::visitProFunction(ProFunction *func) m_lineNo = func->lineNumber(); bool result = evaluateConditionalFunction(funcName.trimmed(), arguments); if (!m_skipLevel && (result ^ m_invertNext)) - m_condition = ConditionTrue; + m_sts.condition = ConditionTrue; } m_invertNext = false; return true; diff --git a/tools/linguist/shared/profileevaluator.h b/tools/linguist/shared/profileevaluator.h index 688022b..88b7590 100644 --- a/tools/linguist/shared/profileevaluator.h +++ b/tools/linguist/shared/profileevaluator.h @@ -95,6 +95,9 @@ public: private: class Private; Private *d; + + // This doesn't help gcc 3.3 ... + template<typename T> friend class QTypeInfo; }; QT_END_NAMESPACE |