diff options
Diffstat (limited to 'sources/shiboken2/tests/libminimal')
-rw-r--r-- | sources/shiboken2/tests/libminimal/CMakeLists.txt | 13 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/libminimalmacros.h | 46 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/listuser.cpp | 124 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/listuser.h | 75 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/minbool.h | 68 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/obj.cpp | 44 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/obj.h | 59 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/typedef.cpp | 75 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/typedef.h | 54 | ||||
-rw-r--r-- | sources/shiboken2/tests/libminimal/val.h | 59 |
10 files changed, 617 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/libminimal/CMakeLists.txt b/sources/shiboken2/tests/libminimal/CMakeLists.txt new file mode 100644 index 000000000..a25892571 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/CMakeLists.txt @@ -0,0 +1,13 @@ +project(libminimal) + +set(libminimal_SRC +obj.cpp +listuser.cpp +typedef.cpp +) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_definitions("-DLIBMINIMAL_BUILD") +add_library(libminimal SHARED ${libminimal_SRC}) +set_property(TARGET libminimal PROPERTY PREFIX "") + diff --git a/sources/shiboken2/tests/libminimal/libminimalmacros.h b/sources/shiboken2/tests/libminimal/libminimalmacros.h new file mode 100644 index 000000000..5c9e62e8a --- /dev/null +++ b/sources/shiboken2/tests/libminimal/libminimalmacros.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 LIBMINIMALMACROS_H +#define LIBMINIMALMACROS_H + +#if defined _WIN32 || defined __CYGWIN__ + #if LIBMINIMAL_BUILD + #define LIBMINIMAL_API __declspec(dllexport) + #else + #define LIBMINIMAL_API __declspec(dllimport) + #endif +#else +#if __GNUC__ >= 4 + #define LIBMINIMAL_API __attribute__ ((visibility("default"))) +#else + #define LIBMINIMAL_API +#endif +#endif + +#endif diff --git a/sources/shiboken2/tests/libminimal/listuser.cpp b/sources/shiboken2/tests/libminimal/listuser.cpp new file mode 100644 index 000000000..ec2eb3923 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/listuser.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** 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" + +std::list<int> +ListUser::createIntList(int num) +{ + std::list<int> retval; + for (int i = 0; i < num; ++i) + retval.push_back(i); + return retval; +} + +int +ListUser::sumIntList(std::list<int> intList) +{ + int total = 0; + for (std::list<int>::iterator iter = intList.begin(); iter != intList.end(); iter++) + total += *iter; + return total; +} + +std::list<MinBool> +ListUser::createMinBoolList(MinBool mb1, MinBool mb2) +{ + std::list<MinBool> retval; + retval.push_back(mb1); + retval.push_back(mb2); + return retval; +} + +MinBool +ListUser::oredMinBoolList(std::list<MinBool> minBoolList) +{ + MinBool result(false); + for (std::list<MinBool>::iterator iter = minBoolList.begin(); iter != minBoolList.end(); iter++) + result |= *iter; + return result; +} + +std::list<Val> +ListUser::createValList(int num) +{ + std::list<Val> retval; + for (int i = 0; i < num; ++i) + retval.push_back(Val(i)); + return retval; +} + +int +ListUser::sumValList(std::list<Val> valList) +{ + int total = 0; + for (std::list<Val>::iterator iter = valList.begin(); iter != valList.end(); iter++) + total += iter->valId(); + return total; +} + +std::list<Obj*> +ListUser::createObjList(Obj* o1, Obj* o2) +{ + std::list<Obj*> retval; + retval.push_back(o1); + retval.push_back(o2); + return retval; +} + +int +ListUser::sumObjList(std::list<Obj*> objList) +{ + int total = 0; + for (std::list<Obj*>::iterator iter = objList.begin(); iter != objList.end(); iter++) + total += (*iter)->objId(); + return total; +} + +std::list<std::list<int> > +ListUser::createListOfIntLists(int num) +{ + std::list<std::list<int> > retval; + for (int i = 0; i < num; ++i) + retval.push_back(createIntList(num)); + return retval; +} + +int +ListUser::sumListOfIntLists(std::list<std::list<int> > intListList) +{ + int total = 0; + for (std::list<std::list<int> >::iterator it0 = intListList.begin(); it0 != intListList.end(); it0++) { + for (std::list<int>::iterator it1 = (*it0).begin(); it1 != (*it0).end(); it1++) + total += *it1; + } + return total; +} + diff --git a/sources/shiboken2/tests/libminimal/listuser.h b/sources/shiboken2/tests/libminimal/listuser.h new file mode 100644 index 000000000..4138b9f3c --- /dev/null +++ b/sources/shiboken2/tests/libminimal/listuser.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 LISTUSER_H +#define LISTUSER_H + +#include <list> +#include "obj.h" +#include "val.h" +#include "minbool.h" + +#include "libminimalmacros.h" + +struct LIBMINIMAL_API ListUser +{ + virtual ~ListUser() {} + + // List of C++ primitive type items + virtual std::list<int> createIntList(int num); + std::list<int> callCreateIntList(int num) { return createIntList(num); } + virtual int sumIntList(std::list<int> intList); + int callSumIntList(std::list<int> intList) { return sumIntList(intList); } + + // List of C++ MinBool objects used as primitives in Python + virtual std::list<MinBool> createMinBoolList(MinBool mb1, MinBool mb2); + std::list<MinBool> callCreateMinBoolList(MinBool mb1, MinBool mb2) { return createMinBoolList(mb1, mb2); } + virtual MinBool oredMinBoolList(std::list<MinBool> minBoolList); + MinBool callOredMinBoolList(std::list<MinBool> minBoolList) { return oredMinBoolList(minBoolList); } + + // List of C++ value types + virtual std::list<Val> createValList(int num); + std::list<Val> callCreateValList(int num) { return createValList(num); } + virtual int sumValList(std::list<Val> valList); + int callSumValList(std::list<Val> valList) { return sumValList(valList); } + + // List of C++ object types + virtual std::list<Obj*> createObjList(Obj* o1, Obj* o2); + std::list<Obj*> callCreateObjList(Obj* o1, Obj* o2) { return createObjList(o1, o2); } + virtual int sumObjList(std::list<Obj*> objList); + int callSumObjList(std::list<Obj*> objList) { return sumObjList(objList); } + + // List of lists of C++ primitive type items + virtual std::list<std::list<int> > createListOfIntLists(int num); + std::list<std::list<int> > callCreateListOfIntLists(int num) { return createListOfIntLists(num); } + virtual int sumListOfIntLists(std::list<std::list<int> > intListList); + int callSumListOfIntLists(std::list<std::list<int> > intListList) { return sumListOfIntLists(intListList); } +}; + +#endif // LISTUSER_H + diff --git a/sources/shiboken2/tests/libminimal/minbool.h b/sources/shiboken2/tests/libminimal/minbool.h new file mode 100644 index 000000000..ebd2f71e2 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/minbool.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 MINBOOL_H +#define MINBOOL_H + +#include "libminimalmacros.h" + +class LIBMINIMAL_API MinBool +{ +public: + inline explicit MinBool(bool b) : m_value(b) {} + bool value() const { return m_value; } + inline MinBool operator!() const { return MinBool(!m_value); } + inline MinBool& operator|=(const MinBool& other) { + m_value = m_value | other.m_value; + return *this; + } +private: + bool m_value; +}; + +inline bool operator==(MinBool b1, bool b2) { return (!b1).value() == !b2; } +inline bool operator==(bool b1, MinBool b2) { return (!b1) == (!b2).value(); } +inline bool operator==(MinBool b1, MinBool b2) { return (!b1).value() == (!b2).value(); } +inline bool operator!=(MinBool b1, bool b2) { return (!b1).value() != !b2; } +inline bool operator!=(bool b1, MinBool b2) { return (!b1) != (!b2).value(); } +inline bool operator!=(MinBool b1, MinBool b2) { return (!b1).value() != (!b2).value(); } + +class LIBMINIMAL_API MinBoolUser +{ +public: + MinBoolUser() : m_minbool(MinBool(false)) {} + virtual ~MinBoolUser() {} + inline MinBool minBool() { return m_minbool; } + inline void setMinBool(MinBool minBool) { m_minbool = minBool; } + virtual MinBool invertedMinBool() { return !m_minbool; } + inline MinBool callInvertedMinBool() { return invertedMinBool(); } +private: + MinBool m_minbool; +}; + +#endif diff --git a/sources/shiboken2/tests/libminimal/obj.cpp b/sources/shiboken2/tests/libminimal/obj.cpp new file mode 100644 index 000000000..a1d18d0e3 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/obj.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 "obj.h" + +Obj::Obj(int objId) : m_objId(objId) +{ +} + +Obj::~Obj() +{ +} + +bool +Obj::virtualMethod(int val) +{ + return !bool(val%2); +} + diff --git a/sources/shiboken2/tests/libminimal/obj.h b/sources/shiboken2/tests/libminimal/obj.h new file mode 100644 index 000000000..16f838e19 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/obj.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 OBJ_H +#define OBJ_H + +#include "libminimalmacros.h" + +class LIBMINIMAL_API Obj +{ +public: + explicit Obj(int objId); + virtual ~Obj(); + + int objId() { return m_objId; } + void setObjId(int objId) { m_objId = objId; } + + virtual bool virtualMethod(int val); + bool callVirtualMethod(int val) { return virtualMethod(val); } + + virtual Obj* passObjectType(Obj* obj) { return obj; } + Obj* callPassObjectType(Obj* obj) { return passObjectType(obj); } + + virtual Obj* passObjectTypeReference(Obj& obj) { return &obj; } + Obj* callPassObjectTypeReference(Obj& obj) { return passObjectTypeReference(obj); } + +private: + Obj(const Obj&); + Obj& operator=(const Obj&); + int m_objId; +}; + +#endif // OBJ_H + diff --git a/sources/shiboken2/tests/libminimal/typedef.cpp b/sources/shiboken2/tests/libminimal/typedef.cpp new file mode 100644 index 000000000..4948d9944 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/typedef.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 "typedef.h" + +// +// Test wrapping of a typedef +// +bool arrayFuncInt(std::vector<int> a) +{ + return a.empty(); +} + +bool arrayFuncIntTypedef(MyArray a) +{ + return arrayFuncInt(a); +} + +std::vector<int> arrayFuncIntReturn(int size) +{ + return std::vector<int>(size); +} + +MyArray arrayFuncIntReturnTypedef(int size) +{ + return arrayFuncIntReturn(size); +} + +// +// Test wrapping of a typedef of a typedef +// +bool arrayFunc(std::vector<int> a) +{ + return a.empty(); +} + +bool arrayFuncTypedef(MyArray a) +{ + return arrayFunc(a); +} + +std::vector<int> arrayFuncReturn(int size) +{ + return std::vector<int>(size); +} + +MyArray arrayFuncReturnTypedef(int size) +{ + return arrayFuncReturn(size); +} diff --git a/sources/shiboken2/tests/libminimal/typedef.h b/sources/shiboken2/tests/libminimal/typedef.h new file mode 100644 index 000000000..f54a6ed18 --- /dev/null +++ b/sources/shiboken2/tests/libminimal/typedef.h @@ -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$ +** +****************************************************************************/ + +#ifndef TYPEDEF_H +#define TYPEDEF_H + +#include "libminimalmacros.h" + +#include <vector> + +// Test wrapping of a typedef +typedef std::vector<int> MyArrayInt; + +LIBMINIMAL_API bool arrayFuncInt(std::vector<int> a); +LIBMINIMAL_API bool arrayFuncIntTypedef(MyArrayInt a); + +LIBMINIMAL_API std::vector<int> arrayFuncIntReturn(int size); +LIBMINIMAL_API MyArrayInt arrayFuncIntReturnTypedef(int size); + +// Test wrapping of a typedef of a typedef +typedef MyArrayInt MyArray; + +LIBMINIMAL_API bool arrayFunc(std::vector<int> a); +LIBMINIMAL_API bool arrayFuncTypedef(MyArray a); + +LIBMINIMAL_API std::vector<int> arrayFuncReturn(int size); +LIBMINIMAL_API MyArray arrayFuncReturnTypedef(int size); + +#endif diff --git a/sources/shiboken2/tests/libminimal/val.h b/sources/shiboken2/tests/libminimal/val.h new file mode 100644 index 000000000..5ba4b3aff --- /dev/null +++ b/sources/shiboken2/tests/libminimal/val.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 VAL_H +#define VAL_H + +#include "libminimalmacros.h" + +class LIBMINIMAL_API Val +{ +public: + explicit Val(int valId) : m_valId(valId) {} + virtual ~Val() {} + + int valId() { return m_valId; } + void setValId(int valId) { m_valId = valId; } + + virtual Val passValueType(Val val) { return val; } + Val callPassValueType(Val val) { return passValueType(val); } + + virtual Val* passValueTypePointer(Val* val) { return val; } + Val* callPassValueTypePointer(Val* val) { return passValueTypePointer(val); } + + virtual Val* passValueTypeReference(Val& val) { return &val; } + Val* callPassValueTypeReference(Val& val) { return passValueTypeReference(val); } + + enum ValEnum { One, Other }; + ValEnum oneOrTheOtherEnumValue(ValEnum enumValue) { return enumValue == One ? Other : One; } +private: + int m_valId; +}; + +#endif // VAL_H + |