Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
Preprocessor Class Reference

#include <preprocessor.h>

+ Inheritance diagram for Preprocessor:
+ Collaboration diagram for Preprocessor:

Public Types

enum  TokenizeMode {
  TokenizeCpp , TokenizePreprocessor , PreparePreprocessorStatement , TokenizePreprocessorStatement ,
  TokenizeInclude , PrepareDefine , TokenizeDefine
}
 

Public Member Functions

 Preprocessor ()
 
QByteArray resolveInclude (const QByteArray &filename, const QByteArray &relativeTo)
 
Symbols preprocessed (const QByteArray &filename, QFile *device)
 
void parseDefineArguments (Macro *m)
 
void skipUntilEndif ()
 
bool skipBranch ()
 
void substituteUntilNewline (Symbols &substituted)
 
int evaluateCondition ()
 
void setDebugIncludes (bool value)
 
- Public Member Functions inherited from Parser
 Parser ()
 
bool hasNext () const
 
Token next ()
 
Token peek ()
 
bool test (Token)
 
void next (Token)
 
void next (Token, const char *msg)
 
void prev ()
 
Token lookup (int k=1)
 
const Symbolsymbol_lookup (int k=1)
 
Token token ()
 
QByteArray lexem ()
 
QByteArray unquotedLexem ()
 
const Symbolsymbol ()
 
const SymbolsymbolAt (qsizetype idx)
 
Q_NORETURN void error (const Symbol &symbol)
 
Q_NORETURN void error (const char *msg=nullptr)
 
void warning (const char *=nullptr)
 
void warning (const Symbol &sym, QByteArrayView msg)
 
void note (const char *=nullptr)
 
void defaultErrorMsg (const Symbol &sym)
 
void printMsg (QByteArrayView formatStringSuffix, QByteArrayView msg, const Symbol &sym)
 
 Parser (const QString &provider)
 
void addIncludeDirs (const QStringList &list)
 
QString resolveInclude (const QString &filename)
 
void addIncludesRecursive (const QString &filename, QStringList &includes)
 
QStringList findEnumValues (const QString &name, const QStringList &includes)
 
void parseParamReplace (const QString &data, qsizetype offset, const QString &name)
 
void parseInstrument (const QString &data, qsizetype offset)
 
void parsePoint (const QString &data, qsizetype offset)
 
void parsePrefix (const QString &data, qsizetype offset)
 
void parseMetadata (const QString &data, qsizetype offset, const QStringList &includes)
 
int lineNumber (qsizetype offset) const
 
void parse (QIODevice &input, const QString &name)
 
void write (QIODevice &input) const
 
bool isEmpty () const
 

Static Public Member Functions

