Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
preprocessor.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef PREPROCESSOR_H
5#define PREPROCESSOR_H
6
7#include "parser.h"
8#include <qlist.h>
9#include <qset.h>
10#include <stdio.h>
11
13
22
25
26class QFile;
27
28// Cached result of resolving an include: the canonical path of the resolved
29// file (null if not found) and the index into the include search list where it
30// was found (-1 if resolved relative to the including file, or not found). The
31// index lets #include_next resume the search *after* the directory the current
32// file was found in.
38
39class Preprocessor : public Parser
40{
41public:
43 static bool preprocessOnly;
48 QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo,
49 qsizetype *foundIndex = nullptr);
50 QByteArray resolveIncludeNext(const QByteArray &filename, qsizetype startIndex,
51 qsizetype *foundIndex = nullptr);
52 Symbols preprocessed(const QByteArray &filename, QFile *device);
53
55
56 void skipUntilEndif();
57 bool skipBranch();
58
59 void substituteUntilNewline(Symbols &substituted);
60 static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName);
61 static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand,
62 qsizetype &index, int lineNum, bool one,
64
66
68 static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode mode = TokenizeCpp);
69
70 void setDebugIncludes(bool value);
71
72private:
73 void until(Token);
74
75 void preprocess(const QByteArray &filename, Symbols &preprocessed, qsizetype includeDirIndex = -1);
76 // Parallel to Parser::currentFilenames: for each file currently being
77 // preprocessed, the index into the include search list where it was found
78 // (-1 if not found via the list). Used to implement #include_next.
80 // The index to start searching from for an #include_next / __has_include_next
81 // in the current file: one past the directory it was found in, or (warning)
82 // the start of the path when it was not found via the include path.
83 qsizetype includeNextStartIndex();
84 bool debugIncludes = false;
85};
86
87QT_END_NAMESPACE
88
89#endif // PREPROCESSOR_H
Definition moc.h:226
void parse()
Definition moc.cpp:702
bool requireCompleteTypes
Definition moc.h:238
void generate(FILE *out, FILE *jsonOutput)
Definition moc.cpp:1215
bool noInclude
Definition moc.h:236
QByteArray resolveIncludeNext(const QByteArray &filename, qsizetype startIndex, qsizetype *foundIndex=nullptr)
void setDebugIncludes(bool value)
void parseDefineArguments(Macro *m)
void skipUntilEndif()
Symbols preprocessed(const QByteArray &filename, QFile *device)
void substituteUntilNewline(Symbols &substituted)
QList< QByteArray > frameworks
QHash< QByteArray, IncludeResolution > nonlocalIncludePathResolutionCache
static bool preprocessOnly
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo, qsizetype *foundIndex=nullptr)
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
static Symbols tokenize(const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
@ PreparePreprocessorStatement
@ TokenizePreprocessorStatement
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
Combined button and popup list for selecting options.
QHash< MacroName, Macro > Macros
SubArray MacroName
#define qPrintable(string)
Definition qstring.h:1705
#define QStringLiteral(str)
Definition qstring.h:1847
static QByteArray combinePath(const QString &infile, const QString &outfile)
Definition main.cpp:40
static bool hasNext(const Symbols &symbols, int i)
Definition main.cpp:78
static const Symbol & next(const Symbols &symbols, int &i)
Definition main.cpp:81
int runMoc(int argc, char **argv)
Definition main.cpp:170
static auto openFileForWriting(const QString &name)
Definition main.cpp:62
void error(const char *msg="Invalid argument")
Definition main.cpp:56
static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments, bool &hasOptionFiles)
Definition main.cpp:138
QByteArray composePreprocessorOutput(const Symbols &symbols)
Definition main.cpp:85
int main(int argc, char *argv[])
[ctor_close]
qsizetype foundIndex
Simple structure used by the Doc and DocParser classes.
Symbols symbols
bool isVariadic
bool isFunction
Symbols arguments
Token token
Definition symbols.h:58
int lineNum
Definition symbols.h:57
QList< Symbol > Symbols
Definition symbols.h:75