From 2271ee6b4b5b89a5f77c4260333921bd9c3e91af Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 May 2023 16:52:27 +0300 Subject: Moc: port to qsizetype Pick-to: 6.6 6.5 Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c Reviewed-by: Fabian Kosmale Reviewed-by: Thiago Macieira --- src/tools/moc/moc.cpp | 12 ++++++------ src/tools/moc/moc.h | 6 +++--- src/tools/moc/parser.h | 4 ++-- src/tools/moc/preprocessor.cpp | 10 +++++----- src/tools/moc/preprocessor.h | 5 +++-- src/tools/moc/symbols.h | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 1d1948525c..fb9f18eaca 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -663,7 +663,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; @@ -972,7 +972,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) { @@ -1760,7 +1760,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) { @@ -1796,7 +1796,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; @@ -1931,7 +1931,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" @@ -1987,7 +1987,7 @@ void Moc::checkProperties(ClassDef *cdef) cdef->nonClassSignalList << p.notify; p.notifyId = int(-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 a3ddb835b5..001252b6eb 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -122,7 +122,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; }; @@ -152,8 +152,8 @@ struct BaseDef { QMap enumDeclarations; QList enumList; QMap 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 715c441e89..7b5c604a71 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -16,7 +16,7 @@ class Parser public: Parser():index(0), displayWarnings(true), displayNotes(true) {} Symbols symbols; - int index; + qsizetype index; bool displayWarnings; bool displayNotes; @@ -65,7 +65,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 7fed80565a..0afadce2b5 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 &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); @@ -1101,7 +1101,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); @@ -1136,14 +1136,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 84186fec9e..624b00ff10 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 &excludeSymbols = QSet()); + static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, + qsizetype &index, int lineNum, bool one, + const QSet &excludeSymbols = QSet()); int evaluateCondition(); diff --git a/src/tools/moc/symbols.h b/src/tools/moc/symbols.h index 8807aeca98..c02f306c12 100644 --- a/src/tools/moc/symbols.h +++ b/src/tools/moc/symbols.h @@ -110,7 +110,7 @@ struct SafeSymbols { Symbols symbols; QByteArray expandedMacro; QSet excludedSymbols; - int index; + qsizetype index; }; Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE); -- cgit v1.2.3