aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-04-09 12:46:56 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-04-10 06:11:03 +0000
commit86d0e51342cd805298e78278f1b66bc8543fb2bd (patch)
tree191cf3d66fd0c7c3a4068557f1d712413fd13694
parent728e94e37d44229d8f31dee4761eaf66f89bf01e (diff)
shiboken/meta builder: Refactor type resolution parseQ_Property()
Use a list instead of splitting and joining repeatedly. Use splitRef() for the tokens. Change-Id: I0519b18126ba828a00aff6e4455c45f682928ca9 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index de971532d..6c0ab3702 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -2874,19 +2874,17 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
void AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass,
const QStringList &declarations)
{
- for (int i = 0; i < declarations.size(); ++i) {
- const QString &p = declarations.at(i);
-
- QStringList l = p.split(QLatin1Char(' '));
+ const QStringList scopes = currentScope()->qualifiedName();
+ for (int i = 0; i < declarations.size(); ++i) {
+ const auto propertyTokens = declarations.at(i).splitRef(QLatin1Char(' '));
- QStringList qualifiedScopeName = currentScope()->qualifiedName();
- AbstractMetaType* type = 0;
- QString scope;
- for (int j = qualifiedScopeName.size(); j >= 0; --j) {
- scope = j > 0 ? QStringList(qualifiedScopeName.mid(0, j)).join(colonColon()) + colonColon() : QString();
+ AbstractMetaType *type = nullptr;
+ for (int j = scopes.size(); j >= 0; --j) {
+ QStringList qualifiedName = scopes.mid(0, j);
+ qualifiedName.append(propertyTokens.at(0).toString());
TypeInfo info;
- info.setQualifiedName((scope + l.at(0)).split(colonColon()));
+ info.setQualifiedName(qualifiedName);
type = translateType(info, metaClass);
if (type)
@@ -2896,23 +2894,23 @@ void AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass,
if (!type) {
qCWarning(lcShiboken).noquote().nospace()
<< QStringLiteral("Unable to decide type of property: '%1' in class '%2'")
- .arg(l.at(0), metaClass->name());
+ .arg(propertyTokens.at(0).toString(), metaClass->name());
continue;
}
QPropertySpec* spec = new QPropertySpec(type->typeEntry());
- spec->setName(l.at(1));
+ spec->setName(propertyTokens.at(1).toString());
spec->setIndex(i);
- for (int pos = 2; pos + 1 < l.size(); pos += 2) {
- if (l.at(pos) == QLatin1String("READ"))
- spec->setRead(l.at(pos + 1));
- else if (l.at(pos) == QLatin1String("WRITE"))
- spec->setWrite(l.at(pos + 1));
- else if (l.at(pos) == QLatin1String("DESIGNABLE"))
- spec->setDesignable(l.at(pos + 1));
- else if (l.at(pos) == QLatin1String("RESET"))
- spec->setReset(l.at(pos + 1));
+ for (int pos = 2; pos + 1 < propertyTokens.size(); pos += 2) {
+ if (propertyTokens.at(pos) == QLatin1String("READ"))
+ spec->setRead(propertyTokens.at(pos + 1).toString());
+ else if (propertyTokens.at(pos) == QLatin1String("WRITE"))
+ spec->setWrite(propertyTokens.at(pos + 1).toString());
+ else if (propertyTokens.at(pos) == QLatin1String("DESIGNABLE"))
+ spec->setDesignable(propertyTokens.at(pos + 1).toString());
+ else if (propertyTokens.at(pos) == QLatin1String("RESET"))
+ spec->setReset(propertyTokens.at(pos + 1).toString());
}
metaClass->addPropertySpec(spec);