35 bool takeLine = (*
data ==
'#');
36 if (*
data ==
'%' && *(
data+1) ==
':') {
48 if (*(
data + 1) ==
'\r') {
58 }
else if (*
data ==
'\r' && *(
data + 1) ==
'\n') {
147 if (
static_cast<signed char>(*
data) < 0) {
155 else if (!
state || nextindex)
168 if (
token == NOTOKEN) {
180 if (
token > SPECIAL_TREATMENT_MARK) {
184 token = STRING_LITERAL;
205 && *(
data-2)!=
'\\')))
209 token = CHARACTER_LITERAL;
220 token = INTEGER_LITERAL;
231 token = FLOATING_LITERAL;
234 case FLOATING_LITERAL:
272 const char *rewind =
data;
297 while (*
data && (*(
data-1) !=
'/' || *(
data-2) !=
'*')) {
320#ifdef USE_LEXEM_STORE
322 &&
token != IDENTIFIER
323 &&
token != STRING_LITERAL
324 &&
token != FLOATING_LITERAL
325 &&
token != INTEGER_LITERAL)
341 if (
static_cast<signed char>(*
data) < 0) {
349 else if (!
state || nextindex)
388 && *(
data-2)!=
'\\')))
458 while (*
data && (*(
data-1) !=
'/' || *(
data-2) !=
'*')) {
479 const char *rewind =
data;
500#ifdef USE_LEXEM_STORE
566 *macroName =
s.lexem();
572 bool haveSpace =
false;
598 }
else if (
t ==
PP_COMMA && nesting == 0) {
609 that->
error(
"missing ')' in macro usage");
628 if (
s.token == HASH ||
s.token == PP_HASHHASH) {
629 mode = (
s.token == HASH ? Hash : HashHash);
636 if (
it == lastSym || std::next(
it)->token != PP_HASHHASH) {
646 }
else if (
mode == Hash) {
648 that->
error(
"'#' is not followed by a macro parameter");
651 that->
error(
"Macro invoked with too few parameters for a use of '#'");
658 stringified += sym.lexem();
660 stringified.
replace(
'"',
"\\\"");
663 expansion +=
Symbol(lineNum, STRING_LITERAL, stringified);
664 }
else if (
mode == HashHash){
665 if (
s.token == WHITESPACE)
674 if (
arg.size() == 0) {
700 that->
error(
"'#' or '##' found at the end of a macro argument");
713 }
else if (
token == PP_DEFINED) {
717 definedOrNotDefined.
token =
macros.
contains(definedOrNotDefined)? PP_MOC_TRUE : PP_MOC_FALSE;
718 substituted += definedOrNotDefined;
760 return value ? alt1 : alt2;
882 return remainder ?
value % remainder : 0;
887 return div ?
value / div : 0;
905 return ~unary_expression();
958 return expression.
value();
964 char *rawInput =
reinterpret_cast<char*
>(
file->
map(0,
size));
971 for (Symbols::iterator
i = symbols.
begin();
i != symbols.
end(); ++
i) {
972 if (
i->token == STRING_LITERAL) {
974 qsizetype literalsLength = mergeSymbol->len;
975 while (++
i != symbols.
end() &&
i->token == STRING_LITERAL)
976 literalsLength +=
i->len - 2;
978 if (literalsLength != mergeSymbol->len) {
979 QByteArray mergeSymbolOriginalLexem = mergeSymbol->unquotedLexem();
980 QByteArray &mergeSymbolLexem = mergeSymbol->lex;
981 mergeSymbolLexem.
resize(0);
982 mergeSymbolLexem.
reserve(literalsLength);
983 mergeSymbolLexem.
append(
'"');
984 mergeSymbolLexem.
append(mergeSymbolOriginalLexem);
985 for (Symbols::iterator
j = mergeSymbol + 1;
j !=
i; ++
j)
986 mergeSymbolLexem.
append(
j->lex.constData() +
j->from + 1,
j->len - 2);
987 mergeSymbolLexem.
append(
'"');
988 mergeSymbol->len = mergeSymbol->lex.
size();
989 mergeSymbol->from = 0;
990 i = symbols.
erase(mergeSymbol + 1,
i);
992 if (
i == symbols.
end())
1000 const bool debugIncludes)
1005 fprintf(stderr,
"debug-includes: searching for '%s'\n", include.
constData());
1012 if (
p.isFrameworkPath) {
1024 fprintf(stderr,
"debug-includes: considering '%s'\n", candidate.constData());
1037 fprintf(stderr,
"debug-includes: can't find '%s'\n", include.
constData());
1045 fprintf(stderr,
"debug-includes: found '%s'\n",
result.constData());
1105 if (
input.isEmpty())
1153 if (
token == WHITESPACE) {
1154 if (lastToken == PP_HASH || lastToken == HASH ||
1155 lastToken == PP_HASHHASH ||
1156 lastToken == WHITESPACE)
1158 }
else if (
token == PP_HASHHASH) {
1160 lastToken == WHITESPACE)
1174 error(
"'##' cannot appear at either end of a macro expansion");
1201 if (
test(PP_ELIF)) {
1221 sym.
token = IDENTIFIER;
1223 sym.
token = (
token == SIGNALS ? Q_SIGNALS_TOKEN : Q_SLOTS_TOKEN);
1239 if (
input.isEmpty())
1251 fprintf(stderr,
"line %d: %s(%s)\n",
1263 preprocess(filename,
result);
1268 fprintf(stderr,
"line %d: %s(%s)\n",
1288 m->isVariadic =
true;
1292 error(
"missing ')' in macro argument list");
1295 error(
"Unexpected character in macro argument list.");
1301 error(
"Duplicate macro parameter.");
1310 if (
lexem() ==
"...") {
1313 m->isVariadic =
true;
1316 error(
"missing ')' in macro argument list");
1319 error(
"Unexpected character in macro argument list.");
1325void Preprocessor::until(
Token t)
1333 debugIncludes =
value;
int relational_expression()
int exclusive_OR_expression()
bool unary_expression_lookup()
int logical_OR_expression()
int equality_expression()
int logical_AND_expression()
int additive_expression()
int multiplicative_expression()
int conditional_expression()
bool primary_expression_lookup()
int inclusive_OR_expression()
QList< IncludePath > includes
Q_NORETURN void error(const Symbol &symbol)
std::stack< QByteArray, QByteArrayList > currentFilenames
QByteArray unquotedLexem()
QSet< QByteArray > preprocessedIncludes
void setDebugIncludes(bool value)
void parseDefineArguments(Macro *m)
QHash< QByteArray, QByteArray > nonlocalIncludePathResolutionCache
Symbols preprocessed(const QByteArray &filename, QFile *device)
void substituteUntilNewline(Symbols &substituted)
static bool preprocessOnly
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo)
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
QByteArray & prepend(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
int toInt(bool *ok=nullptr, int base=10) const
Returns the byte array converted to an int using base base, which is ten by default.
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool startsWith(QByteArrayView bv) const
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QByteArray left(qsizetype len) const
Returns a byte array that contains the first len bytes of this byte array.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
QByteArray mid(qsizetype index, qsizetype len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
QByteArray & replace(qsizetype index, qsizetype len, const char *s, qsizetype alen)
This is an overloaded member function, provided for convenience. It differs from the above function o...
uchar * map(qint64 offset, qint64 size, MemoryMapFlags flags=NoOptions)
Maps size bytes of the file into memory starting at offset.
void close() override
Calls QFileDevice::flush() and closes the file.
\inmodule QtCore \reentrant
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
QString filePath() const
Returns the file name, including the path (which may be absolute or relative).
bool exists() const
Returns true if the file exists; otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
qint64 size() const override
\reimp
bool remove(const Key &key)
Removes the item that has the key from the hash.
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
iterator erase(const_iterator begin, const_iterator end)
const_reference at(qsizetype i) const noexcept
const T & constFirst() const noexcept
void reserve(qsizetype size)
const_iterator cend() const noexcept
void append(parameter_type t)
const_iterator cbegin() const noexcept
iterator insert(const T &value)
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toLocal8Bit() const &
QSet< QString >::iterator it
QList< QVariant > arguments
bool is_ident_start(char s)
static const short keyword_trans[][128]
static const struct @480 keywords[]
bool is_identifier(const char *s, qsizetype len)
const char * skipQuote(const char *data)
Combined button and popup list for selecting options.
constexpr bool isAsciiDigit(char32_t c) noexcept
constexpr bool isHexDigit(char32_t c) noexcept
static const short pp_keyword_trans[][128]
static const struct @478 pp_keywords[]
static QByteArray readOrMapFile(QFile *file)
static void mergeStringLiterals(Symbols *_symbols)
static QByteArray searchIncludePaths(const QList< Parser::IncludePath > &includepaths, const QByteArray &include, const bool debugIncludes)
static QByteArray cleaned(const QByteArray &input)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static bool contains(const QJsonArray &haystack, unsigned needle)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLenum input
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QT_BEGIN_NAMESPACE typedef uchar * output
QFileInfo fi("c:/temp/foo")
[newstuff]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
bool contains(const AT &t) const noexcept
QSet< QByteArray > excludedSymbols
QByteArray unquotedLexem() const