static Symbols macroExpandIdentifier (Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
 
static void macroExpand (Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
 
static Symbols tokenize (const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
 

Public Attributes

QList< QByteArrayframeworks
 
QSet< QByteArraypreprocessedIncludes
 
QHash< QByteArray, QByteArraynonlocalIncludePathResolutionCache
 
Macros macros
 
- Public Attributes inherited from Parser
Symbols symbols
 
qsizetype index
 
bool displayWarnings
 
bool displayNotes
 
QList< IncludePathincludes
 
std::stack< QByteArray, QByteArrayListcurrentFilenames
 
QList< Functionm_functions
 
QList< Pointm_points
 
QList< Replacem_replaces
 
QList< QStringm_prefixes
 
QList< QStringm_metadata
 
QList< LineNumberm_offsets
 
QList< QStringm_includeDirs
 
QString m_provider
 

Static Public Attributes

static bool preprocessOnly = false
 

Detailed Description

Definition at line 32 of file preprocessor.h.

Member Enumeration Documentation

◆ TokenizeMode

Enumerator
TokenizeCpp 
TokenizePreprocessor 
PreparePreprocessorStatement 
TokenizePreprocessorStatement 
TokenizeInclude 
PrepareDefine 
TokenizeDefine 

Definition at line 57 of file preprocessor.h.

Constructor & Destructor Documentation

◆ Preprocessor()

Preprocessor::Preprocessor ( )
inline

Definition at line 35 of file preprocessor.h.

Member Function Documentation

◆ evaluateCondition()

int Preprocessor::evaluateCondition ( )

Definition at line 951 of file preprocessor.cpp.

References Parser::currentFilenames, substituteUntilNewline(), Parser::symbols, and PP_Expression::value().

+ Here is the call graph for this function:

◆ macroExpand()

void Preprocessor::macroExpand ( Symbols into,
Preprocessor that,
const Symbols toExpand,
qsizetype index,
int  lineNum,
bool  one,
const QSet< QByteArray > &  excludeSymbols = QSet<QByteArray>() 
)
static

Definition at line 515 of file preprocessor.cpp.

References SafeSymbols::excludedSymbols, SafeSymbols::expandedMacro, Parser::index, SafeSymbols::index, QByteArray::isEmpty(), QList< T >::isEmpty(), macroExpandIdentifier(), QList< T >::size(), Parser::symbols, and SafeSymbols::symbols.

Referenced by macroExpandIdentifier(), and substituteUntilNewline().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macroExpandIdentifier()

Symbols Preprocessor::macroExpandIdentifier ( Preprocessor that,
SymbolStack symbols,
int  lineNum,
QByteArray macroName 
)
static

◆ parseDefineArguments()

void Preprocessor::parseDefineArguments ( Macro m)

Definition at line 1277 of file preprocessor.cpp.

References arg, arguments, QByteArray::constData(), QListSpecialMethodsBase< T >::contains(), error, Parser::hasNext(), is_identifier(), Parser::lexem(), Parser::next(), PP_COMMA, PP_IDENTIFIER, PP_RPAREN, PP_WHITESPACE, QByteArray::size(), Parser::symbol(), and Parser::test().

+ Here is the call graph for this function:

◆ preprocessed()

Symbols Preprocessor::preprocessed ( const QByteArray filename,
QFile device 
)

Definition at line 1235 of file preprocessor.cpp.

References cleaned(), file, j, Parser::lexem(), mergeStringLiterals(), readOrMapFile(), QList< T >::size(), QFile::size(), Parser::symbols, Parser::token(), and tokenize().

Referenced by main(), and runMoc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveInclude()

QByteArray Preprocessor::resolveInclude ( const QByteArray filename,
const QByteArray relativeTo 
)

Definition at line 1051 of file preprocessor.cpp.

References QFileInfo::canonicalFilePath(), dir, QHash< Key, T >::end(), QFileInfo::exists(), fi, QHash< Key, T >::find(), QString::fromLocal8Bit(), Parser::includes, QHash< Key, T >::insert(), QFileInfo::isDir(), QByteArray::isEmpty(), it, nonlocalIncludePathResolutionCache, searchIncludePaths(), QFileInfo::setFile(), and QString::toLocal8Bit().

Referenced by runMoc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDebugIncludes()

void Preprocessor::setDebugIncludes ( bool  value)

Definition at line 1331 of file preprocessor.cpp.

Referenced by runMoc().

+ Here is the caller graph for this function:

◆ skipBranch()

bool Preprocessor::skipBranch ( )

Definition at line 106 of file preprocessor.cpp.

References QList< T >::at(), Parser::index, QList< T >::size(), skipUntilEndif(), Parser::symbols, and QCss::Symbol::token.

+ Here is the call graph for this function:

◆ skipUntilEndif()

void Preprocessor::skipUntilEndif ( )

Definition at line 89 of file preprocessor.cpp.

References QList< T >::at(), Parser::index, QList< T >::size(), skipUntilEndif(), Parser::symbols, and QCss::Symbol::token.

Referenced by skipBranch(), and skipUntilEndif().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ substituteUntilNewline()

void Preprocessor::substituteUntilNewline ( Symbols substituted)

Definition at line 707 of file preprocessor.cpp.

References QHash< Key, T >::contains(), Parser::hasNext(), macroExpand(), macros, Parser::next(), PP_IDENTIFIER, PP_LPAREN, PP_NEWLINE, PP_RPAREN, Parser::symbol(), Parser::symbols, Parser::test(), Parser::token(), and Symbol::token.

Referenced by evaluateCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tokenize()

Member Data Documentation

◆ frameworks

QList<QByteArray> Preprocessor::frameworks

Definition at line 37 of file preprocessor.h.

◆ macros

Macros Preprocessor::macros

Definition at line 40 of file preprocessor.h.

Referenced by macroExpandIdentifier(), main(), runMoc(), and substituteUntilNewline().

◆ nonlocalIncludePathResolutionCache

QHash<QByteArray, QByteArray> Preprocessor::nonlocalIncludePathResolutionCache

Definition at line 39 of file preprocessor.h.

Referenced by resolveInclude().

◆ preprocessedIncludes

QSet<QByteArray> Preprocessor::preprocessedIncludes

Definition at line 38 of file preprocessor.h.

Referenced by runMoc().

◆ preprocessOnly

bool Preprocessor::preprocessOnly = false
static

Definition at line 36 of file preprocessor.h.

Referenced by runMoc(), and tokenize().


The documentation for this class was generated from the following files: