diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 15 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.h | 2 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index f253c49995..14850b3e0c 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -529,7 +529,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso return symbols; } -Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &index, +void Preprocessor::macroExpand(Symbols *into, Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one, const QSet<QByteArray> &excludeSymbols) { SymbolStack symbols; @@ -539,16 +539,15 @@ Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &in sf.excludedSymbols = excludeSymbols; symbols.push(sf); - Symbols result; if (toExpand.isEmpty()) - return result; + return; for (;;) { QByteArray macro; Symbols newSyms = macroExpandIdentifier(that, symbols, lineNum, ¯o); if (macro.isEmpty()) { - result += newSyms; + *into += newSyms; } else { SafeSymbols sf; sf.symbols = newSyms; @@ -565,8 +564,6 @@ Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &in index = symbols.top().index; else index = toExpand.size(); - - return result; } @@ -653,7 +650,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym if (i == macro.symbols.size() - 1 || macro.symbols.at(i + 1).token != PP_HASHHASH) { Symbols arg = arguments.at(index); int idx = 1; - expansion += macroExpand(that, arg, idx, lineNum, false, symbols.excludeSymbols()); + macroExpand(&expansion, that, arg, idx, lineNum, false, symbols.excludeSymbols()); } else { expansion += arguments.at(index); } @@ -726,7 +723,7 @@ void Preprocessor::substituteUntilNewline(Symbols &substituted) while (hasNext()) { Token token = next(); if (token == PP_IDENTIFIER) { - substituted += macroExpand(this, symbols, index, symbol().lineNum, true); + macroExpand(&substituted, this, symbols, index, symbol().lineNum, true); } else if (token == PP_DEFINED) { bool braces = test(PP_LPAREN); next(PP_IDENTIFIER); @@ -1148,7 +1145,7 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) } case PP_IDENTIFIER: { // substitute macros - preprocessed += macroExpand(this, symbols, index, symbol().lineNum, true); + macroExpand(&preprocessed, this, symbols, index, symbol().lineNum, true); continue; } case PP_HASH: diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index 28691d316b..8d3bf4edbe 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -76,7 +76,7 @@ public: void substituteUntilNewline(Symbols &substituted); static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName); - static Symbols macroExpand(Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one, + static void macroExpand(Symbols *into, Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one, const QSet<QByteArray> &excludeSymbols = QSet<QByteArray>()); int evaluateCondition(); |