Moc: port to qsizetype

Pick-to: 6.6 6.5
Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-05-23 16:52:27 +03:00 committed by Fabian Kosmale
parent 7022d0e223
commit 2271ee6b4b
6 changed files with 20 additions and 19 deletions

View File

@ -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);
}
}
}

View File

@ -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<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 {

View File

@ -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;
}

View File

@ -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);
@ -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 ||

View File

@ -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();

View File

@ -110,7 +110,7 @@ struct SafeSymbols {
Symbols symbols;
QByteArray expandedMacro;
QSet<QByteArray> excludedSymbols;
int index;
qsizetype index;
};
Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE);