Commit a49d1bff authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

add ProFile::tokPtr(): centralize nasty cast

parent 01c0b845
......@@ -457,9 +457,8 @@ uint ProFileEvaluator::Private::getBlockLen(const ushort *&tokPtr)
ProString ProFileEvaluator::Private::getStr(const ushort *&tokPtr)
{
const QString &str(m_current.pro->items());
uint len = *tokPtr++;
ProString ret(str, tokPtr - (const ushort *)str.constData(), len, NoHash);
ProString ret(m_current.pro->items(), tokPtr - m_current.pro->tokPtr(), len, NoHash);
tokPtr += len;
return ret;
}
......@@ -468,8 +467,7 @@ ProString ProFileEvaluator::Private::getHashStr(const ushort *&tokPtr)
{
uint hash = getBlockLen(tokPtr);
uint len = *tokPtr++;
const QString &str(m_current.pro->items());
ProString ret(str, tokPtr - (const ushort *)str.constData(), len, hash);
ProString ret(m_current.pro->items(), tokPtr - m_current.pro->tokPtr(), len, hash);
tokPtr += len;
return ret;
}
......@@ -914,8 +912,7 @@ void ProFileEvaluator::Private::visitProFunctionDef(
(tok == TokTestDef
? &m_functionDefs.testFunctions
: &m_functionDefs.replaceFunctions);
hash->insert(name, FunctionDef(m_current.pro,
tokPtr - (const ushort *)m_current.pro->items().constData()));
hash->insert(name, FunctionDef(m_current.pro, tokPtr - m_current.pro->tokPtr()));
}
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProLoop(
......@@ -1283,7 +1280,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
}
}
visitProBlock(pro, (const ushort *)pro->items().constData());
visitProBlock(pro, pro->tokPtr());
if (m_profileStack.count() == 1) {
if (m_parsePreAndPostFiles) {
......@@ -2420,7 +2417,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
if (!pro)
return ReturnFalse;
m_locationStack.push(m_current);
VisitReturn ret = visitProBlock(pro, (const ushort *)pro->items().constData());
VisitReturn ret = visitProBlock(pro, pro->tokPtr());
m_current = m_locationStack.pop();
pro->deref();
return ret;
......
......@@ -81,7 +81,7 @@ public:
return *this;
}
ProFile *pro() const { return m_pro; }
const ushort *tokPtr() const { return (const ushort *)m_pro->items().constData() + m_offset; }
const ushort *tokPtr() const { return m_pro->tokPtr() + m_offset; }
private:
ProFile *m_pro;
int m_offset;
......
......@@ -190,6 +190,7 @@ public:
QString directoryName() const { return m_directoryName; }
const QString &items() const { return m_proitems; }
QString *itemsRef() { return &m_proitems; }
const ushort *tokPtr() const { return (const ushort *)m_proitems.constData(); }
void ref() { m_refCount.ref(); }
void deref() { if (!m_refCount.deref()) delete this; }
......
......@@ -183,7 +183,7 @@ void ProWriter::addVarValues(ProFile *profile, QStringList *lines,
}
// Check if variable item exists as child of root item
const ushort *tokPtr = (const ushort *)profile->items().constData();
const ushort *tokPtr = profile->tokPtr();
int lineNo = 0;
QString tmp;
const ushort *lastXpr = 0;
......@@ -259,7 +259,7 @@ QStringList ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
QStringList notChanged = values;
QList<int> varLines;
findProVariables((const ushort *)profile->items().constData(), vars, &varLines);
findProVariables(profile->tokPtr(), vars, &varLines);
QStringList valuesToFind;
if (valuesAreFiles) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment