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.location = index;
|
||||||
|
propDef.relativeIndex = propertyIndex;
|
||||||
|
|
||||||
QByteArray type = parseType().name;
|
QByteArray type = parseType().name;
|
||||||
if (type.isEmpty())
|
if (type.isEmpty())
|
||||||
@ -1401,7 +1402,7 @@ void Moc::parseProperty(ClassDef *def)
|
|||||||
{
|
{
|
||||||
next(LPAREN);
|
next(LPAREN);
|
||||||
PropertyDef propDef;
|
PropertyDef propDef;
|
||||||
createPropertyDef(propDef);
|
createPropertyDef(propDef, int(def->propertyList.size()));
|
||||||
next(RPAREN);
|
next(RPAREN);
|
||||||
|
|
||||||
def->propertyList += propDef;
|
def->propertyList += propDef;
|
||||||
@ -1495,7 +1496,7 @@ void Moc::parsePrivateProperty(ClassDef *def)
|
|||||||
|
|
||||||
next(COMMA);
|
next(COMMA);
|
||||||
|
|
||||||
createPropertyDef(propDef);
|
createPropertyDef(propDef, int(def->propertyList.size()));
|
||||||
|
|
||||||
def->propertyList += propDef;
|
def->propertyList += propDef;
|
||||||
}
|
}
|
||||||
@ -2068,7 +2069,7 @@ QJsonObject PropertyDef::toJson() const
|
|||||||
prop[QLatin1String("constant")] = constant;
|
prop[QLatin1String("constant")] = constant;
|
||||||
prop[QLatin1String("final")] = final;
|
prop[QLatin1String("final")] = final;
|
||||||
prop[QLatin1String("required")] = required;
|
prop[QLatin1String("required")] = required;
|
||||||
|
prop[QLatin1String("index")] = relativeIndex;
|
||||||
if (revision > 0)
|
if (revision > 0)
|
||||||
prop[QLatin1String("revision")] = revision;
|
prop[QLatin1String("revision")] = revision;
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ struct PropertyDef
|
|||||||
bool constant = false;
|
bool constant = false;
|
||||||
bool final = false;
|
bool final = false;
|
||||||
bool required = false;
|
bool required = false;
|
||||||
|
int relativeIndex = -1; // property index in current metaobject
|
||||||
|
|
||||||
int location = -1; // token index, used for error reporting
|
int location = -1; // token index, used for error reporting
|
||||||
|
|
||||||
@ -263,7 +264,7 @@ public:
|
|||||||
void parseSignals(ClassDef *def);
|
void parseSignals(ClassDef *def);
|
||||||
void parseProperty(ClassDef *def);
|
void parseProperty(ClassDef *def);
|
||||||
void parsePluginData(ClassDef *def);
|
void parsePluginData(ClassDef *def);
|
||||||
void createPropertyDef(PropertyDef &def);
|
void createPropertyDef(PropertyDef &def, int propertyIndex);
|
||||||
void parsePropertyAttributes(PropertyDef &propDef);
|
void parsePropertyAttributes(PropertyDef &propDef);
|
||||||
void parseEnumOrFlag(BaseDef *def, bool isFlag);
|
void parseEnumOrFlag(BaseDef *def, bool isFlag);
|
||||||
void parseFlag(BaseDef *def);
|
void parseFlag(BaseDef *def);
|
||||||
|
@ -1136,6 +1136,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "prop1",
|
"name": "prop1",
|
||||||
"read": "getProp1",
|
"read": "getProp1",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1149,6 +1150,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 1,
|
||||||
"name": "prop2",
|
"name": "prop2",
|
||||||
"read": "getProp2",
|
"read": "getProp2",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1162,6 +1164,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 2,
|
||||||
"name": "prop3",
|
"name": "prop3",
|
||||||
"read": "getProp3",
|
"read": "getProp3",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1274,6 +1277,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "flags",
|
"name": "flags",
|
||||||
"read": "flags",
|
"read": "flags",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1300,6 +1304,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "flags",
|
"name": "flags",
|
||||||
"read": "flags",
|
"read": "flags",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1313,6 +1318,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 1,
|
||||||
"name": "flagsList",
|
"name": "flagsList",
|
||||||
"read": "flagsList",
|
"read": "flagsList",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1854,6 +1860,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "blah",
|
"name": "blah",
|
||||||
"read": "blah",
|
"read": "blah",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -1906,6 +1913,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "blah",
|
"name": "blah",
|
||||||
"read": "blah",
|
"read": "blah",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2081,6 +2089,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "gadgetPoperty",
|
"name": "gadgetPoperty",
|
||||||
"read": "gadgetPoperty",
|
"read": "gadgetPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2093,6 +2102,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 1,
|
||||||
"name": "objectPoperty",
|
"name": "objectPoperty",
|
||||||
"read": "objectPoperty",
|
"read": "objectPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2118,6 +2128,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "nestedGadgetPoperty",
|
"name": "nestedGadgetPoperty",
|
||||||
"read": "nestedGadgetPoperty",
|
"read": "nestedGadgetPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2143,6 +2154,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "nestedObjectPoperty",
|
"name": "nestedObjectPoperty",
|
||||||
"read": "nestedObjectPoperty",
|
"read": "nestedObjectPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2276,6 +2288,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "gadgetPoperty",
|
"name": "gadgetPoperty",
|
||||||
"read": "gadgetPoperty",
|
"read": "gadgetPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2288,6 +2301,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 1,
|
||||||
"name": "objectPoperty",
|
"name": "objectPoperty",
|
||||||
"read": "objectPoperty",
|
"read": "objectPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2313,6 +2327,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "nestedGadgetPoperty",
|
"name": "nestedGadgetPoperty",
|
||||||
"read": "nestedGadgetPoperty",
|
"read": "nestedGadgetPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -2338,6 +2353,7 @@
|
|||||||
"constant": false,
|
"constant": false,
|
||||||
"designable": true,
|
"designable": true,
|
||||||
"final": false,
|
"final": false,
|
||||||
|
"index": 0,
|
||||||
"name": "nestedObjectPoperty",
|
"name": "nestedObjectPoperty",
|
||||||
"read": "nestedObjectPoperty",
|
"read": "nestedObjectPoperty",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user