aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/libsample
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/tests/libsample')
-rw-r--r--sources/shiboken2/tests/libsample/CMakeLists.txt57
-rw-r--r--sources/shiboken2/tests/libsample/abstract.cpp97
-rw-r--r--sources/shiboken2/tests/libsample/abstract.h107
-rw-r--r--sources/shiboken2/tests/libsample/blackbox.cpp131
-rw-r--r--sources/shiboken2/tests/libsample/blackbox.h67
-rw-r--r--sources/shiboken2/tests/libsample/bucket.cpp86
-rw-r--r--sources/shiboken2/tests/libsample/bucket.h59
-rw-r--r--sources/shiboken2/tests/libsample/bytearray.cpp214
-rw-r--r--sources/shiboken2/tests/libsample/bytearray.h89
-rw-r--r--sources/shiboken2/tests/libsample/collector.cpp62
-rw-r--r--sources/shiboken2/tests/libsample/collector.h71
-rw-r--r--sources/shiboken2/tests/libsample/complex.cpp54
-rw-r--r--sources/shiboken2/tests/libsample/complex.h55
-rw-r--r--sources/shiboken2/tests/libsample/ctorconvrule.h45
-rw-r--r--sources/shiboken2/tests/libsample/cvlist.h53
-rw-r--r--sources/shiboken2/tests/libsample/derived.cpp119
-rw-r--r--sources/shiboken2/tests/libsample/derived.h92
-rw-r--r--sources/shiboken2/tests/libsample/echo.cpp29
-rw-r--r--sources/shiboken2/tests/libsample/echo.h55
-rw-r--r--sources/shiboken2/tests/libsample/expression.cpp137
-rw-r--r--sources/shiboken2/tests/libsample/expression.h64
-rw-r--r--sources/shiboken2/tests/libsample/filter.cpp73
-rw-r--r--sources/shiboken2/tests/libsample/filter.h99
-rw-r--r--sources/shiboken2/tests/libsample/functions.cpp214
-rw-r--r--sources/shiboken2/tests/libsample/functions.h93
-rw-r--r--sources/shiboken2/tests/libsample/handle.cpp44
-rw-r--r--sources/shiboken2/tests/libsample/handle.h72
-rw-r--r--sources/shiboken2/tests/libsample/implicitconv.cpp66
-rw-r--r--sources/shiboken2/tests/libsample/implicitconv.h83
-rw-r--r--sources/shiboken2/tests/libsample/injectcode.cpp108
-rw-r--r--sources/shiboken2/tests/libsample/injectcode.h65
-rw-r--r--sources/shiboken2/tests/libsample/libsamplemacros.h46
-rw-r--r--sources/shiboken2/tests/libsample/list.h106
-rw-r--r--sources/shiboken2/tests/libsample/listuser.cpp91
-rw-r--r--sources/shiboken2/tests/libsample/listuser.h74
-rw-r--r--sources/shiboken2/tests/libsample/main.cpp244
-rw-r--r--sources/shiboken2/tests/libsample/mapuser.cpp69
-rw-r--r--sources/shiboken2/tests/libsample/mapuser.h65
-rw-r--r--sources/shiboken2/tests/libsample/modelindex.h72
-rw-r--r--sources/shiboken2/tests/libsample/modifications.cpp151
-rw-r--r--sources/shiboken2/tests/libsample/modifications.h142
-rw-r--r--sources/shiboken2/tests/libsample/modified_constructor.cpp42
-rw-r--r--sources/shiboken2/tests/libsample/modified_constructor.h46
-rw-r--r--sources/shiboken2/tests/libsample/multiple_derived.cpp64
-rw-r--r--sources/shiboken2/tests/libsample/multiple_derived.h195
-rw-r--r--sources/shiboken2/tests/libsample/noimplicitconversion.h49
-rw-r--r--sources/shiboken2/tests/libsample/nondefaultctor.h75
-rw-r--r--sources/shiboken2/tests/libsample/null.h44
-rw-r--r--sources/shiboken2/tests/libsample/objectmodel.cpp42
-rw-r--r--sources/shiboken2/tests/libsample/objectmodel.h58
-rw-r--r--sources/shiboken2/tests/libsample/objecttype.cpp311
-rw-r--r--sources/shiboken2/tests/libsample/objecttype.h176
-rw-r--r--sources/shiboken2/tests/libsample/objecttypebyvalue.h46
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeholder.cpp52
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeholder.h51
-rw-r--r--sources/shiboken2/tests/libsample/objecttypelayout.cpp68
-rw-r--r--sources/shiboken2/tests/libsample/objecttypelayout.h56
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeoperators.cpp63
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeoperators.h61
-rw-r--r--sources/shiboken2/tests/libsample/objectview.cpp54
-rw-r--r--sources/shiboken2/tests/libsample/objectview.h58
-rw-r--r--sources/shiboken2/tests/libsample/oddbool.h83
-rw-r--r--sources/shiboken2/tests/libsample/onlycopy.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/onlycopy.h59
-rw-r--r--sources/shiboken2/tests/libsample/overload.cpp50
-rw-r--r--sources/shiboken2/tests/libsample/overload.h143
-rw-r--r--sources/shiboken2/tests/libsample/overloadsort.cpp30
-rw-r--r--sources/shiboken2/tests/libsample/overloadsort.h88
-rw-r--r--sources/shiboken2/tests/libsample/pairuser.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/pairuser.h55
-rw-r--r--sources/shiboken2/tests/libsample/pen.cpp67
-rw-r--r--sources/shiboken2/tests/libsample/pen.h62
-rw-r--r--sources/shiboken2/tests/libsample/photon.cpp50
-rw-r--r--sources/shiboken2/tests/libsample/photon.h140
-rw-r--r--sources/shiboken2/tests/libsample/point.cpp155
-rw-r--r--sources/shiboken2/tests/libsample/point.h99
-rw-r--r--sources/shiboken2/tests/libsample/pointerholder.h45
-rw-r--r--sources/shiboken2/tests/libsample/pointf.cpp126
-rw-r--r--sources/shiboken2/tests/libsample/pointf.h88
-rw-r--r--sources/shiboken2/tests/libsample/polygon.cpp75
-rw-r--r--sources/shiboken2/tests/libsample/polygon.h66
-rw-r--r--sources/shiboken2/tests/libsample/privatector.h55
-rw-r--r--sources/shiboken2/tests/libsample/privatedtor.h60
-rw-r--r--sources/shiboken2/tests/libsample/protected.cpp32
-rw-r--r--sources/shiboken2/tests/libsample/protected.h151
-rw-r--r--sources/shiboken2/tests/libsample/rect.h86
-rw-r--r--sources/shiboken2/tests/libsample/reference.cpp78
-rw-r--r--sources/shiboken2/tests/libsample/reference.h81
-rw-r--r--sources/shiboken2/tests/libsample/removednamespaces.h68
-rw-r--r--sources/shiboken2/tests/libsample/sample.cpp39
-rw-r--r--sources/shiboken2/tests/libsample/sample.h48
-rw-r--r--sources/shiboken2/tests/libsample/samplenamespace.cpp128
-rw-r--r--sources/shiboken2/tests/libsample/samplenamespace.h162
-rw-r--r--sources/shiboken2/tests/libsample/sbkdate.cpp48
-rw-r--r--sources/shiboken2/tests/libsample/sbkdate.h50
-rw-r--r--sources/shiboken2/tests/libsample/simplefile.cpp108
-rw-r--r--sources/shiboken2/tests/libsample/simplefile.h56
-rw-r--r--sources/shiboken2/tests/libsample/size.cpp39
-rw-r--r--sources/shiboken2/tests/libsample/size.h206
-rw-r--r--sources/shiboken2/tests/libsample/sometime.cpp99
-rw-r--r--sources/shiboken2/tests/libsample/sometime.h92
-rw-r--r--sources/shiboken2/tests/libsample/str.cpp185
-rw-r--r--sources/shiboken2/tests/libsample/str.h78
-rw-r--r--sources/shiboken2/tests/libsample/strlist.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/strlist.h65
-rw-r--r--sources/shiboken2/tests/libsample/templateptr.cpp33
-rw-r--r--sources/shiboken2/tests/libsample/templateptr.h43
-rw-r--r--sources/shiboken2/tests/libsample/transform.cpp65
-rw-r--r--sources/shiboken2/tests/libsample/transform.h45
-rw-r--r--sources/shiboken2/tests/libsample/valueandvirtual.h47
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.cpp59
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.h139
-rw-r--r--sources/shiboken2/tests/libsample/voidholder.h50
113 files changed, 9478 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/libsample/CMakeLists.txt b/sources/shiboken2/tests/libsample/CMakeLists.txt
new file mode 100644
index 000000000..7bbc0c3dd
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/CMakeLists.txt
@@ -0,0 +1,57 @@
+project(libsample)
+
+set(libsample_SRC
+abstract.cpp
+blackbox.cpp
+bytearray.cpp
+bucket.cpp
+collector.cpp
+complex.cpp
+onlycopy.cpp
+derived.cpp
+echo.cpp
+functions.cpp
+handle.cpp
+implicitconv.cpp
+injectcode.cpp
+listuser.cpp
+modifications.cpp
+mapuser.cpp
+modified_constructor.cpp
+multiple_derived.cpp
+objectmodel.cpp
+objecttype.cpp
+objecttypeholder.cpp
+objecttypelayout.cpp
+objecttypeoperators.cpp
+objectview.cpp
+overload.cpp
+overloadsort.cpp
+pairuser.cpp
+pen.cpp
+photon.cpp
+point.cpp
+pointf.cpp
+polygon.cpp
+protected.cpp
+reference.cpp
+sample.cpp
+samplenamespace.cpp
+sbkdate.cpp
+simplefile.cpp
+size.cpp
+sometime.cpp
+str.cpp
+strlist.cpp
+templateptr.cpp
+transform.cpp
+virtualmethods.cpp
+expression.cpp
+filter.cpp
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_definitions("-DLIBSAMPLE_BUILD")
+add_library(libsample SHARED ${libsample_SRC})
+set_property(TARGET libsample PROPERTY PREFIX "")
+
diff --git a/sources/shiboken2/tests/libsample/abstract.cpp b/sources/shiboken2/tests/libsample/abstract.cpp
new file mode 100644
index 000000000..ab00a3bcc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/abstract.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "abstract.h"
+#include "objecttype.h"
+
+using namespace std;
+
+const int Abstract::staticPrimitiveField = 0;
+
+Abstract::Abstract(int id) : m_id(id)
+{
+ primitiveField = 123;
+ valueTypeField = Point(12, 34);
+ objectTypeField = 0;
+ bitField = 0;
+}
+
+Abstract::~Abstract()
+{
+}
+
+void
+Abstract::unpureVirtual()
+{
+}
+
+void
+Abstract::callUnpureVirtual()
+{
+ this->unpureVirtual();
+}
+
+
+void
+Abstract::callPureVirtual()
+{
+ this->pureVirtual();
+}
+
+void
+Abstract::show(PrintFormat format)
+{
+ cout << '<';
+ switch(format) {
+ case Short:
+ cout << this;
+ break;
+ case Verbose:
+ cout << "class " << className() << " | cptr: " << this;
+ cout << ", id: " << m_id;
+ break;
+ case OnlyId:
+ cout << "id: " << m_id;
+ break;
+ case ClassNameAndId:
+ cout << className() << " - id: " << m_id;
+ break;
+ }
+ cout << '>';
+}
+
+void Abstract::callVirtualGettingEnum(PrintFormat p)
+{
+ virtualGettingAEnum(p);
+}
+
+void Abstract::virtualGettingAEnum(Abstract::PrintFormat p)
+{
+}
+
diff --git a/sources/shiboken2/tests/libsample/abstract.h b/sources/shiboken2/tests/libsample/abstract.h
new file mode 100644
index 000000000..77a43f3d1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/abstract.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACT_H
+#define ABSTRACT_H
+
+#include "libsamplemacros.h"
+#include "point.h"
+#include "complex.h"
+
+class ObjectType;
+
+// this class is not exported to python
+class HideType
+{
+};
+
+class LIBSAMPLE_API Abstract
+{
+private:
+ enum PrivateEnum {
+ PrivValue0,
+ PrivValue1,
+ PrivValue2 = PrivValue1 + 2
+ };
+public:
+ enum PrintFormat {
+ Short,
+ Verbose,
+ OnlyId,
+ ClassNameAndId,
+ DummyItemToTestPrivateEnum1 = Abstract::PrivValue1,
+ DummyItemToTestPrivateEnum2 = PrivValue2,
+ };
+
+ enum Type {
+ TpAbstract, TpDerived
+ };
+
+ static const int staticPrimitiveField;
+ int primitiveField;
+ Complex userPrimitiveField;
+ Point valueTypeField;
+ ObjectType* objectTypeField;
+
+ Abstract(int id = -1);
+ virtual ~Abstract();
+
+ inline int id() { return m_id; }
+
+ // factory method
+ inline static Abstract* createObject() { return 0; }
+
+ // method that receives an Object Type
+ inline static int getObjectId(Abstract* obj) { return obj->id(); }
+
+ virtual void pureVirtual() = 0;
+ virtual void* pureVirtualReturningVoidPtr() = 0;
+ virtual void unpureVirtual();
+
+ virtual PrintFormat returnAnEnum() = 0;
+ void callVirtualGettingEnum(PrintFormat p);
+ virtual void virtualGettingAEnum(PrintFormat p);
+
+ void callPureVirtual();
+ void callUnpureVirtual();
+
+ void show(PrintFormat format = Verbose);
+ virtual Type type() const { return TpAbstract; }
+
+ virtual void hideFunction(HideType* arg) = 0;
+
+protected:
+ virtual const char* className() { return "Abstract"; }
+
+ // Protected bit-field structure member.
+ unsigned int bitField: 1;
+
+private:
+ int m_id;
+};
+#endif // ABSTRACT_H
diff --git a/sources/shiboken2/tests/libsample/blackbox.cpp b/sources/shiboken2/tests/libsample/blackbox.cpp
new file mode 100644
index 000000000..9a10850f3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/blackbox.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "blackbox.h"
+
+using namespace std;
+
+BlackBox::~BlackBox()
+{
+ // Free all maps.
+ while (!m_objects.empty()) {
+ delete (*m_objects.begin()).second;
+ m_objects.erase(m_objects.begin());
+ }
+ while (!m_points.empty()) {
+ delete (*m_points.begin()).second;
+ m_points.erase(m_points.begin());
+ }
+}
+
+int
+BlackBox::keepObjectType(ObjectType* object)
+{
+ m_ticket++;
+ std::pair<int, ObjectType*> item(m_ticket, object);
+ m_objects.insert(item);
+ object->setParent(0);
+
+ return m_ticket;
+}
+
+ObjectType*
+BlackBox::retrieveObjectType(int ticket)
+{
+ map<int, ObjectType*>::iterator it = m_objects.find(ticket);
+ if (it != m_objects.end()) {
+ ObjectType* second = it->second;
+ m_objects.erase(it);
+ return second;
+ }
+ return 0;
+}
+
+void
+BlackBox::disposeObjectType(int ticket)
+{
+ ObjectType* object = retrieveObjectType(ticket);
+ if (object)
+ delete object;
+}
+
+int
+BlackBox::keepPoint(Point* point)
+{
+ m_ticket++;
+ std::pair<int, Point*> item(m_ticket, point);
+ m_points.insert(item);
+
+ return m_ticket;
+}
+
+Point*
+BlackBox::retrievePoint(int ticket)
+{
+ map<int, Point*>::iterator it = m_points.find(ticket);
+ if (it != m_points.end()) {
+ Point* second = it->second;
+ m_points.erase(it);
+ return second;
+ }
+ return 0;
+}
+
+void
+BlackBox::disposePoint(int ticket)
+{
+ Point* point = retrievePoint(ticket);
+ if (point)
+ delete point;
+}
+
+
+std::list<ObjectType*>
+BlackBox::objects()
+{
+ std::list<ObjectType*> l;
+ map<int, ObjectType*>::iterator it;
+
+ for ( it = m_objects.begin() ; it != m_objects.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
+std::list<Point*>
+BlackBox::points()
+{
+ std::list<Point*> l;
+ map<int, Point*>::iterator it;
+
+ for ( it = m_points.begin() ; it != m_points.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
diff --git a/sources/shiboken2/tests/libsample/blackbox.h b/sources/shiboken2/tests/libsample/blackbox.h
new file mode 100644
index 000000000..de776668c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/blackbox.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLACKBOX_H
+#define BLACKBOX_H
+
+#include "libsamplemacros.h"
+#include <map>
+#include "objecttype.h"
+#include "point.h"
+
+class LIBSAMPLE_API BlackBox
+{
+public:
+ typedef std::map<int, ObjectType*> ObjectTypeMap;
+ typedef std::map<int, Point*> PointMap;
+
+ BlackBox() { m_ticket = -1;}
+ ~BlackBox();
+
+ int keepObjectType(ObjectType* object);
+ ObjectType* retrieveObjectType(int ticket);
+ void disposeObjectType(int ticket);
+
+ int keepPoint(Point* point);
+ Point* retrievePoint(int ticket);
+ void disposePoint(int ticket);
+
+ std::list<ObjectType*> objects();
+ std::list<Point*> points();
+
+ inline void referenceToValuePointer(Point*&) {}
+ inline void referenceToObjectPointer(ObjectType*&) {}
+
+private:
+ ObjectTypeMap m_objects;
+ PointMap m_points;
+ int m_ticket;
+};
+
+#endif // BLACKBOX_H
+
diff --git a/sources/shiboken2/tests/libsample/bucket.cpp b/sources/shiboken2/tests/libsample/bucket.cpp
new file mode 100644
index 000000000..50a1310e7
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bucket.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bucket.h"
+#include <iostream>
+
+#ifdef _WIN32 // _WIN32 is defined by all Windows 32 and 64 bit compilers, but not by others.
+#include <windows.h>
+#define SLEEP(x) Sleep(x)
+#else
+#include <unistd.h>
+#define SLEEP(x) usleep(x)
+#endif
+
+
+using namespace std;
+
+Bucket::Bucket() : m_locked(false)
+{
+}
+
+void Bucket::push(int x)
+{
+ m_data.push_back(x);
+}
+
+int Bucket::pop(void)
+{
+ int x = 0;
+
+ if (m_data.size() > 0) {
+ x = m_data.front();
+ m_data.pop_front();
+ }
+
+ return x;
+}
+
+bool Bucket::empty()
+{
+ return m_data.empty();
+}
+
+void Bucket::lock()
+{
+ m_locked = true;
+ while (m_locked) { SLEEP(300); }
+}
+
+void Bucket::unlock()
+{
+ m_locked = false;
+}
+
+bool Bucket::virtualBlockerMethod()
+{
+ lock();
+ // The return value was added just for diversity sake.
+ return true;
+}
+
diff --git a/sources/shiboken2/tests/libsample/bucket.h b/sources/shiboken2/tests/libsample/bucket.h
new file mode 100644
index 000000000..bd8648b6b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bucket.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BUCKET_H
+#define BUCKET_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include <list>
+
+class ObjectType;
+
+class LIBSAMPLE_API Bucket : public ObjectType
+{
+public:
+ Bucket();
+ void push(int);
+ int pop();
+ bool empty();
+ void lock();
+ inline bool locked() { return m_locked; }
+ void unlock();
+
+ virtual bool virtualBlockerMethod();
+ inline bool callVirtualBlockerMethodButYouDontKnowThis() { return virtualBlockerMethod(); }
+
+private:
+ std::list<int> m_data;
+
+ volatile bool m_locked;
+};
+
+#endif // BUCKET_H
+
diff --git a/sources/shiboken2/tests/libsample/bytearray.cpp b/sources/shiboken2/tests/libsample/bytearray.cpp
new file mode 100644
index 000000000..c86ada124
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bytearray.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <cstring>
+#include "bytearray.h"
+
+ByteArray::ByteArray()
+{
+ m_data = std::vector<char>(1);
+ m_data[0] = '\0';
+}
+
+ByteArray::ByteArray(char c)
+{
+ m_data = std::vector<char>(2);
+ m_data[0] = c;
+ m_data[1] = '\0';
+}
+
+ByteArray::ByteArray(const char* data)
+{
+ size_t len = strlen(data);
+ m_data = std::vector<char>(len + 1);
+ memcpy(&m_data[0], data, len);
+ m_data[len] = '\0';
+}
+
+ByteArray::ByteArray(const char* data, int len)
+{
+ m_data = std::vector<char>(len + 1);
+ memcpy(&m_data[0], data, len);
+ m_data[len] = '\0';
+}
+
+ByteArray::ByteArray(const ByteArray& other)
+{
+ m_data = std::vector<char>(other.size() + 1);
+ memcpy(&m_data[0], &other.m_data[0], other.size());
+ m_data[other.size()] = '\0';
+}
+
+int
+ByteArray::size() const
+{
+ return m_data.size() - 1;
+}
+
+char
+ByteArray::at(int pos) const
+{
+ return m_data[pos];
+}
+
+const char*
+ByteArray::data() const
+{
+ return &(m_data[0]);
+}
+
+ByteArray&
+ByteArray::append(char c)
+{
+ m_data.pop_back();
+ m_data.push_back(c);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const char* data)
+{
+ m_data.pop_back();
+ for (int i = 0; i < (int)strlen(data); ++i)
+ m_data.push_back(data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const char* data, int len)
+{
+ m_data.pop_back();
+ for (int i = 0; i < len; ++i)
+ m_data.push_back(data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const ByteArray& other)
+{
+ m_data.pop_back();
+ for (int i = 0; i < (int)other.m_data.size(); ++i)
+ m_data.push_back(other.m_data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+static bool compare(const std::vector<char>& mine, const char* other)
+{
+ for (int i = 0; i < (int)mine.size() - 1; ++i) {
+ if (mine[i] != other[i])
+ return false;
+ }
+ return true;
+}
+
+bool
+ByteArray::operator==(const ByteArray& other) const
+{
+ return compare(m_data, &other.m_data[0]);
+}
+bool
+operator==(const ByteArray& ba1, const char* ba2)
+{
+ return compare(ba1.m_data, ba2);
+}
+bool
+operator==(const char* ba1, const ByteArray& ba2)
+{
+ return compare(ba2.m_data, ba1);
+}
+
+bool
+ByteArray::operator!=(const ByteArray& other) const
+{
+ return !(m_data == other.m_data);
+}
+bool
+operator!=(const ByteArray& ba1, const char* ba2)
+{
+ return !(ba1 == ba2);
+}
+bool
+operator!=(const char* ba1, const ByteArray& ba2)
+{
+ return !(ba1 == ba2);
+}
+
+ByteArray&
+ByteArray::operator+=(char c)
+{
+ return append(c);
+}
+ByteArray&
+ByteArray::operator+=(const char* data)
+{
+ return append(data);
+}
+ByteArray&
+ByteArray::operator+=(const ByteArray& other)
+{
+ return append(other);
+}
+
+ByteArray
+operator+(const ByteArray& ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+ByteArray
+operator+(const ByteArray& ba1, const char* ba2)
+{
+ return ByteArray(ba1) += ByteArray(ba2);
+}
+ByteArray
+operator+(const char* ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+ByteArray
+operator+(const ByteArray& ba1, char ba2)
+{
+ return ByteArray(ba1) += ByteArray(ba2);
+}
+ByteArray
+operator+(char ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+
+unsigned int
+ByteArray::hash(const ByteArray& byteArray)
+{
+ unsigned int result = 0;
+ for (int i = 0; i < (int)byteArray.m_data.size(); ++i)
+ result = 5 * result + byteArray.m_data[i];
+ return result;
+}
diff --git a/sources/shiboken2/tests/libsample/bytearray.h b/sources/shiboken2/tests/libsample/bytearray.h
new file mode 100644
index 000000000..d2219ee5d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bytearray.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BYTEARRAY_H
+#define BYTEARRAY_H
+
+#include "str.h"
+#include "libsamplemacros.h"
+#include <vector>
+
+class LIBSAMPLE_API ByteArray
+{
+public:
+ ByteArray();
+ ByteArray(char data);
+ ByteArray(const char* data);
+ ByteArray(const char* data, int len);
+ ByteArray(const ByteArray& other);
+
+ int size() const;
+ char at(int i) const;
+ char operator[](int i) const;
+
+ const char* data() const;
+
+ ByteArray& append(char c);
+ ByteArray& append(const char* data);
+ ByteArray& append(const char* data, int len);
+ ByteArray& append(const ByteArray& other);
+
+ bool operator==(const ByteArray& other) const;
+ bool operator!=(const ByteArray& other) const;
+
+ ByteArray& operator+=(char c);
+ ByteArray& operator+=(const char* data);
+ ByteArray& operator+=(const ByteArray& other);
+
+ static unsigned int hash(const ByteArray& byteArray);
+private:
+ std::vector<char> m_data;
+ friend LIBSAMPLE_API bool operator==(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API bool operator==(const char* ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API bool operator!=(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API bool operator!=(const char* ba1, const ByteArray& ba2);
+
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const char* ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, char ba2);
+ friend LIBSAMPLE_API ByteArray operator+(char ba1, const ByteArray& ba2);
+};
+
+LIBSAMPLE_API bool operator==(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API bool operator==(const char* ba1, const ByteArray& ba2);
+LIBSAMPLE_API bool operator!=(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API bool operator!=(const char* ba1, const ByteArray& ba2);
+
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const ByteArray& ba2);
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API ByteArray operator+(const char* ba1, const ByteArray& ba2);
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, char ba2);
+LIBSAMPLE_API ByteArray operator+(char ba1, const ByteArray& ba2);
+
+#endif // BYTEARRAY_H
diff --git a/sources/shiboken2/tests/libsample/collector.cpp b/sources/shiboken2/tests/libsample/collector.cpp
new file mode 100644
index 000000000..e60ed3af3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/collector.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "collector.h"
+
+void Collector::clear()
+{
+ m_items.clear();
+}
+
+Collector& Collector::operator<<(ObjectType::Identifier item)
+{
+ m_items.push_back(item);
+ return *this;
+}
+
+Collector& Collector::operator<<(const ObjectType *obj)
+{
+ m_items.push_back(obj->identifier());
+ return *this;
+}
+
+std::list<ObjectType::Identifier> Collector::items()
+{
+ return m_items;
+}
+
+int Collector::size()
+{
+ return (int) m_items.size();
+}
+
+Collector &operator<<(Collector &s, const IntWrapper &w)
+{
+ s << w.value;
+ return s;
+}
diff --git a/sources/shiboken2/tests/libsample/collector.h b/sources/shiboken2/tests/libsample/collector.h
new file mode 100644
index 000000000..fe82909cb
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/collector.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLLECTOR_H
+#define COLLECTOR_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+#include "objecttype.h"
+
+class LIBSAMPLE_API Collector
+{
+public:
+ Collector() {}
+ virtual ~Collector() {}
+
+ void clear();
+
+ Collector& operator<<(ObjectType::Identifier item);
+
+ Collector& operator<<(const ObjectType *);
+
+ std::list<ObjectType::Identifier> items();
+ int size();
+
+private:
+ std::list<ObjectType::Identifier> m_items;
+
+ Collector(const Collector&);
+ Collector& operator=(const Collector&);
+};
+
+/* Helper for testing external operators */
+class IntWrapper
+{
+public:
+ IntWrapper(int x=0):value(x){}
+
+ int value;
+};
+
+LIBSAMPLE_API Collector &operator<<(Collector&, const IntWrapper&);
+
+#endif // COLLECTOR_H
+
diff --git a/sources/shiboken2/tests/libsample/complex.cpp b/sources/shiboken2/tests/libsample/complex.cpp
new file mode 100644
index 000000000..10e4b3f58
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/complex.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "complex.h"
+
+using namespace std;
+
+Complex::Complex(double real, double imag)
+ : m_real(real), m_imag(imag)
+{
+}
+
+Complex
+Complex::operator+(Complex& other)
+{
+ Complex result;
+ result.setReal(m_real + other.real());
+ result.setImaginary(m_imag + other.imag());
+ return result;
+}
+
+void
+Complex::show()
+{
+ cout << "(real: " << m_real << ", imag: " << m_imag << ")";
+}
+
+
diff --git a/sources/shiboken2/tests/libsample/complex.h b/sources/shiboken2/tests/libsample/complex.h
new file mode 100644
index 000000000..cb167bde9
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/complex.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COMPLEX_H
+#define COMPLEX_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Complex
+{
+public:
+ Complex(double real = 0.0, double imag = 0.0);
+ ~Complex() {}
+
+ inline double real() const { return m_real; }
+ inline void setReal(double real) { m_real = real; }
+ inline double imag() const { return m_imag; }
+ inline void setImaginary(double imag) { m_imag = imag; }
+
+ Complex operator+(Complex& other);
+
+ void show();
+
+private:
+ double m_real;
+ double m_imag;
+};
+
+#endif // COMPLEX_H
+
diff --git a/sources/shiboken2/tests/libsample/ctorconvrule.h b/sources/shiboken2/tests/libsample/ctorconvrule.h
new file mode 100644
index 000000000..776f4744c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/ctorconvrule.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CTORCONVRULE_H
+#define CTORCONVRULE_H
+
+#include "libsamplemacros.h"
+
+class CtorConvRule
+{
+public:
+ explicit CtorConvRule(long value) : m_value(value) {}
+ virtual ~CtorConvRule() {}
+ virtual void dummyVirtualMethod() {}
+ long value() { return m_value; }
+private:
+ long m_value;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/cvlist.h b/sources/shiboken2/tests/libsample/cvlist.h
new file mode 100644
index 000000000..c74007945
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/cvlist.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONSTVALUELIST_H
+#define CONSTVALUELIST_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+class CVValueType
+{
+ CVValueType();
+};
+
+typedef std::list<const CVValueType*> const_ptr_value_list;
+
+// This tests binding generation for a container of a const value type. The
+// class doesn't need to do anything; this is just to verify that the generated
+// binding code (the container conversion in particular) is const-valid.
+
+class CVListUser
+{
+public:
+ static const_ptr_value_list produce() { return const_ptr_value_list(); }
+ static void consume(const const_ptr_value_list& l) { (void)l; }
+};
+
+#endif // LIST_H
diff --git a/sources/shiboken2/tests/libsample/derived.cpp b/sources/shiboken2/tests/libsample/derived.cpp
new file mode 100644
index 000000000..00ac8ebe5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/derived.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "derived.h"
+
+using namespace std;
+
+Derived::Derived(int id) : Abstract(id)
+{
+}
+
+Derived::~Derived()
+{
+}
+
+Abstract*
+Derived::createObject()
+{
+ static int id = 100;
+ return new Derived(id++);
+}
+
+void
+Derived::pureVirtual()
+{
+}
+
+void*
+Derived::pureVirtualReturningVoidPtr()
+{
+ return 0;
+}
+
+void
+Derived::unpureVirtual()
+{
+}
+
+bool
+Derived::singleArgument(bool b)
+{
+ return !b;
+}
+
+double
+Derived::defaultValue(int n)
+{
+ return ((double) n) + 0.1;
+}
+
+OverloadedFuncEnum
+Derived::overloaded(int i, int d)
+{
+ return OverloadedFunc_ii;
+}
+
+OverloadedFuncEnum
+Derived::overloaded(double n)
+{
+ return OverloadedFunc_d;
+}
+
+Derived::OtherOverloadedFuncEnum
+Derived::otherOverloaded(int a, int b, bool c, double d)
+{
+ return OtherOverloadedFunc_iibd;
+}
+
+Derived::OtherOverloadedFuncEnum
+Derived::otherOverloaded(int a, double b)
+{
+ return OtherOverloadedFunc_id;
+}
+
+struct SecretClass : public Abstract {
+ virtual void pureVirtual() {}
+ virtual void* pureVirtualReturningVoidPtr() { return 0; }
+ virtual PrintFormat returnAnEnum() { return Short; }
+ void hideFunction(HideType*){};
+};
+
+Abstract* Derived::triggerImpossibleTypeDiscovery()
+{
+ return new SecretClass;
+}
+
+struct AnotherSecretClass : public Derived {
+};
+
+Abstract* Derived::triggerAnotherImpossibleTypeDiscovery()
+{
+ return new AnotherSecretClass;
+}
diff --git a/sources/shiboken2/tests/libsample/derived.h b/sources/shiboken2/tests/libsample/derived.h
new file mode 100644
index 000000000..5c57e4691
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/derived.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DERIVED_H
+#define DERIVED_H
+
+#include "libsamplemacros.h"
+#include "abstract.h"
+
+enum OverloadedFuncEnum {
+ OverloadedFunc_ii,
+ OverloadedFunc_d
+};
+
+class LIBSAMPLE_API Derived : public Abstract
+{
+public:
+ enum OtherOverloadedFuncEnum {
+ OtherOverloadedFunc_iibd,
+ OtherOverloadedFunc_id
+ };
+
+ class SomeInnerClass {
+ public:
+ void uselessMethod() {}
+ SomeInnerClass operator+(const SomeInnerClass& other) { return other; }
+ bool operator==(const SomeInnerClass& other) { return true; }
+ };
+
+ Derived(int id = -1);
+ virtual ~Derived();
+ virtual void pureVirtual();
+ virtual void* pureVirtualReturningVoidPtr();
+ virtual void unpureVirtual();
+
+ virtual PrintFormat returnAnEnum() { return Short; }
+ virtual Type type() const { return TpDerived; }
+
+ // factory method
+ static Abstract* createObject();
+
+ // single argument
+ bool singleArgument(bool b);
+
+ // method with default value
+ double defaultValue(int n = 0);
+
+ // overloads
+ OverloadedFuncEnum overloaded(int i = 0, int d = 0);
+ OverloadedFuncEnum overloaded(double n);
+
+ // more overloads
+ OtherOverloadedFuncEnum otherOverloaded(int a, int b, bool c, double d);
+ OtherOverloadedFuncEnum otherOverloaded(int a, double b);
+
+ inline SomeInnerClass returnMyParameter(const SomeInnerClass& s) { return s; }
+
+ static Abstract* triggerImpossibleTypeDiscovery();
+ static Abstract* triggerAnotherImpossibleTypeDiscovery();
+
+ void hideFunction(HideType*) {}
+protected:
+ const char* getClassName() { return className(); }
+ virtual const char* className() { return "Derived"; }
+};
+#endif // DERIVED_H
+
diff --git a/sources/shiboken2/tests/libsample/echo.cpp b/sources/shiboken2/tests/libsample/echo.cpp
new file mode 100644
index 000000000..00fec78b0
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/echo.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "echo.h"
diff --git a/sources/shiboken2/tests/libsample/echo.h b/sources/shiboken2/tests/libsample/echo.h
new file mode 100644
index 000000000..a976c9cbc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/echo.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ECHO_H
+#define ECHO_H
+
+#include "libsamplemacros.h"
+#include "str.h"
+
+class ObjectType;
+
+class Echo
+{
+public:
+ Echo(){}
+ ~Echo(){}
+
+ void doNothingWithConstBool(const bool hi) {}
+ void methodWithNamedArg(const Str& string = Str("")) {}
+
+ Str operator()(const Str& s, const int i) { return s + i; }
+
+ // These method are here just for compilation test purposes
+ Echo& operator<<(unsigned int item) { return *this; }
+ Echo& operator<<(signed int item) { return *this; }
+ Echo& operator<<(const ObjectType* item) { return *this; }
+ Echo& operator<<(Str str) { return *this; }
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/expression.cpp b/sources/shiboken2/tests/libsample/expression.cpp
new file mode 100644
index 000000000..ff87e2ed2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/expression.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "expression.h"
+#include <sstream>
+
+Expression::Expression() : m_value(0), m_operation(None), m_operand1(0), m_operand2(0)
+{
+}
+
+Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(0), m_operand2(0)
+{
+}
+
+Expression::Expression(const Expression& other)
+{
+ m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0;
+ m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0;
+ m_value = other.m_value;
+ m_operation = other.m_operation;
+}
+
+Expression& Expression::operator=(const Expression& other)
+{
+ delete m_operand1;
+ delete m_operand2;
+ m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0;
+ m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0;
+ m_operation = other.m_operation;
+ m_value = other.m_value;
+ return *this;
+}
+
+Expression::~Expression()
+{
+ delete m_operand1;
+ delete m_operand2;
+}
+
+Expression Expression::operator+(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = Add;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator-(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = Add;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator<(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = LessThan;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator>(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = GreaterThan;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+std::string Expression::toString() const
+{
+ if (m_operation == None) {
+ std::ostringstream s;
+ s << m_value;
+ return s.str();
+ }
+
+ std::string result;
+ result += '(';
+ result += m_operand1->toString();
+ char op;
+ switch (m_operation) {
+ case Add:
+ op = '+';
+ break;
+ case Sub:
+ op = '-';
+ break;
+ case LessThan:
+ op = '<';
+ break;
+ case GreaterThan:
+ op = '<';
+ break;
+ case None: // just to avoid the compiler warning
+ default:
+ op = '?';
+ break;
+ }
+ result += op;
+ result += m_operand2->toString();
+ result += ')';
+ return result;
+}
+
diff --git a/sources/shiboken2/tests/libsample/expression.h b/sources/shiboken2/tests/libsample/expression.h
new file mode 100644
index 000000000..c4bb1a1f5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/expression.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef EXPRESSION_H
+#define EXPRESSION_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class LIBSAMPLE_API Expression
+{
+public:
+ enum Operation {
+ None, Add, Sub, LessThan, GreaterThan
+ };
+
+ Expression(int number);
+ Expression(const Expression& other);
+ Expression& operator=(const Expression& other);
+
+ ~Expression();
+
+ Expression operator>(const Expression& other);
+ Expression operator<(const Expression& other);
+ Expression operator+(const Expression& other);
+ Expression operator-(const Expression& other);
+
+ std::string toString() const;
+private:
+ int m_value;
+ Operation m_operation;
+ Expression* m_operand1;
+ Expression* m_operand2;
+
+ Expression();
+};
+
+#endif // EXPRESSION_H
diff --git a/sources/shiboken2/tests/libsample/filter.cpp b/sources/shiboken2/tests/libsample/filter.cpp
new file mode 100644
index 000000000..dac5d5e96
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/filter.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <string>
+#include "filter.h"
+Data::Data(Field field, std::string value)
+ : m_field(field), m_value(value)
+{
+}
+
+Union::Union(const Data& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Union::Union(const Intersection& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Union::Union(const Union& filter)
+{
+ m_filters = filter.filters();
+}
+
+Intersection::Intersection(const Data& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Intersection::Intersection(const Union& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Intersection::Intersection(const Intersection& filter)
+{
+ m_filters = filter.filters();
+}
+
+Intersection operator&(const Intersection& a, const Intersection& b)
+{
+ Intersection filter;
+ filter.addFilter(a);
+ filter.addFilter(b);
+
+ return filter;
+}
diff --git a/sources/shiboken2/tests/libsample/filter.h b/sources/shiboken2/tests/libsample/filter.h
new file mode 100644
index 000000000..6ee2e6123
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/filter.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILTER_H
+#define FILTER_H
+
+#include <string>
+#include <list>
+
+#include "libsamplemacros.h"
+
+class Intersection;
+
+class LIBSAMPLE_API Filter
+{
+};
+
+class LIBSAMPLE_API Data : public Filter
+{
+
+public:
+ enum Field {
+ Name,
+ Album,
+ Year
+ };
+
+ Data(Field field, std::string value);
+
+ Field field() const { return m_field; }
+ std::string value() const { return m_value; }
+
+private:
+ Field m_field;
+ std::string m_value;
+};
+
+class LIBSAMPLE_API Union : public Filter
+{
+public:
+
+ Union(const Data&);
+ Union(const Intersection&);
+ Union() {};
+ Union(const Union&);
+
+ std::list<Filter> filters() const { return m_filters; }
+ void addFilter(const Filter& data) { m_filters.push_back(data); }
+
+private:
+ std::list<Filter> m_filters;
+};
+
+class LIBSAMPLE_API Intersection : public Filter
+{
+public:
+
+ Intersection(const Data&);
+ Intersection(const Union&);
+ Intersection() {};
+ Intersection(const Intersection&);
+
+ std::list<Filter> filters() const { return m_filters; }
+ void addFilter(const Filter& data) { m_filters.push_back(data); }
+
+private:
+ std::list<Filter> m_filters;
+};
+
+LIBSAMPLE_API Intersection operator&(const Intersection& a, const Intersection& b);
+
+#endif // FILTER_H
+
+
diff --git a/sources/shiboken2/tests/libsample/functions.cpp b/sources/shiboken2/tests/libsample/functions.cpp
new file mode 100644
index 000000000..4a15cdae8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/functions.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "functions.h"
+#include <string.h>
+#include <iostream>
+
+using namespace std;
+
+void
+printSomething()
+{
+ cout << __FUNCTION__ << endl;
+}
+
+int
+gimmeInt()
+{
+ static int val = 2;
+ val = val * 1.3;
+ return val;
+}
+
+double
+gimmeDouble()
+{
+ static double val = 7.77;
+ val = val * 1.3;
+ return val;
+}
+
+std::list<Complex>
+gimmeComplexList()
+{
+ std::list<Complex> lst;
+ lst.push_back(Complex());
+ lst.push_back(Complex(1.1, 2.2));
+ lst.push_back(Complex(1.3, 2.4));
+ return lst;
+}
+
+Complex
+sumComplexPair(std::pair<Complex, Complex> cpx_pair)
+{
+ return cpx_pair.first + cpx_pair.second;
+}
+
+double
+multiplyPair(std::pair<double, double> pair)
+{
+ return pair.first * pair.second;
+}
+
+int
+countCharacters(const char* text)
+{
+ if (!text)
+ return -1;
+ int count;
+ for(count = 0; text[count] != '\0'; count++)
+ ;
+ return count;
+}
+
+char*
+makeCString()
+{
+ char* string = new char[strlen(__FUNCTION__) + 1];
+ strcpy(string, __FUNCTION__);
+ return string;
+}
+
+const char*
+returnCString()
+{
+ return __FUNCTION__;
+}
+
+GlobalOverloadFuncEnum
+overloadedFunc(int val)
+{
+ return GlobalOverloadFunc_i;
+}
+
+GlobalOverloadFuncEnum
+overloadedFunc(double val)
+{
+ return GlobalOverloadFunc_d;
+}
+
+char*
+returnNullPrimitivePointer()
+{
+ return 0;
+}
+
+ObjectType*
+returnNullObjectTypePointer()
+{
+ return 0;
+}
+
+Event*
+returnNullValueTypePointer()
+{
+ return 0;
+}
+
+unsigned int
+doubleUnsignedInt(unsigned int value)
+{
+ return value * 2;
+}
+
+long long
+doubleLongLong(long long value)
+{
+ return value * 2;
+}
+
+unsigned long long
+doubleUnsignedLongLong(unsigned long long value)
+{
+ return value * 2;
+}
+
+short
+doubleShort(short value)
+{
+ return value * 2;
+}
+
+int
+acceptInt(int x)
+{
+ return x;
+}
+
+unsigned int
+acceptUInt(unsigned int x)
+{
+ return x;
+}
+
+long
+acceptLong(long x)
+{
+ return x;
+}
+
+unsigned long
+acceptULong(unsigned long x)
+{
+ return x;
+}
+
+double
+acceptDouble(double x)
+{
+ return x;
+}
+
+int
+acceptIntReference(int& x)
+{
+ return x;
+}
+
+OddBool
+acceptOddBoolReference(OddBool& x)
+{
+ return x;
+}
+
+ClassWithFunctionPointer::ClassWithFunctionPointer()
+{
+ callFunctionPointer(0, &ClassWithFunctionPointer::doNothing);
+}
+
+void ClassWithFunctionPointer::callFunctionPointer(int dummy, void (*fp)(void *))
+{
+ size_t a = dummy;
+ fp(reinterpret_cast<void *>(a));
+}
+
+void ClassWithFunctionPointer::doNothing(void *operand)
+{
+ (void) operand;
+}
diff --git a/sources/shiboken2/tests/libsample/functions.h b/sources/shiboken2/tests/libsample/functions.h
new file mode 100644
index 000000000..89a175bc4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/functions.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FUNCTIONS_H
+#define FUNCTIONS_H
+
+#include "libsamplemacros.h"
+#include <list>
+#include <utility>
+#include "oddbool.h"
+#include "complex.h"
+#include "objecttype.h"
+
+enum GlobalEnum {
+ NoThing,
+ FirstThing,
+ SecondThing,
+ ThirdThing
+};
+
+enum GlobalOverloadFuncEnum {
+ GlobalOverloadFunc_i,
+ GlobalOverloadFunc_d
+};
+
+LIBSAMPLE_API void printSomething();
+LIBSAMPLE_API int gimmeInt();
+LIBSAMPLE_API double gimmeDouble();
+LIBSAMPLE_API double multiplyPair(std::pair<double, double> pair);
+LIBSAMPLE_API std::list<Complex> gimmeComplexList();
+LIBSAMPLE_API Complex sumComplexPair(std::pair<Complex, Complex> cpx_pair);
+
+LIBSAMPLE_API int countCharacters(const char* text);
+LIBSAMPLE_API char* makeCString();
+LIBSAMPLE_API const char* returnCString();
+
+LIBSAMPLE_API char* returnNullPrimitivePointer();
+LIBSAMPLE_API ObjectType* returnNullObjectTypePointer();
+LIBSAMPLE_API Event* returnNullValueTypePointer();
+
+// Tests overloading on functions (!methods)
+LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(int val);
+LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(double val);
+
+LIBSAMPLE_API unsigned int doubleUnsignedInt(unsigned int value);
+LIBSAMPLE_API long long doubleLongLong(long long value);
+LIBSAMPLE_API unsigned long long doubleUnsignedLongLong(unsigned long long value);
+LIBSAMPLE_API short doubleShort(short value);
+
+LIBSAMPLE_API int acceptInt(int x);
+LIBSAMPLE_API unsigned int acceptUInt(unsigned int x);
+LIBSAMPLE_API long acceptLong(long x);
+LIBSAMPLE_API unsigned long acceptULong(unsigned long x);
+LIBSAMPLE_API double acceptDouble(double x);
+
+LIBSAMPLE_API int acceptIntReference(int& x);
+LIBSAMPLE_API OddBool acceptOddBoolReference(OddBool& x);
+
+
+class LIBSAMPLE_API ClassWithFunctionPointer
+{
+public:
+ explicit ClassWithFunctionPointer();
+ void callFunctionPointer(int dummy, void (*fp)(void *));
+ static void doNothing(void *operand);
+};
+
+#endif // FUNCTIONS_H
diff --git a/sources/shiboken2/tests/libsample/handle.cpp b/sources/shiboken2/tests/libsample/handle.cpp
new file mode 100644
index 000000000..e0b1d8d18
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/handle.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "handle.h"
+
+HANDLE HandleHolder::createHandle()
+{
+ return (HANDLE) new OBJ;
+}
+
+bool HandleHolder::compare(HandleHolder* other)
+{
+ return other->m_handle == m_handle;
+}
+
+bool HandleHolder::compare2(HandleHolder* other)
+{
+ return other->m_handle2 == m_handle2;
+}
diff --git a/sources/shiboken2/tests/libsample/handle.h b/sources/shiboken2/tests/libsample/handle.h
new file mode 100644
index 000000000..d656f946b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/handle.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HANDLE_H
+#define HANDLE_H
+
+#include "libsamplemacros.h"
+
+/* See http://bugs.pyside.org/show_bug.cgi?id=1105. */
+namespace Foo {
+ typedef unsigned long HANDLE;
+}
+
+class LIBSAMPLE_API OBJ
+{
+};
+
+typedef OBJ* HANDLE;
+
+class LIBSAMPLE_API HandleHolder
+{
+public:
+ explicit HandleHolder(HANDLE ptr = 0) : m_handle(ptr) {}
+ explicit HandleHolder(Foo::HANDLE val): m_handle2(val) {}
+
+ inline void set(HANDLE ptr) { HANDLE tmp; tmp = m_handle; m_handle = tmp; }
+ inline void set(const Foo::HANDLE& val) { m_handle2 = val; }
+ inline HANDLE handle() { return m_handle; }
+ inline Foo::HANDLE handle2() { return m_handle2; }
+
+ static HANDLE createHandle();
+ bool compare(HandleHolder* other);
+ bool compare2(HandleHolder* other);
+
+private:
+ HANDLE m_handle;
+ Foo::HANDLE m_handle2;
+};
+
+struct LIBSAMPLE_API PrimitiveStruct {};
+typedef struct PrimitiveStruct* PrimitiveStructPtr;
+struct LIBSAMPLE_API PrimitiveStructPointerHolder
+{
+ PrimitiveStructPtr primitiveStructPtr;
+};
+
+#endif // HANDLE_H
diff --git a/sources/shiboken2/tests/libsample/implicitconv.cpp b/sources/shiboken2/tests/libsample/implicitconv.cpp
new file mode 100644
index 000000000..df4af2537
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/implicitconv.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "implicitconv.h"
+
+ImplicitConv
+ImplicitConv::implicitConvCommon(ImplicitConv implicit)
+{
+ return implicit;
+}
+
+ImplicitConv
+ImplicitConv::implicitConvDefault(ImplicitConv implicit)
+{
+ return implicit;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(ImplicitConv implicit, int dummyArg)
+{
+ return ImplicitConv::OverFunc_Ii;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(ImplicitConv implicit, bool dummyArg)
+{
+ return ImplicitConv::OverFunc_Ib;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(int dummyArg)
+{
+ return ImplicitConv::OverFunc_i;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(CtorEnum dummyArg)
+{
+ return ImplicitConv::OverFunc_C;
+}
+
diff --git a/sources/shiboken2/tests/libsample/implicitconv.h b/sources/shiboken2/tests/libsample/implicitconv.h
new file mode 100644
index 000000000..2a8ac66c2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/implicitconv.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMPLICITCONV_H
+#define IMPLICITCONV_H
+
+#include "libsamplemacros.h"
+#include "null.h"
+
+class ObjectType;
+
+class LIBSAMPLE_API ImplicitConv
+{
+public:
+ enum CtorEnum {
+ CtorNone,
+ CtorOne,
+ CtorTwo,
+ CtorThree,
+ CtorObjectTypeReference,
+ CtorPrimitiveType
+ };
+
+ enum ICOverloadedFuncEnum {
+ OverFunc_Ii,
+ OverFunc_Ib,
+ OverFunc_i,
+ OverFunc_C
+ };
+
+ ImplicitConv() : m_ctorEnum(CtorNone), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(int objId) : m_ctorEnum(CtorOne), m_objId(objId), m_value(-1.0) {}
+ ImplicitConv(CtorEnum ctorEnum) : m_ctorEnum(ctorEnum), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(ObjectType&) : m_ctorEnum(CtorObjectTypeReference), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(double value, bool=true) : m_ctorEnum(CtorNone), m_value(value) {}
+ ImplicitConv(const Null& null) : m_ctorEnum(CtorPrimitiveType) {}
+ ~ImplicitConv() {}
+
+ inline CtorEnum ctorEnum() { return m_ctorEnum; }
+ inline int objId() { return m_objId; }
+ inline double value() { return m_value; }
+
+ static ImplicitConv implicitConvCommon(ImplicitConv implicit);
+
+ static ImplicitConv implicitConvDefault(ImplicitConv implicit = CtorTwo);
+
+ static ICOverloadedFuncEnum implicitConvOverloading(ImplicitConv implicit, int dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(ImplicitConv implicit, bool dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(int dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(CtorEnum dummyArg);
+
+private:
+ CtorEnum m_ctorEnum;
+ int m_objId;
+ double m_value;
+};
+
+#endif // IMPLICITCONV_H
diff --git a/sources/shiboken2/tests/libsample/injectcode.cpp b/sources/shiboken2/tests/libsample/injectcode.cpp
new file mode 100644
index 000000000..4406cdc5c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/injectcode.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "injectcode.h"
+#include <sstream>
+
+using namespace std;
+
+InjectCode::InjectCode()
+{
+}
+
+InjectCode::~InjectCode()
+{
+}
+
+template<typename T>
+const char* InjectCode::toStr(const T& value)
+{
+ std::ostringstream s;
+ s << value;
+ m_valueHolder = s.str();
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::simpleMethod1(int arg0, int arg1)
+{
+ return toStr(arg0 + arg1);
+}
+
+const char* InjectCode::simpleMethod2()
+{
+ return "_";
+}
+
+const char* InjectCode::simpleMethod3(int argc, char** argv)
+{
+ for (int i = 0; i < argc; ++i)
+ m_valueHolder += argv[i];
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::overloadedMethod(int arg0, bool arg1)
+{
+ toStr(arg0);
+ m_valueHolder += arg1 ? "true" : "false";
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::overloadedMethod(int arg0, double arg1)
+{
+ return toStr(arg0 + arg1);
+}
+
+const char* InjectCode::overloadedMethod(int argc, char** argv)
+{
+ return simpleMethod3(argc, argv);
+}
+
+const char* InjectCode::virtualMethod(int arg)
+{
+ return toStr(arg);
+}
+
+int InjectCode::arrayMethod(int count, int *values) const
+{
+ int ret = 0;
+ for (int i=0; i < count; i++)
+ ret += values[i];
+ return ret;
+}
+
+int InjectCode::sumArrayAndLength(int* values) const
+{
+ int sum = 0;
+
+ while(*values) {
+ sum = sum + *values + 1;
+ values++;
+ }
+
+ return sum;
+}
diff --git a/sources/shiboken2/tests/libsample/injectcode.h b/sources/shiboken2/tests/libsample/injectcode.h
new file mode 100644
index 000000000..ba1bedb17
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/injectcode.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef INJECTCODE_H
+#define INJECTCODE_H
+
+#include "libsamplemacros.h"
+#include <utility>
+#include <string>
+
+class LIBSAMPLE_API InjectCode
+{
+public:
+ InjectCode();
+ virtual ~InjectCode();
+
+ const char* simpleMethod1(int arg0, int arg1);
+ const char* simpleMethod2();
+ const char* simpleMethod3(int argc, char** argv);
+
+ const char* overloadedMethod(int argc, char** argv);
+ const char* overloadedMethod(int arg0, double arg1);
+ const char* overloadedMethod(int arg0, bool arg1);
+
+ virtual int arrayMethod(int count, int* values) const;
+ inline int callArrayMethod(int count, int *values) const { return arrayMethod(count, values); }
+ virtual const char* virtualMethod(int arg);
+ int sumArrayAndLength(int* values) const;
+private:
+ // This attr is just to retain the memory pointed by all return values,
+ // So, the memory returned by all methods will be valid until someone call
+ // another method of this class.
+ std::string m_valueHolder;
+
+ template<typename T>
+ const char* toStr(const T& value);
+};
+
+#endif // INJECTCODE_H
+
diff --git a/sources/shiboken2/tests/libsample/libsamplemacros.h b/sources/shiboken2/tests/libsample/libsamplemacros.h
new file mode 100644
index 000000000..6a1bba88d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/libsamplemacros.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIBSAMPLEMACROS_H
+#define LIBSAMPLEMACROS_H
+
+#if defined _WIN32 || defined __CYGWIN__
+ #if LIBSAMPLE_BUILD
+ #define LIBSAMPLE_API __declspec(dllexport)
+ #else
+ #define LIBSAMPLE_API __declspec(dllimport)
+ #endif
+#else
+#if __GNUC__ >= 4
+ #define LIBSAMPLE_API __attribute__ ((visibility("default")))
+#else
+ #define LIBSAMPLE_API
+#endif
+#endif
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/list.h b/sources/shiboken2/tests/libsample/list.h
new file mode 100644
index 000000000..f1183440c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/list.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIST_H
+#define LIST_H
+
+#include <list>
+#include "libsamplemacros.h"
+#include "point.h"
+
+class ObjectType;
+
+template<class T>
+class List : public std::list<T>
+{
+};
+
+class IntList : public List<int>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ IntCtor,
+ CopyCtor,
+ ListOfIntCtor
+ };
+
+ inline IntList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit IntList(int val) : m_ctorUsed(IntCtor) { push_back(val); }
+ inline IntList(const IntList& lst) : List<int>(lst), m_ctorUsed(CopyCtor) {}
+ inline IntList(const List<int>& lst) : List<int>(lst), m_ctorUsed(ListOfIntCtor) {}
+
+ inline void append(int v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+class PointValueList : public List<Point>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ PointCtor,
+ CopyCtor,
+ ListOfPointValuesCtor
+ };
+
+ inline PointValueList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit PointValueList(Point val) : m_ctorUsed(PointCtor) { push_back(val); }
+ inline PointValueList(const PointValueList& lst) : List<Point>(lst), m_ctorUsed(CopyCtor) {}
+ inline PointValueList(const List<Point>& lst) : List<Point>(lst), m_ctorUsed(ListOfPointValuesCtor) {}
+
+ inline void append(Point v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+class ObjectTypePtrList : public List<ObjectType*>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ ObjectTypeCtor,
+ CopyCtor,
+ ListOfObjectTypePtrCtor
+ };
+
+ inline ObjectTypePtrList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit ObjectTypePtrList(ObjectType* val) : m_ctorUsed(ObjectTypeCtor) { push_back(val); }
+ inline ObjectTypePtrList(const ObjectTypePtrList& lst) : List<ObjectType*>(lst), m_ctorUsed(CopyCtor) {}
+ inline ObjectTypePtrList(const List<ObjectType*>& lst) : List<ObjectType*>(lst), m_ctorUsed(ListOfObjectTypePtrCtor) {}
+
+ inline void append(ObjectType* v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+#endif // LIST_H
diff --git a/sources/shiboken2/tests/libsample/listuser.cpp b/sources/shiboken2/tests/libsample/listuser.cpp
new file mode 100644
index 000000000..24389766e
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/listuser.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <numeric>
+#include <cstdlib>
+#include "listuser.h"
+
+using namespace std;
+
+std::list<int>
+ListUser::callCreateList()
+{
+ return createList();
+}
+
+std::list<int>
+ListUser::createList()
+{
+ std::list<int> retval;
+ for (int i = 0; i < 4; i++)
+ retval.push_front(rand());
+ return retval;
+}
+
+std::list<Complex>
+ListUser::createComplexList(Complex cpx0, Complex cpx1)
+{
+ std::list<Complex> retval;
+ retval.push_back(cpx0);
+ retval.push_back(cpx1);
+ return retval;
+}
+
+double
+ListUser::sumList(std::list<int> vallist)
+{
+ return std::accumulate(vallist.begin(), vallist.end(), 0.0);
+}
+
+double
+ListUser::sumList(std::list<double> vallist)
+{
+ return std::accumulate(vallist.begin(), vallist.end(), 0.0);
+}
+
+ListUser::ListOfSomething
+ListUser::listOfPoints(const std::list<Point>& pointlist)
+{
+ return ListOfPoint;
+}
+
+ListUser::ListOfSomething
+ListUser::listOfPoints(const std::list<PointF>& pointlist)
+{
+ return ListOfPointF;
+}
+
+void
+ListUser::multiplyPointList(PointList& points, double multiplier)
+{
+ for(PointList::iterator piter = points.begin(); piter != points.end(); piter++) {
+ (*piter)->setX((*piter)->x() * multiplier);
+ (*piter)->setY((*piter)->y() * multiplier);
+ }
+}
+
diff --git a/sources/shiboken2/tests/libsample/listuser.h b/sources/shiboken2/tests/libsample/listuser.h
new file mode 100644
index 000000000..8f49c80d3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/listuser.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LISTUSER_H
+#define LISTUSER_H
+
+#include <list>
+#include "complex.h"
+#include "point.h"
+#include "pointf.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ListUser
+{
+public:
+ typedef std::list<Point*> PointList;
+
+ enum ListOfSomething {
+ ListOfPoint,
+ ListOfPointF
+ };
+
+ ListUser() {}
+ ListUser(const ListUser& other) : m_lst(other.m_lst) {}
+ virtual ~ListUser() {}
+
+ virtual std::list<int> createList();
+ std::list<int> callCreateList();
+
+ static std::list<Complex> createComplexList(Complex cpx0, Complex cpx1);
+
+ double sumList(std::list<int> vallist);
+ double sumList(std::list<double> vallist);
+
+ static ListOfSomething listOfPoints(const std::list<Point>& pointlist);
+ static ListOfSomething listOfPoints(const std::list<PointF>& pointlist);
+
+ static void multiplyPointList(PointList& points, double multiplier);
+
+ inline void setList(std::list<int> lst) { m_lst = lst; }
+ inline std::list<int> getList() { return m_lst; }
+
+private:
+ std::list<int> m_lst;
+};
+
+#endif // LISTUSER_H
+
diff --git a/sources/shiboken2/tests/libsample/main.cpp b/sources/shiboken2/tests/libsample/main.cpp
new file mode 100644
index 000000000..b22d05a36
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/main.cpp
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include <list>
+#include "abstract.h"
+#include "derived.h"
+#include "kindergarten.h"
+#include "complex.h"
+#include "point.h"
+#include "size.h"
+#include "listuser.h"
+#include "samplenamespace.h"
+
+using namespace std;
+
+int
+main(int argv, char **argc)
+{
+ cout << endl;
+
+ Derived derived;
+
+ cout << endl;
+
+ derived.unpureVirtual();
+ derived.pureVirtual();
+ derived.callPureVirtual();
+
+ cout << endl;
+ Abstract* abs;
+ abs = Abstract::createObject();
+ cout << "Abstract::createObject(): " << abs << endl << endl;
+ delete abs;
+
+ abs = Derived::createObject();
+ cout << "Derived::createObject() : ";
+ abs->show();
+ cout << endl;
+ delete abs;
+ cout << endl;
+
+ abs = Derived::createObject();
+ cout << "Derived::createObject() : ";
+ abs->show();
+ cout << endl;
+ delete abs;
+ cout << endl;
+
+ cout << endl << "-----------------------------------------" << endl;
+
+ KinderGarten kg;
+ Derived* d[] = { 0, 0, 0 };
+
+ for (int i = 0; i < 3; i++) {
+ d[i] = new Derived(i);
+ d[i]->show();
+ cout << endl;
+ kg.addChild(d[i]);
+ }
+
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* kill child ";
+ d[2]->show();
+ cout << " ----------------" << endl;
+ kg.killChild(d[2]);
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* release child ";
+ d[1]->show();
+ cout << " -------------" << endl;
+ Abstract* released = kg.releaseChild(d[1]);
+ cout << "released: ";
+ released->show();
+ cout << endl;
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* kill children ------------------------------------" << endl;
+ kg.killChildren();
+ kg.show();
+ cout << endl << endl;
+
+ cout << "-----------------------------------------" << endl;
+ ListUser lu;
+ cout << "ListUser::createList()" << endl;
+ std::list<int> intlist = lu.createList();
+ for (std::list<int>::iterator it = intlist.begin(); it != intlist.end(); it++) {
+ cout << "* " << *it << endl;
+ }
+
+ cout << "ListUser::createComplexList" << endl;
+ std::list<Complex> cpxlist = ListUser::createComplexList(Complex(1.1, 2.2), Complex(3.3, 4.4));
+ for (std::list<Complex>::iterator it = cpxlist.begin(); it != cpxlist.end(); it++) {
+ cout << "* ";
+ (*it).show();
+ cout << endl;
+ }
+ cout << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "SampleNamespace" << endl;
+
+ cout << "SampleNamespace::RandomNumber: ";
+ cout << SampleNamespace::getNumber(SampleNamespace::RandomNumber);
+ cout << endl;
+ cout << "SampleNamespace::UnixTime: ";
+ cout << SampleNamespace::getNumber(SampleNamespace::UnixTime);
+ cout << endl;
+ double val_d = 1.3;
+ cout << "SampleNamespace::powerOfTwo(" << val_d << "): ";
+ cout << SampleNamespace::powerOfTwo(val_d) << endl;
+ int val_i = 7;
+ cout << "SampleNamespace::powerOfTwo(" << val_i << "): ";
+ cout << SampleNamespace::powerOfTwo(val_i) << endl;
+ cout << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "Point" << endl;
+
+ Point p1(1.1, 2.2);
+ cout << "p1: ";
+ p1.show();
+ cout << endl;
+
+ Point p2(3.4, 5.6);
+ cout << "p2: ";
+ p2.show();
+ cout << endl;
+
+ cout << "p1 + p2 == ";
+ (p1 + p2).show();
+ cout << endl;
+
+ cout << "p1 * 2.0 == ";
+ (p1 * 2.0).show();
+ cout << endl;
+
+ cout << "1.5 * p2 == ";
+ (1.5 * p2).show();
+ cout << endl;
+
+ cout << "p1: ";
+ p1.show();
+ cout << endl << "p2: ";
+ p2.show();
+ cout << endl << "p1 += p2" << endl;
+ p1 += p2;
+ cout << "p1: ";
+ p1.show();
+ cout << endl;
+
+ cout << "p1 == p2 ? " << ((p1 == p2) ? "true" : "false") << endl;
+ cout << "p1 == p1 ? " << ((p1 == p1) ? "true" : "false") << endl;
+ cout << "p2 == p2 ? " << ((p2 == p2) ? "true" : "false") << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "Size" << endl;
+
+ Size s1(2, 2);
+ cout << "s1: ";
+ s1.show();
+ cout << ", area: " << s1.calculateArea();
+ cout << endl;
+
+ Size s2(3, 5);
+ cout << "s2: ";
+ s2.show();
+ cout << ", area: " << s2.calculateArea();
+ cout << endl;
+
+ cout << endl;
+
+ cout << "s1 == s2 ? " << ((s1 == s2) ? "true" : "false") << endl;
+ cout << "s1 != s2 ? " << ((s1 != s2) ? "true" : "false") << endl;
+
+ cout << "s1 < s2 ? " << ((s1 < s2) ? "true" : "false") << endl;
+ cout << "s1 <= s2 ? " << ((s1 <= s2) ? "true" : "false") << endl;
+ cout << "s1 > s2 ? " << ((s1 > s2) ? "true" : "false") << endl;
+ cout << "s1 >= s2 ? " << ((s1 >= s2) ? "true" : "false") << endl;
+
+ cout << "s1 < 10 ? " << ((s1 < 10) ? "true" : "false") << endl;
+ cout << "s1 <= 10 ? " << ((s1 <= 10) ? "true" : "false") << endl;
+ cout << "s1 > 10 ? " << ((s1 > 10) ? "true" : "false") << endl;
+ cout << "s1 >= 10 ? " << ((s1 >= 10) ? "true" : "false") << endl;
+ cout << "s2 < 10 ? " << ((s2 < 10) ? "true" : "false") << endl;
+ cout << "s2 <= 10 ? " << ((s2 <= 10) ? "true" : "false") << endl;
+ cout << "s2 > 10 ? " << ((s2 > 10) ? "true" : "false") << endl;
+ cout << "s2 >= 10 ? " << ((s2 >= 10) ? "true" : "false") << endl;
+ cout << endl;
+
+ cout << "s1: ";
+ s1.show();
+ cout << endl << "s2: ";
+ s2.show();
+ cout << endl << "s1 += s2" << endl;
+ s1 += s2;
+ cout << "s1: ";
+ s1.show();
+ cout << endl;
+
+ cout << endl;
+
+ cout << "s1: ";
+ s1.show();
+ cout << endl << "s1 *= 2.0" << endl;
+ s1 *= 2.0;
+ cout << "s1: ";
+ s1.show();
+ cout << endl;
+
+ cout << endl;
+
+ return 0;
+}
+
diff --git a/sources/shiboken2/tests/libsample/mapuser.cpp b/sources/shiboken2/tests/libsample/mapuser.cpp
new file mode 100644
index 000000000..666188512
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/mapuser.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "mapuser.h"
+
+using namespace std;
+
+std::map<std::string, std::pair<Complex, int> >
+MapUser::callCreateMap()
+{
+ return createMap();
+}
+
+
+std::map<std::string, std::pair<Complex, int> >
+MapUser::createMap()
+{
+ std::map<std::string, std::pair<Complex, int> > retval;
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item0("zero", std::pair<Complex, int>(Complex(1.2, 3.4), 2));
+ retval.insert(item0);
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item1("one", std::pair<Complex, int>(Complex(5.6, 7.8), 3));
+ retval.insert(item1);
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item2("two", std::pair<Complex, int>(Complex(9.1, 2.3), 5));
+ retval.insert(item2);
+
+ return retval;
+}
+
+void
+MapUser::showMap(std::map<std::string, int> mapping)
+{
+ std::map<std::string, int>::iterator it;
+ cout << __FUNCTION__ << endl;
+ for (it = mapping.begin() ; it != mapping.end(); it++)
+ cout << (*it).first << " => " << (*it).second << endl;
+}
+
diff --git a/sources/shiboken2/tests/libsample/mapuser.h b/sources/shiboken2/tests/libsample/mapuser.h
new file mode 100644
index 000000000..90d036945
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/mapuser.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAPUSER_H
+#define MAPUSER_H
+
+#include <map>
+#include <list>
+#include <utility>
+#include <string>
+#include "complex.h"
+#include "bytearray.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API MapUser
+{
+public:
+ MapUser() {}
+ virtual ~MapUser() {}
+
+ virtual std::map<std::string, std::pair<Complex, int> > createMap();
+ std::map<std::string, std::pair<Complex, int> > callCreateMap();
+
+ void showMap(std::map<std::string, int> mapping);
+
+ inline void setMap(std::map<std::string, std::list<int> > map) { m_map = map; }
+ inline std::map<std::string, std::list<int> > getMap() { return m_map; }
+
+ // Compile test
+ static void pointerToMap(std::map<std::string, std::string>* arg) {}
+ static void referenceToMap(std::map<std::string, std::string>& arg) {}
+
+ inline const std::map<int, ByteArray>& passMapIntValueType(const std::map<int, ByteArray>& arg) { return arg; }
+
+private:
+ std::map<std::string, std::list<int> > m_map;
+};
+
+#endif // MAPUSER_H
diff --git a/sources/shiboken2/tests/libsample/modelindex.h b/sources/shiboken2/tests/libsample/modelindex.h
new file mode 100644
index 000000000..12cc97ce4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modelindex.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODELINDEX_H
+#define MODELINDEX_H
+
+#include "libsamplemacros.h"
+
+class ModelIndex
+{
+public:
+ ModelIndex() : m_value(0) {}
+ ModelIndex(const ModelIndex& other) { m_value = other.m_value; }
+ inline void setValue(int value) { m_value = value; }
+ inline int value() const { return m_value; }
+ static int getValue(const ModelIndex& index) { return index.value(); }
+private:
+ int m_value;
+};
+
+class ReferentModelIndex
+{
+public:
+ ReferentModelIndex() {}
+ ReferentModelIndex(const ModelIndex& index) : m_index(index) {}
+ ReferentModelIndex(const ReferentModelIndex& other) { m_index = other.m_index; }
+ inline void setValue(int value) { m_index.setValue(value); }
+ inline int value() const { return m_index.value(); }
+ operator const ModelIndex&() const { return m_index; }
+private:
+ ModelIndex m_index;
+};
+
+class PersistentModelIndex
+{
+public:
+ PersistentModelIndex() {}
+ PersistentModelIndex(const ModelIndex& index) : m_index(index) {}
+ PersistentModelIndex(const PersistentModelIndex& other) { m_index = other.m_index; }
+ inline void setValue(int value) { m_index.setValue(value); }
+ inline int value() const { return m_index.value(); }
+ operator ModelIndex() const { return m_index; }
+private:
+ ModelIndex m_index;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/modifications.cpp b/sources/shiboken2/tests/libsample/modifications.cpp
new file mode 100644
index 000000000..4a60a8071
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modifications.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "modifications.h"
+#include "objecttype.h"
+
+using namespace std;
+
+Modifications::Modifications()
+{
+ m_object = new ObjectType();
+ m_object->setObjectName("MyObject");
+}
+
+Modifications::~Modifications()
+{
+ delete m_object;
+}
+
+std::pair<double, double>
+Modifications::pointToPair(Point pt, bool* ok)
+{
+ std::pair<double, double> retval(pt.x(), pt.y());
+ *ok = true;
+ return retval;
+}
+
+double
+Modifications::multiplyPointCoordsPlusValue(bool* ok, Point pt, double value)
+{
+ double retval = (pt.x() * pt.y()) + value;
+ *ok = true;
+ return retval;
+}
+
+int
+Modifications::doublePlus(int value, int plus)
+{
+ return (2 * value) + plus;
+}
+
+int
+Modifications::power(int base, int exponent)
+{
+ if (exponent == 0)
+ return 1;
+ int retval = base;
+ for (int i = 1; i < exponent; i++)
+ retval = retval * base;
+ return retval;
+}
+
+int
+Modifications::timesTen(int number)
+{
+ return number * 10;
+}
+
+int
+Modifications::increment(int number)
+{
+ return ++number;
+}
+
+void
+Modifications::exclusiveCppStuff()
+{
+ cout << __FUNCTION__ << endl;
+}
+
+int
+Modifications::cppMultiply(int a, int b)
+{
+ return a * b;
+}
+
+const char*
+Modifications::className()
+{
+ return "Modifications";
+}
+
+Point
+Modifications::sumPointArray(int arraySize, const Point pointArray[])
+{
+ Point point;
+ for (int i = 0; i < arraySize; ++i)
+ point = point + pointArray[i];
+ return point;
+}
+
+int
+Modifications::getSize(const void* data, int size)
+{
+ (void)data;
+ return size;
+}
+
+int
+Modifications::sumPointCoordinates(const Point* point)
+{
+ return point->x() + point->y();
+}
+
+double
+Modifications::differenceOfPointCoordinates(const Point* pt, bool* ok)
+{
+ if (!pt) {
+ *ok = false;
+ return 0.0;
+ }
+ *ok = true;
+ double result = pt->x() - pt->y();
+ if (result < 0)
+ result = result * -1.0;
+ return result;
+}
+
+bool
+Modifications::nonConversionRuleForArgumentWithDefaultValue(ObjectType** object)
+{
+ if (object)
+ *object = m_object;
+ return true;
+}
diff --git a/sources/shiboken2/tests/libsample/modifications.h b/sources/shiboken2/tests/libsample/modifications.h
new file mode 100644
index 000000000..2978270b0
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modifications.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODIFICATIONS_H
+#define MODIFICATIONS_H
+
+#include "libsamplemacros.h"
+#include <utility>
+#include "point.h"
+#include "oddbool.h"
+
+class ObjectType;
+
+class LIBSAMPLE_API Modifications
+{
+public:
+ Modifications();
+ virtual ~Modifications();
+
+ enum OverloadedModFunc {
+ OverloadedNone,
+ Overloaded_ibid,
+ Overloaded_ibib,
+ Overloaded_ibiP,
+ Overloaded_ibii,
+ Overloaded_ibPP
+ };
+
+ // those overloaded methods should be heavily modified
+ // to push the overload decisor to its limits
+ inline OverloadedModFunc overloaded(int a0, bool b0, int c0, double d0) { return Overloaded_ibid; }
+ inline OverloadedModFunc overloaded(int a1, bool b1, int c1, bool d1) { return Overloaded_ibib; }
+ inline OverloadedModFunc overloaded(int a2, bool b2, int c2, Point d2) { return Overloaded_ibiP; }
+ inline OverloadedModFunc overloaded(int a3, bool b3, int c3 = 123, int d3 = 456) { return Overloaded_ibii; }
+ inline OverloadedModFunc overloaded(int a4, bool b4, Point c4, Point d4) { return Overloaded_ibPP; }
+
+ inline void argRemoval0(int a0, bool a1, int a2 = 123, int a3 = 456) {}
+ inline void argRemoval0(int a0, bool a1, int a2, bool a3) {}
+
+ inline void argRemoval1(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+ inline void argRemoval1(int a0, bool a1, int a2, bool a3) {}
+
+ inline void argRemoval2(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval3(int a0, Point a1 = Point(1, 2), bool a2 = true, Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval4(int a0, Point a1, bool a2, Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval5(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+ inline void argRemoval5(int a0, bool a1, int a2, bool a3) {}
+
+ // 'ok' must be removed and the return value will be changed
+ // to a tuple (PyObject*) containing the expected result plus
+ // the 'ok' value as a Python boolean
+ std::pair<double, double> pointToPair(Point pt, bool* ok);
+
+ // same as 'pointToPair' except that this time 'ok' is the first argument
+ double multiplyPointCoordsPlusValue(bool* ok, Point pt, double value);
+
+ // completely remove 'plus' from the Python side
+ int doublePlus(int value, int plus = 0);
+
+ // the default value for both arguments must be changed in Python
+ int power(int base = 1, int exponent = 0);
+
+ // in Python set argument default value to 10
+ int timesTen(int number);
+
+ // in Python remove the argument default value
+ int increment(int number = 0);
+
+ // don't export this method to Python
+ void exclusiveCppStuff();
+
+ // change the name of this regular method
+ int cppMultiply(int a, int b);
+
+ // change the name of this virtual method
+ virtual const char* className();
+
+ Point sumPointArray(int arraySize, const Point pointArray[]);
+
+ // Replace 'const void*' by 'ByteArray&'.
+ int getSize(const void* data, int size);
+
+ // Mark the argument with a <no-null-pointer/> tag;
+ // the test implementation must expect point never to be null.
+ int sumPointCoordinates(const Point* point);
+
+ // Modify the return value of a virtual method.
+ virtual double differenceOfPointCoordinates(const Point* pt, bool* ok);
+ double callDifferenceOfPointCoordinates(const Point* pt, bool* ok) { return differenceOfPointCoordinates(pt, ok); }
+
+ // Sets an ObjectType in the argument and returns true.
+ bool nonConversionRuleForArgumentWithDefaultValue(ObjectType** object = 0);
+ ObjectType* getObject() const { return m_object; }
+
+ // Inject code with a %CONVERTTOPYTHON that receives an user's primitive type.
+ static inline OddBool passOddBool(OddBool ob) { return ob; }
+
+private:
+ ObjectType* m_object;
+};
+
+class LIBSAMPLE_API AbstractModifications : public Modifications
+{
+public:
+ AbstractModifications() {}
+ virtual ~AbstractModifications() {}
+
+ inline bool invert(bool value) { return !value; }
+
+ // completely remove this method in Python
+ virtual void pointlessPureVirtualMethod() = 0;
+};
+
+#endif // MODIFICATIONS_H
diff --git a/sources/shiboken2/tests/libsample/modified_constructor.cpp b/sources/shiboken2/tests/libsample/modified_constructor.cpp
new file mode 100644
index 000000000..48224358f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modified_constructor.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "modified_constructor.h"
+
+ModifiedConstructor::ModifiedConstructor(int first_arg)
+{
+ m_stored_value = first_arg;
+}
+
+int
+ModifiedConstructor::retrieveValue()
+{
+ return m_stored_value;
+}
+
+
diff --git a/sources/shiboken2/tests/libsample/modified_constructor.h b/sources/shiboken2/tests/libsample/modified_constructor.h
new file mode 100644
index 000000000..9ac5497d7
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modified_constructor.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODIFIEDCONSTRUCTOR_H
+#define MODIFIEDCONSTRUCTOR_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ModifiedConstructor
+{
+public:
+
+ ModifiedConstructor(int first_arg);
+ int retrieveValue();
+
+private:
+ int m_stored_value;
+};
+
+#endif // MODIFIEDCONSTRUCTOR_H
+
diff --git a/sources/shiboken2/tests/libsample/multiple_derived.cpp b/sources/shiboken2/tests/libsample/multiple_derived.cpp
new file mode 100644
index 000000000..1d7a33cbe
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/multiple_derived.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "multiple_derived.h"
+
+MDerived1::MDerived1() : m_value(100)
+{
+}
+
+MDerived2::MDerived2() : m_value(200)
+{
+}
+
+MDerived3::MDerived3() : m_value(3000)
+{
+}
+
+MDerived4::MDerived4()
+{
+}
+
+MDerived5::MDerived5()
+{
+}
+
+MDerived1*
+MDerived1::transformFromBase1(Base1* self)
+{
+ MDerived1* ptr = dynamic_cast<MDerived1*>(self);
+ return ptr;
+}
+
+MDerived1*
+MDerived1::transformFromBase2(Base2* self)
+{
+ MDerived1* ptr = dynamic_cast<MDerived1*>(self);
+ return ptr;
+}
+
diff --git a/sources/shiboken2/tests/libsample/multiple_derived.h b/sources/shiboken2/tests/libsample/multiple_derived.h
new file mode 100644
index 000000000..5825e59b4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/multiple_derived.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MDERIVED_H
+#define MDERIVED_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class Base1
+{
+public:
+ Base1() : m_value(1) {}
+ virtual ~Base1() {}
+ virtual int base1Method() { return m_value; }
+
+ virtual void publicMethod() {};
+private:
+ int m_value;
+};
+
+class Base2
+{
+public:
+ Base2() : m_value(2) {}
+ virtual ~Base2() {}
+ virtual int base2Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived1 : public Base1, public Base2
+{
+public:
+ MDerived1();
+ virtual ~MDerived1() {}
+
+ virtual int mderived1Method() { return m_value; }
+ virtual int base1Method() { return Base1::base1Method() * 10; }
+ virtual int base2Method() { return Base2::base2Method() * 10; }
+
+ inline Base1* castToBase1() { return (Base1*) this; }
+ inline Base2* castToBase2() { return (Base2*) this; }
+
+ static MDerived1* transformFromBase1(Base1 *self);
+ static MDerived1* transformFromBase2(Base2 *self);
+
+private:
+ virtual void publicMethod() {}
+ int m_value;
+};
+
+class SonOfMDerived1 : public MDerived1
+{
+public:
+ SonOfMDerived1() : m_value(0) {}
+ ~SonOfMDerived1() {}
+
+ inline MDerived1* castToMDerived1() { return (MDerived1*) this; }
+
+ int sonOfMDerived1Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base3
+{
+public:
+ explicit Base3(int val = 3) : m_value(val) {}
+ virtual ~Base3() {}
+ int base3Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base4
+{
+public:
+ Base4() : m_value(4) {}
+ virtual ~Base4() {}
+ int base4Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base5
+{
+public:
+ Base5() : m_value(5) {}
+ virtual ~Base5() {}
+ virtual int base5Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base6
+{
+public:
+ Base6() : m_value(6) {}
+ virtual ~Base6() {}
+ virtual int base6Method() { return m_value; }
+private:
+ int m_value;
+};
+
+
+class LIBSAMPLE_API MDerived2 : public Base3, public Base4, public Base5, public Base6
+{
+public:
+ MDerived2();
+ virtual ~MDerived2() {}
+
+ inline int base4Method() { return Base3::base3Method() * 10; }
+ inline int mderived2Method() { return m_value; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+ inline Base5* castToBase5() { return (Base5*) this; }
+ inline Base6* castToBase6() { return (Base6*) this; }
+
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived3 : public MDerived1, public MDerived2
+{
+public:
+ MDerived3();
+ virtual ~MDerived3() {}
+
+ inline virtual int mderived3Method() { return m_value; }
+
+ inline MDerived1* castToMDerived1() { return (MDerived1*) this; }
+ inline MDerived2* castToMDerived2() { return (MDerived2*) this; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived4 : public Base3, public Base4
+{
+public:
+ MDerived4();
+ ~MDerived4() {}
+
+ inline int mderived4Method() { return 0; }
+ inline int justDummyMethod() { return m_value; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived5 : public Base3, public Base4
+{
+public:
+ MDerived5();
+ virtual ~MDerived5() {}
+
+ virtual int mderived5Method() { return 0; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+};
+
+#endif // MDERIVED_H
+
diff --git a/sources/shiboken2/tests/libsample/noimplicitconversion.h b/sources/shiboken2/tests/libsample/noimplicitconversion.h
new file mode 100644
index 000000000..0a8882d3a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/noimplicitconversion.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOIMPLICITCONVERSION_H
+#define NOIMPLICITCONVERSION_H
+
+#include "libsamplemacros.h"
+
+// This class must not have implicit conversions AND
+// no conversion operators should be defined in its own module.
+class NoImplicitConversion
+{
+public:
+ explicit NoImplicitConversion(int objId) : m_objId(objId) {}
+ inline int objId() const { return m_objId; }
+ inline static int receivesNoImplicitConversionByValue(NoImplicitConversion arg) { return arg.m_objId; }
+ inline static int receivesNoImplicitConversionByPointer(NoImplicitConversion* arg) { return arg->m_objId; }
+ inline static int receivesNoImplicitConversionByReference(NoImplicitConversion& arg) { return arg.m_objId; }
+private:
+ int m_objId;
+};
+
+#endif // NOIMPLICITCONVERSION_H
+
diff --git a/sources/shiboken2/tests/libsample/nondefaultctor.h b/sources/shiboken2/tests/libsample/nondefaultctor.h
new file mode 100644
index 000000000..d2b186bd8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/nondefaultctor.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NONDEFAULTCTOR_H
+#define NONDEFAULTCTOR_H
+
+#include "libsamplemacros.h"
+
+class NonDefaultCtor
+{
+ int m_value;
+public:
+ NonDefaultCtor(int value) : m_value(value)
+ {
+ }
+
+ inline int value()
+ {
+ return m_value;
+ }
+
+ inline NonDefaultCtor returnMyself()
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor returnMyself(int)
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor returnMyself(int, NonDefaultCtor)
+ {
+ return *this;
+ }
+
+ virtual NonDefaultCtor returnMyselfVirtual()
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor callReturnMyselfVirtual()
+ {
+ return returnMyselfVirtual();
+ }
+
+ virtual ~NonDefaultCtor() {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/null.h b/sources/shiboken2/tests/libsample/null.h
new file mode 100644
index 000000000..634262a99
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/null.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NULL_H
+#define NULL_H
+
+class Null
+{
+public:
+ Null(bool value) : m_isNull(value) {}
+ Null() : m_isNull(false) {}
+ void setIsNull(bool flag) { m_isNull = flag; }
+
+private:
+ bool m_isNull;
+};
+
+#endif // STR_H
+
diff --git a/sources/shiboken2/tests/libsample/objectmodel.cpp b/sources/shiboken2/tests/libsample/objectmodel.cpp
new file mode 100644
index 000000000..370b58aa1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectmodel.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objectmodel.h"
+
+void
+ObjectModel::setData(ObjectType* data)
+{
+ m_data = data;
+}
+
+ObjectType*
+ObjectModel::data() const
+{
+ return m_data;
+}
+
diff --git a/sources/shiboken2/tests/libsample/objectmodel.h b/sources/shiboken2/tests/libsample/objectmodel.h
new file mode 100644
index 000000000..aa4a64433
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectmodel.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTMODEL_H
+#define OBJECTMODEL_H
+
+#include "objecttype.h"
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ObjectModel : public ObjectType
+{
+public:
+ explicit ObjectModel(ObjectType* parent = 0)
+ : ObjectType(parent), m_data(0)
+ {}
+
+ void setData(ObjectType* data);
+ virtual ObjectType* data() const;
+
+ // The MethodCalled enum and related static methods were created to
+ // test bug #630 [http://bugs.openbossa.org/show_bug.cgi?id=630]
+ enum MethodCalled { ObjectTypeCalled, ObjectModelCalled };
+ static MethodCalled receivesObjectTypeFamily(const ObjectType& object) { return ObjectModel::ObjectTypeCalled; }
+ static MethodCalled receivesObjectTypeFamily(const ObjectModel& object) { return ObjectModel::ObjectModelCalled; }
+
+private:
+ // The model holds only one piece of data.
+ // (This is just a test after all.)
+ ObjectType* m_data;
+};
+
+#endif // OBJECTMODEL_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttype.cpp b/sources/shiboken2/tests/libsample/objecttype.cpp
new file mode 100644
index 000000000..4f10b01df
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttype.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttype.h"
+#include "objecttypelayout.h"
+#include <algorithm>
+#include <iostream>
+#include <string>
+#include <assert.h>
+
+using namespace std;
+
+ObjectType::ObjectType(ObjectType* parent) : m_parent(0), m_layout(0), m_call_id(-1)
+{
+ setParent(parent);
+}
+
+ObjectType::~ObjectType()
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter)
+ delete *child_iter;
+}
+
+ObjectType*
+ObjectType::createWithChild()
+{
+ ObjectType* parent = create();
+ ObjectType* child = create();
+ child->setObjectName("child");
+ child->setParent(parent);
+ return parent;
+}
+
+void
+ObjectType::removeChild(ObjectType* child)
+{
+ if (!child)
+ return;
+
+ ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child);
+ if (child_iter != m_children.end()) {
+ m_children.erase(child_iter);
+ child->m_parent = 0;
+ }
+}
+
+ObjectType*
+ObjectType::takeChild(ObjectType* child)
+{
+ if (!child)
+ return 0;
+
+ ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child);
+ if (child_iter != m_children.end()) {
+ m_children.erase(child_iter);
+ child->m_parent = 0;
+ return child;
+ }
+ return 0;
+}
+
+ObjectType*
+ObjectType::takeChild(const Str& name)
+{
+ return takeChild(findChild(name));
+
+}
+
+ObjectType*
+ObjectType::findChild(const Str& name)
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter) {
+
+ if ((*child_iter)->objectName() == name)
+ return *child_iter;
+ }
+ return 0;
+}
+
+void
+ObjectType::killChild(const Str& name)
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter) {
+
+ if ((*child_iter)->objectName() == name) {
+ ObjectType* child = *child_iter;
+ removeChild(child);
+ delete child;
+ break;
+ }
+ }
+}
+
+void
+ObjectType::setParent(ObjectType* parent)
+{
+ if (m_parent == parent)
+ return;
+
+ if (m_parent)
+ m_parent->removeChild(this);
+
+ m_parent = parent;
+ if (m_parent)
+ m_parent->m_children.push_back(this);
+}
+
+void
+ObjectType::setObjectName(const Str& name)
+{
+ m_objectName = name;
+}
+
+Str
+ObjectType::objectName() const
+{
+ return m_objectName;
+}
+
+bool
+ObjectType::causeEvent(Event::EventType eventType)
+{
+ Event e(eventType);
+ return event(&e);
+}
+
+bool
+ObjectType::event(Event* event)
+{
+ return true;
+}
+
+int
+ObjectType::processEvent(ObjectTypeList objects, Event *event)
+{
+ int evaluated = 0;
+
+ for (ObjectTypeList::iterator obj_iter = objects.begin();
+ obj_iter != objects.end(); ++obj_iter) {
+ if((*obj_iter)->event(event))
+ evaluated++;
+ }
+
+ return evaluated;
+
+}
+
+void
+ObjectType::callInvalidateEvent(Event* event)
+{
+ invalidateEvent(event);
+}
+
+void
+ObjectType::setLayout(ObjectTypeLayout* l)
+{
+ if (!l) {
+ cerr << "[WARNING] ObjectType::setLayout: Cannot set layout to 0." << endl;
+ return;
+ }
+
+ if (layout()) {
+ if (layout() != l) {
+ cerr << "[WARNING] ObjectType::setLayout: Attempting to set ObjectTypeLayout '" << l->objectName().cstring();
+ cerr << "' on ObjectType '" << objectName().cstring() << "', which already has a layout." << endl;
+ }
+ return;
+ }
+
+ ObjectType* oldParent = l->parent();
+ if (oldParent && oldParent != this) {
+ if (oldParent->isLayoutType()) {
+ cerr << "[WARNING] ObjectType::setLayout: Attempting to set ObjectTypeLayout '" << l->objectName().cstring();
+ cerr << "' on ObjectType '" << objectName().cstring() << "', when the ObjectTypeLayout already has a parent layout." << endl;
+ return;
+ } else {
+ // Steal the layout from an ObjectType parent.
+ oldParent->takeLayout();
+ }
+ }
+
+ m_layout = l;
+ if (oldParent != this) {
+ l->setParent(this);
+ l->reparentChildren(this);
+ }
+}
+
+ObjectTypeLayout* ObjectType::takeLayout()
+{
+ ObjectTypeLayout* l = layout();
+ if (!l)
+ return 0;
+ m_layout = 0;
+ l->setParent(0);
+ return l;
+}
+
+unsigned int
+objectTypeHash(const ObjectType* objectType)
+{
+ return reinterpret_cast<std::size_t>(objectType);
+}
+
+unsigned char
+ObjectType::callWithEnum(const Str& prefix, Event::EventType type, unsigned char value){
+ return value*value;
+}
+
+unsigned char
+ObjectType::callWithEnum(const Str& prefix, unsigned char value) {
+ return value;
+}
+
+void
+ObjectType::setObjectSplittedName(const char*, const Str& prefix, const Str& suffix)
+{
+ std::string result(prefix.cstring());
+ result += suffix.cstring();
+ m_objectName = result.c_str();
+}
+
+void
+ObjectType::setObjectNameWithSize(const char*, int size, const Str& name)
+{
+ std::string result(name.cstring(), size);
+ m_objectName = result.c_str();
+}
+
+void
+ObjectType::setObjectNameWithSize(const Str& name, int size)
+{
+ setObjectNameWithSize("", size, name);
+}
+
+void ObjectType::setObject(ObjectType *)
+{
+ m_call_id = 0;
+}
+
+void ObjectType::setObject(const Null&)
+{
+ m_call_id = 1;
+}
+
+int ObjectType::callId() const
+{
+ return m_call_id;
+}
+
+
+void ObjectType::callVirtualCreateChild()
+{
+ ObjectType* fake_parent = new ObjectType();
+ ObjectType* fake_child = createChild(fake_parent);
+ assert(fake_child->isPython());
+ delete fake_parent;
+}
+
+ObjectType* ObjectType::createChild(ObjectType* parent)
+{
+ return new ObjectType(parent);
+}
+
+std::size_t ObjectType::createObjectType()
+{
+ void* addr = new ObjectType();
+ return (std::size_t) addr;
+}
+
+OtherBase::~OtherBase()
+{
+}
+
+ObjectTypeDerived::~ObjectTypeDerived()
+{
+}
+
+bool
+ObjectTypeDerived::event(Event* event)
+{
+ return true;
+}
diff --git a/sources/shiboken2/tests/libsample/objecttype.h b/sources/shiboken2/tests/libsample/objecttype.h
new file mode 100644
index 000000000..eae95b3b1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttype.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPE_H
+#define OBJECTTYPE_H
+
+#include <list>
+#include "str.h"
+#include "null.h"
+
+#include "libsamplemacros.h"
+
+#include <stddef.h>
+
+struct Event
+{
+ enum EventType {
+ NO_EVENT,
+ BASIC_EVENT,
+ SOME_EVENT,
+ ANY_EVENT
+ };
+ Event(EventType eventType) : m_eventType(eventType) {}
+ EventType eventType() { return m_eventType; }
+private:
+ EventType m_eventType;
+};
+
+class ObjectTypeLayout;
+class ObjectType;
+typedef std::list<ObjectType*> ObjectTypeList;
+
+class LIBSAMPLE_API ObjectType
+{
+public:
+ // ### Fixme: Use uintptr_t in C++ 11
+ typedef size_t Identifier;
+
+ explicit ObjectType(ObjectType* parent = 0);
+ virtual ~ObjectType();
+
+ // factory method
+ inline static ObjectType* create() { return new ObjectType(); }
+ static ObjectType* createWithChild();
+
+ void setParent(ObjectType* parent);
+ inline ObjectType* parent() const { return m_parent; }
+ inline const ObjectTypeList& children() const { return m_children; }
+ void killChild(const Str& name);
+ void removeChild(ObjectType* child);
+ ObjectType* takeChild(ObjectType* child);
+ virtual ObjectType* takeChild(const Str& name);
+ ObjectType* findChild(const Str& name);
+
+ Str objectName() const;
+ void setObjectName(const Str& name);
+
+ inline Identifier identifier() const { return reinterpret_cast<Identifier>(this); }
+
+ bool causeEvent(Event::EventType eventType);
+
+ // Returns true if the event is processed.
+ virtual bool event(Event* event);
+ static int processEvent(ObjectTypeList objects, Event *event);
+
+ void callInvalidateEvent(Event* event);
+ virtual void invalidateEvent(Event* event) {}
+
+ // This nonsense method emulate QWidget.setLayout method
+ // All layout objects will became children of this object.
+ void setLayout(ObjectTypeLayout* layout);
+ inline ObjectTypeLayout* layout() const { return m_layout; }
+
+ // This method should be reimplemented by ObjectTypeLayout.
+ virtual bool isLayoutType() { return false; }
+
+ unsigned char callWithEnum(const Str& prefix, Event::EventType type, unsigned char value=80);
+ unsigned char callWithEnum(const Str& prefix, unsigned char value=0);
+
+ //Functions used in test with named arguments
+ void setObjectSplittedName(const char*, const Str& prefix = Str("<unk"), const Str& suffix = Str("nown>"));
+ void setObjectNameWithSize(const char*, int size=9, const Str& name = Str("<unknown>"));
+ void setObjectNameWithSize(const Str& name = Str("<unknown>"), int size=9);
+
+ //Function used to confuse the generator when two values accept Null as arg
+ void setObject(ObjectType *);
+ void setObject(const Null&);
+ int callId() const;
+
+ //Function used to create a parent from C++
+ virtual bool isPython() { return false; }
+ void callVirtualCreateChild();
+ virtual ObjectType* createChild(ObjectType* parent);
+ static std::size_t createObjectType();
+
+ //return a parent from C++
+ ObjectType* getCppParent() {
+ if (!m_parent) {
+ ObjectType* parent = new ObjectType();
+ setParent(parent);
+ }
+ return m_parent;
+ }
+
+ void destroyCppParent() {
+ delete m_parent;
+ m_parent = 0;
+ }
+
+ //Deprecated test
+ bool deprecatedFunction() { return true; }
+
+ // nextInFocusChain simply returns the parent to test object cycles; the parent
+ // may be returned by the QWidget's implementation but isn't always returned
+ ObjectType* nextInFocusChain() { return m_parent; }
+
+private:
+ ObjectType(const ObjectType&);
+ ObjectType& operator=(const ObjectType&);
+
+ ObjectTypeLayout* takeLayout();
+
+ Str m_objectName;
+ ObjectType* m_parent;
+ ObjectTypeList m_children;
+
+ ObjectTypeLayout* m_layout;
+
+
+ //used on overload null test
+ int m_call_id;
+};
+
+LIBSAMPLE_API unsigned int objectTypeHash(const ObjectType* objectType);
+
+class LIBSAMPLE_API OtherBase {
+public:
+ OtherBase() {};
+ virtual ~OtherBase();
+};
+
+class LIBSAMPLE_API ObjectTypeDerived: public ObjectType, public OtherBase {
+public:
+ ObjectTypeDerived(): ObjectType(), OtherBase() {};
+
+ virtual bool event(Event* event);
+ virtual ~ObjectTypeDerived();
+};
+
+#endif // OBJECTTYPE_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttypebyvalue.h b/sources/shiboken2/tests/libsample/objecttypebyvalue.h
new file mode 100644
index 000000000..1b61ec4dc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypebyvalue.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEBYVALUE_H
+#define OBJECTTYPEBYVALUE_H
+#include <list>
+#include "protected.h"
+
+class ObjectTypeByValue
+{
+public:
+ ObjectTypeByValue returnSomeKindOfMe() { return ObjectTypeByValue(); }
+ void acceptKindOfMeAsValue(ObjectTypeByValue kindOfMe) {}
+
+ void acceptListOfObjectTypeByValue(std::list<ObjectTypeByValue> listOfMe) {}
+
+ // prop used to check for segfaults
+ ProtectedProperty prop;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/objecttypeholder.cpp b/sources/shiboken2/tests/libsample/objecttypeholder.cpp
new file mode 100644
index 000000000..dabeb2f86
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeholder.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypeholder.h"
+
+ObjectTypeHolder::ObjectTypeHolder(const char* objectName)
+{
+ m_objectType = new ObjectType();
+ m_objectType->setObjectName(objectName);
+}
+
+ObjectTypeHolder::~ObjectTypeHolder()
+{
+ delete m_objectType;
+}
+
+Str
+ObjectTypeHolder::passObjectTypeAsReference(const ObjectType& objectType)
+{
+ return objectType.objectName();
+}
+
+Str
+ObjectTypeHolder::callPassObjectTypeAsReference()
+{
+ return passObjectTypeAsReference(*m_objectType);
+}
diff --git a/sources/shiboken2/tests/libsample/objecttypeholder.h b/sources/shiboken2/tests/libsample/objecttypeholder.h
new file mode 100644
index 000000000..c2e7275d4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeholder.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEHOLDER_H
+#define OBJECTTYPEHOLDER_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include "str.h"
+
+class LIBSAMPLE_API ObjectTypeHolder
+{
+public:
+ explicit ObjectTypeHolder(const char* objectName);
+ virtual ~ObjectTypeHolder();
+
+ ObjectType* getObjecType() { return m_objectType; }
+
+ virtual Str passObjectTypeAsReference(const ObjectType& objectType);
+ Str callPassObjectTypeAsReference();
+
+private:
+ ObjectType* m_objectType;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/objecttypelayout.cpp b/sources/shiboken2/tests/libsample/objecttypelayout.cpp
new file mode 100644
index 000000000..d2a7d1bba
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypelayout.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypelayout.h"
+#include <iostream>
+
+using namespace std;
+
+void ObjectTypeLayout::addObject(ObjectType* obj)
+{
+ if (obj->isLayoutType()) {
+ ObjectTypeLayout* l = reinterpret_cast<ObjectTypeLayout*>(obj);
+ if (l->parent()) {
+ cerr << "[WARNING] ObjectTypeLayout::addObject: layout '" << l->objectName().cstring();
+ cerr << "' already has a parent." << endl;
+ return;
+ }
+
+ l->setParent(this);
+
+ if (parent() && !parent()->isLayoutType())
+ l->reparentChildren(parent());
+ }
+
+ m_objects.push_back(obj);
+}
+
+std::list< ObjectType* > ObjectTypeLayout::objects() const
+{
+ return m_objects;
+}
+
+void ObjectTypeLayout::reparentChildren(ObjectType* parent)
+{
+ std::list<ObjectType*>::const_iterator it = m_objects.begin();
+ for (; it != m_objects.end(); ++it) {
+ if ((*it)->isLayoutType())
+ reinterpret_cast<ObjectTypeLayout*>(*it)->reparentChildren(parent);
+ else
+ (*it)->setParent(parent);
+ }
+}
+
diff --git a/sources/shiboken2/tests/libsample/objecttypelayout.h b/sources/shiboken2/tests/libsample/objecttypelayout.h
new file mode 100644
index 000000000..3fa8b9dbf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypelayout.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPELAYOUT_H
+#define OBJECTTYPELAYOUT_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include <list>
+
+class ObjectType;
+
+class LIBSAMPLE_API ObjectTypeLayout : public ObjectType
+{
+public:
+ void addObject(ObjectType* obj);
+ std::list<ObjectType*> objects() const;
+
+ virtual bool isLayoutType() { return true; }
+ inline static ObjectTypeLayout* create() { return new ObjectTypeLayout(); }
+
+ virtual ObjectType* takeChild(const Str& name) { return ObjectType::takeChild(name); }
+private:
+ std::list<ObjectType*> m_objects;
+
+ void reparentChildren(ObjectType* parent);
+ friend LIBSAMPLE_API void ObjectType::setLayout(ObjectTypeLayout* l);
+};
+
+#endif // OBJECTTYPELAYOUT_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttypeoperators.cpp b/sources/shiboken2/tests/libsample/objecttypeoperators.cpp
new file mode 100644
index 000000000..1bdaded30
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeoperators.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypeoperators.h"
+
+ObjectTypeOperators::ObjectTypeOperators(const std::string key) : m_key(key)
+{
+}
+
+bool ObjectTypeOperators::operator==(const ObjectTypeOperators& other) const
+{
+ return m_key == other.m_key;
+}
+
+const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const
+{
+ return m_key < other.m_key ? *this : other;
+}
+
+bool operator==(const ObjectTypeOperators* obj, const std::string& str)
+{
+ return obj->key() == str;
+}
+
+bool operator==(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str == obj->key();
+}
+
+std::string operator+(const ObjectTypeOperators* obj, const std::string& str)
+{
+ return obj->key() + str;
+}
+
+std::string operator+(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str + obj->key();
+}
diff --git a/sources/shiboken2/tests/libsample/objecttypeoperators.h b/sources/shiboken2/tests/libsample/objecttypeoperators.h
new file mode 100644
index 000000000..5795ac456
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeoperators.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEOPERATORS_H
+#define OBJECTTYPEOPERATORS_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class LIBSAMPLE_API ObjectTypeOperators
+{
+public:
+ explicit ObjectTypeOperators(const std::string key);
+ virtual ~ObjectTypeOperators() {}
+
+ bool operator==(const ObjectTypeOperators& other) const;
+ const ObjectTypeOperators& operator<(const ObjectTypeOperators& other) const;
+
+ // chaos!
+ virtual void operator>(const ObjectTypeOperators&) { m_key.append("operator>"); }
+
+ std::string key() const { return m_key; }
+
+private:
+ std::string m_key;
+
+ ObjectTypeOperators(ObjectTypeOperators&);
+ ObjectTypeOperators& operator=(ObjectTypeOperators&);
+};
+
+LIBSAMPLE_API bool operator==(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API bool operator==(const std::string& str, const ObjectTypeOperators* obj);
+LIBSAMPLE_API std::string operator+(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API std::string operator+(const std::string& str, const ObjectTypeOperators* obj);
+
+#endif // OBJECTTYPEOPERATORS_H
diff --git a/sources/shiboken2/tests/libsample/objectview.cpp b/sources/shiboken2/tests/libsample/objectview.cpp
new file mode 100644
index 000000000..08c5f45f6
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectview.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objectview.h"
+#include "objectmodel.h"
+#include "str.h"
+
+Str
+ObjectView::displayModelData()
+{
+ if (!m_model)
+ return Str("(NULL)");
+ return Str("Name: %VAR").arg(m_model->objectName());
+}
+
+void
+ObjectView::modifyModelData(Str& data)
+{
+ if (m_model)
+ m_model->setObjectName(data);
+}
+
+
+ObjectType*
+ObjectView::getRawModelData()
+{
+ return m_model->data();
+}
+
diff --git a/sources/shiboken2/tests/libsample/objectview.h b/sources/shiboken2/tests/libsample/objectview.h
new file mode 100644
index 000000000..0bcc09a30
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectview.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTVIEW_H
+#define OBJECTVIEW_H
+
+#include "objecttype.h"
+#include "libsamplemacros.h"
+
+class Str;
+class ObjectModel;
+
+class LIBSAMPLE_API ObjectView : public ObjectType
+{
+public:
+ ObjectView(ObjectModel* model = 0, ObjectType* parent = 0)
+ : ObjectType(parent), m_model(model)
+ {}
+
+ inline void setModel(ObjectModel* model) { m_model = model; }
+ inline ObjectModel* model() const { return m_model; }
+
+ Str displayModelData();
+ void modifyModelData(Str& data);
+
+ ObjectType* getRawModelData();
+
+private:
+ ObjectModel* m_model;
+};
+
+#endif // OBJECTVIEW_H
+
diff --git a/sources/shiboken2/tests/libsample/oddbool.h b/sources/shiboken2/tests/libsample/oddbool.h
new file mode 100644
index 000000000..ee0f4fa03
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/oddbool.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ODDBOOL_H
+#define ODDBOOL_H
+
+#include "libsamplemacros.h"
+
+class OddBool
+{
+
+public:
+ inline explicit OddBool(bool b) : m_value(b) {}
+ bool value() const { return m_value; }
+
+ inline OddBool operator!() const { return OddBool(!m_value); }
+
+private:
+ bool m_value;
+};
+
+inline bool operator==(OddBool b1, bool b2) { return (!b1).value() == !b2; }
+inline bool operator==(bool b1, OddBool b2) { return (!b1) == (!b2).value(); }
+inline bool operator==(OddBool b1, OddBool b2) { return (!b1).value() == (!b2).value(); }
+inline bool operator!=(OddBool b1, bool b2) { return (!b1).value() != !b2; }
+inline bool operator!=(bool b1, OddBool b2) { return (!b1) != (!b2).value(); }
+inline bool operator!=(OddBool b1, OddBool b2) { return (!b1).value() != (!b2).value(); }
+
+class OddBoolUser
+{
+public:
+ OddBoolUser() : m_oddbool(OddBool(false)) {}
+ OddBoolUser(const OddBool& oddBool) : m_oddbool(oddBool) {}
+ virtual ~OddBoolUser() {}
+
+ inline OddBool oddBool() { return m_oddbool; }
+ inline void setOddBool(OddBool oddBool) { m_oddbool = oddBool; }
+
+ virtual OddBool invertedOddBool()
+ {
+ return !m_oddbool;
+ }
+
+ inline OddBool callInvertedOddBool()
+ {
+ return invertedOddBool();
+ }
+
+ static inline OddBool getOddBool(const OddBoolUser& oddBoolUser)
+ {
+ return oddBoolUser.m_oddbool;
+ }
+
+private:
+ OddBool m_oddbool;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/onlycopy.cpp b/sources/shiboken2/tests/libsample/onlycopy.cpp
new file mode 100644
index 000000000..5407f9d33
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/onlycopy.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "onlycopy.h"
+
+OnlyCopy::OnlyCopy(const OnlyCopy& other)
+{
+ m_value = other.m_value;
+}
+
+OnlyCopy&
+OnlyCopy::operator=(const OnlyCopy& other)
+{
+ m_value = other.m_value;
+ return *this;
+}
+
+OnlyCopy
+FriendOfOnlyCopy::createOnlyCopy(int value)
+{
+
+ return OnlyCopy(value);
+}
+
+std::list<OnlyCopy>
+FriendOfOnlyCopy::createListOfOnlyCopy(int quantity)
+{
+ std::list<OnlyCopy> list;
+ for (int i = 0; i < quantity; ++i)
+ list.push_back(createOnlyCopy(i));
+ return list;
+}
diff --git a/sources/shiboken2/tests/libsample/onlycopy.h b/sources/shiboken2/tests/libsample/onlycopy.h
new file mode 100644
index 000000000..6abad7382
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/onlycopy.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ONLYCOPYCLASS_H
+#define ONLYCOPYCLASS_H
+
+#include "libsamplemacros.h"
+#include <list>
+
+// These classes simulate a situation found in
+// QtWebKit's QWebDatabase and QWebSecurityOrigin.
+
+class LIBSAMPLE_API OnlyCopy
+{
+public:
+ OnlyCopy(const OnlyCopy& other);
+ OnlyCopy& operator=(const OnlyCopy& other);
+ int value() const { return m_value; }
+ static int getValue(OnlyCopy onlyCopy) { return onlyCopy.m_value; }
+ static int getValueFromReference(const OnlyCopy& onlyCopy) { return onlyCopy.m_value; }
+private:
+ int m_value;
+ OnlyCopy(int value) : m_value(value) {};
+ friend class FriendOfOnlyCopy;
+};
+
+class LIBSAMPLE_API FriendOfOnlyCopy
+{
+public:
+ static OnlyCopy createOnlyCopy(int value);
+ static std::list<OnlyCopy> createListOfOnlyCopy(int quantity);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/overload.cpp b/sources/shiboken2/tests/libsample/overload.cpp
new file mode 100644
index 000000000..753407e35
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overload.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "overload.h"
+
+Overload::FunctionEnum Overload::overloaded()
+{
+ return Function0;
+}
+
+Overload::FunctionEnum Overload::overloaded(Size* size)
+{
+ return Function1;
+}
+
+Overload::FunctionEnum Overload::overloaded(Point* point, ParamEnum param)
+{
+ return Function2;
+}
+
+Overload::FunctionEnum Overload::overloaded(const Point& point)
+{
+ return Function3;
+}
+
diff --git a/sources/shiboken2/tests/libsample/overload.h b/sources/shiboken2/tests/libsample/overload.h
new file mode 100644
index 000000000..5005b4f8c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overload.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OVERLOAD_H
+#define OVERLOAD_H
+
+#include "echo.h"
+#include "str.h"
+#include "size.h"
+#include "point.h"
+#include "pointf.h"
+#include "polygon.h"
+#include "rect.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Overload
+{
+public:
+ enum FunctionEnum {
+ Function0,
+ Function1,
+ Function2,
+ Function3,
+ Function4,
+ Function5,
+ Function6
+ };
+
+ enum ParamEnum {
+ Param0,
+ Param1
+ };
+
+ Overload() {}
+ virtual ~Overload() {}
+
+ FunctionEnum overloaded();
+ FunctionEnum overloaded(Size* size);
+ FunctionEnum overloaded(Point* point, ParamEnum param);
+ FunctionEnum overloaded(const Point& point);
+
+ inline void differentReturnTypes(ParamEnum param = Param0) {}
+ inline int differentReturnTypes(ParamEnum param, int val) { return val; }
+
+ inline int intOverloads(const Point& p, double d) { return 1; }
+ inline int intOverloads(int i, int i2) { return 2; }
+ inline int intOverloads(int i, int removedArg, double d) { return 3; }
+
+ inline FunctionEnum intDoubleOverloads(int a0, int a1) const { return Function0; }
+ inline FunctionEnum intDoubleOverloads(double a0, double a1) const { return Function1; }
+
+ void singleOverload(Point* x) {}
+ Point* singleOverload() {return new Point();}
+
+ // Similar to QImage::trueMatrix(QMatrix,int,int) and QImage::trueMatrix(QTransform,int,int)
+ FunctionEnum wrapperIntIntOverloads(const Point& arg0, int arg1, int arg2) { return Function0; }
+ FunctionEnum wrapperIntIntOverloads(const Polygon& arg0, int arg1, int arg2) { return Function1; }
+
+ // Similar to QImage constructor
+ FunctionEnum strBufferOverloads(const Str& arg0, const char* arg1 = 0, bool arg2 = true) { return Function0; }
+ FunctionEnum strBufferOverloads(unsigned char* arg0, int arg1) { return Function1; }
+ FunctionEnum strBufferOverloads() { return Function2; }
+
+ // Similar to QPainter::drawText(...)
+ FunctionEnum drawText(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ FunctionEnum drawText(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
+ FunctionEnum drawText(int a0, int a1, const Str& a2) { return Function5; }
+ FunctionEnum drawText(int a0, int a1, int a2, int a3, int a4, const Str& a5) { return Function6; }
+
+ // A variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText2(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText2(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText2(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText2(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ FunctionEnum drawText2(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
+ FunctionEnum drawText2(int a0, int a1, const Str& a2) { return Function5; }
+ FunctionEnum drawText2(int a0, int a1, int a2, int a3 = 0, int a4 = 0, const Str& a5 = Str()) { return Function6; }
+
+ // A simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText3(const Str& a0, const Str& a1, const Str& a2) { return Function0; }
+ FunctionEnum drawText3(int a0, int a1, int a2, int a3, int a4) { return Function1; }
+
+ // Another simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText4(int a0, int a1, int a2) { return Function0; }
+ FunctionEnum drawText4(int a0, int a1, int a2, int a3, int a4) { return Function1; }
+
+ FunctionEnum acceptSequence() { return Function0; }
+ FunctionEnum acceptSequence(int a0, int a1) { return Function1; }
+ FunctionEnum acceptSequence(const Str& a0, ParamEnum a1 = Param0) { return Function2; }
+ FunctionEnum acceptSequence(const Size& a0) { return Function3; }
+ // The type must be changed to PySequence.
+ FunctionEnum acceptSequence(const char* const a0[]) { return Function4; }
+ FunctionEnum acceptSequence(void* a0) { return Function5; }
+};
+
+class LIBSAMPLE_API Overload2 : public Overload
+{
+public:
+ // test bug#616, public and private method differ only by const
+ void doNothingInPublic() const {}
+ void doNothingInPublic(int) {}
+ virtual void doNothingInPublic3() const {}
+ void doNothingInPublic3(int) const {}
+protected:
+ void doNothingInPublic2() const {}
+ void doNothingInPublic2(int) {}
+private:
+ void doNothingInPublic() {}
+ void doNothingInPublic2() {}
+ void doNothingInPublic3() {}
+};
+
+#endif // OVERLOAD_H
+
diff --git a/sources/shiboken2/tests/libsample/overloadsort.cpp b/sources/shiboken2/tests/libsample/overloadsort.cpp
new file mode 100644
index 000000000..f1bc9665b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overloadsort.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "overloadsort.h"
+
diff --git a/sources/shiboken2/tests/libsample/overloadsort.h b/sources/shiboken2/tests/libsample/overloadsort.h
new file mode 100644
index 000000000..9145504ae
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overloadsort.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OVERLOADSORT_H
+#define OVERLOADSORT_H
+
+#include "libsamplemacros.h"
+
+#include <list>
+
+class ImplicitTarget
+{
+public:
+ ImplicitTarget(){}
+};
+
+class ImplicitBase
+{
+public:
+ ImplicitBase(){}
+ ImplicitBase(const ImplicitTarget &b){}
+};
+
+class SortedOverload
+{
+public:
+
+ inline const char *overload(int x) {
+ return "int";
+ }
+
+ inline const char *overload(double x) {
+ return "double";
+ }
+
+ inline const char *overload(ImplicitBase x) {
+ return "ImplicitBase";
+ }
+
+ inline const char *overload(ImplicitTarget x) {
+ return "ImplicitTarget";
+ }
+
+ inline const char *overload(const std::list<ImplicitBase> &x) {
+ return "list(ImplicitBase)";
+ }
+
+ inline int implicit_overload(const ImplicitBase &x) {
+ return 1;
+ }
+
+ inline const char *overloadDeep(int x, ImplicitBase &y) {
+ return "ImplicitBase";
+ }
+
+
+ inline const char* pyObjOverload(int, int) { return "int,int"; }
+ inline const char* pyObjOverload(unsigned char*, int) { return "PyObject,int"; }
+
+};
+
+#endif // OVERLOADSORT_H
+
diff --git a/sources/shiboken2/tests/libsample/pairuser.cpp b/sources/shiboken2/tests/libsample/pairuser.cpp
new file mode 100644
index 000000000..b4b51b8cf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pairuser.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "pairuser.h"
+
+using namespace std;
+
+std::pair<int, int>
+PairUser::callCreatePair()
+{
+ return createPair();
+}
+
+std::pair<int, int>
+PairUser::createPair()
+{
+ return std::pair<int, int>(10, 20);
+}
+
+std::pair<Complex, Complex>
+PairUser::createComplexPair(Complex cpx0, Complex cpx1)
+{
+ return std::pair<Complex, Complex>(cpx0, cpx1);
+}
+
+double
+PairUser::sumPair(std::pair<int, double> pair)
+{
+ return ((double) pair.first) + pair.second;
+}
+
diff --git a/sources/shiboken2/tests/libsample/pairuser.h b/sources/shiboken2/tests/libsample/pairuser.h
new file mode 100644
index 000000000..7b87ba65b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pairuser.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PAIRUSER_H
+#define PAIRUSER_H
+
+#include <utility>
+#include "complex.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API PairUser
+{
+public:
+ PairUser() {}
+ virtual ~PairUser() {}
+
+ virtual std::pair<int, int> createPair();
+ std::pair<int, int> callCreatePair();
+ static std::pair<Complex, Complex> createComplexPair(Complex cpx0, Complex cpx1);
+ double sumPair(std::pair<int, double> pair);
+
+ inline void setPair(std::pair<int, int> pair) { m_pair = pair; }
+ inline std::pair<int, int> getPair() { return m_pair; }
+
+private:
+ std::pair<int, int> m_pair;
+};
+#endif // PAIRUSER_H
+
diff --git a/sources/shiboken2/tests/libsample/pen.cpp b/sources/shiboken2/tests/libsample/pen.cpp
new file mode 100644
index 000000000..509b47c76
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pen.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pen.h"
+
+Color::Color() : m_null(true)
+{
+}
+
+Color::Color(SampleNamespace::InValue arg) : m_null(false)
+{
+}
+
+Color::Color(unsigned int arg) : m_null(false)
+{
+}
+
+bool Color::isNull() const
+{
+ return m_null;
+}
+
+Pen::Pen() : m_ctor(EmptyCtor)
+{
+}
+
+Pen::Pen(SampleNamespace::Option option) : m_ctor(EnumCtor)
+{
+}
+
+Pen::Pen(const Color& color) : m_ctor(ColorCtor)
+{
+}
+
+Pen::Pen(const Pen& pen) : m_ctor(CopyCtor)
+{
+}
+
+int Pen::ctorType()
+{
+ return m_ctor;
+}
diff --git a/sources/shiboken2/tests/libsample/pen.h b/sources/shiboken2/tests/libsample/pen.h
new file mode 100644
index 000000000..e1fb641d3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pen.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEN_H
+#define PEN_H
+
+#include "libsamplemacros.h"
+#include "samplenamespace.h"
+
+class LIBSAMPLE_API Color
+{
+public:
+ Color();
+ Color(SampleNamespace::InValue arg);
+ Color(unsigned int arg);
+
+ bool isNull() const;
+private:
+ bool m_null;
+};
+
+class LIBSAMPLE_API Pen
+{
+public:
+ enum { EmptyCtor, EnumCtor, ColorCtor, CopyCtor };
+
+ Pen();
+ Pen(SampleNamespace::Option option);
+ Pen(const Color& color);
+ Pen(const Pen& pen);
+
+ int ctorType();
+private:
+ int m_ctor;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/photon.cpp b/sources/shiboken2/tests/libsample/photon.cpp
new file mode 100644
index 000000000..debc9f116
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/photon.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "photon.h"
+
+namespace Photon
+{
+const ClassType Base::staticType;
+int callCalculateForValueDuplicatorPointer(ValueDuplicator* value)
+{
+ return value->calculate();
+}
+int callCalculateForValueDuplicatorReference(ValueDuplicator& value)
+{
+ return value.calculate();
+}
+int countValueIdentities(const std::list<ValueIdentity>& values)
+{
+ return values.size();
+}
+int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values)
+{
+ return values.size();
+}
+} // namespace Photon
diff --git a/sources/shiboken2/tests/libsample/photon.h b/sources/shiboken2/tests/libsample/photon.h
new file mode 100644
index 000000000..d8b1be423
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/photon.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PHOTON_H
+#define PHOTON_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+// This namespace and classes simulate
+// situations found in Qt's phonon module.
+
+namespace Photon
+{
+
+enum ClassType {
+ BaseType = 0,
+ IdentityType = 1,
+ DuplicatorType = 2
+};
+
+class LIBSAMPLE_API Base
+{
+public:
+ explicit Base(int value) : m_value(value) {}
+ virtual ~Base() {}
+ inline void setValue(int value) { m_value = value; }
+ inline int value() const { return m_value; }
+
+ template <class T> bool isType() { return type() == T::staticType; }
+ bool isType(ClassType t) { return type() == t; }
+
+ virtual ClassType type() const { return BaseType; };
+ static const ClassType staticType = BaseType;
+
+protected:
+ int m_value;
+};
+
+template<ClassType CLASS_TYPE>
+class LIBSAMPLE_API TemplateBase : public Base
+{
+public:
+ explicit TemplateBase(int value) : Base(value) {}
+ inline int multiplicator() const { return (int)CLASS_TYPE; }
+ inline int calculate() const { return m_value * ((int)CLASS_TYPE); }
+ static inline ClassType classType() { return CLASS_TYPE; }
+
+ inline int sumValueUsingPointer(TemplateBase<CLASS_TYPE>* other) const { return m_value + other->m_value; }
+ inline int sumValueUsingReference(TemplateBase<CLASS_TYPE>& other) const { return m_value + other.m_value; }
+
+ inline std::list<TemplateBase<CLASS_TYPE> > getListOfThisTemplateBase()
+ {
+ std::list<TemplateBase<CLASS_TYPE> > objs;
+ objs.push_back(*this);
+ objs.push_back(*this);
+ return objs;
+ }
+
+ static inline TemplateBase<CLASS_TYPE>* passPointerThrough(TemplateBase<CLASS_TYPE>* obj) { return obj; }
+
+ virtual ClassType type() const { return CLASS_TYPE; }
+ static const ClassType staticType = CLASS_TYPE;
+};
+
+#if defined _WIN32 || defined __CYGWIN__
+template class LIBSAMPLE_API TemplateBase<IdentityType>;
+template class LIBSAMPLE_API TemplateBase<DuplicatorType>;
+#endif
+
+typedef TemplateBase<IdentityType> ValueIdentity;
+typedef TemplateBase<DuplicatorType> ValueDuplicator;
+
+LIBSAMPLE_API int callCalculateForValueDuplicatorPointer(ValueDuplicator* value);
+LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& value);
+LIBSAMPLE_API int countValueIdentities(const std::list<ValueIdentity>& values);
+LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values);
+
+// This simulates an internal error (SEGV) caused by 'noexcept' in
+// boost::intrusive_ptr before support for 'noexcept' was added. The ENTIRE
+// code below is needed to trigger the exception; it isn't seen with just a
+// 'noexcept' following a declaration.
+//
+// NOTE: For reasons that should be fairly obvious, this test unfortunately can
+// only be "run" when building in C++11 mode.
+#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
+# define PHOTON_NOEXCEPT noexcept
+#else
+# define PHOTON_NOEXCEPT
+#endif
+class Pointer
+{
+public:
+ Pointer() PHOTON_NOEXCEPT : px(0) {}
+ Pointer(int* p) : px(p) {}
+
+ void reset() PHOTON_NOEXCEPT { Pointer().swap(*this); }
+
+ int* get() const PHOTON_NOEXCEPT { return px; }
+ int& operator*() const { return *px; }
+
+ void swap(Pointer& rhs) PHOTON_NOEXCEPT
+ {
+ int* tmp = px;
+ px = rhs.px;
+ rhs.px = tmp;
+ }
+
+private:
+ int* px;
+};
+
+} // namespace Photon
+
+#endif // PHOTON_H
diff --git a/sources/shiboken2/tests/libsample/point.cpp b/sources/shiboken2/tests/libsample/point.cpp
new file mode 100644
index 000000000..30275393b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/point.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "point.h"
+
+using namespace std;
+
+Point::Point(int x, int y) : m_x(x), m_y(y)
+{
+}
+
+Point::Point(double x, double y) : m_x(x), m_y(y)
+{
+}
+
+void
+Point::midpoint(const Point& other, Point* midpoint) const
+{
+ if (!midpoint)
+ return;
+ midpoint->setX((m_x + other.m_x) / 2.0);
+ midpoint->setY((m_y + other.m_y) / 2.0);
+}
+
+Point*
+Point::copy() const
+{
+ Point* pt = new Point();
+ pt->m_x = m_x;
+ pt->m_y = m_y;
+ return pt;
+}
+
+void
+Point::show()
+{
+ cout << "(x: " << m_x << ", y: " << m_y << ")";
+}
+
+bool
+Point::operator==(const Point& other)
+{
+ return m_x == other.m_x && m_y == other.m_y;
+}
+
+Point
+Point::operator+(const Point& other)
+{
+ return Point(m_x + other.m_x, m_y + other.m_y);
+}
+
+Point
+Point::operator-(const Point& other)
+{
+ return Point(m_x - other.m_x, m_y - other.m_y);
+}
+
+Point&
+Point::operator+=(Point &other)
+{
+ m_x += other.m_x;
+ m_y += other.m_y;
+ return *this;
+}
+
+Point&
+Point::operator-=(Point &other)
+{
+ m_x -= other.m_x;
+ m_y -= other.m_y;
+ return *this;
+}
+
+Point
+operator*(const Point& pt, double mult)
+{
+ return Point(pt.m_x * mult, pt.m_y * mult);
+}
+
+Point
+operator*(const Point& pt, int mult)
+{
+ return Point(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+Point
+operator*(double mult, const Point& pt)
+{
+ return Point(pt.m_x * mult, pt.m_y * mult);
+}
+
+Point
+operator*(int mult, const Point& pt)
+{
+ return Point(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+Point
+operator-(const Point& pt)
+{
+ return Point(-pt.m_x, -pt.m_y);
+}
+
+bool
+operator!(const Point& pt)
+{
+ return (pt.m_x == 0.0 && pt.m_y == 0.0);
+}
+
+Point
+Point::operator/(int operand)
+{
+ return Point(m_x/operand, m_y/operand);
+}
+
+Complex
+transmutePointIntoComplex(const Point& point)
+{
+ Complex cpx(point.x(), point.y());
+ return cpx;
+}
+
+Point
+transmuteComplexIntoPoint(const Complex& cpx)
+{
+ Point pt(cpx.real(), cpx.imag());
+ return pt;
+}
+
diff --git a/sources/shiboken2/tests/libsample/point.h b/sources/shiboken2/tests/libsample/point.h
new file mode 100644
index 000000000..9416d6ddf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/point.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINT_H
+#define POINT_H
+
+#include "complex.h"
+#include <utility>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Point
+{
+public:
+ Point(int x = 0, int y = 0);
+ Point(double x, double y);
+ ~Point() {}
+
+ inline double x() const { return m_x; }
+ inline double y() const { return m_y; }
+
+ inline void setX(double x) { m_x = x; }
+ inline void setY(double y) { m_y = y; }
+ inline void setXAsUint(unsigned int x) { m_x = x; }
+ inline void setYAsUint(unsigned int y) { m_y = y; }
+
+ // This method could simply return the midpoint,
+ // but the interesting part of the test is to set the
+ // result in the pointer argument.
+ void midpoint(const Point& other, Point* midpoint) const;
+
+ Point* copy() const;
+
+ inline const Point& getConstReferenceToSelf() const { return *this; }
+ inline const Point* getSelf() const { return this; }
+
+ // The != operator is not implemented for the purpose of testing
+ // for the absense of the __ne__ method in the Python binding.
+ bool operator==(const Point& other);
+
+ Point operator+(const Point& other);
+ Point operator-(const Point& other);
+ Point operator/(int operand);
+
+ friend LIBSAMPLE_API Point operator*(const Point& pt, double mult);
+ friend LIBSAMPLE_API Point operator*(const Point& pt, int mult);
+ friend LIBSAMPLE_API Point operator*(double mult, const Point& pt);
+ friend LIBSAMPLE_API Point operator*(int mult, const Point& pt);
+ friend LIBSAMPLE_API Point operator-(const Point& pt);
+ friend LIBSAMPLE_API bool operator!(const Point& pt);
+
+ Point& operator+=(Point &other);
+ Point& operator-=(Point &other);
+
+ void show();
+
+private:
+ double m_x;
+ double m_y;
+};
+
+LIBSAMPLE_API Point operator*(const Point& pt, double mult);
+LIBSAMPLE_API Point operator*(const Point& pt, int mult);
+LIBSAMPLE_API Point operator*(double mult, const Point& pt);
+LIBSAMPLE_API Point operator*(int mult, const Point& pt);
+LIBSAMPLE_API Point operator-(const Point& pt);
+LIBSAMPLE_API bool operator!(const Point& pt);
+
+LIBSAMPLE_API Complex transmutePointIntoComplex(const Point& point);
+LIBSAMPLE_API Point transmuteComplexIntoPoint(const Complex& cpx);
+
+LIBSAMPLE_API Point operator*(const Point& pt, double multiplier);
+
+#endif // POINT_H
diff --git a/sources/shiboken2/tests/libsample/pointerholder.h b/sources/shiboken2/tests/libsample/pointerholder.h
new file mode 100644
index 000000000..84e709d38
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointerholder.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINTERHOLDER_H
+#define POINTERHOLDER_H
+
+#include "libsamplemacros.h"
+
+class PointerHolder
+{
+public:
+ explicit PointerHolder(void* ptr) : m_pointer(ptr) {}
+ ~PointerHolder() {}
+ inline void* pointer() const { return m_pointer; }
+private:
+ void* m_pointer;
+};
+
+#endif // POINTERHOLDER_H
+
diff --git a/sources/shiboken2/tests/libsample/pointf.cpp b/sources/shiboken2/tests/libsample/pointf.cpp
new file mode 100644
index 000000000..0719bdb87
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointf.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "pointf.h"
+
+using namespace std;
+
+PointF::PointF(const Point& point) : m_x(point.x()), m_y(point.y())
+{
+}
+
+PointF::PointF(double x, double y) : m_x(x), m_y(y)
+{
+}
+
+void
+PointF::midpoint(const PointF& other, PointF* midpoint) const
+{
+ if (!midpoint)
+ return;
+ midpoint->setX((m_x + other.m_x) / 2.0);
+ midpoint->setY((m_y + other.m_y) / 2.0);
+}
+
+void
+PointF::show()
+{
+ cout << "(x: " << m_x << ", y: " << m_y << ")";
+}
+
+bool
+PointF::operator==(const PointF& other)
+{
+ return m_x == other.m_x && m_y == other.m_y;
+}
+
+PointF
+PointF::operator+(const PointF& other)
+{
+ return PointF(m_x + other.m_x, m_y + other.m_y);
+}
+
+PointF
+PointF::operator-(const PointF& other)
+{
+ return PointF(m_x - other.m_x, m_y - other.m_y);
+}
+
+PointF&
+PointF::operator+=(PointF &other)
+{
+ m_x += other.m_x;
+ m_y += other.m_y;
+ return *this;
+}
+
+PointF&
+PointF::operator-=(PointF &other)
+{
+ m_x -= other.m_x;
+ m_y -= other.m_y;
+ return *this;
+}
+
+PointF
+operator*(const PointF& pt, double mult)
+{
+ return PointF(pt.m_x * mult, pt.m_y * mult);
+}
+
+PointF
+operator*(const PointF& pt, int mult)
+{
+ return PointF(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+PointF
+operator*(double mult, const PointF& pt)
+{
+ return PointF(pt.m_x * mult, pt.m_y * mult);
+}
+
+PointF
+operator*(int mult, const PointF& pt)
+{
+ return PointF(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+PointF
+operator-(const PointF& pt)
+{
+ return PointF(-pt.m_x, -pt.m_y);
+}
+
+bool
+operator!(const PointF& pt)
+{
+ return (pt.m_x == 0.0 && pt.m_y == 0.0);
+}
+
diff --git a/sources/shiboken2/tests/libsample/pointf.h b/sources/shiboken2/tests/libsample/pointf.h
new file mode 100644
index 000000000..c80739fea
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointf.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINTF_H
+#define POINTF_H
+
+#include "point.h"
+#include <utility>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API PointF
+{
+public:
+ PointF(const Point& point);
+ PointF(double x = 0.0, double y = 0.0);
+ ~PointF() {}
+
+ inline double x() const { return m_x; }
+ inline double y() const { return m_y; }
+
+ inline void setX(double x) { m_x = x; }
+ inline void setY(double y) { m_y = y; }
+
+ // This method could simply return the midpoint,
+ // but the interesting part of the test is to set the
+ // result in the pointer argument.
+ void midpoint(const PointF& other, PointF* midpoint) const;
+
+ // The != operator is not implemented for the purpose of testing
+ // for the absence of the __ne__ method in the Python binding.
+ bool operator==(const PointF& other);
+
+ PointF operator+(const PointF& other);
+ PointF operator-(const PointF& other);
+
+ friend LIBSAMPLE_API PointF operator*(const PointF& pt, double mult);
+ friend LIBSAMPLE_API PointF operator*(const PointF& pt, int mult);
+ friend LIBSAMPLE_API PointF operator*(double mult, const PointF& pt);
+ friend LIBSAMPLE_API PointF operator*(int mult, const PointF& pt);
+ friend LIBSAMPLE_API PointF operator-(const PointF& pt);
+ friend LIBSAMPLE_API bool operator!(const PointF& pt);
+
+ PointF& operator+=(PointF &other);
+ PointF& operator-=(PointF &other);
+
+ void show();
+
+private:
+ double m_x;
+ double m_y;
+};
+
+LIBSAMPLE_API PointF operator*(const PointF& pt, double mult);
+LIBSAMPLE_API PointF operator*(const PointF& pt, int mult);
+LIBSAMPLE_API PointF operator*(double mult, const PointF& pt);
+LIBSAMPLE_API PointF operator*(int mult, const PointF& pt);
+LIBSAMPLE_API PointF operator-(const PointF& pt);
+LIBSAMPLE_API bool operator!(const PointF& pt);
+
+LIBSAMPLE_API PointF operator*(const PointF& pt, double multiplier);
+
+#endif // POINTF_H
diff --git a/sources/shiboken2/tests/libsample/polygon.cpp b/sources/shiboken2/tests/libsample/polygon.cpp
new file mode 100644
index 000000000..cb553a75c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/polygon.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "polygon.h"
+
+using namespace std;
+
+Polygon::Polygon(double x, double y)
+{
+ m_points.push_back(Point(x, y));
+}
+
+Polygon::Polygon(Point point)
+{
+ m_points.push_back(point);
+}
+
+Polygon::Polygon(PointList points)
+{
+ m_points = points;
+}
+
+void
+Polygon::addPoint(Point point)
+{
+ m_points.push_back(point);
+}
+
+Polygon
+Polygon::doublePolygonScale(Polygon polygon)
+{
+ Polygon result;
+ for(PointList::const_iterator piter = result.points().begin(); piter != result.points().end(); piter++)
+ result.addPoint((*piter) * 2.0);
+ return result;
+}
+
+void
+Polygon::stealOwnershipFromPython(Point* point)
+{
+ delete point;
+}
+
+void
+Polygon::stealOwnershipFromPython(Polygon* polygon)
+{
+ delete polygon;
+}
+
diff --git a/sources/shiboken2/tests/libsample/polygon.h b/sources/shiboken2/tests/libsample/polygon.h
new file mode 100644
index 000000000..5e0769e0f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/polygon.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POLYGON_H
+#define POLYGON_H
+
+#include <list>
+#include "point.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Polygon
+{
+public:
+ typedef std::list<Point> PointList;
+
+ Polygon() {}
+ Polygon(double x, double y);
+ Polygon(Point point);
+ Polygon(PointList points);
+ ~Polygon() {}
+
+ void addPoint(Point point);
+
+ inline const PointList& points() const { return m_points; }
+
+ // This method intentionally receives and returns copies of a Polygon object.
+ static Polygon doublePolygonScale(Polygon polygon);
+
+ // This method invalidates the argument to be used for Polygon(Point) implicit conversion.
+ static void stealOwnershipFromPython(Point* point);
+
+ // This method invalidates the argument to be used in a call to doublePolygonScale(Polygon).
+ static void stealOwnershipFromPython(Polygon* polygon);
+
+private:
+ PointList m_points;
+};
+
+#endif // POLYGON_H
+
diff --git a/sources/shiboken2/tests/libsample/privatector.h b/sources/shiboken2/tests/libsample/privatector.h
new file mode 100644
index 000000000..4f4699761
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/privatector.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PRIVATECTOR_H
+#define PRIVATECTOR_H
+
+#include "libsamplemacros.h"
+
+class PrivateCtor
+{
+public:
+ inline static PrivateCtor* instance()
+ {
+ static PrivateCtor self;
+ self.m_instanciations++;
+ return &self;
+ }
+
+ inline int instanceCalls()
+ {
+ return m_instanciations;
+ }
+
+private:
+ int m_instanciations;
+
+ PrivateCtor() : m_instanciations(0) {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/privatedtor.h b/sources/shiboken2/tests/libsample/privatedtor.h
new file mode 100644
index 000000000..a0c4d4769
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/privatedtor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PRIVATEDTOR_H
+#define PRIVATEDTOR_H
+
+#include "libsamplemacros.h"
+
+class PrivateDtor
+{
+public:
+ inline static PrivateDtor* instance()
+ {
+ static PrivateDtor self;
+ self.m_instanciations++;
+ return &self;
+ }
+
+ inline int instanceCalls()
+ {
+ return m_instanciations;
+ }
+
+protected:
+ inline int protectedInstanceCalls() { return m_instanciations; }
+
+private:
+ int m_instanciations;
+
+ PrivateDtor() : m_instanciations(0) {}
+ PrivateDtor(const PrivateDtor&) {}
+ ~PrivateDtor() {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/protected.cpp b/sources/shiboken2/tests/libsample/protected.cpp
new file mode 100644
index 000000000..08c9fd065
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/protected.cpp
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "protected.h"
+
+int ProtectedVirtualDestructor::dtor_called = 0;
+
diff --git a/sources/shiboken2/tests/libsample/protected.h b/sources/shiboken2/tests/libsample/protected.h
new file mode 100644
index 000000000..c33bdf4b2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/protected.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROTECTED_H
+#define PROTECTED_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include "point.h"
+#include <string>
+#include <list>
+
+class LIBSAMPLE_API ProtectedNonPolymorphic
+{
+public:
+ explicit ProtectedNonPolymorphic(const char *name) : m_name(name) {}
+ ~ProtectedNonPolymorphic() {}
+
+ inline const char* publicName() { return m_name.c_str(); }
+
+ inline static ProtectedNonPolymorphic* create() { return new ProtectedNonPolymorphic("created"); }
+
+protected:
+ inline const char* protectedName() { return m_name.c_str(); }
+ inline int protectedSum(int a0, int a1) { return a0 + a1; }
+ inline int modifiedProtectedSum(int a0, int a1) { return a0 + a1; }
+ inline static const char* protectedStatic() { return "protectedStatic"; }
+ inline const char* dataTypeName(void *data = 0) const { return "pointer"; }
+ inline const char* dataTypeName(int data) const { return "integer"; }
+
+private:
+ std::string m_name;
+};
+
+class LIBSAMPLE_API ProtectedPolymorphic
+{
+public:
+ explicit ProtectedPolymorphic(const char *name) : m_name(name) {}
+ virtual ~ProtectedPolymorphic() {}
+
+ inline static ProtectedPolymorphic* create() { return new ProtectedPolymorphic("created"); }
+ inline const char* publicName() { return m_name.c_str(); }
+ inline const char* callProtectedName() { return protectedName(); }
+
+protected:
+ virtual const char* protectedName() { return m_name.c_str(); }
+
+private:
+ std::string m_name;
+};
+
+class LIBSAMPLE_API ProtectedPolymorphicDaughter : public ProtectedPolymorphic
+{
+public:
+ explicit ProtectedPolymorphicDaughter(const char *name) : ProtectedPolymorphic(name) {}
+ inline static ProtectedPolymorphicDaughter* create() { return new ProtectedPolymorphicDaughter("created"); }
+};
+
+class LIBSAMPLE_API ProtectedPolymorphicGrandDaughter: public ProtectedPolymorphicDaughter
+{
+public:
+ explicit ProtectedPolymorphicGrandDaughter(const char *name) : ProtectedPolymorphicDaughter(name) {}
+ inline static ProtectedPolymorphicGrandDaughter* create() { return new ProtectedPolymorphicGrandDaughter("created"); }
+};
+
+class LIBSAMPLE_API ProtectedVirtualDestructor
+{
+public:
+ ProtectedVirtualDestructor() {}
+ inline static ProtectedVirtualDestructor* create() { return new ProtectedVirtualDestructor(); }
+ inline static int dtorCalled() { return dtor_called; }
+ inline static void resetDtorCounter() { dtor_called = 0; }
+protected:
+ virtual ~ProtectedVirtualDestructor() { dtor_called++; }
+private:
+ static int dtor_called;
+};
+
+class LIBSAMPLE_API ProtectedEnumClass
+{
+public:
+ ProtectedEnumClass() {}
+ virtual ~ProtectedEnumClass() {}
+ enum PublicEnum {
+ PublicItem0,
+ PublicItem1
+ };
+protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+ ProtectedEnum callProtectedEnumMethod(ProtectedEnum in) { return protectedEnumMethod(in); }
+ inline PublicEnum callPublicEnumMethod(PublicEnum in) { return publicEnumMethod(in); }
+
+ virtual ProtectedEnum protectedEnumMethod(ProtectedEnum in) { return in; }
+ virtual PublicEnum publicEnumMethod(PublicEnum in) { return in; }
+};
+
+
+class LIBSAMPLE_API ProtectedProperty
+{
+public:
+ ProtectedProperty()
+ : protectedValueTypeProperty(Point(0, 0)),
+ protectedProperty(0),
+ protectedEnumProperty(Event::NO_EVENT),
+ protectedValueTypePointerProperty(0),
+ protectedObjectTypeProperty(0)
+ {}
+protected:
+ // This is deliberately the first member to test wrapper registration
+ // for value type members sharing the same memory address.
+ Point protectedValueTypeProperty;
+ int protectedProperty;
+ std::list<int> protectedContainerProperty;
+ Event::EventType protectedEnumProperty;
+ Point* protectedValueTypePointerProperty;
+ ObjectType* protectedObjectTypeProperty;
+};
+
+LIBSAMPLE_API inline ProtectedProperty* createProtectedProperty() {
+ return new ProtectedProperty;
+}
+
+#endif // PROTECTED_H
diff --git a/sources/shiboken2/tests/libsample/rect.h b/sources/shiboken2/tests/libsample/rect.h
new file mode 100644
index 000000000..b7ce6e890
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/rect.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RECT_H
+#define RECT_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Rect
+{
+public:
+ Rect()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ Rect(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ ~Rect() {}
+ inline int left() const { return m_left; }
+ inline int top() const { return m_top; }
+ inline int right() const { return m_right; }
+ inline int bottom() const { return m_bottom; }
+private:
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+};
+
+class LIBSAMPLE_API RectF
+{
+public:
+ RectF()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ RectF(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ RectF(const Rect& other)
+ {
+ m_left = other.left();
+ m_top = other.top();
+ m_right = other.right();
+ m_bottom = other.bottom();
+ }
+ ~RectF() {}
+ inline double left() const { return m_left; }
+ inline double top() const { return m_top; }
+ inline double right() const { return m_right; }
+ inline double bottom() const { return m_bottom; }
+private:
+ double m_left;
+ double m_top;
+ double m_right;
+ double m_bottom;
+};
+
+#endif // RECT_H
+
diff --git a/sources/shiboken2/tests/libsample/reference.cpp b/sources/shiboken2/tests/libsample/reference.cpp
new file mode 100644
index 000000000..31a11a8ae
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/reference.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "reference.h"
+
+using namespace std;
+
+void
+Reference::show() const
+{
+ cout << "Reference.objId: " << m_objId << ", address: " << this;
+}
+
+int
+Reference::usesReferenceVirtual(Reference& r, int inc)
+{
+ return r.m_objId + inc;
+}
+
+int
+Reference::usesConstReferenceVirtual(const Reference& r, int inc)
+{
+ return r.m_objId + inc;
+}
+
+int
+Reference::callUsesReferenceVirtual(Reference& r, int inc)
+{
+ return usesReferenceVirtual(r, inc);
+}
+
+int
+Reference::callUsesConstReferenceVirtual(const Reference& r, int inc)
+{
+ return usesConstReferenceVirtual(r, inc);
+}
+
+void
+Reference::alterReferenceIdVirtual(Reference& r)
+{
+ r.setObjId(r.objId() * Reference::multiplier());
+}
+
+void
+Reference::callAlterReferenceIdVirtual(Reference& r)
+{
+ alterReferenceIdVirtual(r);
+}
+
+ObjTypeReference::~ObjTypeReference()
+{
+}
diff --git a/sources/shiboken2/tests/libsample/reference.h b/sources/shiboken2/tests/libsample/reference.h
new file mode 100644
index 000000000..4ec8ee7fd
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/reference.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REFERENCE_H
+#define REFERENCE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Reference
+{
+public:
+ explicit Reference(int objId = -1)
+ : m_objId(objId) {}
+ virtual ~Reference() {}
+
+ inline int objId() { return m_objId; }
+ inline void setObjId(int objId) { m_objId = objId; }
+
+ inline static int usesReference(Reference& r) { return r.m_objId; }
+ inline static int usesConstReference(const Reference& r) { return r.m_objId; }
+
+ virtual int usesReferenceVirtual(Reference& r, int inc);
+ virtual int usesConstReferenceVirtual(const Reference& r, int inc);
+
+ int callUsesReferenceVirtual(Reference& r, int inc);
+ int callUsesConstReferenceVirtual(const Reference& r, int inc);
+
+ virtual void alterReferenceIdVirtual(Reference& r);
+ void callAlterReferenceIdVirtual(Reference& r);
+
+ void show() const;
+
+ inline static int multiplier() { return 10; }
+
+ virtual Reference& returnMyFirstArg(Reference& ref) { return ref; }
+ virtual Reference& returnMySecondArg(int a, Reference& ref) { return ref; }
+
+ // nonsense operator to test if Shiboken is ignoring dereference operators.
+ int operator*() { return m_objId; }
+private:
+ int m_objId;
+};
+
+class LIBSAMPLE_API ObjTypeReference
+{
+public:
+ ObjTypeReference() {}
+ ObjTypeReference(const ObjTypeReference&) {}
+ virtual ~ObjTypeReference();
+ virtual ObjTypeReference& returnMyFirstArg(ObjTypeReference& ref) { return ref; }
+ virtual ObjTypeReference& returnMySecondArg(int a, ObjTypeReference& ref) { return ref; }
+ virtual ObjTypeReference& justAPureVirtualFunc(ObjTypeReference& ref) = 0;
+};
+
+#endif // REFERENCE_H
+
diff --git a/sources/shiboken2/tests/libsample/removednamespaces.h b/sources/shiboken2/tests/libsample/removednamespaces.h
new file mode 100644
index 000000000..4520b6a27
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/removednamespaces.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REMOVEDNAMESPACE_H
+#define REMOVEDNAMESPACE_H
+
+#include "libsamplemacros.h"
+
+namespace RemovedNamespace1
+{
+
+enum RemovedNamespace1_Enum {
+ RemovedNamespace1_Enum_Value0
+};
+
+enum {
+ RemovedNamespace1_AnonymousEnum_Value0
+};
+
+namespace RemovedNamespace2 {
+ enum RemovedNamespace2_Enum {
+ RemovedNamespace2_Enum_Value0
+ };
+}
+
+}
+
+namespace UnremovedNamespace
+{
+namespace RemovedNamespace3
+{
+ enum RemovedNamespace3_Enum {
+ RemovedNamespace3_Enum_Value0
+ };
+
+ enum {
+ RemovedNamespace3_AnonymousEnum_Value0
+ };
+}
+}
+
+#endif // REMOVEDNAMESPACE_H
+
diff --git a/sources/shiboken2/tests/libsample/sample.cpp b/sources/shiboken2/tests/libsample/sample.cpp
new file mode 100644
index 000000000..fa1e1fda3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sample.cpp
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sample.h"
+
+sample::sample::sample(int value) : m_value(value)
+{
+}
+
+int sample::sample::value() const
+{
+ return m_value;
+}
+
diff --git a/sources/shiboken2/tests/libsample/sample.h b/sources/shiboken2/tests/libsample/sample.h
new file mode 100644
index 000000000..46e3d0d1a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sample.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SAMPLE_H
+#define SAMPLE_H
+
+#include "libsamplemacros.h"
+
+// namespace with the same name of the current package to try to mess up with the generator
+namespace sample
+{
+ // to increase the mess we add a class with the same name of the package/namespace
+ class LIBSAMPLE_API sample
+ {
+ public:
+ sample(int value = 0);
+ int value() const;
+ private:
+ int m_value;
+ };
+}
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/samplenamespace.cpp b/sources/shiboken2/tests/libsample/samplenamespace.cpp
new file mode 100644
index 000000000..1fc6dff40
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/samplenamespace.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include <cstdlib>
+#include <time.h>
+#include "samplenamespace.h"
+
+using namespace std;
+
+namespace SampleNamespace
+{
+
+OutValue
+enumInEnumOut(InValue in)
+{
+ OutValue retval;
+ switch(in) {
+ case ZeroIn:
+ retval = ZeroOut;
+ break;
+ case OneIn:
+ retval = OneOut;
+ break;
+ case TwoIn:
+ retval = TwoOut;
+ break;
+ default:
+ retval = (OutValue) -1;
+ }
+ return retval;
+}
+
+Option
+enumArgumentWithDefaultValue(Option opt)
+{
+ return opt;
+}
+
+int
+getNumber(Option opt)
+{
+ int retval;
+ switch(opt) {
+ case RandomNumber:
+ retval = rand() % 100;
+ break;
+ case UnixTime:
+ retval = (int) time(0);
+ break;
+ default:
+ retval = 0;
+ }
+ return retval;
+}
+
+void
+doSomethingWithArray(const unsigned char* data, unsigned int size, const char* format)
+{
+ // This function does nothing in fact.
+ // It is here as a dummy copy of QPixmap.loadFromData method
+ // to check compilation issues, i.e. if it compiles, it's ok.
+}
+
+int
+enumItemAsDefaultValueToIntArgument(int value)
+{
+ return value;
+}
+
+void
+forceDecisorSideA(ObjectType* object)
+{
+}
+
+void
+forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object)
+{
+}
+
+void
+forceDecisorSideB(int a, ObjectType* object)
+{
+}
+
+void
+forceDecisorSideB(int a, const Point& pt, const Str& text, ObjectType* object)
+{
+}
+
+double
+passReferenceToValueType(const Point& point, double multiplier)
+{
+ return (point.x() + point.y()) * multiplier;
+}
+
+int
+passReferenceToObjectType(const ObjectType& obj, int multiplier)
+{
+ return obj.objectName().size() * multiplier;
+}
+
+} // namespace SampleNamespace
diff --git a/sources/shiboken2/tests/libsample/samplenamespace.h b/sources/shiboken2/tests/libsample/samplenamespace.h
new file mode 100644
index 000000000..3ce410941
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/samplenamespace.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SAMPLENAMESPACE_H
+#define SAMPLENAMESPACE_H
+
+#include <list>
+#include "libsamplemacros.h"
+#include "str.h"
+#include "point.h"
+#include "objecttype.h"
+
+// Anonymous global enum
+enum {
+ AnonymousGlobalEnum_Value0,
+ AnonymousGlobalEnum_Value1
+};
+
+// Invisible namespace
+namespace Invisible
+{
+
+enum EnumOnNamespace {
+ Option1 = 1,
+ Option2 = 2,
+ Option3 = 3
+};
+
+};
+
+namespace SampleNamespace
+{
+
+enum Option {
+ None_,
+ RandomNumber,
+ UnixTime
+};
+
+enum InValue {
+ ZeroIn,
+ OneIn,
+ TwoIn
+};
+
+enum OutValue {
+ ZeroOut,
+ OneOut,
+ TwoOut
+};
+
+// Anonymous non-global enum.
+// This counts as a class enum, since C++ namespaces
+// are represented as classes in Python.
+enum {
+ AnonymousClassEnum_Value0,
+ AnonymousClassEnum_Value1
+};
+
+LIBSAMPLE_API OutValue enumInEnumOut(InValue in);
+
+LIBSAMPLE_API Option enumArgumentWithDefaultValue(Option opt = UnixTime);
+
+LIBSAMPLE_API int getNumber(Option opt);
+
+inline double powerOfTwo(double num) {
+ return num * num;
+}
+
+LIBSAMPLE_API void doSomethingWithArray(const unsigned char* data, unsigned int size, const char* format = 0);
+
+LIBSAMPLE_API int enumItemAsDefaultValueToIntArgument(int value = ZeroIn);
+
+class SomeClass
+{
+public:
+ class SomeInnerClass
+ {
+ public:
+ class OkThisIsRecursiveEnough
+ {
+ public:
+ virtual ~OkThisIsRecursiveEnough() {}
+ enum NiceEnum {
+ NiceValue1, NiceValue2
+ };
+
+ inline int someMethod(SomeInnerClass*) { return 0; }
+ virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
+ };
+ protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+ };
+ struct SomeOtherInnerClass {
+ std::list<SomeInnerClass> someInnerClasses;
+ };
+protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+};
+
+class DerivedFromNamespace : public SomeClass::SomeInnerClass::OkThisIsRecursiveEnough
+{
+public:
+ // FIXME Uncomment this when the fix for MSVC is available
+ // only to cause namespace confusion
+// enum SampleNamespace {
+// };
+ virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
+ inline OkThisIsRecursiveEnough* methodReturningTypeFromParentScope() { return 0; }
+};
+
+// The combination of the following two overloaded methods could trigger a
+// problematic behaviour on the overload decisor, if it isn't working properly.
+LIBSAMPLE_API void forceDecisorSideA(ObjectType* object = 0);
+LIBSAMPLE_API void forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object = 0);
+
+// The combination of the following two overloaded methods could trigger a
+// problematic behaviour on the overload decisor, if it isn't working properly.
+// This is a variation of forceDecisorSideB.
+LIBSAMPLE_API void forceDecisorSideB(int a, ObjectType* object = 0);
+LIBSAMPLE_API void forceDecisorSideB(int a, const Point& pt, const Str& text, ObjectType* object = 0);
+
+// Add a new signature on type system with only a Point value as parameter.
+LIBSAMPLE_API double passReferenceToValueType(const Point& point, double multiplier);
+// Add a new signature on type system with only a ObjectType pointer as parameter.
+LIBSAMPLE_API int passReferenceToObjectType(const ObjectType& obj, int multiplier);
+
+} // namespace SampleNamespace
+
+#endif // SAMPLENAMESPACE_H
+
diff --git a/sources/shiboken2/tests/libsample/sbkdate.cpp b/sources/shiboken2/tests/libsample/sbkdate.cpp
new file mode 100644
index 000000000..e823521ec
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sbkdate.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sbkdate.h"
+
+SbkDate::SbkDate(int d, int m, int y) : m_d(d), m_m(m), m_y(y)
+{
+}
+
+int SbkDate::day() const
+{
+ return m_d;
+}
+
+int SbkDate::month() const
+{
+ return m_m;
+}
+
+int SbkDate::year() const
+{
+ return m_y;
+}
diff --git a/sources/shiboken2/tests/libsample/sbkdate.h b/sources/shiboken2/tests/libsample/sbkdate.h
new file mode 100644
index 000000000..7d0893cbb
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sbkdate.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SBKDATE_H
+#define SBKDATE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API SbkDate
+{
+public:
+ SbkDate(int d, int m, int y);
+
+ int day() const;
+ int month() const;
+ int year() const;
+
+private:
+ int m_d;
+ int m_m;
+ int m_y;
+};
+
+#endif // SBKDATE_H
+
diff --git a/sources/shiboken2/tests/libsample/simplefile.cpp b/sources/shiboken2/tests/libsample/simplefile.cpp
new file mode 100644
index 000000000..bdbd3d1f5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/simplefile.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <fstream>
+#include "simplefile.h"
+
+class SimpleFile_p
+{
+public:
+ SimpleFile_p(const char* filename) : m_descriptor(0), m_size(0)
+ {
+ m_filename = strdup(filename);
+ }
+
+ ~SimpleFile_p()
+ {
+ free(m_filename);
+ }
+
+ char* m_filename;
+ FILE* m_descriptor;
+ long m_size;
+};
+
+SimpleFile::SimpleFile(const char* filename)
+{
+ p = new SimpleFile_p(filename);
+}
+
+SimpleFile::~SimpleFile()
+{
+ close();
+ delete p;
+}
+
+const char* SimpleFile::filename()
+{
+ return p->m_filename;
+}
+
+long SimpleFile::size()
+{
+ return p->m_size;
+}
+
+bool
+SimpleFile::open()
+{
+ if ((p->m_descriptor = fopen(p->m_filename, "rb")) == 0)
+ return false;
+
+ fseek(p->m_descriptor, 0, SEEK_END);
+ p->m_size = ftell(p->m_descriptor);
+ rewind(p->m_descriptor);
+
+ return true;
+}
+
+void
+SimpleFile::close()
+{
+ if (p->m_descriptor) {
+ fclose(p->m_descriptor);
+ p->m_descriptor = 0;
+ }
+}
+
+bool
+SimpleFile::exists() const
+{
+ std::ifstream ifile(p->m_filename);
+ return !ifile.fail();
+}
+
+bool
+SimpleFile::exists(const char* filename)
+{
+ std::ifstream ifile(filename);
+ return !ifile.fail();
+}
+
diff --git a/sources/shiboken2/tests/libsample/simplefile.h b/sources/shiboken2/tests/libsample/simplefile.h
new file mode 100644
index 000000000..bae3b9998
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/simplefile.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMPLEFILE_H
+#define SIMPLEFILE_H
+
+#include "libsamplemacros.h"
+#include <stdio.h>
+
+class SimpleFile_p;
+
+class LIBSAMPLE_API SimpleFile
+{
+public:
+ explicit SimpleFile(const char* filename);
+ ~SimpleFile();
+
+ const char* filename();
+ long size();
+ bool open();
+ void close();
+
+ bool exists() const;
+ static bool exists(const char* filename);
+
+private:
+ SimpleFile_p *p;
+};
+
+#endif // SIMPLEFILE_H
+
diff --git a/sources/shiboken2/tests/libsample/size.cpp b/sources/shiboken2/tests/libsample/size.cpp
new file mode 100644
index 000000000..1faf5dfb2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/size.cpp
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "size.h"
+
+using namespace std;
+
+void
+Size::show() const
+{
+ cout << "(width: " << m_width << ", height: " << m_height << ")";
+}
+
diff --git a/sources/shiboken2/tests/libsample/size.h b/sources/shiboken2/tests/libsample/size.h
new file mode 100644
index 000000000..433aba770
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/size.h
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIZE_H
+#define SIZE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Size
+{
+public:
+ Size(double width = 0.0, double height = 0.0) : m_width(width), m_height(height) {}
+ ~Size() {}
+
+ inline double width() { return m_width; }
+ inline void setWidth(double width) { m_width = width; }
+ inline double height() { return m_height; }
+ inline void setHeight(double height) { m_height = height; }
+
+ inline double calculateArea() const { return m_width * m_height; }
+
+ // Comparison Operators
+ inline bool operator==(const Size& other)
+ {
+ return m_width == other.m_width && m_height == other.m_height;
+ }
+
+ inline bool operator<(const Size& other)
+ {
+ return calculateArea() < other.calculateArea();
+ }
+
+ inline bool operator>(const Size& other)
+ {
+ // On some x86 hardware and compiler combinations, floating point
+ // comparisons may fail due to a hardware bug. One workaround is to
+ // simplify comparison expressions by putting partial results in
+ // variables. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c109
+ // for details.
+ double a = calculateArea();
+ double b = other.calculateArea();
+ return a > b;
+ }
+
+ inline bool operator<=(const Size& other)
+ {
+ // See comments for operator>()
+ double a = calculateArea();
+ double b = other.calculateArea();
+ return a <= b;
+ }
+
+ inline bool operator>=(const Size& other)
+ {
+ return calculateArea() >= other.calculateArea();
+ }
+
+ inline bool operator<(double area) { return calculateArea() < area; }
+ inline bool operator>(double area) { return calculateArea() > area; }
+ inline bool operator<=(double area) { return calculateArea() <= area; }
+ inline bool operator>=(double area) { return calculateArea() >= area; }
+
+ // Arithmetic Operators
+ inline Size& operator+=(const Size& s)
+ {
+ m_width += s.m_width;
+ m_height += s.m_height;
+ return *this;
+ }
+
+ inline Size& operator-=(const Size& s)
+ {
+ m_width -= s.m_width;
+ m_height -= s.m_height;
+ return *this;
+ }
+
+ inline Size& operator*=(double mult)
+ {
+ m_width *= mult;
+ m_height *= mult;
+ return *this;
+ }
+
+ inline Size& operator/=(double div)
+ {
+ m_width /= div;
+ m_height /= div;
+ return *this;
+ }
+
+ // TODO: add ++size, size++, --size, size--
+
+ // External operators
+ friend inline bool operator!=(const Size&, const Size&);
+ friend inline const Size operator+(const Size&, const Size&);
+ friend inline const Size operator-(const Size&, const Size&);
+ friend inline const Size operator*(const Size&, double);
+ friend inline const Size operator*(double, const Size&);
+ friend inline const Size operator/(const Size&, double);
+
+ friend inline bool operator<(double, const Size&);
+ friend inline bool operator>(double, const Size&);
+ friend inline bool operator<=(double, const Size&);
+ friend inline bool operator>=(double, const Size&);
+
+ void show() const;
+
+private:
+ double m_width;
+ double m_height;
+};
+
+// Comparison Operators
+inline bool operator!=(const Size& s1, const Size& s2)
+{
+ return s1.m_width != s2.m_width || s1.m_height != s2.m_height;
+}
+
+inline bool operator<(double area, const Size& s)
+{
+ return area < s.calculateArea();
+}
+
+inline bool operator>(double area, const Size& s)
+{
+ return area > s.calculateArea();
+}
+
+inline bool operator<=(double area, const Size& s)
+{
+ return area <= s.calculateArea();
+}
+
+inline bool operator>=(double area, const Size& s)
+{
+ return area >= s.calculateArea();
+}
+
+// Arithmetic Operators
+inline const Size operator+(const Size& s1, const Size& s2)
+{
+ return Size(s1.m_width + s2.m_width, s1.m_height + s2.m_height);
+}
+
+inline const Size operator-(const Size& s1, const Size& s2)
+{
+ return Size(s1.m_width - s2.m_width, s1.m_height - s2.m_height);
+}
+
+inline const Size operator*(const Size& s, double mult)
+{
+ return Size(s.m_width * mult, s.m_height * mult);
+}
+
+inline const Size operator*(double mult, const Size& s)
+{
+ return Size(s.m_width * mult, s.m_height * mult);
+}
+
+inline const Size operator/(const Size& s, double div)
+{
+ return Size(s.m_width / div, s.m_height / div);
+}
+
+typedef double real;
+typedef unsigned short ushort;
+class LIBSAMPLE_API SizeF
+{
+public:
+ SizeF(real width, real height) : m_width(width), m_height(height) {}
+ real width() { return m_width; }
+ real height() { return m_height; }
+ static inline ushort passTypedefOfUnsignedShort(ushort value) { return value; }
+private:
+ real m_width;
+ real m_height;
+};
+
+#endif // SIZE_H
+
diff --git a/sources/shiboken2/tests/libsample/sometime.cpp b/sources/shiboken2/tests/libsample/sometime.cpp
new file mode 100644
index 000000000..3038e26ca
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sometime.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sometime.h"
+#include <stdio.h>
+
+void
+Time::setTime()
+{
+ m_hour = 0;
+ m_minute = 0;
+ m_second = 0;
+ m_msec = 0;
+ m_is_null = true;
+}
+
+void
+Time::setTime(int h, int m, int s, int ms)
+{
+ m_hour = h;
+ m_minute = m;
+ m_second = s;
+ m_msec = ms;
+ m_is_null = false;
+}
+
+
+Time::NumArgs
+Time::somethingCompletelyDifferent()
+{
+ return ZeroArgs;
+}
+
+Time::NumArgs
+Time::somethingCompletelyDifferent(int h, int m, ImplicitConv ic, ObjectType* type)
+{
+ if (type)
+ return FourArgs;
+ if (ic.ctorEnum() == ImplicitConv::CtorThree && ic.objId() == -1)
+ return TwoArgs;
+ return ThreeArgs;
+}
+
+Str
+Time::toString() const
+{
+ if (m_is_null)
+ return Str();
+ char buffer[13];
+ sprintf(buffer, "%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_msec);
+ return Str(buffer);
+}
+
+bool
+Time::operator==(const Time& other) const
+{
+ return m_hour == other.m_hour
+ && m_minute == other.m_minute
+ && m_second == other.m_second
+ && m_msec == other.m_msec
+ && m_is_null == other.m_is_null;
+}
+
+bool
+Time::operator!=(const Time& other) const
+{
+ return !operator==(other);
+}
+
+Time::operator Str() const
+{
+ return Time::toString();
+}
+
diff --git a/sources/shiboken2/tests/libsample/sometime.h b/sources/shiboken2/tests/libsample/sometime.h
new file mode 100644
index 000000000..5f2ccf88a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sometime.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SOMETIME_H
+#define SOMETIME_H
+
+#include "libsamplemacros.h"
+#include "str.h"
+#include "implicitconv.h"
+#include "objecttype.h"
+
+class LIBSAMPLE_API Time
+{
+public:
+ enum NumArgs {
+ ZeroArgs,
+ TwoArgs,
+ ThreeArgs,
+ FourArgs
+ };
+
+ Time()
+ : m_hour(0), m_minute(0), m_second(0), m_msec(0), m_is_null(true)
+ {}
+ Time(int h, int m, int s = 0, int ms = 0)
+ : m_hour(h), m_minute(m), m_second(s), m_msec(ms), m_is_null(false)
+ {}
+
+ ~Time() {}
+
+ inline bool isNull() const { return m_is_null; }
+
+ inline int hour() const { return m_hour; }
+ inline int minute() const { return m_minute; }
+ inline int second() const { return m_second; }
+ inline int msec() const { return m_msec; }
+
+ void setTime();
+ void setTime(int h, int m, int s = 0, int ms = 0);
+
+ // This one is completely different from the other methods in this class,
+ // it was added to give the overload decisor a really hard time with
+ // an value-type with implicit conversion and a default argument, and also
+ // an object-type, just because I feel like it.
+ NumArgs somethingCompletelyDifferent();
+ NumArgs somethingCompletelyDifferent(int h, int m,
+ ImplicitConv ic = ImplicitConv::CtorThree,
+ ObjectType* type = 0);
+
+ Str toString() const;
+ bool operator==(const Time& other) const;
+ bool operator!=(const Time& other) const;
+
+ // This cast operator must become an implicit conversion of Str.
+ operator Str() const;
+
+private:
+ int m_hour;
+ int m_minute;
+ int m_second;
+ int m_msec;
+
+ bool m_is_null;
+};
+
+#endif // SOMETIME_H
+
diff --git a/sources/shiboken2/tests/libsample/str.cpp b/sources/shiboken2/tests/libsample/str.cpp
new file mode 100644
index 000000000..f3be2591e
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/str.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "str.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+using namespace std;
+
+Str::Str(const Str& s)
+{
+ init(s.cstring());
+}
+
+Str::Str(char c)
+{
+ char str[2] = { c, 0 };
+ init(str);
+}
+
+Str::Str(const char* cstr)
+{
+ init(cstr);
+}
+
+void
+Str::init(const char* cstr)
+{
+ if (cstr)
+ m_str = cstr;
+}
+
+Str::~Str()
+{
+}
+
+Str
+Str::arg(const Str& s) const
+{
+ size_t idx = m_str.find_first_of("%VAR");
+ if (idx == std::string::npos) {
+ return *this;
+ } else {
+ std::string result = m_str;
+ result.replace(idx, 4, s.m_str);
+ return result.c_str();
+ }
+}
+
+Str&
+Str::append(const Str& s)
+{
+ m_str += s.m_str;
+ return *this;
+}
+
+Str&
+Str::prepend(const Str& s)
+{
+ m_str = s.m_str + m_str;
+ return *this;
+}
+
+const char*
+Str::cstring() const
+{
+ return m_str.c_str();
+}
+
+int
+Str::toInt(bool* ok, int base) const
+{
+ bool my_ok;
+ int result = 0;
+ istringstream conv(m_str);
+ switch (base) {
+ case 8:
+ conv >> std::oct >> result;
+ break;
+ case 10:
+ conv >> std::dec >> result;
+ break;
+ case 16:
+ conv >> std::hex >> result;
+ break;
+ }
+ my_ok = istringstream::eofbit & conv.rdstate();
+ if (!my_ok)
+ result = 0;
+ if (ok)
+ *ok = my_ok;
+ return result;
+}
+
+void
+Str::show() const
+{
+ printf("%s", cstring());
+}
+
+char
+Str::get_char(int pos) const
+{
+ return m_str[pos];
+}
+
+bool
+Str::set_char(int pos, char ch)
+{
+ m_str[pos] = ch;
+ return true;
+}
+
+Str Str::operator+(int number) const
+{
+ ostringstream in;
+ in << m_str << number;
+ return in.str().c_str();
+}
+
+bool Str::operator==(const Str& other) const
+{
+ return m_str == other.m_str;
+}
+
+Str operator+(int number, const Str& str)
+{
+ ostringstream in;
+ in << number << str.m_str;
+ return in.str().c_str();
+}
+
+bool Str::operator<(const Str& other) const
+{
+ return m_str < other.m_str;
+}
+
+unsigned int strHash(const Str& str)
+{
+ unsigned int result = 0;
+ const std::string& cppStr = str.m_str;
+ std::string::const_iterator it = cppStr.begin();
+ for (; it != cppStr.end(); ++it)
+ result = 5 * result + *it;
+ return result;
+}
+
+void changePStr(PStr* pstr, const char* suffix)
+{
+ pstr->append(suffix);
+}
+
+void duplicatePStr(PStr* pstr)
+{
+ if (!pstr)
+ return;
+ pstr->append(*pstr);
+}
diff --git a/sources/shiboken2/tests/libsample/str.h b/sources/shiboken2/tests/libsample/str.h
new file mode 100644
index 000000000..9c1e8c0a8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/str.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STR_H
+#define STR_H
+#include <string>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Str
+{
+public:
+ Str(const Str& s);
+ Str(char c);
+ Str(const char* cstr = "");
+ ~Str();
+
+ Str arg(const Str& s) const;
+
+ Str& append(const Str& s);
+ Str& prepend(const Str& s);
+
+ const char* cstring() const;
+ char get_char(int pos) const;
+ bool set_char(int pos, char ch);
+
+ int toInt(bool* ok = 0, int base = 10) const;
+
+ void show() const;
+
+ inline int size() const { return m_str.size(); }
+
+ // nonsense operator just to test reverse operators
+ Str operator+(int number) const;
+ bool operator==(const Str& other) const;
+ bool operator<(const Str& other) const;
+
+private:
+ void init(const char* cstr);
+ std::string m_str;
+
+ friend LIBSAMPLE_API Str operator+(int number, const Str& str);
+ friend LIBSAMPLE_API unsigned int strHash(const Str& str);
+};
+
+LIBSAMPLE_API Str operator+(int number, const Str& str);
+LIBSAMPLE_API unsigned int strHash(const Str& str);
+
+typedef Str PStr;
+LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix);
+LIBSAMPLE_API void duplicatePStr(PStr* pstr = 0);
+
+#endif // STR_H
diff --git a/sources/shiboken2/tests/libsample/strlist.cpp b/sources/shiboken2/tests/libsample/strlist.cpp
new file mode 100644
index 000000000..8956110d8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/strlist.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "strlist.h"
+
+bool
+StrList::operator==(const std::list<Str>& other) const
+{
+ if (size() != other.size())
+ return false;
+ StrList::const_iterator this_it = begin();
+ StrList::const_iterator other_it = begin();
+ while (this_it != end()) {
+ if (!((*this_it) == (*other_it)))
+ return false;
+ ++this_it;
+ ++other_it;
+ }
+ return true;
+}
+
+Str
+StrList::join(const Str& sep) const
+{
+ Str result;
+ for (StrList::const_iterator it = begin(); it != end(); ++it) {
+ if (it != begin())
+ result.append(sep);
+ result.append(*it);
+ }
+ return result;
+}
diff --git a/sources/shiboken2/tests/libsample/strlist.h b/sources/shiboken2/tests/libsample/strlist.h
new file mode 100644
index 000000000..be908d5d5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/strlist.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STRLIST_H
+#define STRLIST_H
+
+#include <list>
+#include "str.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API StrList : public std::list<Str>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ StrCtor,
+ CopyCtor,
+ ListOfStrCtor
+ };
+
+ inline StrList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit StrList(const Str& str) : m_ctorUsed(StrCtor) { push_back(str); }
+ inline StrList(const StrList& lst) : std::list<Str>(lst), m_ctorUsed(CopyCtor) {}
+ inline StrList(const std::list<Str>& lst) : std::list<Str>(lst), m_ctorUsed(ListOfStrCtor) {}
+
+ inline void append(Str str) { push_back(str); }
+ Str join(const Str& sep) const;
+
+ bool operator==(const std::list<Str>& other) const;
+ inline bool operator!=(const std::list<Str>& other) const { return !(*this == other); }
+
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+typedef StrList PStrList;
+
+#endif // STRLIST_H
diff --git a/sources/shiboken2/tests/libsample/templateptr.cpp b/sources/shiboken2/tests/libsample/templateptr.cpp
new file mode 100644
index 000000000..571184776
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/templateptr.cpp
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "templateptr.h"
+
+void TemplatePtr::dummy(std::list<std::pair<BlackBox *, BlackBox *> > & items)
+{
+} \ No newline at end of file
diff --git a/sources/shiboken2/tests/libsample/templateptr.h b/sources/shiboken2/tests/libsample/templateptr.h
new file mode 100644
index 000000000..67e154b1c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/templateptr.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEMPLATEPTR_H
+#define TEMPLATEPTR_H
+
+#include <utility>
+#include <list>
+#include "libsamplemacros.h"
+#include "blackbox.h"
+
+class LIBSAMPLE_API TemplatePtr
+{
+public:
+ void dummy(std::list<std::pair<BlackBox *, BlackBox *> > & items);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/transform.cpp b/sources/shiboken2/tests/libsample/transform.cpp
new file mode 100644
index 000000000..951e2ca5b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/transform.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2013 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "transform.h"
+
+#ifdef _WIN32
+#include <math.h>
+#include <float.h>
+static inline bool isfinite(double a) { return _finite(a); }
+#else
+#include <cmath>
+#endif
+
+using namespace std;
+
+Point applyHomogeneousTransform(
+ const Point& in,
+ double m11, double m12, double m13,
+ double m21, double m22, double m23,
+ double m31, double m32, double m33,
+ bool* okay)
+{
+ double x = m11 * in.x() + m12 * in.y() + m13;
+ double y = m21 * in.x() + m22 * in.y() + m23;
+ double w = m31 * in.x() + m32 * in.y() + m33;
+
+ if (isfinite(w) && fabs(w) > 1e-10)
+ {
+ if (okay)
+ *okay = true;
+ return Point(x / w, y / w);
+ }
+ else
+ {
+ if (okay)
+ *okay = false;
+ return Point();
+ }
+}
diff --git a/sources/shiboken2/tests/libsample/transform.h b/sources/shiboken2/tests/libsample/transform.h
new file mode 100644
index 000000000..fda5b33c5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/transform.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2013 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRANSFORM_H
+#define TRANSFORM_H
+
+#include "point.h"
+
+#include "libsamplemacros.h"
+
+LIBSAMPLE_API Point
+applyHomogeneousTransform(
+ const Point& in,
+ double m11, double m12, double m13,
+ double m21, double m22, double m23,
+ double m31, double m32, double m33,
+ bool* okay);
+
+#endif // TRANSFORM_H
diff --git a/sources/shiboken2/tests/libsample/valueandvirtual.h b/sources/shiboken2/tests/libsample/valueandvirtual.h
new file mode 100644
index 000000000..54e8114b5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/valueandvirtual.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VALUEANDVIRTUAL_H
+#define VALUEANDVIRTUAL_H
+
+class ValueAndVirtual
+{
+public:
+ ValueAndVirtual(int id) : m_id(id) {}
+ ValueAndVirtual(const ValueAndVirtual &other) { m_id = other.m_id; }
+
+ bool operator()(int id, int id2) { return id == id2; }
+
+ inline int id() { return m_id; }
+ virtual ~ValueAndVirtual() {};
+private:
+ int m_id;
+};
+
+#endif // VALUEANDVIRTUAL_H
+
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.cpp b/sources/shiboken2/tests/libsample/virtualmethods.cpp
new file mode 100644
index 000000000..05b854e08
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/virtualmethods.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "virtualmethods.h"
+
+int VirtualDtor::dtor_called = 0;
+
+double
+VirtualMethods::virtualMethod0(Point pt, int val, Complex cpx, bool b)
+{
+ return (pt.x() * pt.y() * val) + cpx.imag() + ((int) b);
+}
+
+bool
+VirtualMethods::createStr(const char* text, Str*& ret)
+{
+ if (!text) {
+ ret = 0;
+ return false;
+ }
+
+ ret = new Str(text);
+ return true;
+}
+
+void
+VirtualMethods::getMargins(int* left, int* top, int* right, int* bottom) const
+{
+ *left = m_left;
+ *top = m_top;
+ *right = m_right;
+ *bottom = m_bottom;
+}
+
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.h b/sources/shiboken2/tests/libsample/virtualmethods.h
new file mode 100644
index 000000000..5754d0d5d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/virtualmethods.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIRTUALMETHODS_H
+#define VIRTUALMETHODS_H
+
+#include "point.h"
+#include "complex.h"
+#include "str.h"
+
+#include "libsamplemacros.h"
+#include "strlist.h"
+
+class LIBSAMPLE_API VirtualMethods
+{
+public:
+ VirtualMethods(Str name = "VirtualMethods") : m_name(name)
+ {
+ m_left = m_top = m_right = m_bottom = 0;
+ }
+ virtual ~VirtualMethods() {}
+
+ virtual double virtualMethod0(Point pt, int val, Complex cpx, bool b);
+ double callVirtualMethod0(Point pt, int val, Complex cpx, bool b)
+ {
+ return virtualMethod0(pt, val, cpx, b);
+ }
+
+ // Binding modification: rename.
+ virtual int sum0(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum0(int a0, int a1, int a2) { return sum0(a0, a1, a2); }
+
+ // Binding modification: set default value for the last argument.
+ virtual int sum1(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum1(int a0, int a1, int a2) { return sum1(a0, a1, a2); }
+
+ // Binding modification: remove the last argument and set a default value for it.
+ virtual int sum2(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum2(int a0, int a1, int a2) { return sum2(a0, a1, a2); }
+
+ // Binding modification: remove the second argument.
+ virtual int sum3(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum3(int a0, int a1, int a2) { return sum3(a0, a1, a2); }
+
+ // Binding modification: remove the second argument and set its default
+ // value, then inject code on the binding reimplementation of the virtual
+ // (with a native inject-code) to sum the value of the removed
+ // argument to the first argument before the method is called.
+ virtual int sum4(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum4(int a0, int a1, int a2) { return sum4(a0, a1, a2); }
+
+ // Binding modification: prepend a string to the results of a Python override.
+ virtual Str name() { return m_name; }
+ Str callName() { return name(); }
+
+ // Binding modification: code injection that calls the Python override by itself.
+ virtual void callMe() {}
+ void callCallMe() { callMe(); }
+
+ // Passing reference to pointers.
+ virtual bool createStr(const char* text, Str*& ret);
+ bool callCreateStr(const char* text, Str*& ret) { return createStr(text, ret); }
+
+ // Return a non-binded method
+ std::list<Str> callStrListToStdList(const StrList& strList) { return strListToStdList(strList); }
+ virtual std::list<Str> strListToStdList(const StrList& strList ) { return strList; }
+
+ void setMargins(int left, int top, int right, int bottom)
+ {
+ m_left = left;
+ m_top = top;
+ m_right = right;
+ m_bottom = bottom;
+ }
+ virtual void getMargins(int* left, int* top, int* right, int* bottom) const;
+ void callGetMargins(int* left, int* top, int* right, int* bottom) const
+ {
+ getMargins(left, top, right, bottom);
+ }
+
+ virtual int recursionOnModifiedVirtual(Str arg) const { return 0; }
+ int callRecursionOnModifiedVirtual(Str arg) const { return recursionOnModifiedVirtual(arg); }
+
+private:
+ Str m_name;
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+};
+
+class LIBSAMPLE_API VirtualDaughter : public VirtualMethods
+{
+public:
+ VirtualDaughter() : VirtualMethods() {}
+ VirtualDaughter(Str name) : VirtualMethods(name) {}
+};
+
+class LIBSAMPLE_API VirtualDtor
+{
+public:
+ VirtualDtor() {}
+ virtual ~VirtualDtor() { dtor_called++; }
+
+ static VirtualDtor* create() { return new VirtualDtor(); }
+ static int dtorCalled() { return dtor_called; }
+ static void resetDtorCounter() { dtor_called = 0; }
+
+private:
+ static int dtor_called;
+};
+
+#endif // VIRTUALMETHODS_H
+
diff --git a/sources/shiboken2/tests/libsample/voidholder.h b/sources/shiboken2/tests/libsample/voidholder.h
new file mode 100644
index 000000000..228bbae3f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/voidholder.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VOIDHOLDER_H
+#define VOIDHOLDER_H
+
+#include "libsamplemacros.h"
+
+class VoidHolder
+{
+public:
+ explicit VoidHolder(void* ptr = 0) : m_ptr(ptr) {}
+ ~VoidHolder() {}
+ inline void* voidPointer() { return m_ptr; }
+ inline static void* gimmeMeSomeVoidPointer()
+ {
+ static void* pointerToSomething = new VoidHolder();
+ return pointerToSomething;
+ }
+private:
+ void* m_ptr;
+};
+
+#endif // VOIDHOLDER_H
+