source: trunk/tools/porting/src/preprocessorcontrol.h@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 4.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the qt3to4 porting application of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef PREPROCESSORCONTROL_H
43#define PREPROCESSORCONTROL_H
44
45#include "tokenengine.h"
46#include "tokenizer.h"
47#include "rpplexer.h"
48#include "rpptreeevaluator.h"
49#include "rpp.h"
50#include <QString>
51#include <QStringList>
52#include <QHash>
53
54QT_BEGIN_NAMESPACE
55
56class IncludeFiles
57{
58public:
59 IncludeFiles(const QString &basePath, const QStringList &searchPaths);
60 QString quoteLookup(const QString &currentFile,
61 const QString &includeFile)const;
62 QString angleBracketLookup(const QString &includeFile) const;
63 QString resolve(const QString &filename) const;
64private:
65 QString searchIncludePaths(const QString &includeFile)const;
66 QStringList m_searchPaths;
67 QString m_basePath;
68};
69
70class PreprocessorCache: public QObject
71{
72Q_OBJECT
73public:
74 PreprocessorCache();
75 TokenEngine::TokenContainer sourceTokens(const QString &filename);
76 Rpp::Source *sourceTree(const QString &filename);
77 bool containsSourceTokens(const QString &filename);
78 bool containsSourceTree(const QString &filename);
79signals:
80 void error(QString type, QString text);
81 void readFile(QByteArray &contents, QString filename);
82private:
83 QByteArray readFile(const QString & filename) const;
84 Tokenizer m_tokenizer;
85 Rpp::RppLexer m_lexer;
86 Rpp::Preprocessor m_preprocessor;
87 TypedPool<Rpp::Item> m_memoryPool;
88 QHash<QString, Rpp::Source *> m_sourceTrees;
89 QHash<QString, TokenEngine::TokenContainer> m_sourceTokens;
90};
91
92class PreprocessorController: public QObject
93{
94Q_OBJECT
95public:
96 PreprocessorController(IncludeFiles includefiles,
97 PreprocessorCache &preprocessorCache,
98 QStringList preLoadFilesFilenames = QStringList());
99
100 TokenEngine::TokenSectionSequence evaluate(const QString &filename, Rpp::DefineMap *activedefinitions);
101public slots:
102 void includeSlot(Rpp::Source *&includee, const Rpp::Source *includer,
103 const QString &filename, Rpp::RppTreeEvaluator::IncludeType includeType);
104 void readFile(QByteArray &contents, QString filename);
105signals:
106 void error(QString type, QString text);
107private:
108 IncludeFiles m_includeFiles;
109 Rpp::RppTreeEvaluator m_rppTreeEvaluator;
110 PreprocessorCache &m_preprocessorCache;
111 QHash<QString, QByteArray> m_preLoadFiles;
112};
113
114Rpp::DefineMap *defaultMacros(PreprocessorCache &preprocessorCache);
115
116class StandardOutErrorHandler : public QObject
117{
118Q_OBJECT
119public slots:
120 void error(QString type, QString text);
121};
122
123class RppPreprocessor
124{
125public:
126 RppPreprocessor(QString basePath, QStringList includePaths, QStringList preLoadFilesFilename = QStringList());
127 ~RppPreprocessor();
128 TokenEngine::TokenSectionSequence evaluate(const QString &filename);
129private:
130 IncludeFiles m_includeFiles;
131 PreprocessorCache m_cache;
132 Rpp::DefineMap *m_activeDefinitions;
133 PreprocessorController m_controller;
134 StandardOutErrorHandler m_errorHandler;
135};
136
137QT_END_NAMESPACE
138
139#endif
Note: See TracBrowser for help on using the repository browser.