From 0363a0986e19bfb97ed1b899fc1431a0e1b14dcb Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Fri, 31 Aug 2018 14:27:02 +0200 Subject: Place templates per module There is a main template file that hosts most of the code-templates we use in the typesystems, but there were still several templates written in each module-typesystem file. The templates that are used on different typesystem are now placed in: sources/pyside2/PySide2/templates/core_common.xml Additionally, the templates used only by a certain module, are placed next to it, e.g.: sources/pyside2/PySide2/templates/widgets_common.xml Some simple templates were moved to the snippets files too. Task-number: PYSIDE-799 Change-Id: I4f355cf2ae983aba9e85414e910550189cd18dcb Reviewed-by: Alexandru Croitor Reviewed-by: Qt CI Bot --- sources/pyside2/PySide2/CMakeLists.txt | 14 +- .../PySide2/QtCore/typesystem_core_common.xml | 210 ++------- .../typesystem_datavisualization.xml | 35 +- .../PySide2/QtGui/typesystem_gui_common.xml | 136 +----- .../pyside2/PySide2/QtOpenGL/typesystem_opengl.xml | 21 +- .../QtWebKitWidgets/typesystem_webkitwidgets.xml | 23 +- .../QtWidgets/typesystem_widgets_common.xml | 53 +-- sources/pyside2/PySide2/QtXml/typesystem_xml.xml | 56 +-- sources/pyside2/PySide2/glue/qtcore.cpp | 26 ++ sources/pyside2/PySide2/glue/qtwebkitwidgets.cpp | 15 + sources/pyside2/PySide2/glue/qtwidgets.cpp | 20 + sources/pyside2/PySide2/glue/qtxml.cpp | 15 + sources/pyside2/PySide2/templates/core_common.xml | 395 ++++++++++++++++ .../PySide2/templates/datavisualization_common.xml | 76 +++ sources/pyside2/PySide2/templates/gui_common.xml | 291 ++++++++++++ .../pyside2/PySide2/templates/opengl_common.xml | 61 +++ .../PySide2/templates/webkitwidgets_common.xml | 55 +++ .../pyside2/PySide2/templates/widgets_common.xml | 54 +++ sources/pyside2/PySide2/templates/xml_common.xml | 58 +++ sources/pyside2/PySide2/typesystem_templates.xml | 507 --------------------- 20 files changed, 1152 insertions(+), 969 deletions(-) create mode 100644 sources/pyside2/PySide2/templates/core_common.xml create mode 100644 sources/pyside2/PySide2/templates/datavisualization_common.xml create mode 100644 sources/pyside2/PySide2/templates/gui_common.xml create mode 100644 sources/pyside2/PySide2/templates/opengl_common.xml create mode 100644 sources/pyside2/PySide2/templates/webkitwidgets_common.xml create mode 100644 sources/pyside2/PySide2/templates/widgets_common.xml create mode 100644 sources/pyside2/PySide2/templates/xml_common.xml delete mode 100644 sources/pyside2/PySide2/typesystem_templates.xml (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt index f4c2ae9d4..ea1a7de16 100644 --- a/sources/pyside2/PySide2/CMakeLists.txt +++ b/sources/pyside2/PySide2/CMakeLists.txt @@ -93,7 +93,19 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_config.py" DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_git_pyside_version.py" DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/core_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/gui_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/widgets_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/datavisualization_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/opengl_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/webkitwidgets_common.xml + DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/xml_common.xml DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h DESTINATION include/${BINDING_NAME}${pyside2_SUFFIX}) diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index 7f4cb19b1..8aade34af 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -40,7 +40,7 @@ ****************************************************************************/ --> - + @@ -81,29 +81,18 @@ - - - - + - - - + - - - + @@ -649,30 +638,6 @@ - - - @@ -1005,46 +970,24 @@ - - - - + - - - + - @@ -2829,15 +2772,6 @@ - - - @@ -2884,49 +2818,31 @@ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + @@ -2943,125 +2859,77 @@ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + diff --git a/sources/pyside2/PySide2/QtDataVisualization/typesystem_datavisualization.xml b/sources/pyside2/PySide2/QtDataVisualization/typesystem_datavisualization.xml index 2777f5519..94e6f4b88 100644 --- a/sources/pyside2/PySide2/QtDataVisualization/typesystem_datavisualization.xml +++ b/sources/pyside2/PySide2/QtDataVisualization/typesystem_datavisualization.xml @@ -41,39 +41,8 @@ --> - - - + + diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index e7d1fc76d..090b7a4ec 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -41,18 +41,9 @@ --> + + - @@ -554,26 +545,6 @@ - @@ -703,13 +674,6 @@ - @@ -791,10 +755,6 @@ - @@ -905,48 +865,6 @@ - @@ -1443,42 +1361,6 @@ - - @@ -1488,9 +1370,7 @@ - - - + @@ -1510,6 +1390,7 @@ + @@ -1928,11 +1809,6 @@ - @@ -2905,9 +2781,7 @@ - - - + diff --git a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml index 59019faa1..a234e95d6 100644 --- a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml +++ b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml @@ -40,7 +40,8 @@ ****************************************************************************/ --> - + + @@ -136,24 +137,6 @@ - - diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml index fa54703c3..27a4835e2 100644 --- a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml +++ b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml @@ -46,6 +46,7 @@ + @@ -118,14 +119,7 @@ - - - - - - - - + @@ -150,19 +144,6 @@ - diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index c7fae8d7f..d22d694cc 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -40,7 +40,8 @@ ****************************************************************************/ --> - + + @@ -2297,9 +2298,7 @@ - - - + @@ -2436,9 +2435,7 @@ - - - + @@ -2448,9 +2445,7 @@ - - - + @@ -2461,9 +2456,7 @@ - - - + @@ -2474,9 +2467,7 @@ - - - + @@ -2487,9 +2478,7 @@ - - - + @@ -2500,9 +2489,7 @@ - - - + @@ -2979,16 +2966,6 @@ - @@ -3000,9 +2977,7 @@ - - - + @@ -3014,9 +2989,7 @@ - - - + @@ -3028,9 +3001,7 @@ - - - + diff --git a/sources/pyside2/PySide2/QtXml/typesystem_xml.xml b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml index 4f7839ccf..59343543a 100644 --- a/sources/pyside2/PySide2/QtXml/typesystem_xml.xml +++ b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml @@ -40,8 +40,9 @@ ****************************************************************************/ --> - - + + + @@ -53,19 +54,6 @@ - @@ -85,9 +73,7 @@ - - - + @@ -105,9 +91,7 @@ - - - + @@ -125,9 +109,7 @@ - - - + @@ -145,9 +127,7 @@ - - - + @@ -165,9 +145,7 @@ - - - + @@ -185,9 +163,7 @@ - - - + @@ -205,9 +181,7 @@ - - - + @@ -225,9 +199,7 @@ - - - + @@ -273,12 +245,6 @@ - diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index f4114db3f..084004ceb 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -1008,3 +1008,29 @@ QT_END_NAMESPACE reinterpret_cast(PyBytes_AS_STRING(%PYARG_4))); %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); // @snippet qt-qunregisterresourcedata + +// @snippet use-stream-for-format-security +// Uses the stream version for security reasons +// see gcc man page at -Wformat-security +%FUNCTION_NAME() << %1; +// @snippet use-stream-for-format-security + +// @snippet qresource-registerResource + auto ptr = reinterpret_cast(Shiboken::Buffer::getPointer(%PYARG_1)); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast(ptr), %2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); +// @snippet qresource-registerResource + +// @snippet qstring-return +%PYARG_0 = %CONVERTTOPYTHON[QString](%1); +// @snippet qstring-return + +// @snippet stream-write-method +(*%CPPSELF) << %1; +// @snippet stream-write-method + +// @snippet stream-read-method +%RETURN_TYPE _cpp_result; +(*%CPPSELF) >> _cpp_result; +%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](_cpp_result); +// @snippet stream-read-method diff --git a/sources/pyside2/PySide2/glue/qtwebkitwidgets.cpp b/sources/pyside2/PySide2/glue/qtwebkitwidgets.cpp index 6744c4be2..086ee3b85 100644 --- a/sources/pyside2/PySide2/glue/qtwebkitwidgets.cpp +++ b/sources/pyside2/PySide2/glue/qtwebkitwidgets.cpp @@ -75,3 +75,18 @@ if (_signalIndex == id) { } } // @snippet qwebpage-qt-metacall + +// @snippet qwebframe-metadata +%PYARG_0 = PyDict_New(); +const auto &keys = %0.keys(); +for (const auto &_key : keys) { + Shiboken::AutoDecRef _pyValueList(PyList_New(0)); + for (auto it = %0.lowerBound(key), end = %0.upperBound(key); it ! = end; ++it) { + Shiboken::AutoDecRef _pyValue(%CONVERTTOPYTHON[QString](it.value)); + PyList_Append(_pyValueList, _pyValue); + } + + Shiboken::AutoDecRef _pyKey(%CONVERTTOPYTHON[QString](_key)); + PyDict_SetItem(%PYARG_0, _pyKey, _pyValueList); +} +// @snippet qwebframe-metadata diff --git a/sources/pyside2/PySide2/glue/qtwidgets.cpp b/sources/pyside2/PySide2/glue/qtwidgets.cpp index 02e74c997..2a8a8af0f 100644 --- a/sources/pyside2/PySide2/glue/qtwidgets.cpp +++ b/sources/pyside2/PySide2/glue/qtwidgets.cpp @@ -86,6 +86,26 @@ if (_defaultValue) _defaultValue = %PYARG_1; // @snippet qitemeditorfactory-setdefaultfactory +// @snippet qformlayout-fix-args +int _row; +QFormLayout::ItemRole _role; +%BEGIN_ALLOW_THREADS +%CPPSELF->%FUNCTION_NAME(%ARGUMENT_NAMES, &_row, &_role); +%END_ALLOW_THREADS +%PYARG_0 = PyTuple_New(2); +PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](_row)); +PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QFormLayout::ItemRole](_role)); +// @snippet qformlayout-fix-args + +// @snippet qfiledialog-return +%BEGIN_ALLOW_THREADS +%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &%5, %6); +%END_ALLOW_THREADS +%PYARG_0 = PyTuple_New(2); +PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_)); +PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG5_TYPE](%5)); +// @snippet qfiledialog-return + // @snippet qmenu-addaction-1 %PYARG_0 = addActionWithPyObject(%CPPSELF, QIcon(), %1, %2, %3); // @snippet qmenu-addaction-1 diff --git a/sources/pyside2/PySide2/glue/qtxml.cpp b/sources/pyside2/PySide2/glue/qtxml.cpp index 4c24c0c53..ff8be58e2 100644 --- a/sources/pyside2/PySide2/glue/qtxml.cpp +++ b/sources/pyside2/PySide2/glue/qtxml.cpp @@ -46,3 +46,18 @@ QXmlInputSource* _qxmlinputsource_arg_ = nullptr; PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QXmlInputSource*](_qxmlinputsource_arg_)); // @snippet qxmlentityresolver-resolveentity + +// @snippet qdomdocument-setcontent +QString _errorMsg_; +int _errorLine_ = 0; +int _errorColumn_ = 0; +%BEGIN_ALLOW_THREADS +bool _ret_ = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &_errorMsg_, &_errorLine_, + &_errorColumn_); +%END_ALLOW_THREADS +%PYARG_0 = PyTuple_New(4); +PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[bool](_ret_)); +PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](_errorMsg_)); +PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](_errorLine_)); +PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[int](_errorColumn_)); +// @snippet qdomdocument-setcontent diff --git a/sources/pyside2/PySide2/templates/core_common.xml b/sources/pyside2/PySide2/templates/core_common.xml new file mode 100644 index 000000000..0fe19273b --- /dev/null +++ b/sources/pyside2/PySide2/templates/core_common.xml @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/PySide2/templates/datavisualization_common.xml b/sources/pyside2/PySide2/templates/datavisualization_common.xml new file mode 100644 index 000000000..ee040c977 --- /dev/null +++ b/sources/pyside2/PySide2/templates/datavisualization_common.xml @@ -0,0 +1,76 @@ + + + + + + + diff --git a/sources/pyside2/PySide2/templates/gui_common.xml b/sources/pyside2/PySide2/templates/gui_common.xml new file mode 100644 index 000000000..227d0a460 --- /dev/null +++ b/sources/pyside2/PySide2/templates/gui_common.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/PySide2/templates/opengl_common.xml b/sources/pyside2/PySide2/templates/opengl_common.xml new file mode 100644 index 000000000..46299d8d7 --- /dev/null +++ b/sources/pyside2/PySide2/templates/opengl_common.xml @@ -0,0 +1,61 @@ + + + + + diff --git a/sources/pyside2/PySide2/templates/webkitwidgets_common.xml b/sources/pyside2/PySide2/templates/webkitwidgets_common.xml new file mode 100644 index 000000000..fa70c8de7 --- /dev/null +++ b/sources/pyside2/PySide2/templates/webkitwidgets_common.xml @@ -0,0 +1,55 @@ + + + + + + diff --git a/sources/pyside2/PySide2/templates/widgets_common.xml b/sources/pyside2/PySide2/templates/widgets_common.xml new file mode 100644 index 000000000..b68739533 --- /dev/null +++ b/sources/pyside2/PySide2/templates/widgets_common.xml @@ -0,0 +1,54 @@ + + + + + + + diff --git a/sources/pyside2/PySide2/templates/xml_common.xml b/sources/pyside2/PySide2/templates/xml_common.xml new file mode 100644 index 000000000..b13a10c25 --- /dev/null +++ b/sources/pyside2/PySide2/templates/xml_common.xml @@ -0,0 +1,58 @@ + + + + + + + + + diff --git a/sources/pyside2/PySide2/typesystem_templates.xml b/sources/pyside2/PySide2/typesystem_templates.xml deleted file mode 100644 index f0e4a2bf8..000000000 --- a/sources/pyside2/PySide2/typesystem_templates.xml +++ /dev/null @@ -1,507 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3