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>
This commit is contained in:
parent
6ef69bcef2
commit
e6a2892772
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -1136,6 +1136,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "prop1",
|
||||
"read": "getProp1",
|
||||
"required": false,
|
||||
@ -1149,6 +1150,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 1,
|
||||
"name": "prop2",
|
||||
"read": "getProp2",
|
||||
"required": false,
|
||||
@ -1162,6 +1164,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 2,
|
||||
"name": "prop3",
|
||||
"read": "getProp3",
|
||||
"required": false,
|
||||
@ -1274,6 +1277,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "flags",
|
||||
"read": "flags",
|
||||
"required": false,
|
||||
@ -1300,6 +1304,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "flags",
|
||||
"read": "flags",
|
||||
"required": false,
|
||||
@ -1313,6 +1318,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 1,
|
||||
"name": "flagsList",
|
||||
"read": "flagsList",
|
||||
"required": false,
|
||||
@ -1854,6 +1860,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "blah",
|
||||
"read": "blah",
|
||||
"required": false,
|
||||
@ -1906,6 +1913,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "blah",
|
||||
"read": "blah",
|
||||
"required": false,
|
||||
@ -2081,6 +2089,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "gadgetPoperty",
|
||||
"read": "gadgetPoperty",
|
||||
"required": false,
|
||||
@ -2093,6 +2102,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 1,
|
||||
"name": "objectPoperty",
|
||||
"read": "objectPoperty",
|
||||
"required": false,
|
||||
@ -2118,6 +2128,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "nestedGadgetPoperty",
|
||||
"read": "nestedGadgetPoperty",
|
||||
"required": false,
|
||||
@ -2143,6 +2154,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "nestedObjectPoperty",
|
||||
"read": "nestedObjectPoperty",
|
||||
"required": false,
|
||||
@ -2276,6 +2288,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "gadgetPoperty",
|
||||
"read": "gadgetPoperty",
|
||||
"required": false,
|
||||
@ -2288,6 +2301,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 1,
|
||||
"name": "objectPoperty",
|
||||
"read": "objectPoperty",
|
||||
"required": false,
|
||||
@ -2313,6 +2327,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "nestedGadgetPoperty",
|
||||
"read": "nestedGadgetPoperty",
|
||||
"required": false,
|
||||
@ -2338,6 +2353,7 @@
|
||||
"constant": false,
|
||||
"designable": true,
|
||||
"final": false,
|
||||
"index": 0,
|
||||
"name": "nestedObjectPoperty",
|
||||
"read": "nestedObjectPoperty",
|
||||
"required": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user