From 430d02db24b95a56ae0acc6a9df6a0effe49da0d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Sep 2020 15:01:40 +0200 Subject: 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 --- sources/pyside2/libpyside/CMakeLists.txt | 2 +- sources/pyside2/libpyside/pysidemacros.h | 31 ++++++---------- sources/pyside2/tests/pysidetest/CMakeLists.txt | 4 ++ sources/pyside2/tests/pysidetest/hiddenobject.h | 11 ++---- .../pyside2/tests/pysidetest/pysidetest_global.h | 8 +++- .../pyside2/tests/pysidetest/pysidetest_macros.h | 43 ++++++++++++++++++++++ sources/pyside2/tests/pysidetest/testobject.cpp | 2 + sources/pyside2/tests/pysidetest/testobject.h | 33 +++++++++-------- sources/pyside2/tests/pysidetest/testview.h | 10 ++--- 9 files changed, 92 insertions(+), 52 deletions(-) create mode 100644 sources/pyside2/tests/pysidetest/pysidetest_macros.h (limited to 'sources/pyside2') 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 + +#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 +#include "pysidetest_macros.h" + +#include // 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 + +#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 + 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 -#include -#include -#include -#include -#ifdef pysidetest_EXPORTS -#define PYSIDE_EXPORTS 1 -#endif -#include "pysidemacros.h" +#include "pysidetest_macros.h" + +#include + +#include +#include +#include + +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 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 -#ifdef pysidetest_EXPORTS -#define PYSIDE_EXPORTS 1 -#endif -#include "pysidemacros.h" +#include "pysidetest_macros.h" + +#include 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: -- cgit v1.2.3 From 62c21af778b7bff6c86e7f89ef03a87efa6c51cb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Oct 2020 08:53:29 +0200 Subject: Move the annotations for parsing Qt-based headers to shiboken2 It is one of the lesser known things that any project generating bindings for Qt-based code needs to include pyside2_global.h in order for signals, slots and properties to be recognized, since the annotation macro definitions are in this file. Move the definitions over to shiboken2 to remove the need to include it. [ChangeLog][shiboken2] Projects generating bindings for Qt-based code no longer need to include pyside2_global.h. Change-Id: I531bb7444561ccfc352f3be09ecdf854f9f7dd3d Reviewed-by: Qt CI Bot Reviewed-by: Cristian Maureira-Fredes --- sources/pyside2/tests/pysidetest/pysidetest_global.h | 1 - 1 file changed, 1 deletion(-) (limited to 'sources/pyside2') diff --git a/sources/pyside2/tests/pysidetest/pysidetest_global.h b/sources/pyside2/tests/pysidetest/pysidetest_global.h index 6cc8570f0..f65662cb5 100644 --- a/sources/pyside2/tests/pysidetest/pysidetest_global.h +++ b/sources/pyside2/tests/pysidetest/pysidetest_global.h @@ -30,7 +30,6 @@ #define PYSIDETEST_GLOBAL_H // PySide global.h file -#include "pyside2_global.h" #include "testobject.h" #include "testview.h" #include "hiddenobject.h" -- cgit v1.2.3 From c09502eaae9167b63f2b7e076b9872692ee03041 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Fri, 2 Oct 2020 13:37:40 +0200 Subject: Add Network as dependency for WebEngineCore This enable to expose types like QNetworkCookie which is required for the setCookie, and deleteCookie methods. Fixes: PYSIDE-644 Change-Id: I28d0b81e59a6ca411f22e1f9afd7f4139927b1a2 Reviewed-by: Friedemann Kleint --- sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt | 5 ++++- sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'sources/pyside2') diff --git a/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt b/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt index f0fb1eeda..52a071606 100644 --- a/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt @@ -21,14 +21,17 @@ set(QtWebEngineCore_include_dirs ${QtWebEngineCore_SOURCE_DIR} ${QtWebEngineCore_BINARY_DIR} ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS} + ${Qt${QT_MAJOR_VERSION}Network_INCLUDE_DIRS} ${libpyside_SOURCE_DIR} ${QtCore_GEN_DIR} + ${QtNetwork_GEN_DIR} ) set(QtWebEngineCore_libraries pyside2 ${Qt${QT_MAJOR_VERSION}WebEngineCore_LIBRARIES} ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} + ${Qt${QT_MAJOR_VERSION}Network_LIBRARIES} ) -set(QtWebEngineCore_deps QtCore) +set(QtWebEngineCore_deps QtCore QtNetwork) create_pyside_module(NAME QtWebEngineCore INCLUDE_DIRS QtWebEngineCore_include_dirs LIBRARIES QtWebEngineCore_libraries diff --git a/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml b/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml index eb1ab3d61..65c0e8137 100644 --- a/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml +++ b/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml @@ -41,6 +41,7 @@ --> + -- cgit v1.2.3 From a633ba483890f91cf949c2b384274175043415cd Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 5 Oct 2020 14:13:25 +0200 Subject: doc: remove qApp import Fixes: PYSIDE-1382 Change-Id: I84dbd296093f38642922b3642e866e77224a58f2 Reviewed-by: Christian Tismer Reviewed-by: Friedemann Kleint --- .../pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py | 2 +- .../pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py | 2 +- .../pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py | 2 +- .../pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py | 2 +- sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sources/pyside2') diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py index 64f831e5d..188e4930e 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QKeySequence from PySide2.QtWidgets import QMainWindow, QAction diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py index 9f7c6814f..6a0374af0 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QKeySequence from PySide2.QtWidgets import QMainWindow, QAction diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py index 4786365e8..5f9003a92 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QKeySequence from PySide2.QtWidgets import QMainWindow, QAction diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py index c223aa69b..5c2c009d2 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QKeySequence from PySide2.QtWidgets import QMainWindow, QAction diff --git a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py index 4bc4cf48b..33b92879b 100644 --- a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py +++ b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py @@ -40,7 +40,7 @@ from __future__ import print_function, absolute_import -from PySide2.QtWidgets import (QAction, QAbstractItemView, qApp, QDataWidgetMapper, +from PySide2.QtWidgets import (QAction, QAbstractItemView, QDataWidgetMapper, QHeaderView, QMainWindow, QMessageBox) from PySide2.QtGui import QKeySequence from PySide2.QtSql import (QSqlRelation, QSqlRelationalTableModel, QSqlTableModel, -- cgit v1.2.3 From b57f329ecbf1fd0b29ae0e8284c885adc0eb4ed3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 Oct 2020 08:27:24 +0200 Subject: Documentation: Fix virtualenv URL Fixes: PYSIDE-1391 Change-Id: I48e8878cca28831eb881383a31d4b4b87236c85d Reviewed-by: Christian Tismer --- sources/pyside2/doc/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources/pyside2') diff --git a/sources/pyside2/doc/quickstart.rst b/sources/pyside2/doc/quickstart.rst index 5d8ddfe2d..b6a3dbbb3 100644 --- a/sources/pyside2/doc/quickstart.rst +++ b/sources/pyside2/doc/quickstart.rst @@ -9,7 +9,7 @@ Before you can install |project|, first you must install the following software: * Python 2.7 or 3.5+, * We recommend using a virtual environment, such as `venv `_ or - `virtualenv `_ + `virtualenv `_ Installation ------------ -- cgit v1.2.3