aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libother
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/libother')
-rw-r--r--sources/shiboken6/tests/libother/CMakeLists.txt23
-rw-r--r--sources/shiboken6/tests/libother/extendsnoimplicitconversion.h21
-rw-r--r--sources/shiboken6/tests/libother/libothermacros.h18
-rw-r--r--sources/shiboken6/tests/libother/number.cpp28
-rw-r--r--sources/shiboken6/tests/libother/number.h32
-rw-r--r--sources/shiboken6/tests/libother/otherderived.cpp33
-rw-r--r--sources/shiboken6/tests/libother/otherderived.h43
-rw-r--r--sources/shiboken6/tests/libother/othermultiplederived.cpp24
-rw-r--r--sources/shiboken6/tests/libother/othermultiplederived.h21
-rw-r--r--sources/shiboken6/tests/libother/otherobjecttype.cpp20
-rw-r--r--sources/shiboken6/tests/libother/otherobjecttype.h22
-rw-r--r--sources/shiboken6/tests/libother/othertypesystypedef.cpp19
-rw-r--r--sources/shiboken6/tests/libother/othertypesystypedef.h21
-rw-r--r--sources/shiboken6/tests/libother/smartptrtester.cpp30
-rw-r--r--sources/shiboken6/tests/libother/smartptrtester.h24
15 files changed, 379 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libother/CMakeLists.txt b/sources/shiboken6/tests/libother/CMakeLists.txt
new file mode 100644
index 000000000..0379d740b
--- /dev/null
+++ b/sources/shiboken6/tests/libother/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+project(libother)
+
+set(libother_SRC
+extendsnoimplicitconversion.h
+libothermacros.h
+number.cpp number.h
+otherderived.cpp otherderived.h
+othermultiplederived.cpp othermultiplederived.h
+otherobjecttype.cpp otherobjecttype.h
+othertypesystypedef.cpp othertypesystypedef.h
+smartptrtester.cpp smartptrtester.h
+)
+
+add_library(libother SHARED ${libother_SRC})
+target_include_directories(libother PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_compile_definitions(libother PRIVATE LIBOTHER_BUILD)
+target_link_libraries(libother PUBLIC libsample libsmart)
+set_property(TARGET libother PROPERTY PREFIX "")
+
+
diff --git a/sources/shiboken6/tests/libother/extendsnoimplicitconversion.h b/sources/shiboken6/tests/libother/extendsnoimplicitconversion.h
new file mode 100644
index 000000000..36d503fe8
--- /dev/null
+++ b/sources/shiboken6/tests/libother/extendsnoimplicitconversion.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef EXTENDSNOIMPLICITCONVERSION_H
+#define EXTENDSNOIMPLICITCONVERSION_H
+
+#include "libothermacros.h"
+#include "noimplicitconversion.h"
+
+class ExtendsNoImplicitConversion
+{
+public:
+ explicit ExtendsNoImplicitConversion(int objId) : m_objId(objId) {};
+ inline int objId() const { return m_objId; }
+ inline operator NoImplicitConversion() const { return NoImplicitConversion(m_objId); }
+
+private:
+ int m_objId;
+};
+
+#endif // EXTENDSNOIMPLICITCONVERSION_H
diff --git a/sources/shiboken6/tests/libother/libothermacros.h b/sources/shiboken6/tests/libother/libothermacros.h
new file mode 100644
index 000000000..567757abd
--- /dev/null
+++ b/sources/shiboken6/tests/libother/libothermacros.h
@@ -0,0 +1,18 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef LIBOTHERMACROS_H
+#define LIBOTHERMACROS_H
+
+#include "../libminimal/libminimalmacros.h"
+
+#define LIBOTHER_EXPORT LIBMINIMAL_EXPORT
+#define LIBOTHER_IMPORT LIBMINIMAL_IMPORT
+
+#ifdef LIBOTHER_BUILD
+# define LIBOTHER_API LIBOTHER_EXPORT
+#else
+# define LIBOTHER_API LIBOTHER_IMPORT
+#endif
+
+#endif // LIBOTHERMACROS_H
diff --git a/sources/shiboken6/tests/libother/number.cpp b/sources/shiboken6/tests/libother/number.cpp
new file mode 100644
index 000000000..fbf50dc4a
--- /dev/null
+++ b/sources/shiboken6/tests/libother/number.cpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "number.h"
+
+#include <sstream>
+
+Str Number::toStr() const
+{
+ std::ostringstream in;
+ in << m_value;
+ return in.str().c_str();
+}
+
+Point operator*(const Point &p, const Number &n)
+{
+ return {p.x() * n.value(), p.y() * n.value()};
+}
+
+Complex Number::toComplex() const
+{
+ return Complex(m_value);
+}
+
+Number Number::fromComplex(Complex cpx)
+{
+ return Number(cpx.real());
+}
diff --git a/sources/shiboken6/tests/libother/number.h b/sources/shiboken6/tests/libother/number.h
new file mode 100644
index 000000000..2c480e7f2
--- /dev/null
+++ b/sources/shiboken6/tests/libother/number.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef NUMBER_H
+#define NUMBER_H
+
+#include "libothermacros.h"
+#include "str.h"
+#include "point.h"
+#include "complex.h"
+
+class LIBOTHER_API Number
+{
+public:
+ explicit Number(int value) : m_value(value) {};
+ inline int value() const { return m_value; }
+
+ Str toStr() const;
+ inline operator Str() const { return toStr(); }
+
+ friend LIBOTHER_API Point operator*(const Point &, const Number &);
+
+ Complex toComplex() const;
+ static Number fromComplex(Complex cpx);
+
+private:
+ int m_value;
+};
+
+LIBOTHER_API Point operator*(const Point &, const Number &);
+
+#endif // NUMBER_H
diff --git a/sources/shiboken6/tests/libother/otherderived.cpp b/sources/shiboken6/tests/libother/otherderived.cpp
new file mode 100644
index 000000000..93a18876e
--- /dev/null
+++ b/sources/shiboken6/tests/libother/otherderived.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "otherderived.h"
+
+OtherDerived::OtherDerived(int id) : Abstract(id)
+{
+}
+
+OtherDerived::~OtherDerived() = default;
+
+Abstract *OtherDerived::createObject()
+{
+ static int id = 100;
+ return new OtherDerived(id++);
+}
+
+void OtherDerived::pureVirtual()
+{
+}
+
+void *OtherDerived::pureVirtualReturningVoidPtr()
+{
+ return nullptr;
+}
+
+void OtherDerived::unpureVirtual()
+{
+}
+
+void OtherDerived::pureVirtualPrivate()
+{
+}
diff --git a/sources/shiboken6/tests/libother/otherderived.h b/sources/shiboken6/tests/libother/otherderived.h
new file mode 100644
index 000000000..d6bde8808
--- /dev/null
+++ b/sources/shiboken6/tests/libother/otherderived.h
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef OTHERDERIVED_H
+#define OTHERDERIVED_H
+
+#include "libothermacros.h"
+#include "abstract.h"
+#include "derived.h"
+#include "objecttype.h"
+#include "complex.h"
+
+class ObjectType;
+
+class LIBOTHER_API OtherDerived : public Abstract
+{
+public:
+ OtherDerived(int id = -1);
+ ~OtherDerived() override;
+ void pureVirtual() override;
+ void *pureVirtualReturningVoidPtr() override;
+ void unpureVirtual() override;
+ PrintFormat returnAnEnum() override { return Short; }
+
+ inline void useObjectTypeFromOtherModule(ObjectType *) {}
+ inline Event useValueTypeFromOtherModule(const Event &e) { return e; }
+ inline Complex useValueTypeFromOtherModule(const Complex &c) { return c; }
+ inline void useEnumTypeFromOtherModule(OverloadedFuncEnum) {}
+
+ // factory method
+ static Abstract *createObject();
+
+ void hideFunction(HideType*) override {}
+
+protected:
+ inline const char *getClassName() { return className(); }
+ const char *className() const override { return "OtherDerived"; }
+
+private:
+ void pureVirtualPrivate() override;
+};
+
+#endif // OTHERDERIVED_H
diff --git a/sources/shiboken6/tests/libother/othermultiplederived.cpp b/sources/shiboken6/tests/libother/othermultiplederived.cpp
new file mode 100644
index 000000000..cfbbfb2c2
--- /dev/null
+++ b/sources/shiboken6/tests/libother/othermultiplederived.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "othermultiplederived.h"
+
+VirtualMethods OtherMultipleDerived::returnUselessClass()
+{
+ return VirtualMethods();
+}
+
+Base1 *OtherMultipleDerived::createObject(const std::string &objName)
+{
+ if (objName == "Base1")
+ return new Base1;
+ if (objName == "MDerived1")
+ return new MDerived1;
+ if (objName == "SonOfMDerived1")
+ return new SonOfMDerived1;
+ if (objName == "MDerived3")
+ return new MDerived3;
+ if (objName == "OtherMultipleDerived")
+ return new OtherMultipleDerived;
+ return nullptr;
+}
diff --git a/sources/shiboken6/tests/libother/othermultiplederived.h b/sources/shiboken6/tests/libother/othermultiplederived.h
new file mode 100644
index 000000000..cd9910687
--- /dev/null
+++ b/sources/shiboken6/tests/libother/othermultiplederived.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef OTHERMULTIPLEDERIVED_H
+#define OTHERMULTIPLEDERIVED_H
+
+#include "libothermacros.h"
+#include "multiple_derived.h"
+#include "virtualmethods.h"
+
+class ObjectType;
+
+class LIBOTHER_API OtherMultipleDerived : public OtherBase, public MDerived1
+{
+public:
+ // this will use CppCopier from other module (bug#142)
+ VirtualMethods returnUselessClass();
+ static Base1 *createObject(const std::string &objName);
+};
+
+#endif // OTHERMULTIPLEDERIVED_H
diff --git a/sources/shiboken6/tests/libother/otherobjecttype.cpp b/sources/shiboken6/tests/libother/otherobjecttype.cpp
new file mode 100644
index 000000000..eaaa231be
--- /dev/null
+++ b/sources/shiboken6/tests/libother/otherobjecttype.cpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "otherobjecttype.h"
+
+Collector &operator<<(Collector &collector, const OtherObjectType &obj)
+{
+ collector << obj.identifier() * 2;
+ return collector;
+}
+
+int OtherObjectType::enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum value)
+{
+ return static_cast<int>(value);
+}
+
+int OtherObjectType::enumAsIntForInvisibleNamespace(RemovedNamespace1::RemovedNamespace1_Enum value)
+{
+ return static_cast<int>(value);
+}
diff --git a/sources/shiboken6/tests/libother/otherobjecttype.h b/sources/shiboken6/tests/libother/otherobjecttype.h
new file mode 100644
index 000000000..844795118
--- /dev/null
+++ b/sources/shiboken6/tests/libother/otherobjecttype.h
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef OTHEROBJECTTYPE_H
+#define OTHEROBJECTTYPE_H
+
+#include "libothermacros.h"
+#include "objecttype.h"
+#include "collector.h"
+#include "samplenamespace.h"
+#include "removednamespaces.h"
+
+class LIBOTHER_API OtherObjectType : public ObjectType
+{
+public:
+ static int enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum value);
+ static int enumAsIntForInvisibleNamespace(RemovedNamespace1::RemovedNamespace1_Enum value);
+};
+
+LIBOTHER_API Collector &operator<<(Collector &, const OtherObjectType &);
+
+#endif // OTHEROBJECTTYPE_H
diff --git a/sources/shiboken6/tests/libother/othertypesystypedef.cpp b/sources/shiboken6/tests/libother/othertypesystypedef.cpp
new file mode 100644
index 000000000..1a50c4edf
--- /dev/null
+++ b/sources/shiboken6/tests/libother/othertypesystypedef.cpp
@@ -0,0 +1,19 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "othertypesystypedef.h"
+
+OtherValueWithUnitUser::OtherValueWithUnitUser() = default;
+
+
+ValueWithUnit<double, LengthUnit::Inch>
+ OtherValueWithUnitUser::doubleMillimeterToInch(ValueWithUnit<double, LengthUnit::Millimeter> v)
+{
+ return ValueWithUnit<double, LengthUnit::Inch>(v.value() / 254);
+}
+
+ValueWithUnit<int, LengthUnit::Inch>
+ OtherValueWithUnitUser::intMillimeterToInch(ValueWithUnit<int, LengthUnit::Millimeter> v)
+{
+ return ValueWithUnit<int, LengthUnit::Inch>(v.value() / 254);
+}
diff --git a/sources/shiboken6/tests/libother/othertypesystypedef.h b/sources/shiboken6/tests/libother/othertypesystypedef.h
new file mode 100644
index 000000000..999b71fd3
--- /dev/null
+++ b/sources/shiboken6/tests/libother/othertypesystypedef.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef OTHERTYPESYSTYPEDEF_H
+#define OTHERTYPESYSTYPEDEF_H
+
+#include "libothermacros.h"
+
+#include <typesystypedef.h>
+
+class LIBOTHER_API OtherValueWithUnitUser
+{
+public:
+ OtherValueWithUnitUser();
+
+ static ValueWithUnit<double, LengthUnit::Inch> doubleMillimeterToInch(ValueWithUnit<double, LengthUnit::Millimeter>);
+
+ static ValueWithUnit<int, LengthUnit::Inch> intMillimeterToInch(ValueWithUnit<int, LengthUnit::Millimeter>);
+};
+
+#endif // OTHERTYPESYSTYPEDEF_H
diff --git a/sources/shiboken6/tests/libother/smartptrtester.cpp b/sources/shiboken6/tests/libother/smartptrtester.cpp
new file mode 100644
index 000000000..1c6496b1a
--- /dev/null
+++ b/sources/shiboken6/tests/libother/smartptrtester.cpp
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "smartptrtester.h"
+
+SharedPtr<Str> SmartPtrTester::createSharedPtrStr(const char *what)
+{
+ return {new Str(what)};
+}
+
+std::string SmartPtrTester::valueOfSharedPtrStr(const SharedPtr<Str> &str)
+{
+ return str->cstring();
+}
+
+SharedPtr<Integer> SmartPtrTester::createSharedPtrInteger(int v)
+{
+ auto i = SharedPtr<Integer>(new Integer);
+ i->m_int = v;
+ return i;
+}
+
+int SmartPtrTester::valueOfSharedPtrInteger(const SharedPtr<Integer> &v)
+{
+ return v->m_int;
+}
+
+void SmartPtrTester::fiddleInt(const SharedPtr<int> &) // no binding, should not cause errors
+{
+}
diff --git a/sources/shiboken6/tests/libother/smartptrtester.h b/sources/shiboken6/tests/libother/smartptrtester.h
new file mode 100644
index 000000000..6d7991c06
--- /dev/null
+++ b/sources/shiboken6/tests/libother/smartptrtester.h
@@ -0,0 +1,24 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef SMARTPTRTESTER_H
+#define SMARTPTRTESTER_H
+
+#include "libothermacros.h"
+
+#include <smart.h>
+#include <str.h>
+
+class LIBOTHER_API SmartPtrTester
+{
+public:
+ SharedPtr<Str> createSharedPtrStr(const char *what);
+ std::string valueOfSharedPtrStr(const SharedPtr<Str> &);
+
+ SharedPtr<Integer> createSharedPtrInteger(int v);
+ int valueOfSharedPtrInteger(const SharedPtr<Integer> &);
+
+ void fiddleInt(const SharedPtr<int> &);
+};
+
+#endif // SMARTPTRTESTER_H