diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-05-28 11:11:08 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-06-02 19:03:45 +0200 |
commit | e6a2892772c9ea18a941625b2b8dec38e6774f82 (patch) | |
tree | 4248dd3057d7a7b236ac86f972dc6fe7e4a25ab1 /src/tools/moc | |
parent | 6ef69bcef2785baf112b6f91f05995fc01869928 (diff) |
moc: Add relative property index to JSON output of PropertyDef
Needed for QML compiler to know property index of C++ type at
compile time without going through QMetaObject::indexOfProperty
Change-Id: I404e71d6071d36812661df17d12b879a8dcbd146
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/moc.cpp | 9 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index c8fe0e9a83..bce75644f5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1242,9 +1242,10 @@ void Moc::parseSignals(ClassDef *def) } } -void Moc::createPropertyDef(PropertyDef &propDef) +void Moc::createPropertyDef(PropertyDef &propDef, int propertyIndex) { propDef.location = index; + propDef.relativeIndex = propertyIndex; QByteArray type = parseType().name; if (type.isEmpty()) @@ -1401,7 +1402,7 @@ void Moc::parseProperty(ClassDef *def) { next(LPAREN); PropertyDef propDef; - createPropertyDef(propDef); + createPropertyDef(propDef, int(def->propertyList.size())); next(RPAREN); def->propertyList += propDef; @@ -1495,7 +1496,7 @@ void Moc::parsePrivateProperty(ClassDef *def) next(COMMA); - createPropertyDef(propDef); + createPropertyDef(propDef, int(def->propertyList.size())); def->propertyList += propDef; } @@ -2068,7 +2069,7 @@ QJsonObject PropertyDef::toJson() const prop[QLatin1String("constant")] = constant; prop[QLatin1String("final")] = final; prop[QLatin1String("required")] = required; - + prop[QLatin1String("index")] = relativeIndex; if (revision > 0) prop[QLatin1String("revision")] = revision; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 889ee15652..1c2d6624fa 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -140,6 +140,7 @@ struct PropertyDef bool constant = false; bool final = false; bool required = false; + int relativeIndex = -1; // property index in current metaobject int location = -1; // token index, used for error reporting @@ -263,7 +264,7 @@ public: void parseSignals(ClassDef *def); void parseProperty(ClassDef *def); void parsePluginData(ClassDef *def); - void createPropertyDef(PropertyDef &def); + void createPropertyDef(PropertyDef &def, int propertyIndex); void parsePropertyAttributes(PropertyDef &propDef); void parseEnumOrFlag(BaseDef *def, bool isFlag); void parseFlag(BaseDef *def); |