diff options
author | Ahmad Samir <[email protected]> | 2023-05-23 16:52:27 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2023-06-20 07:43:19 +0000 |
commit | ce8dd984043b00a4238807ae31d18f54b285db8c (patch) | |
tree | 71f8e4e123251eadd4bc4f720640c9c463ac27c0 | |
parent | 1a3305114618c9e69b19f48c82b74cc65cc39eea (diff) |
Moc: port to qsizetype
Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
(cherry picked from commit 2271ee6b4b5b89a5f77c4260333921bd9c3e91af)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r-- | src/tools/moc/moc.cpp | 12 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 6 | ||||
-rw-r--r-- | src/tools/moc/parser.h | 4 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 10 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.h | 5 | ||||
-rw-r--r-- | src/tools/moc/symbols.h | 2 |
6 files changed, 20 insertions, 19 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 0dfe2d77a5d..52dbc73dfb5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -624,7 +624,7 @@ void Moc::parse() Token t = next(); switch (t) { case NAMESPACE: { - int rewind = index; + qsizetype rewind = index; if (test(IDENTIFIER)) { QByteArray nsName = lexem(); QByteArrayList nested; @@ -927,7 +927,7 @@ void Moc::parse() default: FunctionDef funcDef; funcDef.access = access; - int rewind = index--; + qsizetype rewind = index--; if (parseMaybeFunction(&def, &funcDef)) { if (funcDef.isConstructor) { if ((access == FunctionDef::Public) && funcDef.isInvokable) { @@ -1708,7 +1708,7 @@ void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access) QByteArray Moc::lexemUntil(Token target) { - int from = index; + qsizetype from = index; until(target); QByteArray s; while (from <= index) { @@ -1744,7 +1744,7 @@ bool Moc::until(Token target) { //when searching commas within the default argument, we should take care of template depth (anglecount) // unfortunately, we do not have enough semantic information to know if '<' is the operator< or // the beginning of a template type. so we just use heuristics. - int possible = -1; + qsizetype possible = -1; while (index < symbols.size()) { Token t = symbols.at(index++).token; @@ -1879,7 +1879,7 @@ void Moc::checkProperties(ClassDef *cdef) } if (p.read.isEmpty() && p.member.isEmpty() && p.bind.isEmpty()) { - const int rewind = index; + const qsizetype rewind = index; if (p.location >= 0) index = p.location; QByteArray msg = "Property declaration " + p.name + " has neither an associated QProperty<> member" @@ -1936,7 +1936,7 @@ void Moc::checkProperties(ClassDef *cdef) cdef->nonClassSignalList << p.notify; p.notifyId = -1 - cdef->nonClassSignalList.size(); } else { - p.notifyId = -2 - index; + p.notifyId = int(-2 - index); } } } diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 94d13916b86..01d39bc4592 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -118,7 +118,7 @@ struct PropertyDef bool required = false; int relativeIndex = -1; // property index in current metaobject - int location = -1; // token index, used for error reporting + qsizetype location = -1; // token index, used for error reporting QJsonObject toJson() const; }; @@ -148,8 +148,8 @@ struct BaseDef { QMap<QByteArray, bool> enumDeclarations; QList<EnumDef> enumList; QMap<QByteArray, QByteArray> flagAliases; - int begin = 0; - int end = 0; + qsizetype begin = 0; + qsizetype end = 0; }; struct ClassDef : BaseDef { diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h index dc86cdec73d..2546370cb08 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -15,7 +15,7 @@ class Parser public: Parser():index(0), displayWarnings(true), displayNotes(true) {} Symbols symbols; - int index; + qsizetype index; bool displayWarnings; bool displayNotes; @@ -62,7 +62,7 @@ inline bool Parser::test(Token token) inline Token Parser::lookup(int k) { - const int l = index - 1 + k; + const qsizetype l = index - 1 + k; return l < symbols.size() ? symbols.at(l).token : NOTOKEN; } diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 36e6b742708..dc040d3bb7b 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -510,7 +510,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso return symbols; } -void Preprocessor::macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, int &index, +void Preprocessor::macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet<QByteArray> &excludeSymbols) { SymbolStack symbols; @@ -630,7 +630,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym // each argument undoergoes macro expansion if it's not used as part of a # or ## if (i == macro.symbols.size() - 1 || macro.symbols.at(i + 1).token != PP_HASHHASH) { Symbols arg = arguments.at(index); - int idx = 1; + qsizetype idx = 1; macroExpand(&expansion, that, arg, idx, lineNum, false, symbols.excludeSymbols()); } else { expansion += arguments.at(index); @@ -1099,7 +1099,7 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) continue; Symbols saveSymbols = symbols; - int saveIndex = index; + qsizetype saveIndex = index; // phase 1: get rid of backslash-newlines input = cleaned(input); @@ -1134,14 +1134,14 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) } else { macro.isFunction = false; } - int start = index; + qsizetype start = index; until(PP_NEWLINE); macro.symbols.reserve(index - start - 1); // remove whitespace where there shouldn't be any: // Before and after the macro, after a # and around ## Token lastToken = HASH; // skip shitespace at the beginning - for (int i = start; i < index - 1; ++i) { + for (qsizetype i = start; i < index - 1; ++i) { Token token = symbols.at(i).token; if (token == WHITESPACE) { if (lastToken == PP_HASH || lastToken == HASH || diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index 84186fec9e2..624b00ff105 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -48,8 +48,9 @@ public: void substituteUntilNewline(Symbols &substituted); static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName); - static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, int &index, int lineNum, bool one, - const QSet<QByteArray> &excludeSymbols = QSet<QByteArray>()); + static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, + qsizetype &index, int lineNum, bool one, + const QSet<QByteArray> &excludeSymbols = QSet<QByteArray>()); int evaluateCondition(); diff --git a/src/tools/moc/symbols.h b/src/tools/moc/symbols.h index 8807aeca980..c02f306c12e 100644 --- a/src/tools/moc/symbols.h +++ b/src/tools/moc/symbols.h @@ -110,7 +110,7 @@ struct SafeSymbols { Symbols symbols; QByteArray expandedMacro; QSet<QByteArray> excludedSymbols; - int index; + qsizetype index; }; Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE); |