diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-23 15:25:45 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-23 16:19:40 +0000 |
commit | ad6766eee85e124bd7661f78388a8f13a5a1a0b2 (patch) | |
tree | 4d07c0b2688e3a3700ec85708101df78ce658cbe /sources/shiboken2/ApiExtractor/tests | |
parent | 4917f84cfa8d526e34e3a6d2164ecf2e23eab408 (diff) |
shiboken: Refactor finding of enumerations
- Add helper AbstractMetaEnum::findEnumValue() which
finds unqualified as well as qualified enum values.
- Remove unused function bstractMetaClass::findEnumForValue(QString).
- Remove 2nd parameter from
AbstractMetaClass::findEnumValue(QString, AbstractMetaEnum *).
The comment claimed that it is excluded from the search, but the
condition was the reverse. Just removing it apparently does not do
harm.
Task-number: PYSIDE-487
Change-Id: I32b036045ea335b805fba79df327cc42d787f18c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests')
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp | 11 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testenum.cpp | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp index 7c9d20ede..cbeb216c9 100644 --- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp @@ -128,7 +128,7 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue() AbstractMetaEnum* someEnum = classA->findEnum(QLatin1String("SomeEnum")); QVERIFY(someEnum); - AbstractMetaEnumValue* nvalues = classA->findEnumValue(QLatin1String("NValues"), someEnum); + AbstractMetaEnumValue *nvalues = classA->findEnumValue(QLatin1String("NValues")); QVERIFY(nvalues); const AbstractMetaArgument* arg = classA->functions().last()->arguments().first(); @@ -159,14 +159,7 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnu AbstractMetaEnum* someEnum = builder->globalEnums().first(); QVERIFY(someEnum); - AbstractMetaEnumValue* nvalues = 0; - const AbstractMetaEnumValueList &values = someEnum->values(); - for (AbstractMetaEnumValue *enumValue : values) { - if (enumValue->name() == QLatin1String("NValues")) { - nvalues = enumValue; - break; - } - } + const AbstractMetaEnumValue *nvalues = someEnum->findEnumValue(QLatin1String("NValues")); QVERIFY(nvalues); const AbstractMetaArgument* arg = classA->functions().last()->arguments().first(); diff --git a/sources/shiboken2/ApiExtractor/tests/testenum.cpp b/sources/shiboken2/ApiExtractor/tests/testenum.cpp index 98e56b86e..55c098840 100644 --- a/sources/shiboken2/ApiExtractor/tests/testenum.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testenum.cpp @@ -83,6 +83,10 @@ void TestEnum::testEnumCppSignature() AbstractMetaEnumList classEnums = classA->enums(); QCOMPARE(classEnums.first()->name(), QLatin1String("ClassEnum")); + AbstractMetaEnumValue *e = AbstractMetaClass::findEnumValue(classes, QLatin1String("CA")); + QVERIFY(e); + e = AbstractMetaClass::findEnumValue(classes, QLatin1String("ClassEnum::CA")); + QVERIFY(e); } void TestEnum::testEnumWithApiVersion() |