summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-08-21 13:00:02 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-02 22:44:27 +0200
commite6988d4d0bef2c3f474576250cb305a2f00a688b (patch)
tree9412573d07041918349dc2542673467739be73ce /src/tools/moc/moc.cpp
parente638e8a28d74af8129aaaf6b67fabbb5dbdf31e4 (diff)
Remove QNotifiedProperty and Q_PRIVATE_QPROPERTY
And all related functionality. This is being replaced by Q_BINDABLE_PROPERTY and Q_OBJECT_BINDABLE_PROPERTY in the next few commits. The new infrastructure coming will play nicer along with the existing property system. Commented out some autotests, that will get reimplemented with the updated infrastructure. Change-Id: I50c30bd4d5c6c6b6471f8eb93870e27d86f5a009 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r--src/tools/moc/moc.cpp157
1 files changed, 28 insertions, 129 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 84eb751bee..1a20d32d7c 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -576,35 +576,6 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
}
-// Try to parse QProperty<MyType> propertName; members
-bool Moc::parseMaybeQProperty(ClassDef *def)
-{
- if (!test(IDENTIFIER))
- return false;
-
- bool hasNotifier = false;
- if (lexem() == "QNotifiedProperty") {
- hasNotifier = true;
- } else if (lexem() != "QProperty") {
- return false;
- }
-
- if (!test(LANGLE))
- return false;
-
- until(RANGLE);
-
- next();
- const auto propName = lexem();
-
- if (!test(SEMIC))
- return false;
-
- def->qPropertyMembersMaybeWithNotifier.insert(propName, hasNotifier);
-
- return true;
-}
-
void Moc::parse()
{
QList<NamespaceDef> namespaceList;
@@ -893,9 +864,6 @@ void Moc::parse()
case Q_PRIVATE_PROPERTY_TOKEN:
parsePrivateProperty(&def);
break;
- case Q_PRIVATE_QPROPERTY_TOKEN:
- parsePrivateQProperty(&def);
- break;
case ENUM: {
EnumDef enumDef;
if (parseEnum(&enumDef))
@@ -953,9 +921,7 @@ void Moc::parse()
}
}
} else {
- index = rewind - 1;
- if (!parseMaybeQProperty(&def))
- index = rewind;
+ index = rewind;
}
}
}
@@ -1055,8 +1021,8 @@ static QByteArrayList requiredQtContainers(const QList<ClassDef> &classes)
const QByteArray pattern = candidate + '<';
for (const auto &c : classes) {
- if (!c.privateQProperties.isEmpty())
- needsQProperty = true;
+ for (const auto &p : c.propertyList)
+ needsQProperty |= p.isQProperty;
if (any_type_contains(c.propertyList, pattern) ||
any_arg_contains(c.slotList, pattern) ||
any_arg_contains(c.signalList, pattern) ||
@@ -1385,19 +1351,8 @@ void Moc::parsePropertyAttributes(PropertyDef &propDef)
checkIsFunction(propDef.designable, "DESIGNABLE");
break;
case 'N': if (l != "NOTIFY") error(2);
- if (v == "false") {
- if (!propDef.isQProperty)
- error(1);
- propDef.isQPropertyWithNotifier = false;
- break;
- } else if (v == "true") {
- if (!propDef.isQProperty)
- error(1);
- break;
- } else {
- propDef.notify = v;
- break;
- }
+ propDef.notify = v;
+ break;
case 'U': if (l != "USER") error(2);
propDef.user = v + v2;
checkIsFunction(propDef.user, "USER");
@@ -1494,19 +1449,19 @@ void Moc::parsePluginData(ClassDef *def)
QByteArray Moc::parsePropertyAccessor()
{
- next(IDENTIFIER);
- QByteArray accessor = lexem();
- while (test(SCOPE)) {
- accessor += lexem();
- next(IDENTIFIER);
+ int nesting = 0;
+ QByteArray accessor;
+ while (1) {
+ Token t = peek();
+ if (!nesting && (t == RPAREN || t == COMMA))
+ break;
+ t = next();
+ if (t == LPAREN)
+ ++nesting;
+ if (t == RPAREN)
+ --nesting;
accessor += lexem();
}
- // also allow void functions
- if (test(LPAREN)) {
- next(RPAREN);
- accessor += "()";
- }
-
return accessor;
}
@@ -1523,48 +1478,6 @@ void Moc::parsePrivateProperty(ClassDef *def)
def->propertyList += propDef;
}
-void Moc::parsePrivateQProperty(ClassDef *def)
-{
- next(LPAREN);
- const QByteArray accessor = parsePropertyAccessor();
- next(COMMA);
- const Type type = parseType();
- next(COMMA);
- next(IDENTIFIER);
- const QByteArray name = lexem();
- next(COMMA);
- next(IDENTIFIER);
- const QByteArray setter = lexem();
-
- PropertyDef propDef;
- propDef.name = name;
- propDef.type = type.name;
- propDef.isQProperty = true;
- propDef.isQPropertyWithNotifier = true;
- propDef.inPrivateClass = accessor;
- propDef.designable = propDef.scriptable = propDef.stored = "true";
- propDef.user = "false";
-
- if (test(COMMA))
- parsePropertyAttributes(propDef);
-
- const bool stored = propDef.stored == "true";
- propDef.qpropertyname = stored ? name : (name + "()");
-
- def->privateQProperties += PrivateQPropertyDef {
- type, name, setter, accessor, propDef.qpropertyname, propDef.isQPropertyWithNotifier
- };
-
- if (propDef.read.isEmpty())
- propDef.read = propDef.qpropertyname + (stored ? ".value" : "->value");
- if (propDef.write.isEmpty())
- propDef.write = propDef.qpropertyname + (stored ? ".setValue" : "->setValue");
-
- next(RPAREN);
-
- def->propertyList += propDef;
-}
-
void Moc::parseEnumOrFlag(BaseDef *def, bool isFlag)
{
next(LPAREN);
@@ -1895,33 +1808,19 @@ void Moc::checkProperties(ClassDef *cdef)
warning(msg.constData());
}
- if (p.read.isEmpty() && p.member.isEmpty()) {
-
- auto qPropertyMemberIt = cdef->qPropertyMembersMaybeWithNotifier.constFind(p.name);
- const bool knownQPropertyMember = qPropertyMemberIt != cdef->qPropertyMembersMaybeWithNotifier.constEnd();
- if (!knownQPropertyMember && !p.isQProperty) {
- const int rewind = index;
- if (p.location >= 0)
- index = p.location;
- QByteArray msg = "Property declaration " + p.name + " has neither an associated QProperty<> member"
- ", nor a READ accessor function nor an associated MEMBER variable. The property will be invalid.";
- warning(msg.constData());
- index = rewind;
- if (p.write.isEmpty()) {
- cdef->propertyList.removeAt(i);
- --i;
- }
- continue;
+ if (p.read.isEmpty() && p.member.isEmpty() && !p.isQProperty) {
+ const int rewind = index;
+ if (p.location >= 0)
+ index = p.location;
+ QByteArray msg = "Property declaration " + p.name + " has neither an associated QProperty<> member"
+ ", nor a READ accessor function nor an associated MEMBER variable. The property will be invalid.";
+ warning(msg.constData());
+ index = rewind;
+ if (p.write.isEmpty()) {
+ cdef->propertyList.removeAt(i);
+ --i;
}
- const bool stored = p.stored == "true";
- p.qpropertyname = stored ? p.name : (p.name + "()");
- p.read = p.qpropertyname + (stored ? ".value" : "->value");
- p.write = p.qpropertyname + (stored ? ".setValue" : "->setValue");;
- p.isQProperty = true;
- const bool hasNotifier = knownQPropertyMember && qPropertyMemberIt.value();
- p.isQPropertyWithNotifier = hasNotifier;
- p.designable = p.scriptable = p.stored = "true";
- p.user = "false";
+ continue;
}
for (int j = 0; j < cdef->publicList.count(); ++j) {