Commit ed69c399 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

More cleanup

parent 2553e250
...@@ -139,7 +139,6 @@ QString TypeOfExpression::preprocessedExpression(const QString &expression, ...@@ -139,7 +139,6 @@ QString TypeOfExpression::preprocessedExpression(const QString &expression,
&env, &processed); &env, &processed);
const QByteArray code = expression.toUtf8(); const QByteArray code = expression.toUtf8();
Preprocessor preproc(0, env); Preprocessor preproc(0, env);
QByteArray preprocessedCode; const QByteArray preprocessedCode = preproc("<expression>", code);
preproc("<expression>", code, &preprocessedCode);
return QString::fromUtf8(preprocessedCode.constData(), preprocessedCode.size()); return QString::fromUtf8(preprocessedCode.constData(), preprocessedCode.size());
} }
...@@ -485,25 +485,25 @@ QByteArray Preprocessor::operator()(const QByteArray &filename, ...@@ -485,25 +485,25 @@ QByteArray Preprocessor::operator()(const QByteArray &filename,
const QByteArray &source) const QByteArray &source)
{ {
QByteArray preprocessed; QByteArray preprocessed;
operator()(filename, source, &preprocessed); preprocess(filename, source, &preprocessed);
return preprocessed; return preprocessed;
} }
QByteArray Preprocessor::operator()(const QByteArray &source) QByteArray Preprocessor::operator()(const QByteArray &source)
{ {
QByteArray preprocessed; QByteArray preprocessed;
operator()(source, &preprocessed); preprocess(source, &preprocessed);
return preprocessed; return preprocessed;
} }
void Preprocessor::operator () (const QByteArray &filename, void Preprocessor::preprocess(const QByteArray &filename,
const QByteArray &source, const QByteArray &source,
QByteArray *result) QByteArray *result)
{ {
const QByteArray previousFile = env.currentFile; const QByteArray previousFile = env.currentFile;
env.currentFile = filename; env.currentFile = filename;
operator () (source, result); preprocess(source, result);
env.currentFile = previousFile; env.currentFile = previousFile;
} }
...@@ -523,7 +523,7 @@ Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source ...@@ -523,7 +523,7 @@ Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source
return state; return state;
} }
void Preprocessor::operator()(const QByteArray &source, QByteArray *result) void Preprocessor::preprocess(const QByteArray &source, QByteArray *result)
{ {
pushState(createStateFromSource(source)); pushState(createStateFromSource(source));
......
...@@ -186,14 +186,14 @@ namespace CPlusPlus { ...@@ -186,14 +186,14 @@ namespace CPlusPlus {
QByteArray operator()(const QByteArray &source); QByteArray operator()(const QByteArray &source);
void operator()(const QByteArray &filename, private:
void preprocess(const QByteArray &filename,
const QByteArray &source, const QByteArray &source,
QByteArray *result); QByteArray *result);
void operator()(const QByteArray &source, void preprocess(const QByteArray &source,
QByteArray *result); QByteArray *result);
private:
void resetIfLevel(); void resetIfLevel();
bool testIfLevel(); bool testIfLevel();
int skipping() const; int skipping() const;
......
...@@ -202,7 +202,7 @@ protected: ...@@ -202,7 +202,7 @@ protected:
private: private:
QPointer<CppModelManager> m_modelManager; QPointer<CppModelManager> m_modelManager;
Environment env; Environment env;
Preprocessor m_proc; Preprocessor preprocess;
QStringList m_includePaths; QStringList m_includePaths;
QStringList m_systemIncludePaths; QStringList m_systemIncludePaths;
QMap<QString, QByteArray> m_workingCopy; QMap<QString, QByteArray> m_workingCopy;
...@@ -220,7 +220,7 @@ private: ...@@ -220,7 +220,7 @@ private:
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager) CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
: snapshot(modelManager->snapshot()), : snapshot(modelManager->snapshot()),
m_modelManager(modelManager), m_modelManager(modelManager),
m_proc(this, env) preprocess(this, env)
{ } { }
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy) void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
...@@ -506,8 +506,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, ...@@ -506,8 +506,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
Document::Ptr previousDoc = switchDocument(doc); Document::Ptr previousDoc = switchDocument(doc);
QByteArray preprocessedCode; const QByteArray preprocessedCode = preprocess(fileName.toUtf8(), contents);
m_proc(fileName.toUtf8(), contents, &preprocessedCode);
doc->setSource(preprocessedCode); doc->setSource(preprocessedCode);
doc->tokenize(); doc->tokenize();
......
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