aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 15:01:40 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-01 10:51:58 +0200
commit430d02db24b95a56ae0acc6a9df6a0effe49da0d (patch)
tree8713f11a51f42205dcf2d06894f7f9caa9a49cbe /sources/pyside2
parent26e4ba3639bac57b0481bd6bb3964b1afa340ab9 (diff)
Consolidate export/import macros
For the 3 libraries that need to export symbols, (libshiboken, libpyside, pysidetest), fix up the export/import macros to follow the Qt convention: - Define generic export/import macros LIBSHIBOKEN_EX/IMPORT equivalent to Q_DECL_EX/IMPORT. Remove definitions for the ancient g++ 4.X. - Reuse those in libpyside, pysidetest as PYSIDE_EX/IMPORT and PYSIDETEST_EX/IMPORT. - While building, define some BUILD_ macro indicating export. - Define the _API macros depending on the BUILD_ macro to be export or import, respectively as is done in Qt. Remove the ugly hack in pysidetest that tried to re-use the PYSIDE_API macro. - Brush up the headers a bit. Change-Id: I635891b7eec5a52a1dcf45022f7bfb6a9cfee83f Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2')
-rw-r--r--sources/pyside2/libpyside/CMakeLists.txt2
-rw-r--r--sources/pyside2/libpyside/pysidemacros.h31
-rw-r--r--sources/pyside2/tests/pysidetest/CMakeLists.txt4
-rw-r--r--sources/pyside2/tests/pysidetest/hiddenobject.h11
-rw-r--r--sources/pyside2/tests/pysidetest/pysidetest_global.h8
-rw-r--r--sources/pyside2/tests/pysidetest/pysidetest_macros.h43
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.cpp2
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.h33
-rw-r--r--sources/pyside2/tests/pysidetest/testview.h10
9 files changed, 92 insertions, 52 deletions
diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
index d6b20c45a..e31c87eef 100644
--- a/sources/pyside2/libpyside/CMakeLists.txt
+++ b/sources/pyside2/libpyside/CMakeLists.txt
@@ -100,7 +100,7 @@ set_target_properties(pyside2 PROPERTIES
VERSION ${BINDING_API_VERSION}
SOVERSION "${PYSIDE_SO_VERSION}"
OUTPUT_NAME "pyside2${pyside2_SUFFIX}${SHIBOKEN_PYTHON_SHARED_LIBRARY_SUFFIX}"
- DEFINE_SYMBOL PYSIDE_EXPORTS)
+ DEFINE_SYMBOL BUILD_LIBPYSIDE)
if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
set_property(TARGET pyside2 PROPERTY CXX_STANDARD 17)
diff --git a/sources/pyside2/libpyside/pysidemacros.h b/sources/pyside2/libpyside/pysidemacros.h
index 5b493a279..fcdfe3c6e 100644
--- a/sources/pyside2/libpyside/pysidemacros.h
+++ b/sources/pyside2/libpyside/pysidemacros.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
@@ -40,25 +40,16 @@
#ifndef PYSIDEMACROS_H
#define PYSIDEMACROS_H
-#if defined _WIN32
- #if PYSIDE_EXPORTS
- #define PYSIDE_API __declspec(dllexport)
- #else
- #if defined __MINGW32__
- #define PYSIDE_API
- #else
- #define PYSIDE_API __declspec(dllimport)
- #endif
- #endif
- #define PYSIDE_DEPRECATED(func) __declspec(deprecated) func
+#include <shibokenmacros.h>
+
+#define PYSIDE_EXPORT LIBSHIBOKEN_EXPORT
+#define PYSIDE_IMPORT LIBSHIBOKEN_IMPORT
+#define PYSIDE_DEPRECATED(func) SBK_DEPRECATED(func)
+
+#ifdef BUILD_LIBPYSIDE
+# define PYSIDE_API PYSIDE_EXPORT
#else
- #if __GNUC__ >= 4
- #define PYSIDE_API __attribute__ ((visibility("default")))
- #define PYSIDE_DEPRECATED(func) func __attribute__ ((deprecated))
- #else
- #define PYSIDE_API
- #define PYSIDE_DEPRECATED(func) func
- #endif
+# define PYSIDE_API PYSIDE_IMPORT
#endif
-#endif
+#endif // PYSIDEMACROS_H
diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt
index 97d04426d..b760b767f 100644
--- a/sources/pyside2/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt
@@ -66,6 +66,7 @@ endif()
make_path(testbinding_include_dirs ${pyside2_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../shiboken2/libshiboken
${CMAKE_CURRENT_SOURCE_DIR}/../../PySide2
${CMAKE_CURRENT_SOURCE_DIR}/../../libpyside
${QT_INCLUDE_DIR}
@@ -104,6 +105,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${libpyside_SOURCE_DIR})
add_library(pysidetest SHARED ${pysidetest_SRC} ${pysidetest_MOC_SRC})
+set_target_properties(pysidetest PROPERTIES
+ DEFINE_SYMBOL BUILD_PYSIDETEST)
+
target_link_libraries(pysidetest
Shiboken2::libshiboken
${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
diff --git a/sources/pyside2/tests/pysidetest/hiddenobject.h b/sources/pyside2/tests/pysidetest/hiddenobject.h
index ffa8d614a..97a2864c5 100644
--- a/sources/pyside2/tests/pysidetest/hiddenobject.h
+++ b/sources/pyside2/tests/pysidetest/hiddenobject.h
@@ -29,11 +29,9 @@
#ifndef HIDDENOBJECT_H
#define HIDDENOBJECT_H
-#ifdef pysidetest_EXPORTS
-#define PYSIDE_EXPORTS 1
-#endif
-#include "pysidemacros.h"
-#include <QObject>
+#include "pysidetest_macros.h"
+
+#include <QtCore/QObject>
// This class shouldn't be exported!
class HiddenObject : public QObject
@@ -49,7 +47,6 @@ private:
};
// Return a instance of HiddenObject
-PYSIDE_API QObject* getHiddenObject();
-
+PYSIDETEST_API QObject* getHiddenObject();
#endif
diff --git a/sources/pyside2/tests/pysidetest/pysidetest_global.h b/sources/pyside2/tests/pysidetest/pysidetest_global.h
index 0077ade96..6cc8570f0 100644
--- a/sources/pyside2/tests/pysidetest/pysidetest_global.h
+++ b/sources/pyside2/tests/pysidetest/pysidetest_global.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of Qt for Python.
@@ -26,9 +26,13 @@
**
****************************************************************************/
+#ifndef PYSIDETEST_GLOBAL_H
+#define PYSIDETEST_GLOBAL_H
+
// PySide global.h file
#include "pyside2_global.h"
#include "testobject.h"
#include "testview.h"
-#define PYSIDE_API
#include "hiddenobject.h"
+
+#endif // PYSIDETEST_GLOBAL_H
diff --git a/sources/pyside2/tests/pysidetest/pysidetest_macros.h b/sources/pyside2/tests/pysidetest/pysidetest_macros.h
new file mode 100644
index 000000000..b561efbbc
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/pysidetest_macros.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $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 PYSIDETEST_MACROS_H
+#define PYSIDETEST_MACROS_H
+
+#include <pysidemacros.h>
+
+#define PYSIDETEST_EXPORT PYSIDE_EXPORT
+#define PYSIDETEST_IMPORT PYSIDE_IMPORT
+
+#ifdef BUILD_PYSIDETEST
+# define PYSIDETEST_API PYSIDETEST_EXPORT
+#else
+# define PYSIDETEST_API PYSIDETEST_IMPORT
+#endif
+
+#endif // PYSIDETEST_MACROS_H
diff --git a/sources/pyside2/tests/pysidetest/testobject.cpp b/sources/pyside2/tests/pysidetest/testobject.cpp
index 441ae872f..43fa93bac 100644
--- a/sources/pyside2/tests/pysidetest/testobject.cpp
+++ b/sources/pyside2/tests/pysidetest/testobject.cpp
@@ -28,6 +28,8 @@
#include "testobject.h"
+#include <QtCore/QDebug>
+
void TestObject::emitIdValueSignal()
{
emit idValue(m_idValue);
diff --git a/sources/pyside2/tests/pysidetest/testobject.h b/sources/pyside2/tests/pysidetest/testobject.h
index f8a174d46..41a97a0db 100644
--- a/sources/pyside2/tests/pysidetest/testobject.h
+++ b/sources/pyside2/tests/pysidetest/testobject.h
@@ -29,15 +29,15 @@
#ifndef TESTOBJECT_H
#define TESTOBJECT_H
-#include <QObject>
-#include <QApplication>
-#include <QMetaType>
-#include <QVariant>
-#include <QDebug>
-#ifdef pysidetest_EXPORTS
-#define PYSIDE_EXPORTS 1
-#endif
-#include "pysidemacros.h"
+#include "pysidetest_macros.h"
+
+#include <QtWidgets/QApplication>
+
+#include <QtCore/QObject>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
class IntValue
{
@@ -50,7 +50,7 @@ public:
typedef IntValue TypedefValue;
-class PYSIDE_API TestObject : public QObject
+class PYSIDETEST_API TestObject : public QObject
{
Q_OBJECT
public:
@@ -82,15 +82,15 @@ private:
int m_idValue;
QList<QObject*> m_children;
};
-PYSIDE_API QDebug operator<<(QDebug dbg, TestObject &testObject);
+PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject &testObject);
typedef int PySideInt;
namespace PySideCPP {
-class PYSIDE_API TestObjectWithNamespace : public QObject
+class PYSIDETEST_API TestObjectWithNamespace : public QObject
{
Q_OBJECT
public:
@@ -106,17 +106,18 @@ signals:
void emitSignalWithNamespace(PySideCPP::TestObjectWithNamespace* obj);
void emitSignalWithTypedef(PySideInt val);
};
-PYSIDE_API QDebug operator<<(QDebug dbg, TestObjectWithNamespace &testObject);
-class PYSIDE_API TestObject2WithNamespace : public QObject
+PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObjectWithNamespace &testObject);
+
+class PYSIDETEST_API TestObject2WithNamespace : public QObject
{
Q_OBJECT
public:
TestObject2WithNamespace(QObject* parent) : QObject(parent) {}
QString name() { return "TestObject2WithNamespace"; }
};
-PYSIDE_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject);
+PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject);
} // Namespace PySideCPP
@@ -127,7 +128,7 @@ enum Enum1 { Option1 = 1, Option2 = 2 };
typedef long PySideLong;
-class PYSIDE_API TestObjectWithoutNamespace : public QObject
+class PYSIDETEST_API TestObjectWithoutNamespace : public QObject
{
Q_OBJECT
public:
diff --git a/sources/pyside2/tests/pysidetest/testview.h b/sources/pyside2/tests/pysidetest/testview.h
index 66d0a94d9..b80a7fca9 100644
--- a/sources/pyside2/tests/pysidetest/testview.h
+++ b/sources/pyside2/tests/pysidetest/testview.h
@@ -29,11 +29,9 @@
#ifndef TESTVIEW_H
#define TESTVIEW_H
-#include <QObject>
-#ifdef pysidetest_EXPORTS
-#define PYSIDE_EXPORTS 1
-#endif
-#include "pysidemacros.h"
+#include "pysidetest_macros.h"
+
+#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QWidget;
@@ -41,7 +39,7 @@ class QAbstractListModel;
class QAbstractItemDelegate;
QT_END_NAMESPACE
-class PYSIDE_API TestView : public QObject
+class PYSIDETEST_API TestView : public QObject
{
Q_OBJECT
public: