1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the porting application of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
28
#ifndef PREPROCESSORCONTROL_H
29
#define PREPROCESSORCONTROL_H
31
#include <QStringList>
33
#include "tokenengine.h"
34
#include "tokenizer.h"
36
#include "rpptreeevaluator.h"
42
IncludeFiles(const QString &basePath, const QStringList &searchPaths);
43
QString quoteLookup(const QString ¤tFile,
44
const QString &includeFile)const;
45
QString angleBracketLookup(const QString &includeFile) const;
46
QString resolve(const QString &filename) const;
48
QString searchIncludePaths(const QString &includeFile)const;
49
QStringList m_searchPaths;
53
class PreprocessorCache: public QObject
58
TokenEngine::TokenContainer sourceTokens(const QString &filename);
59
Rpp::Source *sourceTree(const QString &filename);
60
bool containsSourceTokens(const QString &filename);
61
bool containsSourceTree(const QString &filename);
63
void error(QString type, QString text);
64
void readFile(QByteArray &contents, QString filename);
66
QByteArray readFile(const QString & filename) const;
67
Tokenizer m_tokenizer;
68
Rpp::RppLexer m_lexer;
69
Rpp::Preprocessor m_preprocessor;
70
TypedPool<Rpp::Item> m_memoryPool;
71
QHash<QString, Rpp::Source *> m_sourceTrees;
72
QHash<QString, TokenEngine::TokenContainer> m_sourceTokens;
75
class PreprocessorController: public QObject
79
PreprocessorController(IncludeFiles includefiles,
80
PreprocessorCache &preprocessorCache,
81
QStringList preLoadFilesFilenames = QStringList());
83
TokenEngine::TokenSectionSequence evaluate(const QString &filename, Rpp::DefineMap *activedefinitions);
85
void includeSlot(Rpp::Source *&includee, const Rpp::Source *includer,
86
const QString &filename, Rpp::RppTreeEvaluator::IncludeType includeType);
87
void readFile(QByteArray &contents, QString filename);
89
void error(QString type, QString text);
91
IncludeFiles m_includeFiles;
92
Rpp::RppTreeEvaluator m_rppTreeEvaluator;
93
PreprocessorCache &m_preprocessorCache;
94
QHash<QString, QByteArray> m_preLoadFiles;
97
Rpp::DefineMap *defaultMacros(PreprocessorCache &preprocessorCache);
99
class StandardOutErrorHandler : public QObject
103
void error(QString type, QString text);
106
class RppPreprocessor
109
RppPreprocessor(QString basePath, QStringList includePaths, QStringList preLoadFilesFilename = QStringList());
111
TokenEngine::TokenSectionSequence evaluate(const QString &filename);
113
IncludeFiles m_includeFiles;
114
PreprocessorCache m_cache;
115
Rpp::DefineMap *m_activeDefinitions;
116
PreprocessorController m_controller;
117
StandardOutErrorHandler m_errorHandler;