Skip to content

Commit c0dcb99

Browse files
usiemsmrbean-bremen
authored andcommitted
Improve parsing of Q_PROPERTY types starting with "const"
1 parent eca4f5c commit c0dcb99

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

generator/abstractmetabuilder.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,11 +2278,33 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass *meta_class, const Q
22782278
QStringList qualifiedScopeName = currentScope()->qualifiedName();
22792279
bool ok = false;
22802280
AbstractMetaType *type = 0;
2281-
QString scope;
2281+
int pIndex = 0;
2282+
QString typeName = l.value(pIndex++);
2283+
bool isConst = false;
2284+
if (typeName == "const") {
2285+
// use the next part as the type name
2286+
typeName = l.value(pIndex++);
2287+
isConst = true;
2288+
}
2289+
QString propertyName = l.value(pIndex++);
2290+
QString modifiers;
2291+
while (typeName.endsWith("*") || typeName.endsWith("&")) {
2292+
modifiers.insert(0, typeName.at(typeName.length() - 1));
2293+
typeName.chop(1);
2294+
}
2295+
while (propertyName.startsWith("*") || propertyName.startsWith("&")) {
2296+
modifiers.append(propertyName.at(0));
2297+
propertyName.remove(0, 1);
2298+
if (propertyName.isEmpty() && pIndex < l.size()) {
2299+
propertyName = l.value(pIndex++);
2300+
}
2301+
}
22822302
for (int j=qualifiedScopeName.size(); j>=0; --j) {
2283-
scope = j > 0 ? QStringList(qualifiedScopeName.mid(0, j)).join("::") + "::" : QString();
2303+
QStringList scope(qualifiedScopeName.mid(0, j));
22842304
TypeInfo info;
2285-
info.setQualifiedName((scope + l.at(0)).split("::"));
2305+
info.setIndirections(modifiers.count('*'));
2306+
info.setReference(modifiers.contains('&')); // r-value reference seems improbable for a property...
2307+
info.setQualifiedName(scope + QStringList(typeName));
22862308

22872309
type = translateType(info, &ok);
22882310
if (type != 0 && ok) {
@@ -2291,18 +2313,16 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass *meta_class, const Q
22912313
}
22922314

22932315
if (type == 0 || !ok) {
2294-
ReportHandler::warning(QString("Unable to decide type of property: '%1' in class '%2'")
2295-
.arg(l.at(0)).arg(meta_class->name()));
2316+
ReportHandler::warning(QString("Unable to decide type '%1' of property '%2' in class '%3'")
2317+
.arg(typeName).arg(propertyName).arg(meta_class->name()));
22962318
continue;
22972319
}
22982320

2299-
QString typeName = scope + l.at(0);
2300-
23012321
QPropertySpec *spec = new QPropertySpec(type->typeEntry());
2302-
spec->setName(l.at(1));
2322+
spec->setName(propertyName);
23032323
spec->setIndex(i);
23042324

2305-
for (int pos=2; pos+1<l.size(); pos+=2) {
2325+
for (int pos=pIndex; pos+1<l.size(); pos+=2) {
23062326
if (l.at(pos) == QLatin1String("READ"))
23072327
spec->setRead(l.at(pos+1));
23082328
else if (l.at(pos) == QLatin1String("WRITE"))

0 commit comments

Comments
 (0)