~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/porting/src/preprocessorcontrol.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the porting application of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
#ifndef PREPROCESSORCONTROL_H
 
29
#define PREPROCESSORCONTROL_H
 
30
#include <QString>
 
31
#include <QStringList>
 
32
#include <QHash>
 
33
#include "tokenengine.h"
 
34
#include "tokenizer.h"
 
35
#include "rpplexer.h"
 
36
#include "rpptreeevaluator.h"
 
37
#include "rpp.h"
 
38
 
 
39
class IncludeFiles
 
40
{
 
41
public:
 
42
    IncludeFiles(const QString &basePath, const QStringList &searchPaths);
 
43
    QString quoteLookup(const QString &currentFile,
 
44
                        const QString &includeFile)const;
 
45
    QString angleBracketLookup(const QString &includeFile) const;
 
46
    QString resolve(const QString &filename) const;
 
47
private:
 
48
    QString searchIncludePaths(const QString &includeFile)const;
 
49
    QStringList m_searchPaths;
 
50
    QString m_basePath;
 
51
};
 
52
 
 
53
class PreprocessorCache: public QObject
 
54
{
 
55
Q_OBJECT
 
56
public:
 
57
    PreprocessorCache();
 
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);
 
62
signals:
 
63
    void error(QString type, QString text);
 
64
    void readFile(QByteArray &contents, QString filename);
 
65
private:
 
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;
 
73
};
 
74
 
 
75
class PreprocessorController: public QObject
 
76
{
 
77
Q_OBJECT
 
78
public:
 
79
    PreprocessorController(IncludeFiles includefiles,
 
80
                           PreprocessorCache &preprocessorCache,
 
81
                           QStringList preLoadFilesFilenames = QStringList());
 
82
 
 
83
    TokenEngine::TokenSectionSequence evaluate(const QString &filename, Rpp::DefineMap *activedefinitions);
 
84
public slots:
 
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);
 
88
signals:
 
89
    void error(QString type, QString text);
 
90
private:
 
91
    IncludeFiles m_includeFiles;
 
92
    Rpp::RppTreeEvaluator m_rppTreeEvaluator;
 
93
    PreprocessorCache &m_preprocessorCache;
 
94
    QHash<QString, QByteArray> m_preLoadFiles;
 
95
};
 
96
 
 
97
Rpp::DefineMap *defaultMacros(PreprocessorCache &preprocessorCache);
 
98
 
 
99
class StandardOutErrorHandler : public QObject
 
100
{
 
101
Q_OBJECT
 
102
public slots:
 
103
    void error(QString type, QString text);
 
104
};
 
105
 
 
106
class RppPreprocessor
 
107
{
 
108
public:
 
109
    RppPreprocessor(QString basePath, QStringList includePaths, QStringList preLoadFilesFilename = QStringList());
 
110
    ~RppPreprocessor();
 
111
    TokenEngine::TokenSectionSequence evaluate(const QString &filename);
 
112
private:
 
113
    IncludeFiles m_includeFiles;
 
114
    PreprocessorCache m_cache;
 
115
    Rpp::DefineMap *m_activeDefinitions;
 
116
    PreprocessorController m_controller;
 
117
    StandardOutErrorHandler m_errorHandler;
 
118
};
 
119
 
 
120
 
 
121
#endif
 
122