diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-14 00:50:29 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-17 02:23:17 +0200 |
commit | 0e7212460ba7fab19a47f960b09a011973a7c475 (patch) | |
tree | 6801ba8a3e6e43c1a924411b965248e6f7bc2f8a /tests | |
parent | 8ebd4a1da820cff0e499258f79a3fc139ea06b77 (diff) |
Use member function instead of template function to resolve native interface
The use of a freestanding function is not needed now that the name
doesn't alias the nativeInterface accessor function, and was just
adding complexity to the machinery.
People not familiar with the code will have an easier time following
the flow through the helper member function, and we no longer need
to declare our own export macros.
Pick-to: 6.2
Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp index dfd8d4fca1..dd4cc4755b 100644 --- a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp +++ b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp @@ -37,6 +37,8 @@ private slots: void typeInfo() const; void resolve() const; void accessor() const; + + friend struct PublicClass; }; struct InterfaceImplementation; @@ -46,6 +48,8 @@ struct PublicClass PublicClass(); QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(PublicClass) std::unique_ptr<InterfaceImplementation> m_implementation; + + friend void tst_QNativeInterface::resolve() const; }; QT_BEGIN_NAMESPACE @@ -84,11 +88,9 @@ struct InterfaceImplementation : public Interface PublicClass::PublicClass() : m_implementation(new InterfaceImplementation) {} -template <> -void* QNativeInterface::Private::resolveInterface<PublicClass>( - PublicClass const* that, char const* name, int revision) +void* PublicClass::resolveInterface(char const* name, int revision) const { - auto *implementation = that->m_implementation.get(); + auto *implementation = m_implementation.get(); QT_NATIVE_INTERFACE_RETURN_IF(Interface, implementation); QT_NATIVE_INTERFACE_RETURN_IF(OtherInterface, implementation); return nullptr; @@ -116,14 +118,14 @@ void tst_QNativeInterface::resolve() const PublicClass foo; - QVERIFY(resolveInterface(&foo, "Interface", 10)); + QVERIFY(foo.resolveInterface("Interface", 10)); QTest::ignoreMessage(QtWarningMsg, "Native interface revision mismatch " "(requested 5 / available 10) for interface Interface"); - QCOMPARE(resolveInterface(&foo, "Interface", 5), nullptr); - QCOMPARE(resolveInterface(&foo, "NotInterface", 10), nullptr); - QCOMPARE(resolveInterface(&foo, "OtherInterface", 10), nullptr); + QCOMPARE(foo.resolveInterface("Interface", 5), nullptr); + QCOMPARE(foo.resolveInterface("NotInterface", 10), nullptr); + QCOMPARE(foo.resolveInterface("OtherInterface", 10), nullptr); } void tst_QNativeInterface::accessor() const |