aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-11 09:38:22 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-17 18:14:28 +0100
commitf499c71c3b3f78920be192d35df7e2c8d18e2f1b (patch)
tree1cf53d8b089cfcb054c395bb288951c945f6e582 /sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
parentcf4f1a7488ba3202b44081eade36debf1d665e8f (diff)
shiboken6: Use smart pointers for the TypeEntry classes
TypeEntry instances were previously stored and passed as raw pointers, which made it difficult to track ownership, particularly when synthesized classes were added. Change it to use QSharedPointer. Change-Id: I3612efbc5d467ebeac9aa5dda86c7439bbd03ddd Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
index c17dda953..0f3edcfe5 100644
--- a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
@@ -39,9 +39,9 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
AbstractMetaClassList classes = builder->classes();
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, u"A");
QVERIFY(classA);
- const ComplexTypeEntry *typeEntry = classA->typeEntry();
+ const auto typeEntry = classA->typeEntry();
QVERIFY(typeEntry->isValue());
- auto *vte = static_cast<const ValueTypeEntry *>(typeEntry);
+ auto vte = qSharedPointerCast<const ValueTypeEntry>(typeEntry);
QVERIFY(vte->hasTargetConversionRule());
QCOMPARE(vte->targetConversionRule(), QLatin1String(conversionData));
}
@@ -87,8 +87,8 @@ void TestConversionRuleTag::testConversionRuleTagReplace()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
QVERIFY(!builder.isNull());
auto *typeDb = TypeDatabase::instance();
- auto *typeA = typeDb->findPrimitiveType(u"A"_s);
- QVERIFY(typeA);
+ auto typeA = typeDb->findPrimitiveType(u"A"_s);
+ QVERIFY(!typeA.isNull());
QVERIFY(typeA->hasCustomConversion());
auto conversion = typeA->customConversion();
@@ -114,8 +114,8 @@ void TestConversionRuleTag::testConversionRuleTagReplace()
toNative = conversion->targetToNativeConversions().at(1);
QCOMPARE(toNative.sourceTypeName(), u"B");
QVERIFY(!toNative.isCustomType());
- auto *typeB = typeDb->findType(u"B"_s);
- QVERIFY(typeB);
+ auto typeB = typeDb->findType(u"B"_s);
+ QVERIFY(!typeB.isNull());
QCOMPARE(toNative.sourceType(), typeB);
QCOMPARE(toNative.sourceTypeCheck(), u"CheckIfInputObjectIsB(%IN)");
QCOMPARE(toNative.conversion().trimmed(), u"%OUT = %IN.createA();");
@@ -158,7 +158,7 @@ if (!TargetDateTimeAPI) TargetDateTime_IMPORT;\n\
QVERIFY(classA);
QVERIFY(classA->typeEntry()->isValue());
- auto *vte = static_cast<const ValueTypeEntry *>(classA->typeEntry());
+ auto vte = qSharedPointerCast<const ValueTypeEntry>(classA->typeEntry());
QVERIFY(vte->hasCustomConversion());
auto conversion = vte->customConversion();
@@ -218,8 +218,8 @@ void TestConversionRuleTag::testConversionRuleTagWithInsertTemplate()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
QVERIFY(!builder.isNull());
auto *typeDb = TypeDatabase::instance();
- auto *typeA = typeDb->findPrimitiveType(u"A"_s);
- QVERIFY(typeA);
+ auto typeA = typeDb->findPrimitiveType(u"A"_s);
+ QVERIFY(!typeA.isNull());
QVERIFY(typeA->hasCustomConversion());
auto conversion = typeA->customConversion();