aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/cmake_helpers/helpers.cmake13
-rw-r--r--sources/pyside-tools/CMakeLists.txt59
-rwxr-xr-xsources/pyside-tools/pyside_tool.py89
-rw-r--r--sources/pyside2/CMakeLists.txt42
-rw-r--r--sources/pyside2/PySide2/CMakeLists.txt2
-rw-r--r--sources/pyside2/PySide2/Qt3DCore/CMakeLists.txt41
-rw-r--r--sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml41
-rw-r--r--sources/pyside2/PySide2/Qt3DRender/CMakeLists.txt73
-rw-r--r--sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml25
-rw-r--r--sources/pyside2/PySide2/QtAxContainer/CMakeLists.txt3
-rw-r--r--sources/pyside2/PySide2/QtAxContainer/QtAxContainer_global.post.h.in6
-rw-r--r--sources/pyside2/PySide2/QtAxContainer/typesystem_axcontainer.xml6
-rw-r--r--sources/pyside2/PySide2/QtCore/CMakeLists.txt62
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml489
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_win.xml12
-rw-r--r--sources/pyside2/PySide2/QtGui/CMakeLists.txt70
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml444
-rw-r--r--sources/pyside2/PySide2/QtNetwork/CMakeLists.txt24
-rw-r--r--sources/pyside2/PySide2/QtNetwork/typesystem_network.xml28
-rw-r--r--sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt51
-rw-r--r--sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml783
-rw-r--r--sources/pyside2/PySide2/QtOpenGLFunctions/CMakeLists.txt39
-rw-r--r--sources/pyside2/PySide2/QtOpenGLFunctions/QtOpenGLFunctions_global.post.h.in54
-rw-r--r--sources/pyside2/PySide2/QtOpenGLFunctions/typesystem_openglfunctions.xml9
-rw-r--r--sources/pyside2/PySide2/QtOpenGLWidgets/CMakeLists.txt34
-rw-r--r--sources/pyside2/PySide2/QtOpenGLWidgets/typesystem_openglwidgets.xml (renamed from sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml)15
-rw-r--r--sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml1
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp311
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h19
-rw-r--r--sources/pyside2/PySide2/QtQml/typesystem_qml.xml58
-rw-r--r--sources/pyside2/PySide2/QtQuick/CMakeLists.txt11
-rw-r--r--sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp148
-rw-r--r--sources/pyside2/PySide2/QtQuick/typesystem_quick.xml7
-rw-r--r--sources/pyside2/PySide2/QtScript/CMakeLists.txt42
-rw-r--r--sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp3
-rw-r--r--sources/pyside2/PySide2/QtScript/typesystem_script.xml105
-rw-r--r--sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt37
-rw-r--r--sources/pyside2/PySide2/QtSql/QtSql_global.pre.h.in2
-rw-r--r--sources/pyside2/PySide2/QtSvg/CMakeLists.txt7
-rw-r--r--sources/pyside2/PySide2/QtSvg/typesystem_svg.xml17
-rw-r--r--sources/pyside2/PySide2/QtSvgWidgets/CMakeLists.txt39
-rw-r--r--sources/pyside2/PySide2/QtSvgWidgets/typesystem_svgwidgets.xml (renamed from sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml)31
-rw-r--r--sources/pyside2/PySide2/QtTest/QtTest_global.pre.h.in2
-rw-r--r--sources/pyside2/PySide2/QtTest/typesystem_test.xml10
-rw-r--r--sources/pyside2/PySide2/QtWebKit/CMakeLists.txt34
-rw-r--r--sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt65
-rw-r--r--sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml211
-rw-r--r--sources/pyside2/PySide2/QtWidgets/CMakeLists.txt11
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml178
-rw-r--r--sources/pyside2/PySide2/QtWinExtras/QtWinExtras_global.pre.h.in2
-rw-r--r--sources/pyside2/PySide2/QtXml/CMakeLists.txt14
-rw-r--r--sources/pyside2/PySide2/QtXml/typesystem_xml.xml186
-rw-r--r--sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt41
-rw-r--r--sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml122
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp149
-rw-r--r--sources/pyside2/PySide2/glue/qtgui.cpp18
-rw-r--r--sources/pyside2/PySide2/glue/qtqml.cpp20
-rw-r--r--sources/pyside2/PySide2/glue/qtuitools.cpp16
-rw-r--r--sources/pyside2/PySide2/pysideqtesttouch.h122
-rw-r--r--sources/pyside2/PySide2/templates/core_common.xml21
-rw-r--r--sources/pyside2/PySide2/templates/gui_common.xml17
-rw-r--r--sources/pyside2/cmake/Macros/PySideModules.cmake2
-rw-r--r--sources/pyside2/doc/CMakeLists.txt4
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.h3
-rw-r--r--sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp80
-rw-r--r--sources/pyside2/doc/codesnippets/webkitsnippets/simple/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/webkitsnippets/webelement/main.cpp114
-rw-r--r--sources/pyside2/doc/codesnippets/webkitsnippets/webpage/main.cpp83
-rw-r--r--sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst44
-rw-r--r--sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst41
-rw-r--r--sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst36
-rw-r--r--sources/pyside2/doc/extras/QtWebKit.rst94
-rw-r--r--sources/pyside2/doc/modules.rst4
-rw-r--r--sources/pyside2/doc/qtmodules/pyside-qtxmlpatterns.qdocconf.in2
-rw-r--r--sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py4
-rw-r--r--sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py4
-rw-r--r--sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py4
-rw-r--r--sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py4
-rw-r--r--sources/pyside2/doc/tutorials/expenses/main.py4
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/02-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/03-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/04-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/05-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/06-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/07-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/08-expenses.py3
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/09-expenses.py4
-rw-r--r--sources/pyside2/doc/tutorials/expenses/steps/10-expenses.py4
-rw-r--r--sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py3
-rw-r--r--sources/pyside2/libpyside/globalreceiverv2.cpp11
-rw-r--r--sources/pyside2/libpyside/pyside.cpp2
-rw-r--r--sources/pyside2/libpyside/pyside.h9
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction.cpp4
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp11
-rw-r--r--sources/pyside2/libpyside/pysideqflags.cpp8
-rw-r--r--sources/pyside2/libpyside/pysidesignal.cpp4
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp54
-rw-r--r--sources/pyside2/plugins/CMakeLists.txt26
-rw-r--r--sources/pyside2/tests/CMakeLists.txt96
-rw-r--r--sources/pyside2/tests/QtCore/CMakeLists.txt7
-rw-r--r--sources/pyside2/tests/QtCore/bug_1031.py41
-rw-r--r--sources/pyside2/tests/QtCore/bug_1063.py4
-rw-r--r--sources/pyside2/tests/QtCore/bug_1313.py5
-rw-r--r--sources/pyside2/tests/QtCore/bug_938.py4
-rw-r--r--sources/pyside2/tests/QtCore/bug_994.py5
-rw-r--r--sources/pyside2/tests/QtCore/deepcopy_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/qabstracttransition_test.py191
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py60
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py14
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py12
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_test.py30
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_test.py164
-rw-r--r--sources/pyside2/tests/QtCore/qdatastream_test.py98
-rw-r--r--sources/pyside2/tests/QtCore/qfile_test.py8
-rw-r--r--sources/pyside2/tests/QtCore/qfileread_test.py6
-rw-r--r--sources/pyside2/tests/QtCore/qjsondocument_test.py12
-rw-r--r--sources/pyside2/tests/QtCore/qlinef_test.py2
-rw-r--r--sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/qobject_parent_test.py4
-rw-r--r--sources/pyside2/tests/QtCore/qobject_test.py4
-rw-r--r--sources/pyside2/tests/QtCore/qprocess_test.py6
-rw-r--r--sources/pyside2/tests/QtCore/qregexp_test.py55
-rw-r--r--sources/pyside2/tests/QtCore/qregularexpression_test.py1
-rw-r--r--sources/pyside2/tests/QtCore/qsettings_test.py6
-rw-r--r--sources/pyside2/tests/QtCore/qstate_test.py71
-rw-r--r--sources/pyside2/tests/QtCore/qstatemachine_test.py104
-rw-r--r--sources/pyside2/tests/QtCore/qstring_test.py9
-rw-r--r--sources/pyside2/tests/QtCore/qtext_codec_test.py54
-rw-r--r--sources/pyside2/tests/QtCore/qtextstream_test.py27
-rw-r--r--sources/pyside2/tests/QtCore/qtimezone_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/qurlquery_test.py2
-rw-r--r--sources/pyside2/tests/QtCore/quuid_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/repr_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/setprop_on_ctor_test.py6
-rw-r--r--sources/pyside2/tests/QtCore/translation_test.py9
-rw-r--r--sources/pyside2/tests/QtCore/unicode_test.py8
-rw-r--r--sources/pyside2/tests/QtGui/CMakeLists.txt3
-rw-r--r--sources/pyside2/tests/QtGui/bug_660.py5
-rw-r--r--sources/pyside2/tests/QtGui/bug_740.py3
-rw-r--r--sources/pyside2/tests/QtGui/deepcopy_test.py7
-rw-r--r--sources/pyside2/tests/QtGui/pyside_reload_test.py17
-rw-r--r--sources/pyside2/tests/QtGui/qmatrix_test.py106
-rw-r--r--sources/pyside2/tests/QtGui/qtextdocument_functions.py3
-rw-r--r--sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py4
-rw-r--r--sources/pyside2/tests/QtGui/repr_test.py11
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_1084.py4
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_446.py6
-rw-r--r--sources/pyside2/tests/QtNetwork/udpsocket_test.py4
-rw-r--r--sources/pyside2/tests/QtOpenGL/CMakeLists.txt4
-rw-r--r--sources/pyside2/tests/QtOpenGL/qglwidget_test.py54
-rw-r--r--sources/pyside2/tests/QtOpenGL/qopenglbuffer_test.py (renamed from sources/pyside2/tests/QtGui/qopenglbuffer_test.py)30
-rw-r--r--sources/pyside2/tests/QtOpenGL/qopenglwindow_test.py (renamed from sources/pyside2/tests/QtGui/qopenglwindow_test.py)4
-rw-r--r--sources/pyside2/tests/QtOpenGLWidgets/CMakeLists.txt (renamed from sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt)0
-rw-r--r--sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py25
-rw-r--r--sources/pyside2/tests/QtQml/CMakeLists.txt3
-rw-r--r--sources/pyside2/tests/QtQml/listproperty.py (renamed from sources/pyside2/tests/QtOpenGL/qglbuffer_test.py)89
-rw-r--r--sources/pyside2/tests/QtQml/qquickview_test.py7
-rw-r--r--sources/pyside2/tests/QtQml/registersingletontype.py (renamed from sources/pyside2/tests/QtScript/property_test.py)100
-rw-r--r--sources/pyside2/tests/QtQml/registersingletontype.qml36
-rw-r--r--sources/pyside2/tests/QtQml/registertype.py6
-rw-r--r--sources/pyside2/tests/QtQml/registeruncreatable.qml38
-rw-r--r--sources/pyside2/tests/QtQml/registeruncreatabletype.py (renamed from sources/pyside2/tests/QtWebKit/webframe_test.py)61
-rw-r--r--sources/pyside2/tests/QtScript/CMakeLists.txt5
-rw-r--r--sources/pyside2/tests/QtScript/base_test.py39
-rw-r--r--sources/pyside2/tests/QtScript/bug_1022.py47
-rw-r--r--sources/pyside2/tests/QtScript/engine_test.py47
-rw-r--r--sources/pyside2/tests/QtScript/qscriptvalue_test.py78
-rw-r--r--sources/pyside2/tests/QtScriptTools/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtScriptTools/debugger_test.py81
-rw-r--r--sources/pyside2/tests/QtSql/qvarianttype_test.py12
-rw-r--r--sources/pyside2/tests/QtSvg/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtSvg/qsvgrenderer_test.py10
-rw-r--r--sources/pyside2/tests/QtSvgWidgets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtSvgWidgets/qsvgwidget_test.py (renamed from sources/pyside2/tests/QtSvg/qsvgwidget_test.py)12
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_392.py17
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_426.py11
-rw-r--r--sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py7
-rw-r--r--sources/pyside2/tests/QtWebKit/CMakeLists.txt11
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_448.py52
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_694.py84
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_803.py53
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_899.py71
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_959.py133
-rw-r--r--sources/pyside2/tests/QtWebKit/fox.html7
-rw-r--r--sources/pyside2/tests/QtWebKit/qml_plugin_test.py92
-rw-r--r--sources/pyside2/tests/QtWebKit/qmlplugin/dummy.pys1
-rw-r--r--sources/pyside2/tests/QtWebKit/qmlplugin/index.html5
-rw-r--r--sources/pyside2/tests/QtWebKit/qvariantlist_property_test.py78
-rw-r--r--sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py63
-rw-r--r--sources/pyside2/tests/QtWebKit/webpage_test.py95
-rw-r--r--sources/pyside2/tests/QtWebKit/webview_test.py101
-rw-r--r--sources/pyside2/tests/QtWidgets/CMakeLists.txt4
-rw-r--r--sources/pyside2/tests/QtWidgets/add_action_test.py3
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_363.py59
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_416.py78
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_632.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_711.py3
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_714.py60
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_860.py2
-rw-r--r--sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py4
-rw-r--r--sources/pyside2/tests/QtWidgets/qaction_test.py3
-rw-r--r--sources/pyside2/tests/QtWidgets/qimage_test.py11
-rw-r--r--sources/pyside2/tests/QtWidgets/qshortcut_test.py22
-rw-r--r--sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py7
-rw-r--r--sources/pyside2/tests/QtWidgets/qtoolbar_test.py3
-rw-r--r--sources/pyside2/tests/QtWidgets/wrong_return_test.py6
-rw-r--r--sources/pyside2/tests/QtXml/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtXml/qdomdocument_test.py12
-rw-r--r--sources/pyside2/tests/QtXml/qxmlsimplereader_test.py70
-rw-r--r--sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtXmlPatterns/import_test.py66
-rw-r--r--sources/pyside2/tests/pysidetest/CMakeLists.txt19
-rw-r--r--sources/pyside2/tests/pysidetest/modelview_test.py3
-rw-r--r--sources/pyside2/tests/pysidetest/new_inherited_functions_test.py6
-rw-r--r--sources/pyside2/tests/pysidetest/qvariant_test.py2
-rw-r--r--sources/pyside2/tests/signals/signal_enum_test.py58
-rw-r--r--sources/pyside2/tests/support/voidptr_test.py2
-rwxr-xr-xsources/pyside2/tests/tools/list-class-hierarchy.py1
-rw-r--r--sources/pyside2/tests/util/httpd.py10
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py2
-rw-r--r--sources/pyside2/tests/util/py3kcompat.py82
-rw-r--r--sources/shiboken2/ApiExtractor/CMakeLists.txt21
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp15
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp19
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h10
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp135
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h3
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp37
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangparser.h10
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp4
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangutils.h2
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/fileout.cpp7
-rw-r--r--sources/shiboken2/ApiExtractor/messages.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/messages.h4
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/reporthandler.cpp2
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp6
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.cpp15
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.h3
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp14
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h11
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.cpp166
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.h6
-rw-r--r--sources/shiboken2/ApiExtractor/xmlutils.cpp5
-rw-r--r--sources/shiboken2/ApiExtractor/xmlutils_qt.cpp102
-rw-r--r--sources/shiboken2/CMakeLists.txt19
-rw-r--r--sources/shiboken2/data/shiboken_helpers.cmake151
-rw-r--r--sources/shiboken2/doc/CMakeLists.txt2
-rw-r--r--sources/shiboken2/doc/typesystem_specifying_types.rst8
-rw-r--r--sources/shiboken2/generator/generator.cpp2
-rw-r--r--sources/shiboken2/generator/main.cpp2
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp64
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp82
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp2
-rw-r--r--sources/shiboken2/libshiboken/CMakeLists.txt2
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp14
-rw-r--r--sources/shiboken2/libshiboken/helper.cpp5
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp71
-rw-r--r--sources/shiboken2/libshiboken/qt_attribution.json2
-rw-r--r--sources/shiboken2/libshiboken/sbkarrayconverter.cpp4
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter_p.h17
-rw-r--r--sources/shiboken2/libshiboken/sbkdbg.h2
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.cpp31
-rw-r--r--sources/shiboken2/libshiboken/sbkmodule.cpp4
-rw-r--r--sources/shiboken2/libshiboken/sbkmodule.h16
-rw-r--r--sources/shiboken2/libshiboken/sbkpython.h61
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.cpp53
-rw-r--r--sources/shiboken2/libshiboken/shibokenbuffer.cpp20
-rw-r--r--sources/shiboken2/libshiboken/typespec.cpp777
-rw-r--r--sources/shiboken2/libshiboken/typespec.h153
-rw-r--r--sources/shiboken2/libshiboken/voidptr.cpp8
-rw-r--r--sources/shiboken2/shibokenmodule/CMakeLists.txt8
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/backport_inspect.py900
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py7
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/typing27.py2636
-rw-r--r--sources/shiboken2/tests/CMakeLists.txt2
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.cpp5
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.h5
-rw-r--r--sources/shiboken2/tests/minimalbinding/listuser_test.py6
-rw-r--r--sources/shiboken2/tests/minimalbinding/typedef_test.py7
-rw-r--r--sources/shiboken2/tests/otherbinding/module_reload_test.py5
-rw-r--r--sources/shiboken2/tests/py3k.py2
-rw-r--r--sources/shiboken2/tests/py3kcompat.py82
-rw-r--r--sources/shiboken2/tests/samplebinding/bug_704_test.py11
-rw-r--r--sources/shiboken2/tests/samplebinding/bytearray_test.py9
-rw-r--r--sources/shiboken2/tests/samplebinding/duck_punching_test.py7
-rw-r--r--sources/shiboken2/tests/samplebinding/enum_test.py9
-rw-r--r--sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py23
-rw-r--r--sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py89
-rw-r--r--sources/shiboken2/tests/samplebinding/overflow_test.py8
-rw-r--r--sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py6
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py6
-rw-r--r--sources/shiboken2/tests/samplebinding/point_test.py9
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml31
-rw-r--r--sources/shiboken2/tests/samplebinding/virtualmethods_test.py5
-rw-r--r--sources/shiboken2/tests/shiboken_paths.py2
-rw-r--r--sources/shiboken2/tests/test_generator/CMakeLists.txt2
301 files changed, 2493 insertions, 12649 deletions
diff --git a/sources/cmake_helpers/helpers.cmake b/sources/cmake_helpers/helpers.cmake
index fed96b5cd..2ca9e8228 100644
--- a/sources/cmake_helpers/helpers.cmake
+++ b/sources/cmake_helpers/helpers.cmake
@@ -26,11 +26,11 @@ macro(collect_optional_modules)
# Collect all optional modules.
set(ALL_OPTIONAL_MODULES
Xml
- XmlPatterns
Help Multimedia
MultimediaWidgets
OpenGL
OpenGLFunctions
+ OpenGLWidgets
Positioning
Location
Qml
@@ -39,13 +39,12 @@ set(ALL_OPTIONAL_MODULES
QuickWidgets
RemoteObjects
Scxml
- Script
- ScriptTools
Sensors
SerialPort
TextToSpeech
Charts
Svg
+ SvgWidgets
DataVisualization)
find_package(Qt${QT_MAJOR_VERSION}UiTools)
if(Qt${QT_MAJOR_VERSION}UiTools_FOUND)
@@ -56,9 +55,6 @@ endif()
if(WIN32)
list(APPEND ALL_OPTIONAL_MODULES AxContainer)
endif()
-# Disabling WebKit by default
-# If WebKit support is needed add the following elements
-# to the list: WebKit WebKitWidgets
list(APPEND ALL_OPTIONAL_MODULES WebChannel WebEngineCore WebEngine WebEngineWidgets WebSockets)
if (Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_GREATER 5.9.3) # Depending on fixes in Qt3D
list(APPEND ALL_OPTIONAL_MODULES 3DCore 3DRender 3DInput 3DLogic 3DAnimation 3DExtras)
@@ -173,14 +169,13 @@ macro(COLLECT_MODULE_IF_FOUND shortname)
# record the shortnames for the tests
list(APPEND all_module_shortnames ${shortname})
# Build Qt 5 compatibility variables
- if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
+ if(${QT_MAJOR_VERSION} GREATER_EQUAL 6 AND NOT "${shortname}" STREQUAL "OpenGLFunctions")
get_target_property(Qt6${shortname}_INCLUDE_DIRS Qt6::${shortname}
INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(Qt6${shortname}_PRIVATE_INCLUDE_DIRS
Qt6::${shortname}Private
INTERFACE_INCLUDE_DIRECTORIES)
- get_target_property(Qt6${shortname}_LIBRARIES Qt6::${shortname}
- INTERFACE_LINK_LIBRARIES)
+ set(Qt6${shortname}_LIBRARIES Qt::${shortname})
endif()
else()
if("${module_state}" STREQUAL "optional")
diff --git a/sources/pyside-tools/CMakeLists.txt b/sources/pyside-tools/CMakeLists.txt
new file mode 100644
index 000000000..0def5a82f
--- /dev/null
+++ b/sources/pyside-tools/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 3.16)
+project(pyside-tools)
+
+# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
+if (QUIET_BUILD)
+ set(CMAKE_INSTALL_MESSAGE NEVER)
+endif()
+
+find_package(Qt6 COMPONENTS Core)
+
+set(TOOLS_PATH "${QT6_INSTALL_PREFIX}/bin")
+
+set(UIC_PATH "${TOOLS_PATH}/uic${CMAKE_EXECUTABLE_SUFFIX}")
+set(RCC_PATH "${TOOLS_PATH}/rcc${CMAKE_EXECUTABLE_SUFFIX}")
+if (APPLE)
+ set(DESIGNER_PATH "${TOOLS_PATH}/Designer.app")
+else()
+ set(DESIGNER_PATH "${TOOLS_PATH}/designer${CMAKE_EXECUTABLE_SUFFIX}")
+endif()
+
+install(FILES "${UIC_PATH}"
+ DESTINATION bin
+ PERMISSIONS
+ OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+
+install(FILES "${RCC_PATH}"
+ DESTINATION bin
+ PERMISSIONS
+ OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+
+if (EXISTS ${DESIGNER_PATH})
+ if (APPLE)
+ install(DIRECTORY "${DESIGNER_PATH}"
+ DESTINATION bin
+ FILE_PERMISSIONS
+ OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+ else()
+ install(FILES "${DESIGNER_PATH}"
+ DESTINATION bin
+ PERMISSIONS
+ OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+ endif()
+endif()
+
+# pyside2-rcc, pyside2-uic, pyside2-designer, shiboken and pyside2-lupdate entrypoints
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pyside_tool.py
+ DESTINATION bin
+ PERMISSIONS
+ OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
diff --git a/sources/pyside-tools/pyside_tool.py b/sources/pyside-tools/pyside_tool.py
new file mode 100755
index 000000000..99a3700f4
--- /dev/null
+++ b/sources/pyside-tools/pyside_tool.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#############################################################################
+##
+## Copyright (C) 2020 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## 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 Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## 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-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+import sys
+import os
+import subprocess
+
+from subprocess import Popen, PIPE
+import PySide2 as ref_mod
+
+
+def main():
+ # This will take care of "pyside2-lupdate" listed as an entrypoint
+ # in setup.py are copied to 'scripts/..'
+ cmd = os.path.join("..", os.path.basename(sys.argv[0]))
+ command = [os.path.join(os.path.dirname(os.path.realpath(__file__)), cmd)]
+ command.extend(sys.argv[1:])
+ sys.exit(subprocess.call(command))
+
+
+def qt_tool_wrapper(qt_tool, args):
+ # Taking care of pyside2-uic, pyside2-rcc, and pyside2-designer
+ # listed as an entrypoint in setup.py
+ pyside_dir = os.path.dirname(ref_mod.__file__)
+ exe = os.path.join(pyside_dir, qt_tool)
+
+ cmd = [exe] + args
+ proc = Popen(cmd, stderr=PIPE)
+ out, err = proc.communicate()
+ if err:
+ msg = err.decode("utf-8")
+ print("Error: {}\nwhile executing '{}'".format(msg, ' '.join(cmd)))
+ sys.exit(proc.returncode)
+
+
+def uic():
+ qt_tool_wrapper("uic", ['-g', 'python'] + sys.argv[1:])
+
+
+def rcc():
+ qt_tool_wrapper("rcc", ['-g', 'python'] + sys.argv[1:])
+
+
+def designer():
+ if sys.platform == "darwin":
+ qt_tool_wrapper("Designer.app/Contents/MacOS/Designer", sys.argv[1:])
+ else:
+ qt_tool_wrapper("designer", sys.argv[1:])
+
+
+if __name__ == "__main__":
+ main()
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index dc2beded0..df605b45a 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -1,12 +1,12 @@
include(cmake/Macros/icecc.cmake) # this must be the first line!
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
# Don't ignore targets that do not exist, inside add_dependencies calls.
cmake_policy(SET CMP0046 NEW)
-set (QT_MAJOR_VERSION 5)
+set (QT_MAJOR_VERSION 6)
project(pysidebindings)
@@ -82,20 +82,6 @@ endif()
find_package(Qt${QT_MAJOR_VERSION} 5.12 REQUIRED COMPONENTS Core)
add_definitions(${Qt${QT_MAJOR_VERSION}Core_DEFINITIONS})
-find_file(GL_H "gl.h" PATH_SUFFIXES "GL")
-message(STATUS "GL Headers path:" "${GL_H}")
-include(FindQt5Extra)
-
-set(XVFB_EXEC "")
-option(USE_XVFB "Uses xvfb-run with the unit tests to avoid QtGui tests popping windows on the screen." FALSE)
-if(USE_XVFB)
- find_program(XVFB_RUN NAMES xvfb-run)
- if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND")
- set(XVFB_EXEC ${XVFB_RUN} -a)
- message(STATUS "Using xvfb-run to perform QtGui tests.")
- endif()
-endif()
-
option(BUILD_TESTS "Build tests." TRUE)
option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated files. This is used to allow multiples versions installed simultaneous." FALSE)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
@@ -108,24 +94,13 @@ if(CMAKE_HOST_APPLE)
endif()
endif()
-# Force usage of the C++11 standard, without a silent fallback
-# to C++98 if the compiler does not support C++11.
-if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- set(CMAKE_CXX_STANDARD 17)
-else()
- set(CMAKE_CXX_STANDARD 11)
-endif()
+# Force usage of the C++17 standard
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# >= Qt5: QT_INCLUDE_DIR does no longer exist. Derive from QtCore
-if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- get_target_property(QT_INCLUDE_DIR Qt6::Core INTERFACE_INCLUDE_DIRECTORIES)
- get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}" DIRECTORY)
-else()
- # On Windows, macOS, and Linux it can be computed from Qt5Core_INCLUDE_DIRS, which contains
- # a list of include directories. We take the first one.
- list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
-endif()
+get_target_property(QT_INCLUDE_DIR Qt6::Core INTERFACE_INCLUDE_DIRECTORIES)
+get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}" DIRECTORY)
message(STATUS "*** Qt ${QT_MAJOR_VERSION}, QT_INCLUDE_DIR= ${QT_INCLUDE_DIR}")
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
@@ -253,8 +228,7 @@ endif()
add_subdirectory(libpyside)
find_package(Qt${QT_MAJOR_VERSION}Designer)
-if(${QT_MAJOR_VERSION} LESS 6 AND Qt${QT_MAJOR_VERSION}UiTools_FOUND
- AND Qt${QT_MAJOR_VERSION}Designer_FOUND)
+if(Qt${QT_MAJOR_VERSION}UiTools_FOUND AND Qt${QT_MAJOR_VERSION}Designer_FOUND)
add_subdirectory(plugins)
endif()
diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt
index 120bc8e52..0ded09f5d 100644
--- a/sources/pyside2/PySide2/CMakeLists.txt
+++ b/sources/pyside2/PySide2/CMakeLists.txt
@@ -100,8 +100,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/opengl_common.xml
DESTINATION share/PySide2${pyside_SUFFIX}/typesystems)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/openglfunctions_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
diff --git a/sources/pyside2/PySide2/Qt3DCore/CMakeLists.txt b/sources/pyside2/PySide2/Qt3DCore/CMakeLists.txt
index aa40c6ec8..2fa1ecee3 100644
--- a/sources/pyside2/PySide2/Qt3DCore/CMakeLists.txt
+++ b/sources/pyside2/PySide2/Qt3DCore/CMakeLists.txt
@@ -1,47 +1,32 @@
project(Qt3DCore)
set(Qt3DCore_SRC
-${Qt3DCore_GEN_DIR}/qt3dcore_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qabstractaspect_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qabstractfrontendnodemanager_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qabstractfunctor_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qabstractskeleton_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qarmature_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qaspectengine_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qaspectjob_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qattribute_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qbackendnode_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qboundingvolume_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qbuffer_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qcomponent_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qcomponentaddedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qcomponentremovedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qdynamicpropertyupdatedchange_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qentity_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qgeometry_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qgeometryview_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qjoint_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qnode_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qnodecreatedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qnodedestroyedchange_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qnodeid_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qnodeidtypepair_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertynodeaddedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertynoderemovedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyupdatedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyupdatedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyvalueaddedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyvalueaddedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyvalueremovedchange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qpropertyvalueremovedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qscenechange_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qstaticpropertyupdatedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qstaticpropertyvalueaddedchangebase_wrapper.cpp
-${Qt3DCore_GEN_DIR}/qt3dcore_qstaticpropertyvalueremovedchangebase_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qskeleton_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_qskeletonloader_wrapper.cpp
${Qt3DCore_GEN_DIR}/qt3dcore_qtransform_wrapper.cpp
+${Qt3DCore_GEN_DIR}/qt3dcore_wrapper.cpp
# module is always needed
${Qt3DCore_GEN_DIR}/qt3dcore_module_wrapper.cpp)
-if (Qt${QT_MAJOR_VERSION}3DCore_VERSION VERSION_EQUAL 5.10.0 OR Qt${QT_MAJOR_VERSION}3DCore_VERSION VERSION_GREATER 5.10.0)
- list(APPEND Qt3DCore_SRC
- ${Qt3DCore_GEN_DIR}/qt3dcore_qarmature_wrapper.cpp
- ${Qt3DCore_GEN_DIR}/qt3dcore_qjoint_wrapper.cpp
- ${Qt3DCore_GEN_DIR}/qt3dcore_qabstractskeleton_wrapper.cpp
- ${Qt3DCore_GEN_DIR}/qt3dcore_qnodecommand_wrapper.cpp
- ${Qt3DCore_GEN_DIR}/qt3dcore_qskeleton_wrapper.cpp
- ${Qt3DCore_GEN_DIR}/qt3dcore_qskeletonloader_wrapper.cpp)
-endif()
-
set(Qt3DCore_include_dirs
${Qt3DCore_SOURCE_DIR}
${Qt3DCore_BINARY_DIR}
diff --git a/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml b/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml
index 8696a128c..61b128f73 100644
--- a/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml
+++ b/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml
@@ -45,6 +45,10 @@
<namespace-type name="Qt3DCore" generate-using="no">
<enum-type name="ChangeFlag" flags="ChangeFlags"/>
<object-type name="QAbstractAspect"/>
+ <object-type name="QAbstractFrontEndNodeManager" since="6.0">
+ <enum-type name="DirtyNodeFlag" flags="DirtyNodeSet"/>
+ </object-type>
+ <object-type name="QAbstractFunctor" since="6.0"/>
<object-type name="QAbstractSkeleton" since="5.10"/>
<object-type name="QArmature" since="5.10"/>
<object-type name="QAspectEngine">
@@ -59,13 +63,19 @@
<object-type name="QBackendNode">
<enum-type name="Mode"/>
</object-type>
+ <object-type name="QAttribute">
+ <enum-type name="AttributeType"/>
+ <enum-type name="VertexBaseType"/>
+ </object-type>
<!-- TODO: Solve issues related to windows and a unresolved
external symbol
<object-type name="QBackendNodeMapper"/>-->
+ <object-type name="QBoundingVolume" since="6.0"/>
+ <object-type name="QBuffer" since="6.0">
+ <enum-type name="AccessType"/>
+ <enum-type name="UsageType"/>
+ </object-type>
<object-type name="QComponent"/>
- <object-type name="QComponentAddedChange"/>
- <object-type name="QComponentRemovedChange"/>
- <object-type name="QDynamicPropertyUpdatedChange"/>
<object-type name="QEntity">
<modify-function signature="addComponent(Qt3DCore::QComponent*)">
<modify-argument index="this">
@@ -73,6 +83,10 @@
</modify-argument>
</modify-function>
</object-type>
+ <object-type name="QGeometry" since="6.0"/>
+ <object-type name="QGeometryView" since="6.0">
+ <enum-type name="PrimitiveType"/>
+ </object-type>
<object-type name="QJoint" since="5.10">
<modify-function signature="addChildJoint(Qt3DCore::QJoint*)">
<modify-argument index="this">
@@ -80,32 +94,13 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QNode">
- <enum-type name="PropertyTrackingMode"/>
- </object-type>
- <object-type name="QNodeCommand" since="5.10"/>
- <object-type name="QNodeCreatedChangeBase"/>
- <object-type name="QNodeDestroyedChange"/>
+ <object-type name="QNode"/>
<value-type name="QNodeId"/>
<value-type name="QNodeIdTypePair"/>
- <object-type name="QPropertyNodeAddedChange"/>
- <object-type name="QPropertyNodeRemovedChange"/>
- <object-type name="QPropertyUpdatedChange"/>
- <object-type name="QPropertyUpdatedChangeBase"/>
- <object-type name="QPropertyValueAddedChange"/>
- <object-type name="QPropertyValueAddedChangeBase"/>
- <object-type name="QPropertyValueRemovedChange"/>
- <object-type name="QPropertyValueRemovedChangeBase"/>
- <object-type name="QSceneChange">
- <enum-type name="DeliveryFlag" flags="DeliveryFlags"/>
- </object-type>
<object-type name="QSkeleton" since="5.10"/>
<object-type name="QSkeletonLoader" since="5.10">
<enum-type name="Status"/>
</object-type>
- <object-type name="QStaticPropertyUpdatedChangeBase"/>
- <object-type name="QStaticPropertyValueAddedChangeBase"/>
- <object-type name="QStaticPropertyValueRemovedChangeBase"/>
<object-type name="QTransform">
<!-- Disambiguate from QtGui/qtransform.h -->
<include file-name="Qt3DCore/qtransform.h" location="global"/>
diff --git a/sources/pyside2/PySide2/Qt3DRender/CMakeLists.txt b/sources/pyside2/PySide2/Qt3DRender/CMakeLists.txt
index 32f28e032..208f4df06 100644
--- a/sources/pyside2/PySide2/Qt3DRender/CMakeLists.txt
+++ b/sources/pyside2/PySide2/Qt3DRender/CMakeLists.txt
@@ -1,20 +1,17 @@
project(Qt3DRender)
set(Qt3DRender_SRC
-${Qt3DRender_GEN_DIR}/qt3drender_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_propertyreaderinterface_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qabstractfunctor_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qabstractlight_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qabstractraycaster_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qabstracttexture_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qabstracttextureimage_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qalphacoverage_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qalphatest_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qattribute_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qblendequation_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qblendequationarguments_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qbuffer_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qblitframebuffer_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qbuffercapture_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qbufferdatagenerator_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qcamera_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qcameralens_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qcameraselector_wrapper.cpp
@@ -31,11 +28,8 @@ ${Qt3DRender_GEN_DIR}/qt3drender_qeffect_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qenvironmentlight_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qfilterkey_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qframegraphnode_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qframegraphnodecreatedchangebase_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qfrontface_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qfrustumculling_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qgeometry_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qgeometryfactory_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qgeometryrenderer_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qgraphicsapifilter_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qlayer_wrapper.cpp
@@ -43,22 +37,30 @@ ${Qt3DRender_GEN_DIR}/qt3drender_qlayerfilter_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qlevelofdetail_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qlevelofdetailboundingsphere_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qlevelofdetailswitch_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qlinewidth_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qmaterial_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qmemorybarrier_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qmesh_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qmultisampleantialiasing_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qnodepthmask_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qnodraw_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qnopicking_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qobjectpicker_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpaintedtextureimage_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qparameter_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpickevent_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qpicktriangleevent_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpickingsettings_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qpicklineevent_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qpickpointevent_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qpicktriangleevent_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpointlight_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpointsize_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qpolygonoffset_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qproximityfilter_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qraycaster_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qraycasterhit_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qrenderaspect_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qrendercapabilities_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qrendercapture_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qrendercapturereply_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qrenderpass_wrapper.cpp
@@ -72,9 +74,14 @@ ${Qt3DRender_GEN_DIR}/qt3drender_qrendertargetoutput_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qrendertargetselector_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qsceneloader_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qscissortest_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qscreenraycaster_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qseamlesscubemap_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qsetfence_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qshaderdata_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qshaderimage_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qshaderprogram_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qshaderprogrambuilder_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qsharedgltexture_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qsortpolicy_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qspotlight_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qstencilmask_wrapper.cpp
@@ -95,7 +102,6 @@ ${Qt3DRender_GEN_DIR}/qt3drender_qtexturebuffer_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtexturecubemap_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtexturecubemaparray_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtexturedata_wrapper.cpp
-${Qt3DRender_GEN_DIR}/qt3drender_qtexturegenerator_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtextureimage_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtextureimagedata_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtextureimagedatagenerator_wrapper.cpp
@@ -103,51 +109,11 @@ ${Qt3DRender_GEN_DIR}/qt3drender_qtextureloader_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtexturerectangle_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qtexturewrapmode_wrapper.cpp
${Qt3DRender_GEN_DIR}/qt3drender_qviewport_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_qwaitfence_wrapper.cpp
+${Qt3DRender_GEN_DIR}/qt3drender_wrapper.cpp
# module is always needed
${Qt3DRender_GEN_DIR}/qt3drender_module_wrapper.cpp)
-if (Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_EQUAL 5.10.0
- OR Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_GREATER 5.10.0)
- list(APPEND Qt3DRender_SRC
- ${Qt3DRender_GEN_DIR}/qt3drender_qblitframebuffer_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qlinewidth_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qpicklineevent_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qpickpointevent_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qproximityfilter_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qshaderprogrambuilder_wrapper.cpp
-)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_EQUAL 5.11.0
- OR Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_GREATER 5.11.0)
- list(APPEND Qt3DRender_SRC
- ${Qt3DRender_GEN_DIR}/qt3drender_qabstractraycaster_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qraycaster_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qraycasterhit_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qscreenraycaster_wrapper.cpp)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_EQUAL 5.13.0
- OR Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_GREATER 5.13.0)
- list(APPEND Qt3DRender_SRC
- ${Qt3DRender_GEN_DIR}/qt3drender_qsetfence_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qsharedgltexture_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qwaitfence_wrapper.cpp)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_EQUAL 5.14.0
- OR Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_GREATER 5.14.0)
- list(APPEND Qt3DRender_SRC
- ${Qt3DRender_GEN_DIR}/qt3drender_qnopicking_wrapper.cpp
- ${Qt3DRender_GEN_DIR}/qt3drender_qshaderimage_wrapper.cpp)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_EQUAL 5.15.0
- OR Qt${QT_MAJOR_VERSION}3DRender_VERSION VERSION_GREATER 5.15.0)
- list(APPEND Qt3DRender_SRC
- ${Qt3DRender_GEN_DIR}/qt3drender_qrendercapabilities_wrapper.cpp)
-endif()
-
set(Qt3DRender_include_dirs
${Qt3DRender_SOURCE_DIR}
${Qt3DRender_BINARY_DIR}
@@ -157,12 +123,13 @@ set(Qt3DRender_include_dirs
${libpyside_SOURCE_DIR}
${QtCore_GEN_DIR}
${QtGui_GEN_DIR}
+ ${QtOpenGL_GEN_DIR}
${Qt3DCore_GEN_DIR})
set(Qt3DRender_libraries pyside2
${Qt${QT_MAJOR_VERSION}3DRender_LIBRARIES})
-set(Qt3DRender_deps Qt3DCore)
+set(Qt3DRender_deps Qt3DCore QtOpenGL)
create_pyside_module(NAME Qt3DRender
INCLUDE_DIRS Qt3DRender_include_dirs
diff --git a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml
index 1ab13d7d7..a221ef41a 100644
--- a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml
+++ b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml
@@ -43,8 +43,8 @@
<typesystem package="PySide2.Qt3DRender">
<load-typesystem name="Qt3DCore/typesystem_3dcore.xml" generate="no"/>
<namespace-type name="Qt3DRender">
+ <enum-type name="API"/>
<object-type name="PropertyReaderInterface"/>
- <object-type name="QAbstractFunctor"/>
<object-type name="QAbstractLight">
<enum-type name="Type"/>
</object-type>
@@ -69,10 +69,6 @@
<object-type name="QAlphaTest">
<enum-type name="AlphaFunction"/>
</object-type>
- <object-type name="QAttribute">
- <enum-type name="AttributeType"/>
- <enum-type name="VertexBaseType"/>
- </object-type>
<object-type name="QBlendEquation">
<enum-type name="BlendFunction"/>
</object-type>
@@ -82,15 +78,7 @@
<object-type name="QBlitFramebuffer" since="5.10">
<enum-type name="InterpolationMethod"/>
</object-type>
- <object-type name="QBuffer">
- <enum-type name="AccessType"/>
- <enum-type name="BufferType"/>
- <enum-type name="UsageType"/>
- </object-type>
<object-type name="QBufferCapture"/>
- <object-type name="QBufferDataGenerator">
- <modify-function signature="operator()()" remove="all"/>
- </object-type>
<object-type name="QCamera">
<enum-type name="CameraTranslationOption"/>
</object-type>
@@ -119,15 +107,10 @@
<object-type name="QEnvironmentLight"/>
<object-type name="QFilterKey"/>
<object-type name="QFrameGraphNode"/>
- <object-type name="QFrameGraphNodeCreatedChangeBase"/>
<object-type name="QFrontFace">
<enum-type name="WindingDirection"/>
</object-type>
<object-type name="QFrustumCulling"/>
- <object-type name="QGeometry"/>
- <object-type name="QGeometryFactory">
- <modify-function signature="operator()()" remove="all"/>
- </object-type>
<object-type name="QGeometryRenderer">
<enum-type name="PrimitiveType"/>
</object-type>
@@ -182,7 +165,7 @@
<enum-type name="HitType"/>
</value-type>
<object-type name="QRenderAspect">
- <enum-type name="RenderType"/>
+ <enum-type name="SubmissionType"/>
</object-type>
<object-type name="QRenderCapabilities" since="5.15">
<enum-type name="API"/>
@@ -215,6 +198,7 @@
</object-type>
<object-type name="QShaderData"/>
<object-type name="QShaderProgram">
+ <enum-type name="Format" since="6.0"/>
<enum-type name="ShaderType"/>
<enum-type name="Status"/>
</object-type>
@@ -252,9 +236,6 @@
<object-type name="QTextureCubeMap"/>
<object-type name="QTextureCubeMapArray"/>
<object-type name="QTextureData"/>
- <object-type name="QTextureGenerator">
- <modify-function signature="QTextureGenerator()" remove="all"/>
- </object-type>
<object-type name="QTextureImage">
<enum-type name="Status"/>
</object-type>
diff --git a/sources/pyside2/PySide2/QtAxContainer/CMakeLists.txt b/sources/pyside2/PySide2/QtAxContainer/CMakeLists.txt
index 38e764405..8f8f5d4d1 100644
--- a/sources/pyside2/PySide2/QtAxContainer/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtAxContainer/CMakeLists.txt
@@ -2,7 +2,10 @@ project(QtAxContainer)
set(QtAxContainer_SRC
${QtAxContainer_GEN_DIR}/qaxbase_wrapper.cpp
+${QtAxContainer_GEN_DIR}/qaxbaseobject_wrapper.cpp
+${QtAxContainer_GEN_DIR}/qaxbasewidget_wrapper.cpp
${QtAxContainer_GEN_DIR}/qaxobject_wrapper.cpp
+${QtAxContainer_GEN_DIR}/qaxobjectinterface_wrapper.cpp
${QtAxContainer_GEN_DIR}/qaxscript_wrapper.cpp
${QtAxContainer_GEN_DIR}/qaxscriptengine_wrapper.cpp
${QtAxContainer_GEN_DIR}/qaxscriptmanager_wrapper.cpp
diff --git a/sources/pyside2/PySide2/QtAxContainer/QtAxContainer_global.post.h.in b/sources/pyside2/PySide2/QtAxContainer/QtAxContainer_global.post.h.in
index 22e1b0119..f4033c4f5 100644
--- a/sources/pyside2/PySide2/QtAxContainer/QtAxContainer_global.post.h.in
+++ b/sources/pyside2/PySide2/QtAxContainer/QtAxContainer_global.post.h.in
@@ -1,5 +1 @@
-#include <ActiveQt/QAxSelect>
-#include <ActiveQt/QAxScript>
-#include <ActiveQt/QAxScriptEngine>
-#include <ActiveQt/QAxScriptManager>
-#include <ActiveQt/QAxWidget>
+#include <QtAxContainer/QtAxContainer>
diff --git a/sources/pyside2/PySide2/QtAxContainer/typesystem_axcontainer.xml b/sources/pyside2/PySide2/QtAxContainer/typesystem_axcontainer.xml
index 19856a754..03977fcbf 100644
--- a/sources/pyside2/PySide2/QtAxContainer/typesystem_axcontainer.xml
+++ b/sources/pyside2/PySide2/QtAxContainer/typesystem_axcontainer.xml
@@ -46,10 +46,11 @@
<rejection class="*" function-name="queryInterface"/>
<rejection class="*" function-name="qt_metacall"/>
<rejection class="*" function-name="qt_static_metacall"/>
- <rejection class="*" field-name="qt_meta_stringdata_QAxBase"/>
- <rejection class="*" field-name="qt_meta_data_QAxBase"/>
+
<object-type name="QAxBase"/>
+ <object-type name="QAxBaseObject"/>
<object-type name="QAxObject"/>
+ <object-type name="QAxObjectInterface"/>
<object-type name="QAxScript">
<enum-type name="FunctionFlags"/>
</object-type>
@@ -60,6 +61,7 @@
<!-- Ax Servers only -->
<modify-function signature="addObject(QObject*)" remove="all"/>
</object-type>
+ <object-type name="QAxBaseWidget"/>
<object-type name="QAxSelect">
<enum-type name="SandboxingLevel"/>
</object-type>
diff --git a/sources/pyside2/PySide2/QtCore/CMakeLists.txt b/sources/pyside2/PySide2/QtCore/CMakeLists.txt
index 20ed65a67..e8356b9d8 100644
--- a/sources/pyside2/PySide2/QtCore/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtCore/CMakeLists.txt
@@ -18,30 +18,32 @@ ${QtCore_GEN_DIR}/qabstractitemmodel_wrapper.cpp
${QtCore_GEN_DIR}/qabstractlistmodel_wrapper.cpp
${QtCore_GEN_DIR}/qabstractnativeeventfilter_wrapper.cpp
${QtCore_GEN_DIR}/qabstractproxymodel_wrapper.cpp
-${QtCore_GEN_DIR}/qabstractstate_wrapper.cpp
${QtCore_GEN_DIR}/qabstracttablemodel_wrapper.cpp
-${QtCore_GEN_DIR}/qabstracttransition_wrapper.cpp
${QtCore_GEN_DIR}/qanimationgroup_wrapper.cpp
${QtCore_GEN_DIR}/qbasicmutex_wrapper.cpp
${QtCore_GEN_DIR}/qbasictimer_wrapper.cpp
${QtCore_GEN_DIR}/qbitarray_wrapper.cpp
${QtCore_GEN_DIR}/qbuffer_wrapper.cpp
+${QtCore_GEN_DIR}/qbytearray_frombase64result_wrapper.cpp
${QtCore_GEN_DIR}/qbytearray_wrapper.cpp
${QtCore_GEN_DIR}/qbytearraymatcher_wrapper.cpp
-${QtCore_GEN_DIR}/qchildevent_wrapper.cpp
+${QtCore_GEN_DIR}/qcalendar_wrapper.cpp
+${QtCore_GEN_DIR}/qcalendar_yearmonthday_wrapper.cpp
${QtCore_GEN_DIR}/qcborarray_wrapper.cpp
${QtCore_GEN_DIR}/qcborerror_wrapper.cpp
${QtCore_GEN_DIR}/qcbormap_wrapper.cpp
${QtCore_GEN_DIR}/qcborparsererror_wrapper.cpp
${QtCore_GEN_DIR}/qcborstreamreader_wrapper.cpp
-${QtCore_GEN_DIR}/qcborstringresultstring_wrapper.cpp
-${QtCore_GEN_DIR}/qcborstringresultbytearray_wrapper.cpp
${QtCore_GEN_DIR}/qcborstreamwriter_wrapper.cpp
+${QtCore_GEN_DIR}/qcborstringresultbytearray_wrapper.cpp
+${QtCore_GEN_DIR}/qcborstringresultstring_wrapper.cpp
${QtCore_GEN_DIR}/qcborvalue_wrapper.cpp
+${QtCore_GEN_DIR}/qchildevent_wrapper.cpp
${QtCore_GEN_DIR}/qcollator_wrapper.cpp
${QtCore_GEN_DIR}/qcollatorsortkey_wrapper.cpp
${QtCore_GEN_DIR}/qcommandlineoption_wrapper.cpp
${QtCore_GEN_DIR}/qcommandlineparser_wrapper.cpp
+${QtCore_GEN_DIR}/qconcatenatetablesproxymodel_wrapper.cpp
${QtCore_GEN_DIR}/qcoreapplication_wrapper.cpp
${QtCore_GEN_DIR}/qcryptographichash_wrapper.cpp
${QtCore_GEN_DIR}/qdatastream_wrapper.cpp
@@ -55,26 +57,24 @@ ${QtCore_GEN_DIR}/qeasingcurve_wrapper.cpp
${QtCore_GEN_DIR}/qelapsedtimer_wrapper.cpp
${QtCore_GEN_DIR}/qevent_wrapper.cpp
${QtCore_GEN_DIR}/qeventloop_wrapper.cpp
-${QtCore_GEN_DIR}/qeventtransition_wrapper.cpp
${QtCore_GEN_DIR}/qfactoryinterface_wrapper.cpp
${QtCore_GEN_DIR}/qfile_wrapper.cpp
-${QtCore_GEN_DIR}/qfileselector_wrapper.cpp
${QtCore_GEN_DIR}/qfiledevice_wrapper.cpp
${QtCore_GEN_DIR}/qfileinfo_wrapper.cpp
+${QtCore_GEN_DIR}/qfileselector_wrapper.cpp
${QtCore_GEN_DIR}/qfilesystemwatcher_wrapper.cpp
-${QtCore_GEN_DIR}/qfinalstate_wrapper.cpp
${QtCore_GEN_DIR}/qgenericargument_wrapper.cpp
${QtCore_GEN_DIR}/qgenericreturnargument_wrapper.cpp
-${QtCore_GEN_DIR}/qhistorystate_wrapper.cpp
${QtCore_GEN_DIR}/qidentityproxymodel_wrapper.cpp
${QtCore_GEN_DIR}/qiodevice_wrapper.cpp
+${QtCore_GEN_DIR}/qiodevicebase_wrapper.cpp
+${QtCore_GEN_DIR}/qitemselection_wrapper.cpp
+${QtCore_GEN_DIR}/qitemselectionmodel_wrapper.cpp
+${QtCore_GEN_DIR}/qitemselectionrange_wrapper.cpp
${QtCore_GEN_DIR}/qjsonarray_wrapper.cpp
${QtCore_GEN_DIR}/qjsondocument_wrapper.cpp
${QtCore_GEN_DIR}/qjsonparseerror_wrapper.cpp
${QtCore_GEN_DIR}/qjsonvalue_wrapper.cpp
-${QtCore_GEN_DIR}/qitemselection_wrapper.cpp
-${QtCore_GEN_DIR}/qitemselectionmodel_wrapper.cpp
-${QtCore_GEN_DIR}/qitemselectionrange_wrapper.cpp
${QtCore_GEN_DIR}/qlibraryinfo_wrapper.cpp
${QtCore_GEN_DIR}/qline_wrapper.cpp
${QtCore_GEN_DIR}/qlinef_wrapper.cpp
@@ -107,13 +107,13 @@ ${QtCore_GEN_DIR}/qpointf_wrapper.cpp
${QtCore_GEN_DIR}/qprocess_wrapper.cpp
${QtCore_GEN_DIR}/qprocessenvironment_wrapper.cpp
${QtCore_GEN_DIR}/qpropertyanimation_wrapper.cpp
-${QtCore_GEN_DIR}/qrandomgenerator_wrapper.cpp
${QtCore_GEN_DIR}/qrandomgenerator64_wrapper.cpp
+${QtCore_GEN_DIR}/qrandomgenerator_wrapper.cpp
${QtCore_GEN_DIR}/qreadlocker_wrapper.cpp
${QtCore_GEN_DIR}/qreadwritelock_wrapper.cpp
${QtCore_GEN_DIR}/qrect_wrapper.cpp
${QtCore_GEN_DIR}/qrectf_wrapper.cpp
-${QtCore_GEN_DIR}/qregexp_wrapper.cpp
+${QtCore_GEN_DIR}/qrecursivemutex_wrapper.cpp
${QtCore_GEN_DIR}/qregularexpression_wrapper.cpp
${QtCore_GEN_DIR}/qregularexpressionmatch_wrapper.cpp
${QtCore_GEN_DIR}/qregularexpressionmatchiterator_wrapper.cpp
@@ -126,17 +126,12 @@ ${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp
${QtCore_GEN_DIR}/qsettings_wrapper.cpp
${QtCore_GEN_DIR}/qsignalblocker_wrapper.cpp
${QtCore_GEN_DIR}/qsignalmapper_wrapper.cpp
-${QtCore_GEN_DIR}/qsignaltransition_wrapper.cpp
${QtCore_GEN_DIR}/qsize_wrapper.cpp
${QtCore_GEN_DIR}/qsizef_wrapper.cpp
${QtCore_GEN_DIR}/qsocketdescriptor_wrapper.cpp
${QtCore_GEN_DIR}/qsocketnotifier_wrapper.cpp
${QtCore_GEN_DIR}/qsortfilterproxymodel_wrapper.cpp
-${QtCore_GEN_DIR}/qstate_wrapper.cpp
${QtCore_GEN_DIR}/qstandardpaths_wrapper.cpp
-${QtCore_GEN_DIR}/qstatemachine_signalevent_wrapper.cpp
-${QtCore_GEN_DIR}/qstatemachine_wrappedevent_wrapper.cpp
-${QtCore_GEN_DIR}/qstatemachine_wrapper.cpp
${QtCore_GEN_DIR}/qstorageinfo_wrapper.cpp
${QtCore_GEN_DIR}/qstringlistmodel_wrapper.cpp
${QtCore_GEN_DIR}/qsysinfo_wrapper.cpp
@@ -145,10 +140,6 @@ ${QtCore_GEN_DIR}/qt_wrapper.cpp
${QtCore_GEN_DIR}/qtemporarydir_wrapper.cpp
${QtCore_GEN_DIR}/qtemporaryfile_wrapper.cpp
${QtCore_GEN_DIR}/qtextboundaryfinder_wrapper.cpp
-${QtCore_GEN_DIR}/qtextcodec_converterstate_wrapper.cpp
-${QtCore_GEN_DIR}/qtextcodec_wrapper.cpp
-${QtCore_GEN_DIR}/qtextdecoder_wrapper.cpp
-${QtCore_GEN_DIR}/qtextencoder_wrapper.cpp
${QtCore_GEN_DIR}/qtextstream_wrapper.cpp
${QtCore_GEN_DIR}/qtextstreammanipulator_wrapper.cpp
${QtCore_GEN_DIR}/qthread_wrapper.cpp
@@ -157,9 +148,10 @@ ${QtCore_GEN_DIR}/qtime_wrapper.cpp
${QtCore_GEN_DIR}/qtimeline_wrapper.cpp
${QtCore_GEN_DIR}/qtimer_wrapper.cpp
${QtCore_GEN_DIR}/qtimerevent_wrapper.cpp
-${QtCore_GEN_DIR}/qtimezone_wrapper.cpp
${QtCore_GEN_DIR}/qtimezone_offsetdata_wrapper.cpp
+${QtCore_GEN_DIR}/qtimezone_wrapper.cpp
${QtCore_GEN_DIR}/qtranslator_wrapper.cpp
+${QtCore_GEN_DIR}/qtransposeproxymodel_wrapper.cpp
${QtCore_GEN_DIR}/qurl_wrapper.cpp
${QtCore_GEN_DIR}/qurlquery_wrapper.cpp
${QtCore_GEN_DIR}/quuid_wrapper.cpp
@@ -176,33 +168,11 @@ ${QtCore_GEN_DIR}/qxmlstreamnotationdeclaration_wrapper.cpp
${QtCore_GEN_DIR}/qxmlstreamreader_wrapper.cpp
${QtCore_GEN_DIR}/qxmlstreamwriter_wrapper.cpp
-
${SPECIFIC_OS_FILES}
# module is always needed
${QtCore_GEN_DIR}/qtcore_module_wrapper.cpp
)
-if (Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_EQUAL 5.13.0
- OR Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_GREATER 5.13.0)
- list(APPEND QtCore_SRC
- ${QtCore_GEN_DIR}/qconcatenatetablesproxymodel_wrapper.cpp
- ${QtCore_GEN_DIR}/qtransposeproxymodel_wrapper.cpp)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_EQUAL 5.14.0
- OR Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_GREATER 5.14.0)
- list(APPEND QtCore_SRC
- ${QtCore_GEN_DIR}/qcalendar_wrapper.cpp
- ${QtCore_GEN_DIR}/qcalendar_yearmonthday_wrapper.cpp
- ${QtCore_GEN_DIR}/qrecursivemutex_wrapper.cpp)
-endif()
-
-if (Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_EQUAL 5.15.0
- OR Qt${QT_MAJOR_VERSION}Core_VERSION VERSION_GREATER 5.15.0)
- list(APPEND QtCore_SRC
- ${QtCore_GEN_DIR}/qbytearray_frombase64result_wrapper.cpp)
-endif()
-
set(QtCore_glue_sources
"${QtCore_SOURCE_DIR}/glue/qeasingcurve_glue.cpp"
"${QtCore_SOURCE_DIR}/glue/qeasingcurve_glue.h"
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
index 62928f3cf..144e16ffc 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -51,15 +51,9 @@
<custom-type name="PyTypeObject"/>
<custom-type name="PyUnicode"/>
<custom-type name="list of QAbstractAnimation"/>
- <custom-type name="list of QAbstractState"/>
-
- <function signature="qAcos(qreal)"/>
- <function signature="qAsin(qreal)" since="4.6"/>
- <function signature="qAtan(qreal)" since="4.6"/>
- <function signature="qAtan2(qreal,qreal)" since="4.6"/>
- <function signature="qChecksum(const char*,uint)"/>
- <function signature="qExp(qreal)" since="4.6"/>
- <function signature="qFabs(qreal)" since="4.6"/>
+<!--
+ <function signature="qChecksum(QByteArrayView data, Qt::ChecksumType)"/>
+-->
<function signature="qFastCos(qreal)" since="4.6"/>
<function signature="qFastSin(qreal)" since="4.6"/>
<function signature="qFuzzyCompare(double,double)"/>
@@ -69,14 +63,11 @@
<function signature="qIsNaN(double)"/>
<function signature="qIsNull(double)"/>
<!-- Qt5: gone <function signature="qRound(qreal)"/> -->
- <function signature="qTan(qreal)" since="4.6"/>
<function signature="qtTrId(const char*,int)" since="4.6"/>
<function signature="qVersion()"/>
- <function signature="qrand()"/>
- <function signature="qsrand(uint)"/>
- <function signature="qCompress(const uchar*,int,int)"/>
+ <function signature="qCompress(const uchar*,qsizetype,int)"/>
<function signature="qCompress(const QByteArray&amp;,int)"/>
- <function signature="qUncompress(const uchar*,int)"/>
+ <function signature="qUncompress(const uchar*,qsizetype)"/>
<function signature="qUncompress(const QByteArray&amp;)"/>
<inject-code class="native" position="beginning" file="../glue/qtcore.cpp" snippet="include-pyside"/>
@@ -170,7 +161,6 @@
<enum-type name="QtMsgType"/>
-
<enum-type name="QCborSimpleType" since="5.12"/>
<enum-type name="QCborKnownTags" since="5.12"/>
@@ -189,6 +179,8 @@
<primitive-type name="long long"/>
<primitive-type name="qlonglong" target-lang-api-name="PyLong"/>
<primitive-type name="qulonglong" target-lang-api-name="PyLong"/>
+ <primitive-type name="qsizetype" target-lang-api-name="PyLong"/>
+ <primitive-type name="size_t" target-lang-api-name="PyLong"/>
<primitive-type name="short"/>
<primitive-type name="signed short"/>
<primitive-type name="signed short int"/>
@@ -256,17 +248,18 @@
<native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode"/>
<target-to-native>
<add-conversion type="PyUnicode" file="../glue/qtcore.cpp" snippet="conversion-pyunicode"/>
- <add-conversion type="PyString" check="py2kStrCheck(%in)" file="../glue/qtcore.cpp" snippet="conversion-pystring"/>
<add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/>
</target-to-native>
</conversion-rule>
</primitive-type>
- <primitive-type name="QStringRef">
+ <primitive-type name="QStringView" target-lang-api-name="PyUnicode" view-on="QString">
+ <include file-name="QStringView" location="global"/>
<conversion-rule>
- <native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode-qstringref"/>
+ <native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode"/>
</conversion-rule>
</primitive-type>
+
<primitive-type name="QChar">
<conversion-rule>
<native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode-qchar"/>
@@ -354,7 +347,7 @@
<include file-name="qcborstream.h" location="global"/>
<value-type name="StringResult" generate="no"/>
<!-- 64bit (qsizetype = long long) -->
- <modify-function signature="readStringChunk(char*,long long)" remove="all"/>
+ <modify-function signature="readStringChunk(char*,qsizetype)" remove="all"/>
<!-- 32bit (qsizetype = int) -->
<modify-function signature="readStringChunk(char*,int)" remove="all"/>
</object-type>
@@ -405,6 +398,7 @@
</conversion-rule>
</container-type>
+ <!-- FIXME: Which one is it going to be? -->
<container-type name="QList" type="list">
<include file-name="QList" location="global"/>
<conversion-rule>
@@ -419,21 +413,6 @@
</conversion-rule>
</container-type>
- <container-type name="QVector" type="vector">
- <include file-name="QVector" location="global"/>
- <conversion-rule>
- <native-to-target>
- <insert-template name="cppvector_to_pylist_conversion"/>
- </native-to-target>
- <target-to-native>
- <add-conversion type="PySequence">
- <insert-template name="pyseq_to_cppvector_conversion"/>
- </add-conversion>
- </target-to-native>
- </conversion-rule>
-
- </container-type>
-
<container-type name="QStack" type="stack">
<include file-name="QStack" location="global"/>
<conversion-rule>
@@ -462,20 +441,6 @@
</conversion-rule>
</container-type>
- <container-type name="QLinkedList" type="linked-list">
- <include file-name="QLinkedList" location="global"/>
- <conversion-rule>
- <native-to-target>
- <insert-template name="cpplist_to_pylist_conversion"/>
- </native-to-target>
- <target-to-native>
- <add-conversion type="PySequence">
- <insert-template name="pyseq_to_cpplist_conversion"/>
- </add-conversion>
- </target-to-native>
- </conversion-rule>
- </container-type>
-
<container-type name="QHash" type="hash">
<include file-name="QHash" location="global"/>
<!-- Include to make enum flags work. -->
@@ -550,15 +515,11 @@
<rejection class="" enum-name="enum_1"/>
<rejection class="" enum-name="enum_2"/>
<rejection class="" enum-name="QtValidLicenseForXmlModule"/>
- <rejection class="" enum-name="QtValidLicenseForXmlPatternsModule"/>
<rejection class="" enum-name="QtValidLicenseForActiveQtModule"/>
<rejection class="" enum-name="QtValidLicenseForCoreModule"/>
- <rejection class="" enum-name="QtValidLicenseForQt3SupportLightModule"/>
- <rejection class="" enum-name="QtValidLicenseForQt3SupportModule"/>
<rejection class="" enum-name="QtValidLicenseForNetworkModule"/>
<rejection class="" enum-name="QtValidLicenseForSvgModule"/>
<rejection class="" enum-name="QtValidLicenseForGuiModule"/>
- <rejection class="" enum-name="QtValidLicenseForScriptModule"/>
<rejection class="" enum-name="QtValidLicenseForHelpModule"/>
<!-- Internal -->
<rejection class="QAbstractFileEngine"/> <!--
@@ -634,6 +595,7 @@
<enum-type name="PenCapStyle"/>
<enum-type name="PenJoinStyle"/>
<enum-type name="PenStyle"/>
+ <enum-type name="ReturnByValueConstant" since="6.0"/>
<enum-type name="ScreenOrientation" flags="ScreenOrientations" since="5.0"/>
<enum-type name="ScrollBarPolicy"/>
<enum-type name="ScrollPhase" since="5.2"/>
@@ -747,7 +709,7 @@
</add-function>
</value-type>
<value-type name="QLineF">
- <enum-type name="IntersectType"/>
+ <enum-type name="IntersectionType"/>
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
<insert-template name="repr_code">
@@ -774,7 +736,7 @@
</insert-template>
</inject-code>
</add-function>
- <modify-function signature="intersect(QLineF,QPointF*)const">
+ <modify-function signature="intersects(const QLineF &amp;,QPointF*)const">
<modify-argument index="2">
<remove-argument />
</modify-argument>
@@ -831,7 +793,6 @@
<extra-includes>
<include file-name="datetime.h" location="global"/>
</extra-includes>
- <enum-type name="MonthNameType"/>
<add-function signature="__repr__" return-type="PyObject">
<inject-code class="target" position="beginning">
<insert-template name="repr_code">
@@ -852,7 +813,7 @@
<add-function signature="toPython()" return-type="PyObject">
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qdate-topython"/>
</add-function>
- <modify-function signature="getDate(int*,int*,int*)" >
+ <modify-function signature="getDate(int*,int*,int*)const" >
<modify-argument index="1">
<remove-argument/>
</modify-argument>
@@ -1314,8 +1275,6 @@
<rename to="format"/>
</modify-argument>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toUInt(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toUInt(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1328,8 +1287,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toULongLong(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toULongLong(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1342,8 +1299,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions -->
- <modify-function signature="toDouble(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toDouble(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1356,8 +1311,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions -->
- <modify-function signature="toFloat(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toFloat(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1370,8 +1323,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toInt(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toInt(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1383,8 +1334,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toLongLong(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toLongLong(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1396,8 +1345,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toShort(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toShort(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1409,8 +1356,6 @@
<insert-template name="fix_args,bool*"/>
</inject-code>
</modify-function>
- <!-- Qt5: ignore the new QStringRef versions, int arg is gone -->
- <modify-function signature="toUShort(QStringRef,bool*)const" remove="all"/>
<modify-function signature="toUShort(QString,bool*)const">
<modify-argument index="2">
<remove-argument />
@@ -1509,7 +1454,7 @@
<enum-type name="CheckIndexOption" flags="CheckIndexOptions" since="5.11"/>
<enum-type name="LayoutChangeHint"/>
<!-- This function was replaced by a added function -->
- <modify-function signature="createIndex(int,int,void*)const" remove="all"/>
+ <modify-function signature="createIndex(int,int,const void*)const" remove="all"/>
<!-- This function is the same as createIndex(int, int, int)const -->
<modify-function signature="createIndex(int,int,quintptr)const">
<modify-argument index="3">
@@ -1560,6 +1505,10 @@
</object-type>
<value-type name="QItemSelection">
<include file-name="QList" location="global"/>
+ <!-- Expose operator==, != inherited from QList, which the parser does
+ not see due to the TMP expression of the return type. -->
+ <add-function signature="operator==(const QItemSelection&amp;)" return-type="bool"/>
+ <add-function signature="operator!=(const QItemSelection&amp;)" return-type="bool"/>
</value-type>
<object-type name="QItemSelectionModel">
@@ -1590,10 +1539,6 @@
<reference-count action="set"/>
</modify-argument>
</modify-function>
- <!--### Obsolete in 4.3-->
- <modify-function signature="clear()" remove="all"/>
- <modify-function signature="filterChanged()" remove="all"/>
- <!--### End of obsolete section -->
</object-type>
<object-type name="QIdentityProxyModel"/>
<object-type name="QTransposeProxyModel" since="5.13"/>
@@ -1735,12 +1680,6 @@
<replace-default-expression with="QString()"/>
</modify-argument>
</add-function>
- <add-function signature="findChildren(PyTypeObject*,const QRegExp&amp;)" return-type="PySequence*" >
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qobject-findchildren"/>
- <modify-argument index="return">
- <parent index="this" action="add"/>
- </modify-argument>
- </add-function>
<add-function signature="findChildren(PyTypeObject*,const QRegularExpression&amp;)" return-type="PySequence*" >
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qobject-findchildren"/>
<modify-argument index="return">
@@ -1823,64 +1762,8 @@
</inject-code>
</add-function>
</value-type>
- <value-type name="QRegExp">
- <enum-type name="CaretMode"/>
- <enum-type name="PatternSyntax"/>
- <extra-includes>
- <include file-name="QStringList" location="global"/>
- </extra-includes>
- <add-function signature="__repr__" return-type="PyObject*">
- <inject-code class="target" position="beginning">
- <insert-template name="repr_code">
- <replace from="%REPR_FORMAT" to="'%s', %i, %i"/>
- <replace from="%REPR_ARGS" to="qPrintable(%CPPSELF.pattern()), (int)%CPPSELF.caseSensitivity(), (int)%CPPSELF.patternSyntax()"/>
- </insert-template>
- </inject-code>
- </add-function>
-
- <add-function signature="__reduce__" return-type="PyObject*">
- <inject-code class="target" position="beginning">
- <insert-template name="reduce_code">
- <replace from="%REDUCE_FORMAT" to="sii"/>
- <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.pattern()), (int)%CPPSELF.caseSensitivity(), (int)%CPPSELF.patternSyntax()"/>
- </insert-template>
- </inject-code>
- </add-function>
- <add-function signature="replace(QString,QString)" return-type="QString">
- <modify-argument index="1">
- <rename to="sourceString"/>
- </modify-argument>
- <modify-argument index="2">
- <rename to="after"/>
- </modify-argument>
- <inject-documentation format="target" mode="append">
- Replaces every occurrence of the regular expression in *sourceString* with *after*.
- Returns a new Python string with the modified contents. For example:
-
- ::
-
- s = "Banana"
- re = QRegExp("a[mn]")
- s = re.replace(s, "ox")
- # s == "Boxoxa"
-
-
- For regular expressions containing capturing parentheses, occurrences of \1, \2, ..., in *after*
- are replaced with rx.cap(1), cap(2), ...
-
- ::
-
- t = "A &lt;i>bon mot&lt;/i>."
- re = QRegExp("&lt;i>([^&lt;]*)&lt;/i>")
- t = re.replace(t, "\\emph{\\1}")
- # t == "A \\emph{bon mot}."
-
- </inject-documentation>
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qregexp-replace"/>
- </add-function>
- </value-type>
-
<value-type name="QRegularExpression">
+ <enum-type name="WildcardConversionOption" flags="WildcardConversionOptions" since="6.0"/>
<enum-type name="MatchOption" flags="MatchOptions"/>
<enum-type name="MatchType"/>
<enum-type name="PatternOption" flags="PatternOptions"/>
@@ -1920,58 +1803,23 @@
</extra-includes>
<!-- ### These overloads must be removed accept strings with \x00 in their contents -->
- <modify-function signature="append(const char*,int)" remove="all"/>
<modify-function signature="append(const char*)" remove="all"/>
- <modify-function signature="append(QString)" remove="all"/>
- <modify-function signature="contains(const char*)const" remove="all"/>
- <modify-function signature="count(const char*)const" remove="all"/>
- <modify-function signature="endsWith(const char*)const" remove="all"/>
- <modify-function signature="indexOf(const char*,int)const" remove="all"/>
- <modify-function signature="indexOf(char,int)const" remove="all"/>
- <modify-function signature="indexOf(QString,int)const" remove="all"/>
- <modify-function signature="insert(int,const char*)" remove="all"/>
- <modify-function signature="insert(int,char)" remove="all"/>
- <modify-function signature="insert(int,const char*,int)" since="4.6" remove="all"/>
- <modify-function signature="insert(int,QString)" remove="all"/>
- <modify-function signature="lastIndexOf(const char*,int)const" remove="all"/>
- <modify-function signature="lastIndexOf(QString,int)const" remove="all"/>
- <modify-function signature="lastIndexOf(char,int)const" remove="all"/>
<modify-function signature="prepend(const char*)" remove="all"/>
- <modify-function signature="prepend(const char*,int)" since="4.6" remove="all"/>
- <modify-function signature="replace(QByteArray,const char*)" remove="all"/>
- <modify-function signature="replace(const char*,int,const char*,int)" remove="all"/>
- <modify-function signature="replace(QString,const char*)" remove="all"/>
- <modify-function signature="replace(const char*,QByteArray)" remove="all"/>
- <modify-function signature="replace(const char*,const char*)" remove="all"/>
- <modify-function signature="replace(int,int,const char*)" remove="all"/>
- <modify-function signature="replace(int,int,const char*,int)" since="4.6" remove="all"/>
- <modify-function signature="replace(char,const char*)" remove="all"/>
- <modify-function signature="replace(char,QString)" remove="all"/>
- <modify-function signature="startsWith(const char*)const" remove="all"/>
- <modify-function signature="operator==(QString)const" remove="all"/>
<modify-function signature="operator==(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator==(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator>(QString)const" remove="all"/>
<modify-function signature="operator>(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator>(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator>=(QString)const" remove="all"/>
<modify-function signature="operator>=(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator>=(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator&lt;(QString)const" remove="all"/>
<modify-function signature="operator&lt;(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator&lt;=(QString)const" remove="all"/>
<modify-function signature="operator&lt;=(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator&lt;=(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator!=(QString)const" remove="all"/>
<modify-function signature="operator!=(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator!=(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator+=(QString)" remove="all"/>
<modify-function signature="operator+=(const char*)" remove="all"/>
<modify-function signature="operator+(QByteArray,const char*)" remove="all"/>
<modify-function signature="operator+(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator+(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator+(QString,QByteArray)" remove="all"/>
- <modify-function signature="operator+(QByteArray,QString)" remove="all"/>
<add-function signature="operator+(PyBytes,QByteArray)">
<inject-code file="../glue/qtcore.cpp" snippet="qbytearray-operatorplus-1"/>
</add-function>
@@ -2016,10 +1864,6 @@
</insert-template>
</inject-code>
</add-function>
- <modify-function signature="QByteArray(const char*,int)">
- <!-- Keep \x00 bytes passed in python strings -->
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qbytearray-1"/>
- </modify-function>
<add-function signature="QByteArray(PyByteArray)">
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qbytearray-2"/>
</add-function>
@@ -2056,16 +1900,18 @@
<modify-function signature="operator&lt;=(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator>(const char*,QByteArray)" remove="all"/>
<modify-function signature="operator>=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator[](int)const" remove="all"/>
- <modify-function signature="operator[](uint)const" remove="all"/>
<!-- Those types have the same representation in Python, an overload
would be useless and cause overflow errors. -->
<modify-function signature="setNum(uint,int)" remove="all"/>
<modify-function signature="setNum(ushort,int)" remove="all"/>
<modify-function signature="setNum(float,char,int)" remove="all"/>
<modify-function signature="setNum(short,int)" remove="all"/>
+ <modify-function signature="setNum(long,int)" remove="all"/>
+ <modify-function signature="setNum(ulong,int)" remove="all"/>
<modify-function signature="setNum(qulonglong,int)" remove="all"/>
<modify-function signature="number(uint,int)" remove="all"/>
+ <modify-function signature="number(long,int)" remove="all"/>
+ <modify-function signature="number(ulong,int)" remove="all"/>
<modify-function signature="number(qulonglong,int)" remove="all"/>
<!--### -->
@@ -2147,16 +1993,6 @@
</inject-code>
</modify-function>
<!-- QByteArray(const char *) do the job of this constructor -->
- <modify-function signature="QByteArray(const char*,int)" remove="all"/>
- <modify-function signature="fromRawData(const char*,int)">
- <modify-argument index="1">
- <replace-type modified-type="PyBytes"/>
- </modify-argument>
- <modify-argument index="2">
- <remove-argument />
- </modify-argument>
- <inject-code class="target" file="../glue/qtcore.cpp" snippet="qbytearray-fromrawdata"/>
- </modify-function>
<modify-function signature="toDouble(bool*)const">
<modify-argument index="1">
<remove-argument/>
@@ -2192,18 +2028,24 @@
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qbytearray-msetitem"/>
</add-function>
</value-type>
+ <primitive-type name="QByteArrayView" view-on="QByteArray" since="6.0">
+ <conversion-rule>
+ <native-to-target file="../glue/qtcore.cpp" snippet="return-pybytes"/>
+ </conversion-rule>
+ </primitive-type>
+
<value-type name="QTextBoundaryFinder">
<enum-type name="BoundaryReason" flags="BoundaryReasons"/>
<enum-type name="BoundaryType"/>
<!-- There's no QChar in PySide -->
- <modify-function signature="QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType,const QChar*,int,unsigned char*,int)" remove="all"/>
+ <modify-function signature="QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType,const QChar*,qsizetype,unsigned char*,qsizetype)" remove="all"/>
</value-type>
<object-type name="QXmlStreamEntityResolver"/>
<!-- Qt5: had to move QAbstractEventDispatcher into os-specific files because of Windows -->
<object-type name="QAbstractNativeEventFilter">
<!-- see QWidget::nativeEvent(), QWindow::nativeEvent() -->
- <modify-function signature="nativeEventFilter(const QByteArray&amp;,void*,long*)">
+ <modify-function signature="nativeEventFilter(const QByteArray&amp;,void*,qintptr*)">
<modify-argument index="3">
<remove-argument/>
<conversion-rule class="native">
@@ -2231,7 +2073,7 @@
<object-type name="QFileDevice" since="5.0">
<enum-type name="FileError"/>
<enum-type name="FileTime" since="5.10"/>
- <enum-type name="MemoryMapFlags"/>
+ <enum-type name="MemoryMapFlag" flags="MemoryMapFlags"/>
<enum-type name="Permission" flags="Permissions"/>
<enum-type name="FileHandleFlag" flags="FileHandleFlags"/>
<extra-includes>
@@ -2243,7 +2085,7 @@
</modify-argument>
<inject-code file="../glue/qtcore.cpp" snippet="qfiledevice-unmap"/>
</modify-function>
- <modify-function signature="map(qint64,qint64,QFileDevice::MemoryMapFlags)">
+ <modify-function signature="map(qint64,qint64,QFlags&lt;QFileDevice::MemoryMapFlag&gt;)">
<modify-argument index="return">
<replace-type modified-type="PyObject"/>
</modify-argument>
@@ -2252,8 +2094,8 @@
<modify-function signature="flush()" allow-thread="yes"/>
</object-type>
<object-type name="QFile">
- <modify-function signature="open(QFlags&lt;QIODevice::OpenModeFlag&gt;)" allow-thread="yes"/>
- <modify-function signature="open(int,QFlags&lt;QIODevice::OpenModeFlag&gt;,QFlags&lt;QFileDevice::FileHandleFlag&gt;)" allow-thread="yes"/>
+ <modify-function signature="open(QFlags&lt;QIODeviceBase::OpenModeFlag&gt;)" allow-thread="yes"/>
+ <modify-function signature="open(int,QFlags&lt;QIODeviceBase::OpenModeFlag&gt;,QFlags&lt;QFileDevice::FileHandleFlag&gt;)" allow-thread="yes"/>
<modify-function signature="copy(const QString&amp;)" allow-thread="yes"/>
<modify-function signature="copy(const QString&amp;,const QString&amp;)" allow-thread="yes"/>
<modify-function signature="link(const QString&amp;)" allow-thread="yes"/>
@@ -2267,8 +2109,7 @@
<object-type name="QFileSelector"/>
<object-type name="QIODevice">
- <enum-type name="OpenModeFlag" flags="OpenMode"/>
- <modify-function signature="open(QFlags&lt;QIODevice::OpenModeFlag>)" allow-thread="yes"/>
+ <modify-function signature="open(QFlags&lt;QIODeviceBase::OpenModeFlag>)" allow-thread="yes"/>
<modify-function signature="close()" allow-thread="yes"/>
<modify-function signature="seek(qint64)" allow-thread="yes"/>
<modify-function signature="readAll()" allow-thread="yes"/>
@@ -2315,9 +2156,12 @@
<inject-code class="native" position="end" file="../glue/qtcore.cpp" snippet="return-readData"/>
</modify-function>
</object-type>
+ <value-type name="QIODeviceBase" since="6.0">
+ <enum-type name="OpenModeFlag" flags="OpenMode"/>
+ </value-type>
<object-type name="QCryptographicHash">
<enum-type name="Algorithm"/>
- <modify-function signature="addData(const char*,int)">
+ <modify-function signature="addData(const char*,qsizetype)">
<modify-argument index="2">
<remove-argument />
</modify-argument>
@@ -2328,7 +2172,7 @@
<enum-type name="OSType"/>
</value-type>
<object-type name="QLibraryInfo">
- <enum-type name="LibraryLocation"/>
+ <enum-type name="LibraryPath"/>
<modify-function signature="build()">
<inject-code class="target" position="end" file="../glue/qtcore.cpp" snippet="qlibraryinfo_build"/>
</modify-function>
@@ -2413,40 +2257,7 @@
<include file-name="QUrl" location="global"/>
</extra-includes>
</object-type>
- <object-type name="QTextCodec">
- <enum-type name="ConversionFlag" flags="ConversionFlags"/>
-
- <object-type name="ConverterState">
- <include file-name="QTextCodec" location="global"/>
- <modify-function signature="ConverterState(QFlags&lt;QTextCodec::ConversionFlag&gt;)">
- <modify-argument index="1">
- <replace-default-expression with="QTextCodec::DefaultConversion"/>
- </modify-argument>
- </modify-function>
- </object-type>
-
- <modify-function signature="setCodecForLocale(QTextCodec*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <!-- fromUnicode(QString) does the job -->
- <modify-function signature="fromUnicode(const QChar*,int,QTextCodec::ConverterState*)const" remove="all"/>
- <modify-function signature="convertFromUnicode(const QChar*,int,QTextCodec::ConverterState*)const" remove="all"/>
- <!-- this causes a warning that I cannot avoid. See suppressed warning at the end. -->
- </object-type>
- <object-type name="QTextDecoder">
- <!-- ### toUnicode(QByteArray) does the job -->
- <modify-function signature="toUnicode(const char*,int)" remove="all"/>
- <modify-function signature="toUnicode(QString*,const char*,int)" remove="all"/>
- <!-- ### -->
- </object-type>
- <object-type name="QTextEncoder">
- <!-- fromUnicode(QString) does the job -->
- <modify-function signature="fromUnicode(const QChar*,int)" remove="all"/>
- </object-type>
<object-type name="QTimeLine">
- <enum-type name="CurveShape"/>
<enum-type name="Direction"/>
<enum-type name="State"/>
</object-type>
@@ -2500,7 +2311,6 @@
<modify-function signature="readAllStandardOutput()" allow-thread="yes"/>
<modify-function signature="readAllStandardError()" allow-thread="yes"/>
<modify-function signature="execute(QString,QStringList)" allow-thread="yes"/>
- <modify-function signature="execute(QString)" allow-thread="yes"/>
<modify-function signature="startDetached(QString,QStringList,QString,qint64*)">
<modify-argument index="4">
<remove-argument />
@@ -2510,15 +2320,6 @@
</modify-argument>
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qprocess-startdetached"/>
</modify-function>
- <!-- Function removed because on windows it returns a win32 specific structure -->
- <modify-function signature="pid()const" remove="all"/>
- <add-function signature="pid()" return-type="long">
- <inject-code file="../glue/qtcore.cpp" snippet="qprocess-pid"/>
- </add-function>
- <!--### Obsolete in 4.3-->
- <modify-function signature="setReadChannelMode(QProcess::ProcessChannelMode)" remove="all"/>
- <modify-function signature="readChannelMode()const" remove="all"/>
- <!-- ### -->
</object-type>
<object-type name="QSignalMapper"/>
@@ -2568,7 +2369,6 @@
<!-- blocking functions -->
<modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;,int)" allow-thread="yes"/>
<modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;)" allow-thread="yes"/>
- <modify-function signature="flush()" allow-thread="yes"/>
<modify-function signature="sendEvent(QObject*,QEvent*)" allow-thread="yes"/>
<modify-function signature="sendPostedEvents(QObject*,int)" allow-thread="yes"/>
<modify-function signature="instance()">
@@ -2594,15 +2394,6 @@
<extra-includes>
<include file-name="QStringList" location="global"/>
</extra-includes>
- <!--### Obsolete in 4.3-->
- <modify-function signature="setSystemIniPath(const QString&amp;)" remove="all"/>
- <modify-function signature="setUserIniPath(const QString&amp;)" remove="all"/>
- <!--### Obsolete in 4.3-->
- <modify-function signature="iniCodec()const">
- <modify-argument index="return">
- <define-ownership class="target" owner="default"/>
- </modify-argument>
- </modify-function>
<!-- PYSIDE-1010:
We remove the original implementation of value() to include the optional parameter -->
<modify-function signature="value(const QString&amp;,const QVariant&amp;)const" remove="all"/>
@@ -2791,14 +2582,14 @@
<enum-type name="RealNumberNotation"/>
<enum-type name="Status"/>
<!-- Removed because it expect QString to be mutable -->
- <modify-function signature="QTextStream(QString*,QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
+ <modify-function signature="QTextStream(QString*,QFlags&lt;QIODeviceBase::OpenModeFlag&gt;)" remove="all"/>
<!-- Qt5.5: Removed because it expect QString to be mutable -->
<modify-function signature="readLineInto(QString*,qint64)" since="5.5" remove="all"/>
<!-- Removed because we use the non-const version -->
- <modify-function signature="QTextStream(const QByteArray&amp;,QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
+ <modify-function signature="QTextStream(const QByteArray&amp;,QFlags&lt;QIODeviceBase::OpenModeFlag&gt;)" remove="all"/>
<!-- Removed because it expect QString to be mutable -->
- <modify-function signature="setString(QString*,QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
+ <modify-function signature="setString(QString*,QFlags&lt;QIODeviceBase::OpenModeFlag&gt;)" remove="all"/>
<modify-function signature="operator&lt;&lt;(const void*)" remove="all"/>
<modify-function signature="operator&lt;&lt;(float)" remove="all"/>
@@ -2875,8 +2666,14 @@
<modify-function signature="push_front(QXmlStreamAttribute)" remove="all"/>
<modify-function signature="pop_front()" remove="all"/>
<modify-function signature="toList()const" remove="all"/>
+ <!-- Remove methods from QList -->
+ <modify-function signature="value(qsizetype,const QXmlStreamAttribute&amp;) const" remove="all"/>
<modify-function signature="fromList(const QList&lt;QXmlStreamAttribute&gt; &amp;)" remove="all"/>
<modify-function signature="operator+=(QVector&lt;QXmlStreamAttribute&gt;)" remove="all"/>
+ <!-- Expose operator==, != inherited from QList, which the parser does
+ not see due to the TMP expression of the return type. -->
+ <add-function signature="operator==(const QXmlStreamAttributes&amp;)" return-type="bool"/>
+ <add-function signature="operator!=(const QXmlStreamAttributes&amp;)" return-type="bool"/>
</value-type>
<value-type name="QXmlStreamNamespaceDeclaration"/>
<value-type name="QXmlStreamNotationDeclaration"/>
@@ -2889,11 +2686,6 @@
<object-type name="QXmlStreamWriter">
<!-- Removed because it expect QString to be mutable -->
<modify-function signature="QXmlStreamWriter(QString*)" remove="all"/>
- <modify-function signature="codec()const">
- <modify-argument index="return">
- <define-ownership class="target" owner="default"/>
- </modify-argument>
- </modify-function>
</object-type>
<value-type name="QModelIndex" hash-function="qHash">
<modify-function signature="internalPointer()const">
@@ -2982,61 +2774,6 @@
<enum-type name="State"/>
</object-type>
- <object-type name="QAbstractState" since="4.6">
- <modify-function signature="machine()const">
- <modify-argument index="this">
- <parent index="return" action="add"/>
- </modify-argument>
- </modify-function>
- </object-type>
-
- <object-type name="QAbstractTransition" since="4.6">
- <enum-type name="TransitionType" since="5.5"/>
-
- <modify-function signature="QAbstractTransition(QState*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="addAnimation(QAbstractAnimation*)">
- <modify-argument index="1">
- <reference-count action="add"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="removeAnimation(QAbstractAnimation*)">
- <modify-argument index="1">
- <reference-count action="remove"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="setTargetState(QAbstractState*)">
- <modify-argument index="1">
- <reference-count action="set"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="targetState()const">
- <modify-argument index="return">
- <reference-count action="set" variable-name="setTargetState(QAbstractState*)1"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="targetStates()const">
- <modify-argument index="return">
- <reference-count action="set" variable-name="setTargetState(QAbstractState*)1"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="setTargetStates(QList&lt;QAbstractState*&gt;)">
- <modify-argument index="1">
- <reference-count action="set" variable-name="setTargetState(QAbstractState*)1"/>
- </modify-argument>
- </modify-function>
-
- </object-type>
-
<object-type name="QAnimationGroup" since="4.6">
<modify-function signature="addAnimation(QAbstractAnimation*)">
<modify-argument index="1">
@@ -3111,48 +2848,6 @@
</extra-includes>
</value-type>
- <object-type name="QEventTransition" since="4.6">
- <modify-function signature="QEventTransition(QState*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="QEventTransition(QObject*,QEvent::Type,QState*)">
- <modify-argument index="3">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- </object-type>
-
- <object-type name="QFinalState" since="4.6"/>
-
- <object-type name="QHistoryState" since="4.6">
- <enum-type name="HistoryType"/>
- <modify-documentation xpath='description/code'>
- &lt;code>machine = QStateMachine()
-
-s1 = QState()
-s11 = QState(s1)
-s12 = QState(s1)
-
-s1h = QHistoryState(s1)
-s1h.setDefaultState(s11)
-
-machine.addState(s1)
-
-s2 = QState()
-machine.addState(s2)
-
-button = QPushButton()
-# Clicking the button will cause the state machine to enter the child state
-# that s1 was in the last time s1 was exited, or the history state's default
-# state if s1 has never been entered.
-s1.addTransition(button.clicked, s1h)&lt;/code>
- </modify-documentation>
- </object-type>
-
<value-type name="QMargins" since="4.6"/>
<value-type name="QMarginsF" since="5.3"/>
@@ -3166,82 +2861,6 @@ s1.addTransition(button.clicked, s1h)&lt;/code>
<object-type name="QSequentialAnimationGroup" since="4.6"/>
- <object-type name="QSignalTransition" since="4.6">
- <add-function signature="QSignalTransition(PyObject*,QState*)" return-type="QSignalTransition*">
- <modify-argument index="2">
- <replace-default-expression with="0"/>
- </modify-argument>
- <inject-code file="../glue/qtcore.cpp" snippet="qsignaltransition"/>
- </add-function>
- </object-type>
-
- <object-type name="QState" since="4.6">
- <enum-type name="ChildMode"/>
- <enum-type name="RestorePolicy"/>
- <modify-function signature="addTransition(QAbstractTransition*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="addTransition(const QObject*,const char*,QAbstractState*)">
- <modify-argument index="return">
- <parent index="this" action="add"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qstate-addtransition-1"/>
- </modify-function>
- <modify-function signature="addTransition(QAbstractState*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- <!-- FIXME: the proper signature for this added function would be something like
- addTransition(PySide2.QtCore.Signal, QAbstractState*)
- but that depends on bug #362. -->
- <add-function signature="addTransition(PyObject*,QAbstractState*)" return-type="QSignalTransition*">
- <modify-argument index="return">
- <parent index="this" action="add"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qstate-addtransition-2"/>
- </add-function>
-
- <modify-function signature="removeTransition(QAbstractTransition*)">
- <modify-argument index="1">
- <parent index="this" action="remove"/>
- </modify-argument>
- </modify-function>
- </object-type>
-
- <object-type name="QStateMachine" since="4.6">
- <enum-type name="Error"/>
- <enum-type name="EventPriority"/>
-
- <value-type name="SignalEvent" since="4.6"/>
- <value-type name="WrappedEvent" since="4.6"/>
-
- <modify-function signature="addState(QAbstractState*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="removeState(QAbstractState*)">
- <modify-argument index="1">
- <parent index="this" action="remove"/>
- </modify-argument>
- </modify-function>
-
- <add-function signature="configuration()" return-type="list of QAbstractState" >
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qstatemachine-configuration"/>
- </add-function>
-
- <!-- Replaced by a added function -->
- <modify-function signature="defaultAnimations()const" remove="all"/>
- <add-function signature="defaultAnimations()" return-type="list of QAbstractAnimation" >
- <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qstatemachine-defaultanimations"/>
- </add-function>
- </object-type>
-
<object-type name="QVariantAnimation" since="4.6"/>
<value-type name="QVersionNumber" since="5.6">
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml
index 8e3fa6f5e..6a0e1087e 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml
@@ -49,22 +49,14 @@
<include file-name="wtypes.h" location="global"/>
<conversion-rule>
<native-to-target>
- #ifdef IS_PY3K
- return PyCapsule_New(%in, 0, 0);
- #else
- return PyCObject_FromVoidPtr(%in, 0);
- #endif
+ return PyCapsule_New(%in, nullptr, nullptr);
</native-to-target>
<target-to-native>
<add-conversion type="PyNone">
%out = 0;
</add-conversion>
<add-conversion check="checkPyCapsuleOrPyCObject(%in)" type="PyObject">
- #ifdef IS_PY3K
- %out = (%OUTTYPE)PyCapsule_GetPointer(%in, 0);
- #else
- %out = (%OUTTYPE)PyCObject_AsVoidPtr(%in);
- #endif
+ %out = (%OUTTYPE)PyCapsule_GetPointer(%in, nullptr);
</add-conversion>
</target-to-native>
</conversion-rule>
diff --git a/sources/pyside2/PySide2/QtGui/CMakeLists.txt b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
index c4a38a184..7885af343 100644
--- a/sources/pyside2/PySide2/QtGui/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
@@ -1,18 +1,11 @@
project(QtGui)
-if (${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- qt6_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside2_SOURCE_DIR}/qpytextobject.h")
-else()
- qt5_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside2_SOURCE_DIR}/qpytextobject.h")
-endif()
+qt_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside2_SOURCE_DIR}/qpytextobject.h")
set(QtGui_DROPPED_ENTRIES)
-get_property(QtGui_enabled_features TARGET Qt${QT_MAJOR_VERSION}::Gui
- PROPERTY QT_ENABLED_PUBLIC_FEATURES)
-
set(QtGui_SRC
-${QtGui_GEN_DIR}/qabstractopenglfunctions_wrapper.cpp
+${QtGui_GEN_DIR}/qabstractfileiconprovider_wrapper.cpp
${QtGui_GEN_DIR}/qabstracttextdocumentlayout_paintcontext_wrapper.cpp
${QtGui_GEN_DIR}/qabstracttextdocumentlayout_selection_wrapper.cpp
${QtGui_GEN_DIR}/qabstracttextdocumentlayout_wrapper.cpp
@@ -31,13 +24,18 @@ ${QtGui_GEN_DIR}/qaccessibletextselectionevent_wrapper.cpp
${QtGui_GEN_DIR}/qaccessibletextupdateevent_wrapper.cpp
${QtGui_GEN_DIR}/qaccessiblevaluechangeevent_wrapper.cpp
${QtGui_GEN_DIR}/qaccessiblevalueinterface_wrapper.cpp
+${QtGui_GEN_DIR}/qaction_wrapper.cpp
${QtGui_GEN_DIR}/qactionevent_wrapper.cpp
+${QtGui_GEN_DIR}/qactiongroup_wrapper.cpp
${QtGui_GEN_DIR}/qbackingstore_wrapper.cpp
${QtGui_GEN_DIR}/qbitmap_wrapper.cpp
${QtGui_GEN_DIR}/qbrush_wrapper.cpp
${QtGui_GEN_DIR}/qclipboard_wrapper.cpp
${QtGui_GEN_DIR}/qcloseevent_wrapper.cpp
${QtGui_GEN_DIR}/qcolor_wrapper.cpp
+${QtGui_GEN_DIR}/qcolorspace_wrapper.cpp
+${QtGui_GEN_DIR}/qcolorconstants_wrapper.cpp
+${QtGui_GEN_DIR}/qcolorconstants_svg_wrapper.cpp
${QtGui_GEN_DIR}/qconicalgradient_wrapper.cpp
${QtGui_GEN_DIR}/qcontextmenuevent_wrapper.cpp
${QtGui_GEN_DIR}/qcursor_wrapper.cpp
@@ -49,6 +47,7 @@ ${QtGui_GEN_DIR}/qdragleaveevent_wrapper.cpp
${QtGui_GEN_DIR}/qdragmoveevent_wrapper.cpp
${QtGui_GEN_DIR}/qdropevent_wrapper.cpp
${QtGui_GEN_DIR}/qenterevent_wrapper.cpp
+${QtGui_GEN_DIR}/qeventpoint_wrapper.cpp
${QtGui_GEN_DIR}/qexposeevent_wrapper.cpp
${QtGui_GEN_DIR}/qfileopenevent_wrapper.cpp
${QtGui_GEN_DIR}/qfocusevent_wrapper.cpp
@@ -64,22 +63,23 @@ ${QtGui_GEN_DIR}/qhideevent_wrapper.cpp
${QtGui_GEN_DIR}/qhoverevent_wrapper.cpp
${QtGui_GEN_DIR}/qicon_wrapper.cpp
${QtGui_GEN_DIR}/qicondragevent_wrapper.cpp
-${QtGui_GEN_DIR}/qiconengine_availablesizesargument_wrapper.cpp
+${QtGui_GEN_DIR}/qiconengine_scaledpixmapargument_wrapper.cpp
${QtGui_GEN_DIR}/qiconengine_wrapper.cpp
${QtGui_GEN_DIR}/qimage_wrapper.cpp
${QtGui_GEN_DIR}/qimageiohandler_wrapper.cpp
${QtGui_GEN_DIR}/qimagereader_wrapper.cpp
${QtGui_GEN_DIR}/qimagewriter_wrapper.cpp
+${QtGui_GEN_DIR}/qinputdevice_wrapper.cpp
${QtGui_GEN_DIR}/qinputevent_wrapper.cpp
${QtGui_GEN_DIR}/qinputmethod_wrapper.cpp
${QtGui_GEN_DIR}/qinputmethodevent_attribute_wrapper.cpp
${QtGui_GEN_DIR}/qinputmethodevent_wrapper.cpp
${QtGui_GEN_DIR}/qinputmethodqueryevent_wrapper.cpp
${QtGui_GEN_DIR}/qintvalidator_wrapper.cpp
+${QtGui_GEN_DIR}/qkeycombination_wrapper.cpp
${QtGui_GEN_DIR}/qkeyevent_wrapper.cpp
${QtGui_GEN_DIR}/qkeysequence_wrapper.cpp
${QtGui_GEN_DIR}/qlineargradient_wrapper.cpp
-${QtGui_GEN_DIR}/qmatrix_wrapper.cpp
${QtGui_GEN_DIR}/qmatrix2x2_wrapper.cpp
${QtGui_GEN_DIR}/qmatrix2x3_wrapper.cpp
${QtGui_GEN_DIR}/qmatrix2x4_wrapper.cpp
@@ -95,21 +95,8 @@ ${QtGui_GEN_DIR}/qmovie_wrapper.cpp
${QtGui_GEN_DIR}/qnativegestureevent_wrapper.cpp
${QtGui_GEN_DIR}/qoffscreensurface_wrapper.cpp
${QtGui_GEN_DIR}/qopenglcontextgroup_wrapper.cpp
-${QtGui_GEN_DIR}/qopengldebuglogger_wrapper.cpp
-${QtGui_GEN_DIR}/qopengldebugmessage_wrapper.cpp
${QtGui_GEN_DIR}/qopenglextrafunctions_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglframebufferobjectformat_wrapper.cpp
${QtGui_GEN_DIR}/qopenglfunctions_wrapper.cpp
-# Compile error on Windows: ${QtGui_GEN_DIR}/qopenglpaintdevice_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglpixeltransferoptions_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglshaderprogram_wrapper.cpp
-${QtGui_GEN_DIR}/qopengltexture_wrapper.cpp
-${QtGui_GEN_DIR}/qopengltextureblitter_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglversionprofile_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglvertexarrayobject_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglvertexarrayobject_binder_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglwindow_wrapper.cpp
-${QtGui_GEN_DIR}/qpagedpaintdevice_margins_wrapper.cpp
${QtGui_GEN_DIR}/qpagedpaintdevice_wrapper.cpp
${QtGui_GEN_DIR}/qpagelayout_wrapper.cpp
${QtGui_GEN_DIR}/qpagesize_wrapper.cpp
@@ -127,35 +114,33 @@ ${QtGui_GEN_DIR}/qpalette_wrapper.cpp
${QtGui_GEN_DIR}/qpdfwriter_wrapper.cpp
${QtGui_GEN_DIR}/qpen_wrapper.cpp
${QtGui_GEN_DIR}/qpicture_wrapper.cpp
-${QtGui_GEN_DIR}/qpictureio_wrapper.cpp
${QtGui_GEN_DIR}/qpixmap_wrapper.cpp
${QtGui_GEN_DIR}/qpixmapcache_key_wrapper.cpp
${QtGui_GEN_DIR}/qpixmapcache_wrapper.cpp
${QtGui_GEN_DIR}/qpixelformat_wrapper.cpp
+${QtGui_GEN_DIR}/qpointerevent_wrapper.cpp
+${QtGui_GEN_DIR}/qpointingdevice_wrapper.cpp
${QtGui_GEN_DIR}/qpointingdeviceuniqueid_wrapper.cpp
${QtGui_GEN_DIR}/qpolygon_wrapper.cpp
${QtGui_GEN_DIR}/qpolygonf_wrapper.cpp
${QtGui_GEN_DIR}/qpytextobject_wrapper.cpp
${QtGui_GEN_DIR}/qquaternion_wrapper.cpp
${QtGui_GEN_DIR}/qradialgradient_wrapper.cpp
-${QtGui_GEN_DIR}/qregexpvalidator_wrapper.cpp
${QtGui_GEN_DIR}/qregularexpressionvalidator_wrapper.cpp
${QtGui_GEN_DIR}/qregion_wrapper.cpp
${QtGui_GEN_DIR}/qresizeevent_wrapper.cpp
${QtGui_GEN_DIR}/qsessionmanager_wrapper.cpp
${QtGui_GEN_DIR}/qshortcutevent_wrapper.cpp
${QtGui_GEN_DIR}/qshowevent_wrapper.cpp
+${QtGui_GEN_DIR}/qsinglepointevent_wrapper.cpp
${QtGui_GEN_DIR}/qstandarditem_wrapper.cpp
${QtGui_GEN_DIR}/qstandarditemmodel_wrapper.cpp
${QtGui_GEN_DIR}/qstatustipevent_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglbuffer_wrapper.cpp
${QtGui_GEN_DIR}/qopenglcontext_wrapper.cpp
${QtGui_GEN_DIR}/qaccessible_state_wrapper.cpp
${QtGui_GEN_DIR}/qaccessibleinterface_wrapper.cpp
${QtGui_GEN_DIR}/qscreen_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglshader_wrapper.cpp
-#${QtGui_GEN_DIR}/qopenglshaderprogram_wrapper.cpp
-${QtGui_GEN_DIR}/qopenglframebufferobject_wrapper.cpp
+${QtGui_GEN_DIR}/qshortcut_wrapper.cpp
${QtGui_GEN_DIR}/qrasterwindow_wrapper.cpp
${QtGui_GEN_DIR}/qrawfont_wrapper.cpp
${QtGui_GEN_DIR}/qscrollevent_wrapper.cpp
@@ -199,11 +184,12 @@ ${QtGui_GEN_DIR}/qtexttablecell_wrapper.cpp
${QtGui_GEN_DIR}/qtexttablecellformat_wrapper.cpp
${QtGui_GEN_DIR}/qtexttableformat_wrapper.cpp
${QtGui_GEN_DIR}/qtoolbarchangeevent_wrapper.cpp
-${QtGui_GEN_DIR}/qtouchdevice_wrapper.cpp
-${QtGui_GEN_DIR}/qtouchevent_touchpoint_wrapper.cpp
${QtGui_GEN_DIR}/qtouchevent_wrapper.cpp
${QtGui_GEN_DIR}/qtransform_wrapper.cpp
${QtGui_GEN_DIR}/qt_wrapper.cpp
+${QtGui_GEN_DIR}/qundocommand_wrapper.cpp
+${QtGui_GEN_DIR}/qundogroup_wrapper.cpp
+${QtGui_GEN_DIR}/qundostack_wrapper.cpp
${QtGui_GEN_DIR}/qvalidator_wrapper.cpp
${QtGui_GEN_DIR}/qvector2d_wrapper.cpp
${QtGui_GEN_DIR}/qvector3d_wrapper.cpp
@@ -216,26 +202,6 @@ ${QtGui_GEN_DIR}/qwindowstatechangeevent_wrapper.cpp
${QtGui_GEN_DIR}/qtgui_module_wrapper.cpp
)
-if (Qt${QT_MAJOR_VERSION}Gui_VERSION VERSION_EQUAL 5.14.0
- OR Qt${QT_MAJOR_VERSION}Gui_VERSION VERSION_GREATER 5.14.0)
- list(APPEND QtGui_SRC ${QtGui_GEN_DIR}/qcolorspace_wrapper.cpp)
- list(APPEND QtGui_SRC ${QtGui_GEN_DIR}/qcolorconstants_wrapper.cpp)
- list(APPEND QtGui_SRC ${QtGui_GEN_DIR}/qcolorconstants_svg_wrapper.cpp)
-endif()
-
-# cf qtbase/src/gui/opengl/opengl.pri
-list(FIND QtGui_enabled_features "opengles2" _opengles2Index)
-# ### fixme: For cmake >= 3.3: if(opengles2 IN_LIST QtGui_enabled_features)
-if(_opengles2Index GREATER -1)
- list(APPEND QtGui_DROPPED_ENTRIES QOpenGLTimeMonitor QOpenGLTimerQuery)
- message(STATUS "Qt${QT_MAJOR_VERSION}Gui: Dropping Desktop OpenGL classes (GLES2)")
-else()
- list(APPEND QtGui_SRC
- ${QtGui_GEN_DIR}/qopengltimemonitor_wrapper.cpp
- ${QtGui_GEN_DIR}/qopengltimerquery_wrapper.cpp)
- message(STATUS "Qt${QT_MAJOR_VERSION}Gui: Adding Desktop OpenGL classes")
-endif()
-
configure_file("${QtGui_SOURCE_DIR}/typesystem_gui.xml.in"
"${QtGui_BINARY_DIR}/typesystem_gui.xml" @ONLY)
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
index 04abbae5d..88c19360a 100644
--- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -113,83 +113,8 @@
besides the fact they are accessible by ordinary event methods.
-->
- <rejection class="^QAccessible.*Event$" field-name="^m_.*$"/>
-
- <rejection class="QEnterEvent" field-name="l"/>
- <rejection class="QEnterEvent" field-name="w"/>
- <rejection class="QEnterEvent" field-name="s"/>
-
- <rejection class="QInputEvent" field-name="modState"/>
- <rejection class="QInputEvent" field-name="modState"/>
-
- <rejection class="QMouseEvent" field-name="p"/>
- <rejection class="QMouseEvent" field-name="g"/>
- <rejection class="QMouseEvent" field-name="b"/>
- <rejection class="QMouseEvent" field-name="mouseState"/>
- <rejection class="QNativeGestureEvent" field-name="^m.*$"/>
-
- <rejection class="QHoverEvent" field-name="p"/>
- <rejection class="QHoverEvent" field-name="op"/>
-
- <rejection class="QWheelEvent" field-name="p"/>
- <rejection class="QWheelEvent" field-name="g"/>
- <rejection class="QWheelEvent" field-name="mouseState"/>
- <rejection class="QWheelEvent" field-name="o"/>
-
- <rejection class="QTabletEvent" field-name="mPos"/>
- <rejection class="QTabletEvent" field-name="mGPos"/>
- <rejection class="QTabletEvent" field-name="mHiResGlobalPos"/>
- <rejection class="QTabletEvent" field-name="mDev"/>
- <rejection class="QTabletEvent" field-name="mPointerType"/>
- <rejection class="QTabletEvent" field-name="mXT"/>
- <rejection class="QTabletEvent" field-name="mYT"/>
- <rejection class="QTabletEvent" field-name="mZ"/>
- <rejection class="QTabletEvent" field-name="mPress"/>
- <rejection class="QTabletEvent" field-name="mTangential"/>
- <rejection class="QTabletEvent" field-name="mRot"/>
- <rejection class="QTabletEvent" field-name="mUnique"/>
- <rejection class="QTabletEvent" field-name="mExtra"/>
-
- <rejection class="QKeyEvent" field-name="txt"/>
- <rejection class="QKeyEvent" field-name="k"/>
- <rejection class="QKeyEvent" field-name="c"/>
- <rejection class="QKeyEvent" field-name="auto"/>
-
- <rejection class="QPaintEvent" field-name="m_rect"/>
- <rejection class="QPaintEvent" field-name="m_region"/>
- <rejection class="QPaintEvent" field-name="m_erased"/>
-
- <rejection class="QMoveEvent" field-name="p"/>
- <rejection class="QMoveEvent" field-name="oldp"/>
-
- <rejection class="QResizeEvent" field-name="s"/>
- <rejection class="QResizeEvent" field-name="olds"/>
-
- <rejection class="QContextMenuEvent" field-name="p"/>
- <rejection class="QContextMenuEvent" field-name="gp"/>
- <rejection class="QContextMenuEvent" field-name="reas"/>
-
- <rejection class="QDropEvent" field-name="p"/>
- <rejection class="QDropEvent" field-name="mouseState"/>
- <rejection class="QDropEvent" field-name="modState"/>
- <rejection class="QDropEvent" field-name="act"/>
- <rejection class="QDropEvent" field-name="drop_action"/>
- <rejection class="QDropEvent" field-name="default_action"/>
- <rejection class="QDropEvent" field-name="mdata"/>
- <rejection class="QDropEvent" field-name="fmts"/>
-
- <rejection class="QDragMoveEvent" field-name="rect"/>
-
- <rejection class="QShortcutEvent" field-name="sequence"/>
- <rejection class="QShortcutEvent" field-name="ambig"/>
- <rejection class="QShortcutEvent" field-name="sid"/>
-
- <rejection class="QTouchEvent" field-name="_device"/>
- <rejection class="QTouchEvent" field-name="_widget"/>
- <rejection class="QTouchEvent" field-name="_window"/>
- <rejection class="QTouchEvent" field-name="_deviceType"/>
- <rejection class="QTouchEvent" field-name="_touchPointStates"/>
- <rejection class="QTouchEvent" field-name="_touchPoints"/>
+ <rejection class="^Q.*Event$" field-name="^m_.*$"/>
+ <rejection class="QEventPoint" field-name="^m_.*$"/>
<rejection class="QAbstractTextDocumentLayout::PaintContext" field-name="selections"/>
<rejection class="QBrush" function-name="cleanUp"/>
@@ -218,6 +143,11 @@
</conversion-rule>
</primitive-type>
+ <object-type name="QAbstractFileIconProvider" since="6.0">
+ <enum-type name="IconType"/>
+ <enum-type name="Option" flags="Options"/>
+ </object-type>
+
<value-type name="QAccessible">
<value-type name="State"/>
<enum-type name="Event"/>
@@ -247,6 +177,40 @@
<object-type name="QAccessibleTextUpdateEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QAccessible::TextUpdated"/>
<object-type name="QAccessibleValueChangeEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QAccessible::ValueChanged"/>
+ <object-type name="QAction">
+ <enum-type name="ActionEvent"/>
+ <enum-type name="MenuRole"/>
+ <enum-type name="Priority" since="4.6"/>
+ <modify-function signature="setMenu(QMenu*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="triggered(bool)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QActionGroup">
+ <enum-type name="ExclusionPolicy" since="5.14"/>
+ <modify-function signature="addAction(QAction*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeAction(QAction*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QShortcut">
+ <add-function signature="QShortcut(QKeySequence&amp;,QObject*,PyCallable*,Qt::ShortcutContext)">
+ <modify-argument index="4">
+ <replace-default-expression with="Qt::WindowShortcut"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning" file="../glue/qtwidgets.cpp" snippet="qshortcut-1"/>
+ <inject-code class="target" position="end" file="../glue/qtwidgets.cpp" snippet="qshortcut-2"/>
+ </add-function>
+ </object-type>
+
<value-type name="QTransform">
<enum-type name="TransformationType"/>
<add-function signature="__repr__" return-type="PyObject*">
@@ -372,6 +336,7 @@
<object-type name="QInputMethod">
<enum-type name="Action"/>
</object-type>
+ <value-type name="QKeyCombination"/>
<value-type name="QKeySequence">
<enum-type name="SequenceFormat"/>
<enum-type name="SequenceMatch"/>
@@ -379,11 +344,7 @@
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- <insert-template name="repr_code">
- <replace from="%REPR_FORMAT" to="%i, %i, %i, %i"/>
- <replace from="%REPR_ARGS"
- to="(*%CPPSELF)[0], (*%CPPSELF)[1], (*%CPPSELF)[2], (*%CPPSELF)[3]"/>
- </insert-template>
+ <insert-template name="qkeysequence_repr"/>
</inject-code>
</add-function>
@@ -405,10 +366,10 @@
<modify-function signature="operator QVariant()const" remove="all"/>
</value-type>
<value-type name="QPicture" >
- <modify-function signature="load(QIODevice*,const char*)" allow-thread="yes"/>
- <modify-function signature="load(const QString&amp;,const char*)" allow-thread="yes"/>
- <modify-function signature="save(QIODevice*,const char*)" allow-thread="yes"/>
- <modify-function signature="save(const QString&amp;,const char*)" allow-thread="yes"/>
+ <modify-function signature="load(QIODevice*)" allow-thread="yes"/>
+ <modify-function signature="load(const QString&amp;)" allow-thread="yes"/>
+ <modify-function signature="save(QIODevice*)" allow-thread="yes"/>
+ <modify-function signature="save(const QString&amp;)" allow-thread="yes"/>
<!-- See bug 759 -->
<modify-function signature="data()const">
<modify-argument index="return">
@@ -501,9 +462,12 @@
</value-type>
<value-type name="QPolygon">
<extra-includes>
- <include file-name="QMatrix" location="global"/>
<include file-name="QTransform" location="global"/>
</extra-includes>
+ <!-- Expose operator==, != inherited from QList, which the parser does
+ not see due to the TMP expression of the return type. -->
+ <add-function signature="operator==(const QPolygon&amp;)" return-type="bool"/>
+ <add-function signature="operator!=(const QPolygon&amp;)" return-type="bool"/>
<add-function signature="__reduce__" return-type="PyObject*">
<inject-code class="target" position="beginning" file="../glue/qtgui.cpp" snippet="qpolygon-reduce">
<insert-template name="reduce_code">
@@ -527,7 +491,6 @@
</value-type>
<value-type name="QPolygonF">
<extra-includes>
- <include file-name="QMatrix" location="global"/>
<include file-name="QTransform" location="global"/>
</extra-includes>
<!-- ### A QVector parameter, for no defined type, will generate wrong code. -->
@@ -655,70 +618,6 @@
</modify-function>
</value-type>
- <!-- Qt5: this _should_ be obsolete, but QImage is still using it... -->
- <value-type name="QMatrix">
- <extra-includes>
- <include file-name="QPainterPath" location="global"/>
- </extra-includes>
- <add-function signature="__repr__" return-type="PyObject*">
- <inject-code class="target" position="beginning">
- <insert-template name="repr_code">
- <replace from="%REPR_FORMAT" to="%f, %f, %f, %f, %f, %f"/>
- <replace from="%REPR_ARGS"
- to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.dx(), %CPPSELF.dy()"/>
- </insert-template>
- </inject-code>
- </add-function>
-
- <add-function signature="__reduce__" return-type="PyObject*">
- <inject-code class="target" position="beginning">
- <insert-template name="reduce_code">
- <replace from="%REDUCE_FORMAT" to="dddddd"/>
- <replace from="%REDUCE_ARGS" to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.dx(), %CPPSELF.dy()"/>
- </insert-template>
- </inject-code>
- </add-function>
- <modify-function signature="map(int,int,int*,int*)const">
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <modify-argument index="4">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="qmatrix_map"/>
- </inject-code>
- </modify-function>
- <modify-function signature="map(qreal,qreal,qreal*,qreal*)const">
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <modify-argument index="4">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="qmatrix_map"/>
- </inject-code>
- </modify-function>
- <modify-function signature="map(const QPoint&amp;)const">
- <modify-argument index="return">
- <replace-type modified-type="QPoint"/>
- </modify-argument>
- <inject-code file="../glue/qtgui.cpp" snippet="qmatrix-map-point" />
- </modify-function>
- <modify-function signature="inverted(bool*)const">
- <modify-argument index="1">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PyTuple"/>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_bool*"/>
- </inject-code>
- </modify-function>
- </value-type>
-
<value-type name="QConicalGradient" polymorphic-id-expression="%1-&gt;type() == QGradient::ConicalGradient"/>
<value-type name="QFontInfo"/>
<value-type name="QRadialGradient" polymorphic-id-expression="%1-&gt;type() == QGradient::RadialGradient"/>
@@ -756,7 +655,6 @@
<enum-type name="InvertMode"/>
<extra-includes>
<include file-name="QStringList" location="global"/>
- <include file-name="QMatrix" location="global"/>
</extra-includes>
<modify-function signature="load(const QString&amp;, const char*)" allow-thread="yes"/>
@@ -764,7 +662,7 @@
<modify-function signature="save(const QString&amp;,const char*,int)const" allow-thread="yes"/>
<modify-function signature="save(QIODevice*,const char*,int)const" allow-thread="yes"/>
- <modify-function signature="QImage(uchar*,int,int,int,QImage::Format,QImageCleanupFunction,void*)">
+ <modify-function signature="QImage(uchar*,int,int,qsizetype,QImage::Format,QImageCleanupFunction,void*)">
<modify-argument index="1">
<replace-type modified-type="PyBuffer"/>
</modify-argument>
@@ -801,7 +699,7 @@
</add-function>
<!-- The non-const versions are already used -->
- <modify-function signature="QImage(const uchar*,int,int,int,QImage::Format,QImageCleanupFunction,void*)" remove="all"/>
+ <modify-function signature="QImage(const uchar*,int,int,qsizetype,QImage::Format,QImageCleanupFunction,void*)" remove="all"/>
<modify-function signature="QImage(const uchar*,int,int,QImage::Format,QImageCleanupFunction,void*)" remove="all"/>
<!-- ### -->
@@ -909,7 +807,7 @@
<inject-code class="target" position="beginning" file="../glue/qtgui.cpp" snippet="qcolor"/>
</add-function>
<!-- get* methods. Inject code -->
- <modify-function signature="getCmyk(int*,int*,int*,int*,int*)">
+ <modify-function signature="getCmyk(int*,int*,int*,int*,int*)const">
<modify-argument index="0">
<replace-type modified-type="PyObject*"/>
</modify-argument>
@@ -936,7 +834,7 @@
</insert-template>
</inject-code>
</modify-function>
- <modify-function signature="getCmykF(qreal*,qreal*,qreal*,qreal*,qreal*)">
+ <modify-function signature="getCmykF(float*,float*,float*,float*,float*)const">
<modify-argument index="0">
<replace-type modified-type="PyObject*"/>
</modify-argument>
@@ -959,7 +857,7 @@
<inject-code class="target" position="beginning">
<insert-template name="fix_number*,number*,number*,number*,number*">
- <replace from="$TYPE" to="qreal"/>
+ <replace from="$TYPE" to="float"/>
</insert-template>
</inject-code>
</modify-function>
@@ -986,7 +884,7 @@
</insert-template>
</inject-code>
</modify-function>
- <modify-function signature="getHslF(qreal*,qreal*,qreal*,qreal*)const" since="4.6">
+ <modify-function signature="getHslF(float*,float*,float*,float*)const" since="4.6">
<modify-argument index="0">
<replace-type modified-type="PyObject*"/>
</modify-argument>
@@ -1005,7 +903,7 @@
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="fix_number*,number*,number*,number*">
- <replace from="$TYPE" to="qreal"/>
+ <replace from="$TYPE" to="float"/>
</insert-template>
</inject-code>
</modify-function>
@@ -1032,7 +930,7 @@
</insert-template>
</inject-code>
</modify-function>
- <modify-function signature="getHsvF(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-function signature="getHsvF(float*,float*,float*,float*)const">
<modify-argument index="0">
<replace-type modified-type="PyObject*"/>
</modify-argument>
@@ -1051,7 +949,7 @@
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="fix_number*,number*,number*,number*">
- <replace from="$TYPE" to="qreal"/>
+ <replace from="$TYPE" to="float"/>
</insert-template>
</inject-code>
</modify-function>
@@ -1078,7 +976,7 @@
</insert-template>
</inject-code>
</modify-function>
- <modify-function signature="getRgbF(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-function signature="getRgbF(float*,float*,float*,float*)const">
<modify-argument index="0">
<replace-type modified-type="PyObject*"/>
</modify-argument>
@@ -1097,7 +995,7 @@
</modify-argument>
<inject-code class="target" position="beginning">
<insert-template name="fix_number*,number*,number*,number*">
- <replace from="$TYPE" to="qreal"/>
+ <replace from="$TYPE" to="float"/>
</insert-template>
</inject-code>
</modify-function>
@@ -1131,7 +1029,7 @@
</inject-code>
</modify-function>
- <modify-function signature="width(QChar)const" rename="widthChar">
+ <modify-function signature="horizontalAdvance(QChar)const" rename="horizontalAdvanceChar">
<modify-argument index="1">
<replace-type modified-type="char"/>
</modify-argument>
@@ -1167,7 +1065,7 @@
</inject-code>
</modify-function>
- <modify-function signature="width(QChar)const" rename="widthChar">
+ <modify-function signature="horizontalAdvance(QChar)const" rename="horizontalAdvanceChar">
<modify-argument index="1">
<replace-type modified-type="char"/>
</modify-argument>
@@ -1212,7 +1110,6 @@
<enum-type name="PaintDeviceMetric"/>
</object-type>
<object-type name="QPagedPaintDevice">
- <value-type name="Margins"/>
<enum-type name="PageSize"/>
<enum-type name="PdfVersion" since="5.10"/>
</object-type>
@@ -1243,7 +1140,7 @@
<enum-type name="Notation"/>
</object-type>
<object-type name="QIconEngine">
- <object-type name="AvailableSizesArgument"/>
+ <object-type name="ScaledPixmapArgument"/>
<enum-type name="IconEngineHook"/>
<modify-function signature="paint(QPainter*,QRect,QIcon::Mode,QIcon::State)">
<modify-argument index="1" invalidate-after-use="yes"/>
@@ -1269,23 +1166,16 @@
<object-type name="QIntValidator"/>
<object-type name="QPainterPathStroker" copyable="false"/>
- <object-type name="QPictureIO">
- <modify-function signature="setIODevice(QIODevice*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="read()" allow-thread="yes"/>
- <modify-function signature="write()" allow-thread="yes"/>
- </object-type>
<object-type name="QPixmapCache">
<value-type name="Key"/>
<add-function signature="find(QPixmapCache::Key&amp;)">
<inject-code file="../glue/qtgui.cpp" snippet="qpixmapcache-find"/>
</add-function>
+ <add-function signature="find(const QString&amp;)">
+ <inject-code file="../glue/qtgui.cpp" snippet="qpixmapcache-find"/>
+ </add-function>
</object-type>
- <object-type name="QRegExpValidator"/>
<object-type name="QRegularExpressionValidator"/>
<object-type name="QStandardItem">
@@ -1388,10 +1278,7 @@
<object-type name="QTextItem">
<enum-type name="RenderFlag" flags="RenderFlags"/>
</object-type>
- <object-type name="QTextList" >
- <!--### Obsolete in 4.3-->
- <modify-function signature="isEmpty()const" remove="all"/>
- </object-type>
+ <object-type name="QTextList"/>
<object-type name="QTextObject"/>
<object-type name="QTextObjectInterface" >
<modify-function signature="drawObject(QPainter*,QRectF,QTextDocument*,int,QTextFormat)">
@@ -1429,6 +1316,9 @@
<enum-type name="Reason"/>
</object-type>
+ <value-type name="QEventPoint" since="6.0">
+ <enum-type name="State"/>
+ </value-type>
<object-type name="QDragEnterEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::DragEnter"/>
<object-type name="QDragLeaveEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::DragLeave"/>
<object-type name="QDragMoveEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::DragMove"/>
@@ -1464,11 +1354,9 @@
<object-type name="QShortcutEvent" copyable = "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Shortcut">
</object-type>
<object-type name="QShowEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Show"/>
+ <object-type name="QSinglePointEvent" copyable="false" since="6.0"/>
<object-type name="QStatusTipEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::StatusTip"/>
- <object-type name="QTabletEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::TabletMove || %1-&gt;type() == QEvent::TabletPress || %1-&gt;type() == QEvent::TabletRelease">
- <enum-type name="PointerType"/>
- <enum-type name="TabletDevice"/>
- </object-type>
+ <object-type name="QTabletEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::TabletMove || %1-&gt;type() == QEvent::TabletPress || %1-&gt;type() == QEvent::TabletRelease"/>
<object-type name="QToolBarChangeEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::ToolBarChange"/>
<object-type name="QWhatsThisClickedEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::WhatsThisClicked"/>
<object-type name="QWheelEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Wheel"/>
@@ -1487,6 +1375,7 @@
<object-type name="QScrollEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::Scroll">
<enum-type name="ScrollState"/>
</object-type>
+ <object-type name="QPointerEvent" copyable= "false" since="6.0"/>
<object-type name="QScrollPrepareEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::ScrollPrepare"/>
<object-type name="QTextFrame" >
@@ -1907,14 +1796,6 @@
<insert-template name="qpainter_drawlist"/>
</inject-code>
</add-function>
- <modify-function signature="drawRoundRect(int,int,int,int,int,int)">
- <modify-argument index="5">
- <rename to="xRound"/>
- </modify-argument>
- <modify-argument index="6">
- <rename to="yRound"/>
- </modify-argument>
- </modify-function>
<modify-function signature="drawTiledPixmap(const QRect&amp;,const QPixmap&amp;,const QPoint&amp;)">
<modify-argument index="3">
<rename to="pos"/>
@@ -1930,16 +1811,6 @@
<no-null-pointer/>
</modify-argument>
</modify-function>
- <modify-function signature="setRedirected(const QPaintDevice*,QPaintDevice*,const QPoint&amp;)">
- <modify-argument index="1">
- <no-null-pointer/>
- </modify-argument>
- </modify-function>
- <modify-function signature="restoreRedirected(const QPaintDevice*)">
- <modify-argument index="1">
- <no-null-pointer/>
- </modify-argument>
- </modify-function>
<modify-function signature="drawText(QRectF,int,QString,QRectF*)">
<modify-argument index="4">
<remove-argument/>
@@ -2273,6 +2144,7 @@
</value-type>
<value-type name="QMatrix4x4" since="4.6">
+ <enum-type name="Flag" flags="Flags" since="6.0"/>
<!-- Qt5: HAIRY TRICK ALERT ahead!
Qt5 partially replaced 'qreal' by float.
@@ -2390,15 +2262,11 @@
<modify-function signature="getEulerAngles(float*,float*,float*)const" since="5.5" remove="all"/>
</value-type>
- <object-type name="QTouchEvent" since="4.6">
- <value-type name="TouchPoint" since="4.6">
- <enum-type name="InfoFlag" flags="InfoFlags"/>
- </value-type>
- </object-type>
+ <object-type name="QTouchEvent" since="4.6"/>
- <object-type name="QTouchDevice">
- <enum-type name="CapabilityFlag" flags="Capabilities"/>
- <enum-type name="DeviceType"/>
+ <object-type name="QInputDevice">
+ <enum-type name="Capability" flags="Capabilities"/>
+ <enum-type name="DeviceType" flags="DeviceTypes"/>
</object-type>
<value-type name="QVector2D" since="4.6">
@@ -2542,7 +2410,7 @@
<enum-type name="Visibility"/>
<modify-function signature="raise()" rename="raise_"/>
<!-- see QWidget::nativeEvent(), QAbstractNativeEventFilter::nativeEventFilter() -->
- <modify-function signature="nativeEvent(const QByteArray &amp;,void*,long*)">
+ <modify-function signature="nativeEvent(const QByteArray &amp;,void*,qintptr*)">
<modify-argument index="3">
<remove-argument/>
<conversion-rule class="native">
@@ -2593,29 +2461,10 @@
</object-type>
- <object-type name="QOpenGLBuffer" since="5.0">
- <enum-type name="Access"/>
- <enum-type name="RangeAccessFlag" flags="RangeAccessFlags"/>
- <enum-type name="Type"/>
- <enum-type name="UsagePattern"/>
- </object-type>
<object-type name="QOpenGLContext">
<enum-type name="OpenGLModuleType"/>
</object-type>
<object-type name="QOpenGLContextGroup" since="5.0"/>
- <object-type name="QOpenGLDebugLogger" since="5.1">
- <enum-type name="LoggingMode"/>
- </object-type>
- <value-type name="QOpenGLDebugMessage" since="5.1">
- <enum-type name="Source" flags="Sources"/>
- <enum-type name="Type" flags="Types"/>
- <enum-type name="Severity" flags="Severities"/>
- </value-type>
- <object-type name="QOpenGLFramebufferObject" since="5.0">
- <enum-type name="Attachment"/>
- <enum-type name="FramebufferRestorePolicy" since="5.7"/>
- </object-type>
- <value-type name="QOpenGLFramebufferObjectFormat"/>
<!-- Compile error on Windows: QOpenGLPaintDevice::QOpenGLPaintDevice(const QOpenGLPaintDevice &)': attempting to reference a deleted function
<object-type name="QOpenGLPaintDevice" since="5.0"/>
-->
@@ -2902,7 +2751,6 @@
<modify-argument index="2"><array/></modify-argument>
</modify-function>
</object-type>
- <object-type name="QAbstractOpenGLFunctions" since="5.1"/>
<!-- Classes are result of a macro expansion in src/gui/opengl/qopenglversionfunctions.h
<object-type name="QOpenGLFunctions_1_0" since="5.1"/>
<object-type name="QOpenGLFunctions_1_1" since="5.1"/>
@@ -2932,98 +2780,6 @@
<object-type name="QOpenGLFunctions_4_5_Core" since="5.5"/>
<object-type name="QOpenGLFunctions_ES2" since="5.1"/>
-->
- <value-type name="QOpenGLPixelTransferOptions"/>
- <object-type name="QOpenGLShader" since="5.0">
- <enum-type name="ShaderTypeBit" flags="ShaderType"/>
- </object-type>
- <object-type name="QOpenGLShaderProgram" since="5.0">
- <modify-function signature="setAttributeArray(int,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setAttributeArray(const char*,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setAttributeArray(int,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setAttributeValue(int,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setAttributeValue(const char*,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(int,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(int,const int*,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(int,const unsigned int*,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(const char*,const float*,int,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(const char*,const int*,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <modify-function signature="setUniformValueArray(const char*,const unsigned int*,int)">
- <modify-argument index="2"><array/></modify-argument>
- </modify-function>
- <!-- Add explicit signatures for the setUniformValue functions -->
- <modify-function signature="^setUniformValue\(const char\*,(float|int|uint)\)$" remove="all"/>
- <!-- No need for a signature for GLuint, since Qt (internally) calls the same function: glUniform1i -->
- <add-function signature="setUniformValue1f(const char*, float)" return-type="void">
- <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
- </add-function>
- <add-function signature="setUniformValue1i(const char*, int)" return-type="void">
- <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
- </add-function>
- <add-function signature="setUniformValue1f(int, float)" return-type="void">
- <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
- </add-function>
- <add-function signature="setUniformValue1i(int, int)" return-type="void">
- <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
- </add-function>
- </object-type>
- <object-type name="QOpenGLTexture" since="5.2">
- <enum-type name="BindingTarget"/>
- <enum-type name="CoordinateDirection"/>
- <enum-type name="ComparisonFunction"/>
- <enum-type name="ComparisonMode"/>
- <enum-type name="CubeMapFace"/>
- <enum-type name="DepthStencilMode"/>
- <enum-type name="Feature" flags="Features"/>
- <enum-type name="Filter"/>
- <enum-type name="MipMapGeneration"/>
- <enum-type name="PixelFormat"/>
- <enum-type name="PixelType"/>
- <enum-type name="SwizzleComponent"/>
- <enum-type name="SwizzleValue"/>
- <enum-type name="Target"/>
- <enum-type name="TextureFormat"/>
- <enum-type name="TextureFormatClass"/>
- <enum-type name="TextureUnitReset"/>
- <enum-type name="WrapMode"/>
- <modify-function signature="borderColor(unsigned int*)const" remove="all"/>
- <modify-function signature="borderColor(int*)const" remove="all"/>
- <modify-function signature="borderColor(float*)const" remove="all"/>
- <!-- Work around link error introduced by qtbase/d15b02ff291e3124d9bb8ac3b06b704c292f52ab, can be removed once
- qtbase/1bfabe35d8178c93e66acef21c01e08980f9ed0d has landed -->
- <modify-function signature="setData(int,int,int,int,int,int,int,QOpenGLTexture::PixelFormat,QOpenGLTexture::PixelType,const void*,QOpenGLPixelTransferOptions*const)" remove="all"/>
- </object-type>
- <object-type name="QOpenGLTextureBlitter">
- <enum-type name="Origin"/>
- </object-type>
- <object-type name="QOpenGLTimeMonitor" since="5.1"/>
- <object-type name="QOpenGLTimerQuery" since="5.1"/>
- <object-type name="QOpenGLWindow" since="5.4">
- <enum-type name="UpdateBehavior"/>
- </object-type>
- <value-type name="QOpenGLVersionProfile" since="5.1"/>
- <object-type name="QOpenGLVertexArrayObject">
- <object-type name="Binder"/>
- </object-type>
<value-type name="QPageLayout">
<enum-type name="Mode"/>
<enum-type name="Orientation"/>
@@ -3045,6 +2801,10 @@
<enum-type name="YUVLayout"/>
</value-type>
<object-type name="QPdfWriter"/>
+ <object-type name="QPointingDevice" since="6.0">
+ <enum-type name="PointerType" flags="PointerTypes"/>
+ <enum-type name="GrabTransition"/>
+ </object-type>
<value-type name="QPointingDeviceUniqueId"/>
<value-type name="QRawFont">
<enum-type name="AntialiasingType"/>
@@ -3066,4 +2826,38 @@
</object-type>
<object-type name="QStyleHints"/>
+ <object-type name="QUndoCommand">
+ <modify-function signature="mergeWith(const QUndoCommand*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QUndoGroup">
+ <modify-function signature="addStack(QUndoStack*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeStack(QUndoStack*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QUndoStack">
+ <modify-function signature="createUndoAction(QObject*,const QString&amp;)const">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="createRedoAction(QObject*,const QString&amp;)const">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="push(QUndoCommand*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt b/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt
index 9557c4a26..0f56db57c 100644
--- a/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt
@@ -23,8 +23,6 @@ ${QtNetwork_GEN_DIR}/qlocalsocket_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkaccessmanager_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkaddressentry_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkcachemetadata_wrapper.cpp
-${QtNetwork_GEN_DIR}/qnetworkconfiguration_wrapper.cpp
-${QtNetwork_GEN_DIR}/qnetworkconfigurationmanager_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkcookie_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkcookiejar_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkdatagram_wrapper.cpp
@@ -35,7 +33,6 @@ ${QtNetwork_GEN_DIR}/qnetworkproxyfactory_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkproxyquery_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkreply_wrapper.cpp
${QtNetwork_GEN_DIR}/qnetworkrequest_wrapper.cpp
-${QtNetwork_GEN_DIR}/qnetworksession_wrapper.cpp
${QtNetwork_GEN_DIR}/qpassworddigestor_wrapper.cpp
${QtNetwork_GEN_DIR}/qssl_wrapper.cpp
${QtNetwork_GEN_DIR}/qsslcertificate_wrapper.cpp
@@ -47,17 +44,10 @@ ${QtNetwork_GEN_DIR}/qudpsocket_wrapper.cpp
${QtNetwork_GEN_DIR}/qtnetwork_module_wrapper.cpp
)
-get_property(QtNetwork_enabled_features TARGET Qt${QT_MAJOR_VERSION}::Network
- PROPERTY QT_ENABLED_PUBLIC_FEATURES)
get_property(QtNetwork_disabled_features TARGET Qt${QT_MAJOR_VERSION}::Network
PROPERTY QT_DISABLED_PUBLIC_FEATURES)
-# ### fixme: For cmake >= 3.3, use if( needle IN_LIST list)
-list(FIND QtNetwork_enabled_features "ssl" _sslEnabledIndex)
-list(FIND QtNetwork_disabled_features "dtls" _dtlsDisabledIndex)
-list(FIND QtNetwork_disabled_features "sctp" _sctpDisabledIndex)
-
-if(_sslEnabledIndex EQUAL -1)
+if("ssl" IN_LIST QtNetwork_disabled_features)
list(APPEND QtNetwork_DROPPED_ENTRIES QOcspResponse QSslCipher
QSslConfiguration QSslDiffieHellmanParameters QSslError
QSslKey QSslPreSharedKeyAuthenticator QSslSocket)
@@ -72,16 +62,12 @@ else()
${QtNetwork_GEN_DIR}/qsslerror_wrapper.cpp
${QtNetwork_GEN_DIR}/qsslkey_wrapper.cpp
${QtNetwork_GEN_DIR}/qsslpresharedkeyauthenticator_wrapper.cpp
- ${QtNetwork_GEN_DIR}/qsslsocket_wrapper.cpp)
- if (Qt${QT_MAJOR_VERSION}Network_VERSION VERSION_EQUAL 5.13.0
- OR Qt${QT_MAJOR_VERSION}Network_VERSION VERSION_GREATER 5.13.0)
- list(APPEND QtNetwork_SRC
- ${QtNetwork_GEN_DIR}/qocspresponse_wrapper.cpp)
- endif()
+ ${QtNetwork_GEN_DIR}/qsslsocket_wrapper.cpp
+ ${QtNetwork_GEN_DIR}/qocspresponse_wrapper.cpp)
message(STATUS "Qt${QT_MAJOR_VERSION}Network: Adding SSL classes")
endif()
-if(_dtlsDisabledIndex GREATER -1)
+if("dtls" IN_LIST QtNetwork_disabled_features)
list(APPEND QtNetwork_DROPPED_ENTRIES QDtls)
message(STATUS "Qt${QT_MAJOR_VERSION}Network: Dropping DTLS classes")
else()
@@ -90,7 +76,7 @@ else()
message(STATUS "Qt${QT_MAJOR_VERSION}Network: Adding DTLS classes")
endif()
-if(_sctpDisabledIndex GREATER -1)
+if("sctp" IN_LIST QtNetwork_disabled_features)
list(APPEND QtNetwork_DROPPED_ENTRIES QSctpServer QSctpSocket)
message(STATUS "Qt${QT_MAJOR_VERSION}Network: Dropping SCTP classes")
else()
diff --git a/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml b/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml
index dc60a509d..fab2d01bb 100644
--- a/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml
+++ b/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml
@@ -42,6 +42,8 @@
<typesystem package="PySide2.QtNetwork">
<load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
+ <rejection class="dtlsopenssl"/>
+
<enum-type name="QDtlsError" since="5.12"/>
<enum-type name="QOcspCertificateStatus" since="5.13"/>
<enum-type name="QOcspRevocationReason" since="5.13"/>
@@ -53,6 +55,8 @@
</namespace-type>
<namespace-type name="QSsl">
+ <enum-type name="AlertLevel" since="6.0"/>
+ <enum-type name="AlertType" since="6.0"/>
<enum-type name="AlternativeNameEntryType"/>
<enum-type name="EncodingFormat"/>
<enum-type name="KeyAlgorithm"/>
@@ -75,8 +79,8 @@
<enum-type name="SocketOption" since="4.6"/>
<enum-type name="SocketState"/>
<enum-type name="SocketType"/>
- <modify-function signature="connectToHost(const QString&amp;,quint16,QFlags&lt;QIODevice::OpenModeFlag>,QAbstractSocket::NetworkLayerProtocol)" allow-thread="yes"/>
- <modify-function signature="connectToHost(const QHostAddress&amp;,quint16,QFlags&lt;QIODevice::OpenModeFlag>)" allow-thread="yes"/>
+ <modify-function signature="connectToHost(const QString&amp;,quint16,QFlags&lt;QIODeviceBase::OpenModeFlag>,QAbstractSocket::NetworkLayerProtocol)" allow-thread="yes"/>
+ <modify-function signature="connectToHost(const QHostAddress&amp;,quint16,QFlags&lt;QIODeviceBase::OpenModeFlag>)" allow-thread="yes"/>
<modify-function signature="disconnectFromHost()" allow-thread="yes"/>
<modify-function signature="waitForConnected(int)" allow-thread="yes"/>
<modify-function signature="waitForDisconnected(int)" allow-thread="yes"/>
@@ -172,7 +176,6 @@
<enum-type name="LocalSocketState"/>
</object-type>
<object-type name="QNetworkAccessManager">
- <enum-type name="NetworkAccessibility" since="4.7"/>
<enum-type name="Operation"/>
<modify-function signature="createRequest(QNetworkAccessManager::Operation,const QNetworkRequest&amp;,QIODevice*)">
<modify-argument index="3" invalidate-after-use="yes"/>
@@ -202,10 +205,8 @@
<enum-type name="ConversionModeFlag" flags="ConversionMode" since="5.8"/>
<enum-type name="SpecialAddress"/>
<!-- ### QHostAddress(QIPv6Address) does this -->
- <modify-function signature="QHostAddress(quint8*)" remove="all"/>
<modify-function signature="QHostAddress(const quint8*)" remove="all"/>
<!-- ### -->
- <modify-function signature="setAddress(quint8*)" remove="all"/>
<modify-function signature="setAddress(const quint8*)" remove="all"/>
</value-type>
@@ -262,21 +263,6 @@
<enum-type name="TransferTimeoutConstant" since="5.15"/>
</value-type>
- <value-type name="QNetworkConfiguration" since="4.7">
- <enum-type name="BearerType"/>
- <enum-type name="Purpose" since="4.7"/>
- <enum-type name="StateFlag" flags="StateFlags" since="4.7"/>
- <enum-type name="Type" since="4.7"/>
- </value-type>
- <object-type name="QNetworkConfigurationManager" since="4.7">
- <enum-type name="Capability" flags="Capabilities" since="4.7"/>
- </object-type>
- <object-type name="QNetworkSession" since="4.7">
- <enum-type name="SessionError" since="4.7"/>
- <enum-type name="State" since="4.7"/>
- <enum-type name="UsagePolicy" flags="UsagePolicies"/>
- </object-type>
-
<object-type name="QAbstractNetworkCache"/>
<object-type name="QNetworkDiskCache"/>
<value-type name="QNetworkCacheMetaData"/>
@@ -314,7 +300,7 @@
<object-type name="QSslSocket">
<enum-type name="SslMode"/>
<enum-type name="PeerVerifyMode"/>
- <modify-function signature="connectToHostEncrypted(const QString&amp;,quint16,QFlags&lt;QIODevice::OpenModeFlag>,QAbstractSocket::NetworkLayerProtocol)" allow-thread="yes"/>
+ <modify-function signature="connectToHostEncrypted(const QString&amp;,quint16,QFlags&lt;QIODeviceBase::OpenModeFlag>,QAbstractSocket::NetworkLayerProtocol)" allow-thread="yes"/>
<modify-function signature="waitForEncrypted(int)" allow-thread="yes"/>
</object-type>
diff --git a/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt b/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt
index 1d2c406fc..79df5af4a 100644
--- a/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt
@@ -1,42 +1,59 @@
project(QtOpenGL)
+set(QtOpenGL_DROPPED_ENTRIES)
+
set(QtOpenGL_SRC
-${QtOpenGL_GEN_DIR}/qgl_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglbuffer_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglcolormap_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglcontext_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglformat_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglframebufferobject_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglframebufferobjectformat_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglpixelbuffer_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglshader_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglshaderprogram_wrapper.cpp
-${QtOpenGL_GEN_DIR}/qglwidget_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qabstractopenglfunctions_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopengldebuglogger_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopengldebugmessage_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglframebufferobjectformat_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglpixeltransferoptions_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglshaderprogram_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopengltexture_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopengltextureblitter_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglversionprofile_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglvertexarrayobject_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglvertexarrayobject_binder_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglwindow_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglbuffer_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglshader_wrapper.cpp
+${QtOpenGL_GEN_DIR}/qopenglframebufferobject_wrapper.cpp
# module is always needed
${QtOpenGL_GEN_DIR}/qtopengl_module_wrapper.cpp
)
+get_property(QtGui_enabled_features TARGET Qt${QT_MAJOR_VERSION}::Gui
+ PROPERTY QT_ENABLED_PUBLIC_FEATURES)
+
+if("opengles2" IN_LIST QtGui_enabled_features)
+ list(APPEND QtOpenGL_DROPPED_ENTRIES QOpenGLTimeMonitor QOpenGLTimerQuery)
+ message(STATUS "Qt${QT_MAJOR_VERSION}Gui: Dropping Desktop OpenGL classes (GLES2)")
+else()
+ list(APPEND QtOpenGL_SRC
+ ${QtOpenGL_GEN_DIR}/qopengltimemonitor_wrapper.cpp
+ ${QtOpenGL_GEN_DIR}/qopengltimerquery_wrapper.cpp)
+ message(STATUS "Qt${QT_MAJOR_VERSION}OpenGL: Adding Desktop OpenGL classes")
+endif()
+
set(QtOpenGL_include_dirs ${QtOpenGL_SOURCE_DIR}
${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
${Qt${QT_MAJOR_VERSION}OpenGL_INCLUDE_DIRS}
${libpyside_SOURCE_DIR}
- ${QtWidgets_GEN_DIR}
- ${QtGui_GEN_DIR}
${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
${QtOpenGL_GEN_DIR}
)
set(QtOpenGL_libraries pyside2
${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
${Qt${QT_MAJOR_VERSION}OpenGL_LIBRARIES})
-set(QtOpenGL_deps QtWidgets)
+set(QtOpenGL_deps QtGui)
create_pyside_module(NAME QtOpenGL
INCLUDE_DIRS QtOpenGL_include_dirs
LIBRARIES QtOpenGL_libraries
DEPS QtOpenGL_deps
TYPESYSTEM_PATH QtOpenGL_SOURCE_DIR
- SOURCES QtOpenGL_SRC)
+ SOURCES QtOpenGL_SRC
+ DROPPED_ENTRIES QtOpenGL_DROPPED_ENTRIES)
diff --git a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
index 5e864ca43..c04929cc4 100644
--- a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
+++ b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
@@ -2,7 +2,7 @@
<!--
/****************************************************************************
**
-** 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,677 +40,134 @@
****************************************************************************/
-->
<typesystem package="PySide2.QtOpenGL">
- <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no" />
+ <load-typesystem name="QtCore/typesystem_core.xml" generate="no" />
+ <load-typesystem name="QtGui/typesystem_gui.xml" generate="no" />
<load-typesystem name="templates/opengl_common.xml" generate="no" />
- <primitive-type name="GLbitfield"/>
- <primitive-type name="GLboolean"/>
- <primitive-type name="GLbyte"/>
- <primitive-type name="GLclampd"/>
- <primitive-type name="GLclampf"/>
- <primitive-type name="GLdouble"/>
- <primitive-type name="GLenum"/>
- <primitive-type name="GLfloat"/>
- <primitive-type name="GLint"/>
- <primitive-type name="GLshort"/>
- <primitive-type name="GLsizei"/>
- <primitive-type name="GLubyte"/>
- <primitive-type name="GLuint"/>
- <primitive-type name="GLushort"/>
-
- <rejection class="QGLColormap::QGLColormapData"/>
- <rejection class="QGLContext" field-name="currentCtx"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLboolean ?\*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLchar ?\*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLchar ?\*const"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLenum ?\*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLfloat ?\*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLfloat ?\[.*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLdouble ?\*$"/>
- <rejection class="^QGL.*$" argument-type="GLintptr"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLint64 ?\*$"/>
- <rejection class="^QGL.*$" argument-type="^(const )?GLsizei ?\*$"/>
-
- <namespace-type name="QGL">
- <enum-type name="FormatOption" flags="FormatOptions"/>
- <extra-includes>
- <include file-name="qgl.h" location="global"/>
- </extra-includes>
- </namespace-type>
-
- <value-type name="QGLColormap">
- <modify-function signature="setEntries(int,const unsigned int*,int)">
- <access modifier="private"/>
- </modify-function>
- </value-type>
-
- <value-type name="QGLFormat">
- <enum-type name="OpenGLContextProfile" since="4.7"/>
- <enum-type name="OpenGLVersionFlag" flags="OpenGLVersionFlags"/>
- </value-type>
-
- <rejection class="QGLContext" field-name="currentCtx"/>
- <object-type name="QGLContext">
- <enum-type name="BindOption" flags="BindOptions" since="4.6"/>
- <modify-function signature="chooseContext(const QGLContext*)">
- <modify-argument index="1" invalidate-after-use="yes"/>
- </modify-function>
- <modify-function signature="create(const QGLContext*)">
- <modify-argument index="1" invalidate-after-use="yes"/>
- </modify-function>
-
- <!-- ### Obsolete functions and ctors -->
- <modify-function signature="QGLContext(const QGLFormat&amp;,QPaintDevice*)" remove="all"/>
- <!-- ### -->
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?GLboolean ?\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^GLchar\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?GLchar ?\*(const)?\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^char\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?char ?\*\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="GLintptr"/>
+ <rejection class="^QOpenGL.*$" argument-type="GLsizeiptr"/>
+ <rejection class="^QOpenGL.*$" argument-type="GLsync"/>
+ <rejection class="^QOpenGL.*$" argument-type="^GLubyte( const)?\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?QMatrix.x. ?\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="qopengl_GLintptr"/>
+ <rejection class="^QOpenGL.*$" argument-type="qopengl_GLsizeiptr"/>
+ <rejection class="^QOpenGL.*$" argument-type="QOpenGLTextureHelper*"/>
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?QVector.D ?\*$"/>
+ <rejection class="^QOpenGL.*$" argument-type="^(const )?void ?\*\*$"/>
+
+ <object-type name="QOpenGLBuffer" since="5.0">
+ <enum-type name="Access"/>
+ <enum-type name="RangeAccessFlag" flags="RangeAccessFlags"/>
+ <enum-type name="Type"/>
+ <enum-type name="UsagePattern"/>
+ </object-type>
+ <object-type name="QOpenGLDebugLogger" since="5.1">
+ <enum-type name="LoggingMode"/>
</object-type>
- <object-type name="QGLFramebufferObject">
+ <value-type name="QOpenGLDebugMessage" since="5.1">
+ <enum-type name="Source" flags="Sources"/>
+ <enum-type name="Type" flags="Types"/>
+ <enum-type name="Severity" flags="Severities"/>
+ </value-type>
+ <object-type name="QOpenGLFramebufferObject" since="5.0">
<enum-type name="Attachment"/>
+ <enum-type name="FramebufferRestorePolicy" since="5.7"/>
</object-type>
- <object-type name="QGLPixelBuffer">
- <extra-includes>
- <include file-name="QImage" location="global"/>
- </extra-includes>
+ <value-type name="QOpenGLFramebufferObjectFormat"/>
+ <object-type name="QAbstractOpenGLFunctions" since="5.1"/>
+ <value-type name="QOpenGLPixelTransferOptions"/>
+ <object-type name="QOpenGLShader" since="5.0">
+ <enum-type name="ShaderTypeBit" flags="ShaderType"/>
</object-type>
- <object-type name="QGLWidget">
- <extra-includes>
- <include file-name="QImage" location="global"/>
- <include file-name="QPixmap" location="global"/>
- </extra-includes>
- <modify-function signature="QGLWidget(QGLContext*,QWidget*,const QGLWidget*,QFlags&lt;Qt::WindowType&gt;)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- <modify-argument index="this">
- <parent index="2" action="add"/>
- </modify-argument>
- </modify-function>
- <!-- ### Not part of Qt public API -->
- <modify-function signature="setContext(QGLContext*,const QGLContext*,bool)" remove="all"/>
- <!-- ### -->
- <!--- ### Obsolete functions -->
- <modify-function signature="setFormat(QGLFormat)" remove="all"/>
- <!-- ### -->
+ <object-type name="QOpenGLShaderProgram" since="5.0">
+ <modify-function signature="setAttributeArray(int,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setAttributeArray(const char*,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setAttributeArray(int,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setAttributeValue(int,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setAttributeValue(const char*,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(int,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(int,const int*,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(int,const unsigned int*,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(const char*,const float*,int,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(const char*,const int*,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <modify-function signature="setUniformValueArray(const char*,const unsigned int*,int)">
+ <modify-argument index="2"><array/></modify-argument>
+ </modify-function>
+ <!-- Add explicit signatures for the setUniformValue functions -->
+ <modify-function signature="^setUniformValue\(const char\*,(float|int|uint)\)$" remove="all"/>
+ <!-- No need for a signature for GLuint, since Qt (internally) calls the same function: glUniform1i -->
+ <add-function signature="setUniformValue1f(const char*, float)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
+ </add-function>
+ <add-function signature="setUniformValue1i(const char*, int)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
+ </add-function>
+ <add-function signature="setUniformValue1f(int, float)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
+ </add-function>
+ <add-function signature="setUniformValue1i(int, int)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
+ </add-function>
</object-type>
-
- <value-type name="QGLFramebufferObjectFormat" since="4.6"/>
- <object-type name="QGLShader" since="4.6">
- <enum-type name="ShaderTypeBit" flags="ShaderType"/>
+ <object-type name="QOpenGLTexture" since="5.2">
+ <enum-type name="BindingTarget"/>
+ <enum-type name="CoordinateDirection"/>
+ <enum-type name="ComparisonFunction"/>
+ <enum-type name="ComparisonMode"/>
+ <enum-type name="CubeMapFace"/>
+ <enum-type name="DepthStencilMode"/>
+ <enum-type name="Feature" flags="Features"/>
+ <enum-type name="Filter"/>
+ <enum-type name="MipMapGeneration"/>
+ <enum-type name="PixelFormat"/>
+ <enum-type name="PixelType"/>
+ <enum-type name="SwizzleComponent"/>
+ <enum-type name="SwizzleValue"/>
+ <enum-type name="Target"/>
+ <enum-type name="TextureFormat"/>
+ <enum-type name="TextureFormatClass"/>
+ <enum-type name="TextureUnitReset"/>
+ <enum-type name="WrapMode"/>
+ <modify-function signature="borderColor(unsigned int*)const" remove="all"/>
+ <modify-function signature="borderColor(int*)const" remove="all"/>
+ <modify-function signature="borderColor(float*)const" remove="all"/>
</object-type>
-
- <object-type name="QGLShaderProgram" since="4.6">
- <!-- setAttributeArray -->
- <modify-function signature="setAttributeArray(int,const QVector2D*,int)" rename="setAttributeArray2D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector2D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setAttributeArray(int,const QVector3D*,int)" rename="setAttributeArray3D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector3D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setAttributeArray(int,const QVector4D*,int)" rename="setAttributeArray4D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector4D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setAttributeArray(const char*,const QVector2D*,int)" rename="setAttributeArray2D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector2D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setAttributeArray(const char*,const QVector3D*,int)" rename="setAttributeArray3D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector3D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setAttributeArray(const char*,const QVector4D*,int)" rename="setAttributeArray4D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="%3"/>
- <replace from="$ARG1" to="%3"/>
- <replace from="$ATTR_TYPE" to="QVector4D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <!-- setUniformValueArray -->
- <modify-function signature="setUniformValueArray(int,const GLint*,int)" rename="setUniformValueArrayInt">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- <array/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="GLint"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const GLuint*,int)" rename="setUniformValueArrayUint">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- <array/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="GLuint"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QVector2D*,int)" rename="setUniformValueArray2D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector2D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QVector3D*,int)" rename="setUniformValueArray3D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector3D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QVector4D*,int)" rename="setUniformValueArray4D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector4D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix2x2*,int)" rename="setUniformValueArray2x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix2x3*,int)" rename="setUniformValueArray2x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix2x4*,int)" rename="setUniformValueArray2x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix3x2*,int)" rename="setUniformValueArray3x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix3x3*,int)" rename="setUniformValueArray3x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix3x4*,int)" rename="setUniformValueArray3x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix4x2*,int)" rename="setUniformValueArray4x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix4x3*,int)" rename="setUniformValueArray4x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(int,const QMatrix4x4*,int)" rename="setUniformValueArray4x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const GLint*,int)" rename="setUniformValueArrayInt">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- <array/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="GLint"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const GLuint*,int)" rename="setUniformValueArrayUint">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- <array/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="GLuint"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QVector2D*,int)" rename="setUniformValueArray2D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector2D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QVector3D*,int)" rename="setUniformValueArray3D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector3D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QVector4D*,int)" rename="setUniformValueArray4D">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QVector4D"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix2x2*,int)" rename="setUniformValueArray2x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix2x3*,int)" rename="setUniformValueArray2x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix2x4*,int)" rename="setUniformValueArray2x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix2x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix3x2*,int)" rename="setUniformValueArray3x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix3x3*,int)" rename="setUniformValueArray3x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix3x4*,int)" rename="setUniformValueArray3x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix3x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix4x2*,int)" rename="setUniformValueArray4x2">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x2"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix4x3*,int)" rename="setUniformValueArray4x3">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x3"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <modify-function signature="setUniformValueArray(const char*,const QMatrix4x4*,int)" rename="setUniformValueArray4x4">
- <modify-argument index="2" >
- <replace-type modified-type="PySequence"/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument />
- </modify-argument>
- <inject-code>
- <insert-template name="callArrayFunction">
- <replace from="$ARG0" to="_size"/>
- <replace from="$ARG1" to="0"/>
- <replace from="$ATTR_TYPE" to="QMatrix4x4"/>
- </insert-template>
- </inject-code>
- </modify-function>
-
- <!-- ### Use QMatrixZxY overloads -->
- <modify-function signature="setAttributeArray(int,GLenum,const void*,int,int)" remove="all" since="4.7"/>
- <modify-function signature="setAttributeArray(const char*,GLenum,const void*,int,int)" remove="all" since="4.7"/>
- <!-- ### -->
+ <object-type name="QOpenGLTextureBlitter">
+ <enum-type name="Origin"/>
</object-type>
-
- <!-- Qt 4.7 -->
- <object-type name="QGLBuffer" since="4.7">
- <enum-type name="Access" since="4.7"/>
- <enum-type name="Type" since="4.7"/>
- <enum-type name="UsagePattern" since="4.7"/>
- <modify-function signature="allocate(const void*,int)">
- <modify-argument index="1">
- <replace-type modified-type="QByteArray&amp;"/>
- </modify-argument>
- <modify-argument index="2">
- <replace-default-expression with="-1"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtopengl.cpp" snippet="qglbuffer-allocate"/>
- </modify-function>
- <modify-function signature="map(QGLBuffer::Access)">
- <inject-code file="../glue/qtopengl.cpp" snippet="qglbuffer-map"/>
- </modify-function>
- <modify-function signature="read(int,void*,int)">
- <modify-argument index="2">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="(retval, data)"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtopengl.cpp" snippet="qglbuffer-read"/>
- </modify-function>
- <modify-function signature="write(int,const void*,int)">
- <modify-argument index="2">
- <replace-type modified-type="QByteArray&amp;"/>
- </modify-argument>
- <modify-argument index="3">
- <replace-default-expression with="-1"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtopengl.cpp" snippet="qglbuffer-write"/>
- </modify-function>
+ <object-type name="QOpenGLTimeMonitor" since="5.1"/>
+ <object-type name="QOpenGLTimerQuery" since="5.1"/>
+ <object-type name="QOpenGLWindow" since="5.4">
+ <enum-type name="UpdateBehavior"/>
+ </object-type>
+ <value-type name="QOpenGLVersionProfile" since="5.1"/>
+ <object-type name="QOpenGLVertexArrayObject">
+ <object-type name="Binder"/>
</object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtOpenGLFunctions/CMakeLists.txt b/sources/pyside2/PySide2/QtOpenGLFunctions/CMakeLists.txt
index 383afb68f..7e795989f 100644
--- a/sources/pyside2/PySide2/QtOpenGLFunctions/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtOpenGLFunctions/CMakeLists.txt
@@ -1,17 +1,14 @@
project(QtOpenGLFunctions)
-set(QtOpenGLFunctions_DROPPED_ENTRIES)
-
get_property(QtOpenGLFunctions_enabled_features TARGET Qt${QT_MAJOR_VERSION}::Gui
PROPERTY QT_ENABLED_PUBLIC_FEATURES)
set(QtOpenGLFunctions_SRC ${QtOpenGLFunctions_GEN_DIR}/qtopenglfunctions_module_wrapper.cpp)
-# cf qtbase/src/gui/opengl/opengl.pri
-list(FIND QtOpenGLFunctions_enabled_features "opengles2" _opengles2Index)
-# ### fixme: For cmake >= 3.3: if(opengles2 IN_LIST QtOpenGLFunctions_enabled_features)
-if(_opengles2Index GREATER -1)
- list(APPEND QtOpenGLFunctions_DROPPED_ENTRIES QOpenGLTimeMonitor QOpenGLTimerQuery)
+get_property(QtGui_enabled_features TARGET Qt${QT_MAJOR_VERSION}::Gui
+ PROPERTY QT_ENABLED_PUBLIC_FEATURES)
+
+if("opengles2" IN_LIST QtGui_enabled_features)
list(APPEND QtOpenGLFunctions_SRC
${QtOpenGLFunctions_GEN_DIR}/qopenglfunctions_es2_wrapper.cpp)
message(STATUS "Qt${QT_MAJOR_VERSION}OpenGLFunctions: Dropping Desktop OpenGL classes (GLES2)")
@@ -49,19 +46,23 @@ endif()
configure_file("${QtOpenGLFunctions_SOURCE_DIR}/QtOpenGLFunctions_global.post.h.in"
"${QtOpenGLFunctions_BINARY_DIR}/QtOpenGLFunctions_global.post.h" @ONLY)
-set(QtOpenGLFunctions_include_dirs ${QtGOpenGLFunctions_SOURCE_DIR}
- ${QtOpenGLFunctions_BINARY_DIR}
- ${pyside2_SOURCE_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- ${QtGui_GEN_DIR}
- )
-set(QtOpenGLFunctions_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES})
+set(QtOpenGLFunctions_include_dirs ${QtOpenGLFunctions_SOURCE_DIR}
+ ${QtOpenGLFunctions_BINARY_DIR}
+ ${pyside2_SOURCE_DIR}
+ ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}OpenGL_INCLUDE_DIRS}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtOpenGL_GEN_DIR}
+ )
+
+set(QtOpenGLFunctions_libraries pyside2
+ ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}OpenGL_LIBRARIES})
-set(QtOpenGLFunctions_deps QtGui)
+set(QtOpenGLFunctions_deps QtGui QtOpenGL)
create_pyside_module(NAME QtOpenGLFunctions
INCLUDE_DIRS QtOpenGLFunctions_include_dirs
diff --git a/sources/pyside2/PySide2/QtOpenGLFunctions/QtOpenGLFunctions_global.post.h.in b/sources/pyside2/PySide2/QtOpenGLFunctions/QtOpenGLFunctions_global.post.h.in
index 6c8c77087..c25343e05 100644
--- a/sources/pyside2/PySide2/QtOpenGLFunctions/QtOpenGLFunctions_global.post.h.in
+++ b/sources/pyside2/PySide2/QtOpenGLFunctions/QtOpenGLFunctions_global.post.h.in
@@ -29,33 +29,33 @@
#include <QtGui/qtgui-config.h>
// OpenGL functions are not in the QtGui module header
#if QT_CONFIG(opengl)
-# include <QtGui/qopenglfunctions_1_0.h>
-# include <QtGui/qopenglfunctions_1_1.h>
-# include <QtGui/qopenglfunctions_1_2.h>
-# include <QtGui/qopenglfunctions_1_3.h>
-# include <QtGui/qopenglfunctions_1_4.h>
-# include <QtGui/qopenglfunctions_1_5.h>
-# include <QtGui/qopenglfunctions_2_0.h>
-# include <QtGui/qopenglfunctions_2_1.h>
-# include <QtGui/qopenglfunctions_3_0.h>
-# include <QtGui/qopenglfunctions_3_1.h>
-# include <QtGui/qopenglfunctions_3_2_compatibility.h>
-# include <QtGui/qopenglfunctions_3_2_core.h>
-# include <QtGui/qopenglfunctions_3_3_compatibility.h>
-# include <QtGui/qopenglfunctions_3_3_core.h>
-# include <QtGui/qopenglfunctions_4_0_compatibility.h>
-# include <QtGui/qopenglfunctions_4_0_core.h>
-# include <QtGui/qopenglfunctions_4_1_compatibility.h>
-# include <QtGui/qopenglfunctions_4_1_core.h>
-# include <QtGui/qopenglfunctions_4_2_compatibility.h>
-# include <QtGui/qopenglfunctions_4_2_core.h>
-# include <QtGui/qopenglfunctions_4_3_compatibility.h>
-# include <QtGui/qopenglfunctions_4_3_core.h>
-# include <QtGui/qopenglfunctions_4_4_compatibility.h>
-# include <QtGui/qopenglfunctions_4_4_core.h>
-# include <QtGui/qopenglfunctions_4_5_compatibility.h>
-# include <QtGui/qopenglfunctions_4_5_core.h>
+# include <QtOpenGL/qopenglfunctions_1_0.h>
+# include <QtOpenGL/qopenglfunctions_1_1.h>
+# include <QtOpenGL/qopenglfunctions_1_2.h>
+# include <QtOpenGL/qopenglfunctions_1_3.h>
+# include <QtOpenGL/qopenglfunctions_1_4.h>
+# include <QtOpenGL/qopenglfunctions_1_5.h>
+# include <QtOpenGL/qopenglfunctions_2_0.h>
+# include <QtOpenGL/qopenglfunctions_2_1.h>
+# include <QtOpenGL/qopenglfunctions_3_0.h>
+# include <QtOpenGL/qopenglfunctions_3_1.h>
+# include <QtOpenGL/qopenglfunctions_3_2_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_3_2_core.h>
+# include <QtOpenGL/qopenglfunctions_3_3_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_3_3_core.h>
+# include <QtOpenGL/qopenglfunctions_4_0_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_0_core.h>
+# include <QtOpenGL/qopenglfunctions_4_1_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_1_core.h>
+# include <QtOpenGL/qopenglfunctions_4_2_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_2_core.h>
+# include <QtOpenGL/qopenglfunctions_4_3_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_3_core.h>
+# include <QtOpenGL/qopenglfunctions_4_4_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_4_core.h>
+# include <QtOpenGL/qopenglfunctions_4_5_compatibility.h>
+# include <QtOpenGL/qopenglfunctions_4_5_core.h>
#endif
#if QT_CONFIG(opengles2)
-# include <QtGui/qopenglfunctions_es2.h>
+# include <QtOpenGL/qopenglfunctions_es2.h>
#endif
diff --git a/sources/pyside2/PySide2/QtOpenGLFunctions/typesystem_openglfunctions.xml b/sources/pyside2/PySide2/QtOpenGLFunctions/typesystem_openglfunctions.xml
index 1d5b08edb..f749d1d7c 100644
--- a/sources/pyside2/PySide2/QtOpenGLFunctions/typesystem_openglfunctions.xml
+++ b/sources/pyside2/PySide2/QtOpenGLFunctions/typesystem_openglfunctions.xml
@@ -2,7 +2,7 @@
<!--
/****************************************************************************
**
-** Copyright (C) 2019 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,7 +40,7 @@
****************************************************************************/
-->
<typesystem package="PySide2.QtOpenGLFunctions">
- <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="QtOpenGL/typesystem_opengl.xml" generate="no"/>
<load-typesystem name="templates/openglfunctions_common.xml" generate="no"/>
<rejection class="^QOpenGL.*$" argument-type="^(const )?GLboolean ?\*$"/>
@@ -201,7 +201,6 @@
&openglfunctions_modifications2_1;
&openglfunctions_modifications3_0;
&openglfunctions_modifications3_3;
- &openglfunctions_modifications3_3a;
</object-type>
<object-type name="QOpenGLFunctions_4_0_Compatibility" since="5.1">
&openglfunctions_modifications1_0;
@@ -228,7 +227,6 @@
&openglfunctions_modifications2_1;
&openglfunctions_modifications3_0;
&openglfunctions_modifications3_3;
- &openglfunctions_modifications3_3a;
&openglfunctions_modifications4_0;
</object-type>
<object-type name="QOpenGLFunctions_4_1_Compatibility" since="5.1">
@@ -257,7 +255,6 @@
&openglfunctions_modifications2_1;
&openglfunctions_modifications3_0;
&openglfunctions_modifications3_3;
- &openglfunctions_modifications3_3a;
&openglfunctions_modifications4_0;
&openglfunctions_modifications4_1;
&openglfunctions_modifications_va;
@@ -288,7 +285,6 @@
&openglfunctions_modifications2_1;
&openglfunctions_modifications3_0;
&openglfunctions_modifications3_3;
- &openglfunctions_modifications3_3a;
&openglfunctions_modifications4_0;
&openglfunctions_modifications4_1;
&openglfunctions_modifications_va;
@@ -320,7 +316,6 @@
&openglfunctions_modifications2_1;
&openglfunctions_modifications3_0;
&openglfunctions_modifications3_3;
- &openglfunctions_modifications3_3a;
&openglfunctions_modifications4_0;
&openglfunctions_modifications4_3;
&openglfunctions_modifications4_1;
diff --git a/sources/pyside2/PySide2/QtOpenGLWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtOpenGLWidgets/CMakeLists.txt
new file mode 100644
index 000000000..694bd7f3a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtOpenGLWidgets/CMakeLists.txt
@@ -0,0 +1,34 @@
+project(QtOpenGLWidgets)
+
+set(QtOpenGLWidgets_SRC
+${QtOpenGLWidgets_GEN_DIR}/qopenglwidget_wrapper.cpp
+# module is always needed
+${QtOpenGLWidgets_GEN_DIR}/qtopenglwidgets_module_wrapper.cpp
+)
+
+set(QtOpenGLWidgets_include_dirs ${QtOpenGLWidgets_SOURCE_DIR}
+ ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}OpenGL_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtOpenGLWidgets_GEN_DIR})
+
+set(QtOpenGLWidgets_libraries pyside2
+ ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}OpenGL_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}OpenGLWidgets_LIBRARIES})
+
+set(QtOpenGLWidgets_deps QtOpenGL QtWidgets)
+
+create_pyside_module(NAME QtOpenGLWidgets
+ INCLUDE_DIRS QtOpenGLWidgets_include_dirs
+ LIBRARIES QtOpenGLWidgets_libraries
+ DEPS QtOpenGLWidgets_deps
+ TYPESYSTEM_PATH QtOpenGLWidgets_SOURCE_DIR
+ SOURCES QtOpenGLWidgets_SRC)
diff --git a/sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml b/sources/pyside2/PySide2/QtOpenGLWidgets/typesystem_openglwidgets.xml
index e92417f26..983fc37fc 100644
--- a/sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml
+++ b/sources/pyside2/PySide2/QtOpenGLWidgets/typesystem_openglwidgets.xml
@@ -2,7 +2,7 @@
<!--
/****************************************************************************
**
-** 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.
@@ -39,11 +39,12 @@
**
****************************************************************************/
-->
-<typesystem package="PySide2.QtWebKit">
- <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
- <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
- <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/>
-
- <namespace-type name="WebCore"/>
+<typesystem package="PySide2.QtOpenGLWidgets">
+ <load-typesystem name="QtCore/typesystem_core.xml" generate="no" />
+ <load-typesystem name="QtGui/typesystem_gui.xml" generate="no" />
+ <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no" />
+ <object-type name="QOpenGLWidget">
+ <enum-type name="UpdateBehavior"/>
+ </object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
index 487103875..f51edf67a 100644
--- a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
+++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
@@ -64,7 +64,6 @@
<object-type name="QPrinter" >
<enum-type name="ColorMode"/>
<enum-type name="DuplexMode"/>
- <enum-type name="Orientation"/>
<enum-type name="OutputFormat"/>
<enum-type name="PageOrder"/>
<enum-type name="PaperSource"/>
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
index 2b60c5c7f..fd470cd71 100644
--- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
@@ -52,74 +52,34 @@
#include "pyside2_qtcore_python.h"
#include "pyside2_qtqml_python.h"
-#ifndef PYSIDE_MAX_QML_TYPES
-// Maximum number of different Qt QML types the user can export to QML using
-// qmlRegisterType. This limit exists because the QML engine instantiates objects
-// by calling a function with one argument (a void *pointer where the object should
-// be created), and thus does not allow us to choose which object to create. Thus
-// we create a C++ factory function for each new registered type at compile time.
-#define PYSIDE_MAX_QML_TYPES 50
-#endif
+#include <QtQml/QJSValue>
// Forward declarations.
static void propListMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Call call,
void **args);
-// All registered python types and their creation functions.
-static PyObject *pyTypes[PYSIDE_MAX_QML_TYPES];
-static void (*createFuncs[PYSIDE_MAX_QML_TYPES])(void *);
-
// Mutex used to avoid race condition on PySide::nextQObjectMemoryAddr.
static QMutex nextQmlElementMutex;
-template<int N>
-struct ElementFactoryBase
+static void createInto(void *memory, void *type)
{
- static void createInto(void *memory)
- {
- QMutexLocker locker(&nextQmlElementMutex);
- PySide::setNextQObjectMemoryAddr(memory);
- Shiboken::GilState state;
- PyObject *obj = PyObject_CallObject(pyTypes[N], 0);
- if (!obj || PyErr_Occurred())
- PyErr_Print();
- PySide::setNextQObjectMemoryAddr(0);
- }
-};
-
-template<int N>
-struct ElementFactory : ElementFactoryBase<N>
-{
- static void init()
- {
- createFuncs[N] = &ElementFactoryBase<N>::createInto;
- ElementFactory<N-1>::init();
- }
-};
-
-template<>
-struct ElementFactory<0> : ElementFactoryBase<0>
-{
- static void init()
- {
- createFuncs[0] = &ElementFactoryBase<0>::createInto;
- }
-};
+ QMutexLocker locker(&nextQmlElementMutex);
+ PySide::setNextQObjectMemoryAddr(memory);
+ Shiboken::GilState state;
+ PyObject *obj = PyObject_CallObject(reinterpret_cast<PyObject *>(type), 0);
+ if (!obj || PyErr_Occurred())
+ PyErr_Print();
+ PySide::setNextQObjectMemoryAddr(0);
+}
int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
- int versionMinor, const char *qmlName)
+ int versionMinor, const char *qmlName, const char *noCreationReason,
+ bool creatable)
{
using namespace Shiboken;
static PyTypeObject *qobjectType = Shiboken::Conversions::getPythonTypeObject("QObject*");
assert(qobjectType);
- static int nextType = 0;
-
- if (nextType >= PYSIDE_MAX_QML_TYPES) {
- PyErr_Format(PyExc_TypeError, "You can only export %d custom QML types to QML.",
- PYSIDE_MAX_QML_TYPES);
- return -1;
- }
PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (!PySequence_Contains(pyObjType->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) {
@@ -132,15 +92,15 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
Q_ASSERT(metaObject);
QQmlPrivate::RegisterType type;
- type.version = 0;
// Allow registering Qt Quick items.
bool registered = false;
#ifdef PYSIDE_QML_SUPPORT
QuickRegisterItemFunction quickRegisterItemFunction = getQuickRegisterItemFunction();
if (quickRegisterItemFunction) {
- registered = quickRegisterItemFunction(pyObj, uri, versionMajor, versionMinor,
- qmlName, &type);
+ registered =
+ quickRegisterItemFunction(pyObj, uri, versionMajor, versionMinor,
+ qmlName, creatable, noCreationReason, &type);
}
#endif
@@ -150,11 +110,11 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
// there's no way to unregister a QML type.
Py_INCREF(pyObj);
- pyTypes[nextType] = pyObj;
+ type.structVersion = 0;
// FIXME: Fix this to assign new type ids each time.
- type.typeId = qMetaTypeId<QObject *>();
- type.listId = qMetaTypeId<QQmlListProperty<QObject> >();
+ type.typeId = QMetaType(QMetaType::QObjectStar);
+ type.listId = QMetaType::fromType<QQmlListProperty<QObject> >();
type.attachedPropertiesFunction = QQmlPrivate::attachedPropertiesFunc<QObject>();
type.attachedPropertiesMetaObject = QQmlPrivate::attachedPropertiesMetaObject<QObject>();
@@ -168,16 +128,16 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
int objectSize = static_cast<int>(PySide::getSizeOfQObject(
reinterpret_cast<SbkObjectType *>(pyObj)));
type.objectSize = objectSize;
- type.create = createFuncs[nextType];
+ type.create = creatable ? createInto : nullptr;
+ type.noCreationReason = noCreationReason;
+ type.userdata = pyObj;
type.uri = uri;
- type.versionMajor = versionMajor;
- type.versionMinor = versionMinor;
+ type.version = QTypeRevision::fromVersion(versionMajor, versionMinor);
type.elementName = qmlName;
type.extensionObjectCreate = 0;
type.extensionMetaObject = 0;
type.customParser = 0;
- ++nextType;
}
type.metaObject = metaObject; // Snapshot may have changed.
@@ -189,6 +149,126 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
return qmlTypeId;
}
+int PySide::qmlRegisterSingletonType(PyObject *pyObj, const char *uri, int versionMajor,
+ int versionMinor, const char *qmlName, PyObject *callback,
+ bool isQObject, bool hasCallback)
+{
+ using namespace Shiboken;
+
+ if (hasCallback) {
+ if (!PyCallable_Check(callback)) {
+ PyErr_Format(PyExc_TypeError, "Invalid callback specified.");
+ return -1;
+ }
+
+ AutoDecRef funcCode(PyObject_GetAttrString(callback, "__code__"));
+ AutoDecRef argCount(PyObject_GetAttrString(funcCode, "co_argcount"));
+
+ int count = PyInt_AsLong(argCount);
+
+ if (count != 1) {
+ PyErr_Format(PyExc_TypeError, "Callback has a bad parameter count.");
+ return -1;
+ }
+
+ // Make sure the callback never gets deallocated
+ Py_INCREF(callback);
+ }
+
+ const QMetaObject *metaObject = nullptr;
+
+ if (isQObject) {
+ static PyTypeObject *qobjectType = Conversions::getPythonTypeObject("QObject*");
+ assert(qobjectType);
+
+ PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ if (!PySequence_Contains(pyObjType->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) {
+ PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.",
+ qobjectType->tp_name, pyObjType->tp_name);
+ return -1;
+ }
+
+ // If we don't have a callback we'll need the pyObj to stay allocated indefinitely
+ if (!hasCallback)
+ Py_INCREF(pyObj);
+
+ metaObject = PySide::retrieveMetaObject(pyObjType);
+ Q_ASSERT(metaObject);
+ }
+
+ QQmlPrivate::RegisterSingletonType type;
+ type.structVersion = 0;
+
+ type.uri = uri;
+ type.version = QTypeRevision::fromVersion(versionMajor, versionMinor);
+ type.typeName = qmlName;
+ type.instanceMetaObject = metaObject;
+
+ if (isQObject) {
+ // FIXME: Fix this to assign new type ids each time.
+ type.typeId = QMetaType(QMetaType::QObjectStar);
+
+ type.qObjectApi =
+ [callback, pyObj, hasCallback](QQmlEngine *engine, QJSEngine *) -> QObject * {
+ AutoDecRef args(PyTuple_New(hasCallback ? 1 : 0));
+
+ if (hasCallback) {
+ PyTuple_SET_ITEM(args, 0, Conversions::pointerToPython(
+ (SbkObjectType *)SbkPySide2_QtQmlTypes[SBK_QQMLENGINE_IDX],
+ engine));
+ }
+
+ AutoDecRef retVal(PyObject_CallObject(hasCallback ? callback : pyObj, args));
+
+ SbkObjectType *qobjectType = (SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX];
+
+ // Make sure the callback returns something we can convert, else the entire application will crash.
+ if (retVal.isNull() ||
+ Conversions::isPythonToCppPointerConvertible(qobjectType, retVal) == nullptr) {
+ PyErr_Format(PyExc_TypeError, "Callback returns invalid value.");
+ return nullptr;
+ }
+
+ QObject *obj = nullptr;
+ Conversions::pythonToCppPointer(qobjectType, retVal, &obj);
+
+ if (obj != nullptr)
+ Py_INCREF(retVal);
+
+ return obj;
+ };
+ } else {
+ type.scriptApi =
+ [callback](QQmlEngine *engine, QJSEngine *) -> QJSValue {
+ AutoDecRef args(PyTuple_New(1));
+
+ PyTuple_SET_ITEM(args, 0, Conversions::pointerToPython(
+ (SbkObjectType *)SbkPySide2_QtQmlTypes[SBK_QQMLENGINE_IDX],
+ engine));
+
+ AutoDecRef retVal(PyObject_CallObject(callback, args));
+
+ SbkObjectType *qjsvalueType = (SbkObjectType *)SbkPySide2_QtQmlTypes[SBK_QJSVALUE_IDX];
+
+ // Make sure the callback returns something we can convert, else the entire application will crash.
+ if (retVal.isNull() ||
+ Conversions::isPythonToCppPointerConvertible(qjsvalueType, retVal) == nullptr) {
+ PyErr_Format(PyExc_TypeError, "Callback returns invalid value.");
+ return QJSValue(QJSValue::UndefinedValue);
+ }
+
+ QJSValue *val = nullptr;
+ Conversions::pythonToCppPointer(qjsvalueType, retVal, &val);
+
+ Py_INCREF(retVal);
+
+ return *val;
+ };
+ }
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &type);
+}
+
extern "C"
{
@@ -197,27 +277,51 @@ struct QmlListProperty
{
PyTypeObject *type;
PyObject *append;
+ PyObject *count;
PyObject *at;
PyObject *clear;
- PyObject *count;
+ PyObject *replace;
+ PyObject *removeLast;
};
static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"type", "append", "at", "clear", "count", 0};
+ static const char *kwlist[] = {"type", "append", "count", "at", "clear", "replace", "removeLast", 0};
PySideProperty *pySelf = reinterpret_cast<PySideProperty *>(self);
QmlListProperty *data = new QmlListProperty;
memset(data, 0, sizeof(QmlListProperty));
if (!PyArg_ParseTupleAndKeywords(args, kwds,
- "OO|OOO:QtQml.ListProperty", (char **) kwlist,
+ "O|OOOOOO:QtQml.ListProperty", (char **) kwlist,
&data->type,
&data->append,
+ &data->count,
&data->at,
&data->clear,
- &data->count)) {
+ &data->replace,
+ &data->removeLast)) {
return -1;
}
+
+ static PyTypeObject *qobjectType = Shiboken::Conversions::getPythonTypeObject("QObject*");
+ assert(qobjectType);
+
+ if (!PySequence_Contains(data->type->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) {
+ PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.",
+ qobjectType->tp_name, data->type->tp_name);
+ return -1;
+ }
+
+ if ((data->append && data->append != Py_None && !PyCallable_Check(data->append)) ||
+ (data->count && data->count != Py_None && !PyCallable_Check(data->count)) ||
+ (data->at && data->at != Py_None && !PyCallable_Check(data->at)) ||
+ (data->clear && data->clear != Py_None && !PyCallable_Check(data->clear)) ||
+ (data->replace && data->replace != Py_None && !PyCallable_Check(data->replace)) ||
+ (data->removeLast && data->removeLast != Py_None && !PyCallable_Check(data->removeLast))) {
+ PyErr_Format(PyExc_TypeError, "Non-callable parameter given");
+ return -1;
+ }
+
PySide::Property::setMetaCallHandler(pySelf, &propListMetaCall);
PySide::Property::setTypeName(pySelf, "QQmlListProperty<QObject>");
PySide::Property::setUserData(pySelf, data);
@@ -333,6 +437,38 @@ void propListClear(QQmlListProperty<QObject> * propList)
PyErr_Print();
}
+// Implementation of QQmlListProperty<T>::ReplaceFunction callback
+void propListReplace(QQmlListProperty<QObject> *propList, int index, QObject *value)
+{
+ Shiboken::GilState state;
+
+ Shiboken::AutoDecRef args(PyTuple_New(3));
+ PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object));
+ PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(), &index));
+ PyTuple_SET_ITEM(args, 2, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], value));
+
+ auto data = reinterpret_cast<QmlListProperty *>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->replace, args));
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
+// Implementation of QQmlListProperty<T>::RemoveLastFunction callback
+void propListRemoveLast(QQmlListProperty<QObject> *propList)
+{
+ Shiboken::GilState state;
+
+ Shiboken::AutoDecRef args(PyTuple_New(1));
+ PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object));
+
+ auto data = reinterpret_cast<QmlListProperty *>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->removeLast, args));
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
// qt_metacall specialization for ListProperties
static void propListMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Call call, void **args)
{
@@ -342,7 +478,13 @@ static void propListMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Ca
auto data = reinterpret_cast<QmlListProperty *>(PySide::Property::userData(pp));
QObject *qobj;
Shiboken::Conversions::pythonToCppPointer((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], self, &qobj);
- QQmlListProperty<QObject> declProp(qobj, data, &propListAppender, &propListCount, &propListAt, &propListClear);
+ QQmlListProperty<QObject> declProp(qobj, data,
+ data->append && data->append != Py_None ? &propListAppender : nullptr,
+ data->count && data->count != Py_None ? &propListCount : nullptr,
+ data->at && data->at != Py_None ? &propListAt : nullptr,
+ data->clear && data->clear != Py_None ? &propListClear : nullptr,
+ data->replace && data->replace != Py_None ? &propListReplace : nullptr,
+ data->removeLast && data->removeLast != Py_None ? &propListRemoveLast : nullptr);
// Copy the data to the memory location requested by the meta call
void *v = args[0];
@@ -367,18 +509,23 @@ QtQml_VolatileBoolObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
QtQml_VolatileBoolObject *self
= reinterpret_cast<QtQml_VolatileBoolObject *>(type->tp_alloc(type, 0));
- if (self != Q_NULLPTR)
- self->flag = ok;
+ if (self != nullptr)
+ self->flag = new AtomicBool(ok);
return reinterpret_cast<PyObject *>(self);
}
+static void QtQml_VolatileBoolObject_dealloc(PyObject *self)
+{
+ auto volatileBool = reinterpret_cast<QtQml_VolatileBoolObject *>(self);
+ delete volatileBool->flag;
+ Sbk_object_dealloc(self);
+}
+
static PyObject *
QtQml_VolatileBoolObject_get(QtQml_VolatileBoolObject *self)
{
- if (self->flag)
- return Py_True;
- return Py_False;
+ return *self->flag ? Py_True : Py_False;
}
static PyObject *
@@ -397,10 +544,7 @@ QtQml_VolatileBoolObject_set(QtQml_VolatileBoolObject *self, PyObject *args)
return Q_NULLPTR;
}
- if (ok > 0)
- self->flag = true;
- else
- self->flag = false;
+ *self->flag = ok > 0;
Py_RETURN_NONE;
}
@@ -420,7 +564,7 @@ QtQml_VolatileBoolObject_repr(QtQml_VolatileBoolObject *self)
{
PyObject *s;
- if (self->flag)
+ if (*self->flag)
s = PyBytes_FromFormat("%s(True)",
Py_TYPE(self)->tp_name);
else
@@ -435,12 +579,12 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self)
{
PyObject *s;
- if (self->flag)
+ if (*self->flag)
s = PyBytes_FromFormat("%s(True) -> %p",
- Py_TYPE(self)->tp_name, &(self->flag));
+ Py_TYPE(self)->tp_name, self->flag);
else
s = PyBytes_FromFormat("%s(False) -> %p",
- Py_TYPE(self)->tp_name, &(self->flag));
+ Py_TYPE(self)->tp_name, self->flag);
Py_XINCREF(s);
return s;
}
@@ -450,7 +594,7 @@ static PyType_Slot QtQml_VolatileBoolType_slots[] = {
{Py_tp_str, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str)},
{Py_tp_methods, (void *)QtQml_VolatileBoolObject_methods},
{Py_tp_new, (void *)QtQml_VolatileBoolObject_new},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
+ {Py_tp_dealloc, (void *)QtQml_VolatileBoolObject_dealloc},
{0, 0}
};
static PyType_Spec QtQml_VolatileBoolType_spec = {
@@ -481,8 +625,6 @@ static const char *VolatileBool_SignatureStrings[] = {
void PySide::initQmlSupport(PyObject *module)
{
- ElementFactory<PYSIDE_MAX_QML_TYPES - 1>::init();
-
// Export QmlListProperty type
if (InitSignatureStrings(PropertyListTypeF(), PropertyList_SignatureStrings) < 0) {
PyErr_Print();
@@ -490,6 +632,9 @@ void PySide::initQmlSupport(PyObject *module)
return;
}
+ // Register QQmlListProperty metatype for use in QML
+ qRegisterMetaType<QQmlListProperty<QObject>>();
+
Py_INCREF(reinterpret_cast<PyObject *>(PropertyListTypeF()));
PyModule_AddObject(module, PepType_GetNameStr(PropertyListTypeF()),
reinterpret_cast<PyObject *>(PropertyListTypeF()));
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
index 536348aa3..b147d9888 100644
--- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
@@ -68,10 +68,23 @@ void initQmlSupport(PyObject *module);
* \return the metatype id of the registered type.
*/
int qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int versionMinor,
- const char *qmlName);
-}
+ const char *qmlName, const char *noCreationReason = nullptr, bool creatable = true);
-// Volatile Bool Ptr type definition.
+/**
+ * PySide implementation of qmlRegisterType<T> function.
+ *
+ * \param pyObj Python type to be registered.
+ * \param uri QML element uri.
+ * \param versionMajor QML component major version.
+ * \param versionMinor QML component minor version.
+ * \param qmlName QML element name
+ * \param callback Registration callback
+ * \return the metatype id of the registered type.
+ */
+int qmlRegisterSingletonType(PyObject *pyObj,const char *uri, int versionMajor, int versionMinor, const char *qmlName,
+ PyObject *callback, bool isQObject, bool hasCallback);
+
+}
PyAPI_FUNC(PyTypeObject *) QtQml_VolatileBoolTypeF(void);
diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
index 0a12d44cf..b2def633f 100644
--- a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
+++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
@@ -45,11 +45,14 @@
<load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
<inject-code class="target" position="declaration">
- // Volatile Bool Ptr type definition.
+ // Volatile Bool Ptr type definition for QQmlIncubationController::incubateWhile(std::atomic&lt;bool&gt; *, int)
+ #include &lt;atomic&gt;
+
+ using AtomicBool = std::atomic&lt;bool&gt;;
typedef struct {
PyObject_HEAD
- volatile bool flag;
+ AtomicBool *flag;
} QtQml_VolatileBoolObject;
</inject-code>
@@ -66,32 +69,35 @@
in generator tests folder. -->
</primitive-type>
+ <enum-type name="QQmlModuleImportSpecialVersions" since="6.0"/>
+
<!-- For qmlEngine(const QObject*), qmlContext(const QObject*) in qqml.h -->
<namespace-type name="QtQml"/>
- <add-function signature="qmlRegisterType(PyTypeObject,const char*,int,int,const char*)" return-type="int">
- <inject-documentation format="target" mode="append">
- This function registers the Python type in the QML system with the name qmlName, in the library imported from uri having the version number composed from versionMajor and versionMinor.
- Returns the QML type id.
-
- For example, this registers a Python class MySliderItem as a QML type named Slider for version 1.0 of a module called "com.mycompany.qmlcomponents":
-
- ::
-
- qmlRegisterType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider")
-
- Once this is registered, the type can be used in QML by importing the specified module name and version number:
+ <!-- expose QQmlIncubationController::incubateWhile() (see
+ QtQml_VolatileBoolTypeF/pysideqmlregistertype.h) -->
+ <namespace-type name="std" generate="no">
+ <value-type name="atomic" generate="no"/>
+ </namespace-type>
- ::
+ <add-function signature="qmlRegisterType(PyTypeObject,const char*,int,int,const char*)" return-type="int">
+ <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistertype"/>
+ </add-function>
- import com.mycompany.qmlcomponents 1.0
+ <add-function signature="qmlRegisterSingletonType(PyTypeObject,const char*,int,int,const char*,PyObject*)" return-type="int">
+ <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qobject_callback"/>
+ </add-function>
- Slider { ... }
+ <add-function signature="qmlRegisterSingletonType(PyTypeObject,const char*,int,int,const char*)" return-type="int">
+ <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qobject_nocallback"/>
+ </add-function>
- Note that it's perfectly reasonable for a library to register types to older versions than the actual version of the library. Indeed, it is normal for the new library to allow QML written to previous versions to continue to work, even if more advanced versions of some of its types are available.
- </inject-documentation>
+ <add-function signature="qmlRegisterSingletonType(const char*,int,int,const char*,PyObject*)" return-type="int">
+ <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qjsvalue"/>
+ </add-function>
- <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistertype"/>
+ <add-function signature="qmlRegisterUncreatableType(PyTypeObject,const char*,int,int,const char*,const char*)" return-type="int">
+ <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregisteruncreatabletype"/>
</add-function>
<enum-type identified-by-value="QML_HAS_ATTACHED_PROPERTIES">
@@ -104,6 +110,7 @@
<object-type name="QJSEngine">
<enum-type name="Extension" flags="Extensions" since="5.6"/>
+ <enum-type name="ObjectOwnership" since="6.0"/>
<add-function signature="toScriptValue(const QVariant&amp;)" return-type="QJSValue">
<inject-code class="target" position="end" file="../glue/qtqml.cpp" snippet="qjsengine-toscriptvalue"/>
</add-function>
@@ -133,7 +140,6 @@
<enum-type name="StartMode"/>
</object-type>
<object-type name="QQmlEngine">
- <enum-type name="ObjectOwnership"/>
<modify-function signature="addImageProvider(const QString&amp;,QQmlImageProviderBase*)">
<modify-argument index="2">
<define-ownership owner="c++"/>
@@ -173,14 +179,14 @@
<extra-includes>
<include file-name="pysideqmlregistertype.h" location="local"/>
</extra-includes>
- <modify-function signature="incubateWhile(volatile bool*,int)" allow-thread="yes">
+ <modify-function signature="incubateWhile(std::atomic&lt;bool&gt;*,int)" allow-thread="yes">
<modify-argument index="1">
- <!-- The replace type is needed to use the VolatileBool_Check macro instead of
- a template conversion function with "volatile bool" as argument. -->
+ The replace type is needed to use the VolatileBool_Check macro instead of
+ a template conversion function with "volatile bool" as argument.
<replace-type modified-type="VolatileBool"/>
<conversion-rule class="native">
- volatile bool * %out =
- &amp;((reinterpret_cast&lt;QtQml_VolatileBoolObject *&gt;(%PYARG_1))->flag);
+ auto volatileBool = reinterpret_cast&lt;QtQml_VolatileBoolObject *&gt;(%PYARG_1);
+ std::atomic&lt;bool&gt; *%out = volatileBool->flag;
</conversion-rule>
</modify-argument>
</modify-function>
diff --git a/sources/pyside2/PySide2/QtQuick/CMakeLists.txt b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt
index 0f453c90e..25f54679f 100644
--- a/sources/pyside2/PySide2/QtQuick/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt
@@ -3,10 +3,12 @@ project(QtQuick)
set(QtQuick_registerType "${QtQuick_SOURCE_DIR}/pysidequickregistertype.cpp")
set(QtQuick_SRC
+${QtQuick_GEN_DIR}/qquickasyncimageprovider_wrapper.cpp
${QtQuick_GEN_DIR}/qquickframebufferobject_wrapper.cpp
${QtQuick_GEN_DIR}/qquickframebufferobject_renderer_wrapper.cpp
${QtQuick_GEN_DIR}/qquicktexturefactory_wrapper.cpp
${QtQuick_GEN_DIR}/qquickimageprovider_wrapper.cpp
+${QtQuick_GEN_DIR}/qquickimageresponse_wrapper.cpp
${QtQuick_GEN_DIR}/qquicktransform_wrapper.cpp
${QtQuick_GEN_DIR}/qquickitem_wrapper.cpp
${QtQuick_GEN_DIR}/qquickitem_updatepaintnodedata_wrapper.cpp
@@ -17,11 +19,9 @@ ${QtQuick_GEN_DIR}/qquickrendercontrol_wrapper.cpp
${QtQuick_GEN_DIR}/qquicktextdocument_wrapper.cpp
${QtQuick_GEN_DIR}/qquickview_wrapper.cpp
${QtQuick_GEN_DIR}/qquickwindow_wrapper.cpp
-${QtQuick_GEN_DIR}/qsgabstractrenderer_wrapper.cpp
${QtQuick_GEN_DIR}/qsgbasicgeometrynode_wrapper.cpp
${QtQuick_GEN_DIR}/qsgclipnode_wrapper.cpp
${QtQuick_GEN_DIR}/qsgdynamictexture_wrapper.cpp
-${QtQuick_GEN_DIR}/qsgengine_wrapper.cpp
#${QtQuick_GEN_DIR}/qsgflatcolormaterial_wrapper.cpp
${QtQuick_GEN_DIR}/qsggeometry_attribute_wrapper.cpp
${QtQuick_GEN_DIR}/qsggeometry_attributeset_wrapper.cpp
@@ -51,13 +51,6 @@ ${QtQuick_GEN_DIR}/qsgtransformnode_wrapper.cpp
${QtQuick_GEN_DIR}/qtquick_module_wrapper.cpp
)
-if (Qt${QT_MAJOR_VERSION}Quick_VERSION VERSION_GREATER 5.5.1)
- set(QtQuick_SRC ${QtQuick_SRC}
- ${QtQuick_GEN_DIR}/qquickasyncimageprovider_wrapper.cpp
- ${QtQuick_GEN_DIR}/qquickimageresponse_wrapper.cpp
- )
-endif()
-
set(QtQuick_include_dirs ${QtQuick_SOURCE_DIR}
${QtQml_SOURCE_DIR}
${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
diff --git a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
index a042ac2cc..acb733f73 100644
--- a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
+++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
@@ -51,56 +51,19 @@
#include "pyside2_qtquick_python.h"
#include "pyside2_qtqml_python.h"
-#ifndef PYSIDE_MAX_QUICK_TYPES
-// Maximum number of different Qt Quick types the user can export to QML using
-// qmlRegisterType. This limit exists because the QML engine instantiates objects
-// by calling a function with one argument (a void* pointer where the object should
-// be created), and thus does not allow us to choose which object to create. Thus
-// we create a C++ factory function for each new registered type at compile time.
-# define PYSIDE_MAX_QUICK_TYPES 50
-#endif // !PYSIDE_MAX_QUICK_TYPES
-
-// All registered python types and their creation functions.
-static PyObject *pyTypes[PYSIDE_MAX_QUICK_TYPES];
-static void (*createFuncs[PYSIDE_MAX_QUICK_TYPES])(void *);
-
// Mutex used to avoid race condition on PySide::nextQObjectMemoryAddr.
static QMutex nextQmlElementMutex;
-// Python object factory functions.
-template<int N>
-struct ElementFactoryBase
-{
- static void createQuickItem(void *memory)
- {
- QMutexLocker locker(&nextQmlElementMutex);
- PySide::setNextQObjectMemoryAddr(memory);
- Shiboken::GilState state;
- PyObject *obj = PyObject_CallObject(pyTypes[N], 0);
- if (!obj || PyErr_Occurred())
- PyErr_Print();
- PySide::setNextQObjectMemoryAddr(0);
- }
-};
-
-template<int N>
-struct ElementFactory : ElementFactoryBase<N>
-{
- static void init()
- {
- createFuncs[N] = &ElementFactoryBase<N>::createQuickItem;
- ElementFactory<N-1>::init();
- }
-};
-
-template<>
-struct ElementFactory<0> : ElementFactoryBase<0>
+static void createQuickItem(void *memory, void *type)
{
- static void init()
- {
- createFuncs[0] = &ElementFactoryBase<0>::createQuickItem;
- }
-};
+ QMutexLocker locker(&nextQmlElementMutex);
+ PySide::setNextQObjectMemoryAddr(memory);
+ Shiboken::GilState state;
+ PyObject *obj = PyObject_CallObject(reinterpret_cast<PyObject *>(type), 0);
+ if (!obj || PyErr_Occurred())
+ PyErr_Print();
+ PySide::setNextQObjectMemoryAddr(0);
+}
#define PY_REGISTER_IF_INHERITS_FROM(className, typeToRegister,typePointerName, \
typeListName, typeMetaObject, type, registered) \
@@ -117,6 +80,40 @@ bool pyTypeObjectInheritsFromClass(PyTypeObject *pyObjType, QByteArray className
return isDerived;
}
+template <typename T>
+struct QPysideQmlMetaTypeInterface : QtPrivate::QMetaTypeInterface
+{
+ const QByteArray name;
+
+ QPysideQmlMetaTypeInterface(const QByteArray &name, const QMetaObject *metaObject = nullptr)
+ : QMetaTypeInterface {
+ /*.revision=*/ 0,
+ /*.alignment=*/ alignof(T),
+ /*.size=*/ sizeof(T),
+ /*.flags=*/ QtPrivate::QMetaTypeTypeFlags<T>::Flags,
+ /*.typeId=*/ 0,
+ /*.metaObject=*/ metaObject,
+ /*.name=*/ name.constData(),
+ /*.defaultCtr=*/ [](const QMetaTypeInterface *, void *addr) { new (addr) T(); },
+ /*.copyCtr=*/ [](const QMetaTypeInterface *, void *addr, const void *other) {
+ new (addr) T(*reinterpret_cast<const T *>(other));
+ },
+ /*.moveCtr=*/ [](const QMetaTypeInterface *, void *addr, void *other) {
+ new (addr) T(std::move(*reinterpret_cast<T *>(other)));
+ },
+ /*.dtor=*/ [](const QMetaTypeInterface *, void *addr) {
+ reinterpret_cast<T *>(addr)->~T();
+ },
+ /*.equals=*/ nullptr,
+ /*.lessThan=*/ nullptr,
+ /*.debugStream=*/ nullptr,
+ /*.dataStreamOut=*/ nullptr,
+ /*.dataStreamIn=*/ nullptr,
+ /*.legacyRegisterOp=*/ nullptr
+ }
+ , name(name) {}
+};
+
template <class WrapperClass>
void registerTypeIfInheritsFromClass(
QByteArray className,
@@ -129,40 +126,11 @@ void registerTypeIfInheritsFromClass(
{
bool shouldRegister = !registered && pyTypeObjectInheritsFromClass(typeToRegister, className);
if (shouldRegister) {
- int ptrType =
- QMetaType::registerNormalizedType(
- typePointerName.constData(),
- QtMetaTypePrivate::QMetaTypeFunctionHelper<WrapperClass *>::Destruct,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<WrapperClass *>::Construct,
- sizeof(WrapperClass *),
- static_cast< ::QFlags<QMetaType::TypeFlag> >(QtPrivate::QMetaTypeTypeFlags<
- WrapperClass *>::Flags),
- typeMetaObject);
- if (ptrType == -1) {
- PyErr_Format(PyExc_TypeError, "Meta type registration of \"%s\" for QML usage failed.",
- typePointerName.constData());
- return;
- }
+ QMetaType ptrType(new QPysideQmlMetaTypeInterface<WrapperClass *>(typePointerName, typeMetaObject));
+ QMetaType lstType(new QPysideQmlMetaTypeInterface<QQmlListProperty<WrapperClass>>(typeListName));
- int lstType =
- QMetaType::registerNormalizedType(
- typeListName.constData(),
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QQmlListProperty<WrapperClass> >
- ::Destruct,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QQmlListProperty<WrapperClass> >
- ::Construct,
- sizeof(QQmlListProperty<WrapperClass>),
- static_cast< ::QFlags<QMetaType::TypeFlag> >(
- QtPrivate::QMetaTypeTypeFlags<QQmlListProperty<WrapperClass> >::Flags),
- nullptr);
- if (lstType == -1) {
- PyErr_Format(PyExc_TypeError, "Meta type registration of \"%s\" for QML usage failed.",
- typeListName.constData());
- return;
- }
-
- type->typeId = ptrType;
- type->listId = lstType;
+ type->typeId = std::move(ptrType);
+ type->listId = std::move(lstType);
type->attachedPropertiesFunction = QQmlPrivate::attachedPropertiesFunc<WrapperClass>();
type->attachedPropertiesMetaObject =
QQmlPrivate::attachedPropertiesMetaObject<WrapperClass>();
@@ -178,16 +146,9 @@ void registerTypeIfInheritsFromClass(
}
bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int versionMinor,
- const char *qmlName, QQmlPrivate::RegisterType *type)
+ const char *qmlName, bool creatable, const char *noCreationReason, QQmlPrivate::RegisterType *type)
{
using namespace Shiboken;
- static int nextType = 0;
-
- if (nextType >= PYSIDE_MAX_QUICK_TYPES) {
- PyErr_Format(PyExc_TypeError,
- "You can only export %d Qt Quick types to QML.", PYSIDE_MAX_QUICK_TYPES);
- return false;
- }
PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
PyTypeObject *qQuickItemPyType =
@@ -208,8 +169,6 @@ bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int v
// there's no way to unregister a QML type.
Py_INCREF(pyObj);
- pyTypes[nextType] = pyObj;
-
// Used in macro registration.
QByteArray pointerName(qmlName);
pointerName.append('*');
@@ -227,11 +186,12 @@ bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int v
if (!registered)
return false;
- type->create = createFuncs[nextType];
- type->version = 0;
+ type->structVersion = 0;
+ type->create = creatable ? createQuickItem : nullptr;
+ type->noCreationReason = noCreationReason;
+ type->userdata = pyObj;
type->uri = uri;
- type->versionMajor = versionMajor;
- type->versionMinor = versionMinor;
+ type->version = QTypeRevision::fromVersion(versionMajor, versionMinor);
type->elementName = qmlName;
type->metaObject = metaObject;
@@ -239,14 +199,12 @@ bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int v
type->extensionMetaObject = 0;
type->customParser = 0;
- ++nextType;
return true;
}
void PySide::initQuickSupport(PyObject *module)
{
Q_UNUSED(module);
- ElementFactory<PYSIDE_MAX_QUICK_TYPES - 1>::init();
#ifdef PYSIDE_QML_SUPPORT
setQuickRegisterItemFunction(quickRegisterType);
#endif
diff --git a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
index 223eff773..31e05979b 100644
--- a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
+++ b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
@@ -107,16 +107,9 @@
<enum-type name="TextRenderType" since="5.10"/>
</object-type>
- <object-type name="QSGAbstractRenderer">
- <enum-type name="ClearModeBit" flags="ClearMode"/>
- <enum-type name="MatrixTransformFlag" flags="MatrixTransformFlags" since="5.14"/>
- </object-type>
<object-type name="QSGBasicGeometryNode"/>
<object-type name="QSGClipNode"/>
<object-type name="QSGDynamicTexture"/>
- <object-type name="QSGEngine">
- <enum-type name="CreateTextureOption" flags="CreateTextureOptions"/>
- </object-type>
<!-- <object-type name="QSGFlatColorMaterial"/> -->
<object-type name="QSGGeometry">
<enum-type name="DataPattern"/>
diff --git a/sources/pyside2/PySide2/QtScript/CMakeLists.txt b/sources/pyside2/PySide2/QtScript/CMakeLists.txt
deleted file mode 100644
index 81d6c03d3..000000000
--- a/sources/pyside2/PySide2/QtScript/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-project(QtScript)
-
-set(QtScript_SRC
-${QtScript_GEN_DIR}/qscriptable_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptclass_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptclasspropertyiterator_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptcontext_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptcontextinfo_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptengineagent_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptprogram_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptengine_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptextensioninterface_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptextensionplugin_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptstring_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptvalue_wrapper.cpp
-${QtScript_GEN_DIR}/qscriptvalueiterator_wrapper.cpp
-# module is always needed
-${QtScript_GEN_DIR}/qtscript_module_wrapper.cpp
-)
-
-set(QtScript_glue_sources
- "${QtScript_SOURCE_DIR}/qscript_value_iterator_glue.cpp"
-)
-
-set(QtScript_include_dirs ${QtScript_SOURCE_DIR}
- ${QtScript_BINARY_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Script_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- )
-set(QtScript_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Script_LIBRARIES})
-set(QtScript_deps QtCore)
-create_pyside_module(NAME QtScript
- INCLUDE_DIRS QtScript_include_dirs
- LIBRARIES QtScript_libraries
- DEPS QtScript_deps
- TYPESYSTEM_PATH QtScript_SOURCE_DIR
- SOURCES QtScript_SRC
- GLUE_SOURCES QtScript_glue_sources)
diff --git a/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp b/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp
deleted file mode 100644
index 11dfd19b0..000000000
--- a/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-%PYARG_0 = Shiboken::Object::newObject(
- reinterpret_cast<SbkObjectType *>(Shiboken::SbkType< ::QScriptValueIterator >()),
- new QScriptValueIterator(*%CPPSELF), true, true);
diff --git a/sources/pyside2/PySide2/QtScript/typesystem_script.xml b/sources/pyside2/PySide2/QtScript/typesystem_script.xml
deleted file mode 100644
index 1fdad5d47..000000000
--- a/sources/pyside2/PySide2/QtScript/typesystem_script.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<typesystem package="PySide2.QtScript">
- <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
-
- <object-type name="QScriptable"/>
- <object-type name="QScriptClass">
- <enum-type name="Extension"/>
- <enum-type name="QueryFlag"/>
- </object-type>
- <object-type name="QScriptClassPropertyIterator"/>
- <object-type name="QScriptContext">
- <enum-type name="Error"/>
- <enum-type name="ExecutionState"/>
- </object-type>
- <value-type name="QScriptContextInfo">
- <enum-type name="FunctionType"/>
- </value-type>
- <object-type name="QScriptEngineAgent">
- <enum-type name="Extension"/>
- </object-type>
- <object-type name="QScriptEngine">
- <enum-type name="QObjectWrapOption" flags="QObjectWrapOptions"/>
- <enum-type name="ValueOwnership"/>
- <!-- Not supported BUG #957-->
- <modify-function signature="scriptValueFromQMetaObject()" remove="all"/>
- </object-type>
- <object-type name="QScriptExtensionInterface"/>
- <object-type name="QScriptExtensionPlugin"/>
- <value-type name="QScriptProgram" since="4.7"/>
- <value-type name="QScriptString">
- <modify-function signature="toArrayIndex(bool*)const">
- <modify-argument index="1">
- <remove-argument/>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_bool*"/>
- </inject-code>
- </modify-function>
- </value-type>
- <value-type name="QScriptValue">
- <enum-type name="PropertyFlag" flags="PropertyFlags"/>
- <enum-type name="ResolveFlag" flags="ResolveFlags"/>
- <enum-type name="SpecialValue"/>
- <add-function signature="__repr__" return-type="PyObject*">
- <inject-code class="target" position="beginning" file="../glue/qtscript.cpp" snippet="qscriptvalue-repr"/>
- </add-function>
- <add-function signature="__mgetitem__">
- <inject-code file="../glue/qtscript.cpp" snippet="qscriptvalue-mgetitem"/>
- </add-function>
- <add-function signature="__iter__()" return-type="PyObject*">
- <inject-code file="qscript_value_iterator_glue.cpp"/>
- </add-function>
- </value-type>
- <object-type name="QScriptValueIterator">
- <add-function signature="__iter__()" return-type="PyObject*">
- <inject-code>
- <insert-template name="__iter__"/>
- </inject-code>
- </add-function>
- <add-function signature="__next__()" return-type="PyObject*">
- <inject-code file="../glue/qtscript.cpp" snippet="qscriptvalueiterator-next"/>
- </add-function>
- </object-type>
-</typesystem>
-
diff --git a/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt b/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt
deleted file mode 100644
index 7c19856cb..000000000
--- a/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-project(QtScriptTools)
-
-set(QtScriptTools_SRC
-${QtScriptTools_GEN_DIR}/qscriptenginedebugger_wrapper.cpp
-# module is always needed
-${QtScriptTools_GEN_DIR}/qtscripttools_module_wrapper.cpp
-)
-
-set(QtScriptTools_include_dirs ${QtScriptTools_SOURCE_DIR}
- ${QtScriptTools_BINARY_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Script_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}ScriptTools_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- ${QtGui_GEN_DIR}
- ${QtWidgets_GEN_DIR}
- ${QtScript_GEN_DIR}
- )
-
-set(QtScriptTools_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Script_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}ScriptTools_LIBRARIES})
-
-set(QtScriptTools_deps QtCore QtScript QtGui QtWidgets)
-
-create_pyside_module(NAME QtScriptTools
- INCLUDE_DIRS QtScriptTools_include_dirs
- LIBRARIES QtScriptTools_libraries
- DEPS QtScriptTools_deps
- TYPESYSTEM_PATH QtScriptTools_SOURCE_DIR
- SOURCES QtScriptTools_SRC)
diff --git a/sources/pyside2/PySide2/QtSql/QtSql_global.pre.h.in b/sources/pyside2/PySide2/QtSql/QtSql_global.pre.h.in
index 0c20c1888..c56bc78c1 100644
--- a/sources/pyside2/PySide2/QtSql/QtSql_global.pre.h.in
+++ b/sources/pyside2/PySide2/QtSql/QtSql_global.pre.h.in
@@ -1,5 +1,5 @@
// QT_WIDGETS_LIB must be defined for QSqlRelationalDelegate to become visible.
-#if @Qt5Widgets_FOUND@
+#if @Qt6Widgets_FOUND@
# define QT_WIDGETS_LIB
#endif
diff --git a/sources/pyside2/PySide2/QtSvg/CMakeLists.txt b/sources/pyside2/PySide2/QtSvg/CMakeLists.txt
index 19768274d..34f72219e 100644
--- a/sources/pyside2/PySide2/QtSvg/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtSvg/CMakeLists.txt
@@ -1,10 +1,8 @@
project(QtSvg)
set(QtSvg_SRC
-${QtSvg_GEN_DIR}/qgraphicssvgitem_wrapper.cpp
${QtSvg_GEN_DIR}/qsvggenerator_wrapper.cpp
${QtSvg_GEN_DIR}/qsvgrenderer_wrapper.cpp
-${QtSvg_GEN_DIR}/qsvgwidget_wrapper.cpp
# module is always needed
${QtSvg_GEN_DIR}/qtsvg_module_wrapper.cpp
)
@@ -13,20 +11,17 @@ set(QtSvg_include_dirs ${QtSvg_SOURCE_DIR}
${QtSvg_BINARY_DIR}
${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
${Qt${QT_MAJOR_VERSION}Svg_INCLUDE_DIRS}
${libpyside_SOURCE_DIR}
${QtCore_GEN_DIR}
${QtGui_GEN_DIR}
- ${QtWidgets_GEN_DIR}
)
set(QtSvg_libraries pyside2
${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
${Qt${QT_MAJOR_VERSION}Svg_LIBRARIES}
)
-set(QtSvg_deps QtWidgets)
+set(QtSvg_deps QtGui)
create_pyside_module(NAME QtSvg
INCLUDE_DIRS QtSvg_include_dirs
diff --git a/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml b/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml
index 079a79e96..c921c631e 100644
--- a/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml
+++ b/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml
@@ -2,7 +2,7 @@
<!--
/****************************************************************************
**
-** 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,10 +40,9 @@
****************************************************************************/
-->
<typesystem package="PySide2.QtSvg">
- <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
+ <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
<object-type name="QSvgRenderer"/>
- <object-type name="QSvgWidget"/>
<object-type name="QSvgGenerator">
<modify-function signature="setOutputDevice(QIODevice*)">
@@ -59,16 +58,4 @@
</modify-function>
</object-type>
- <object-type name="QGraphicsSvgItem">
- <modify-function signature="QGraphicsSvgItem(QGraphicsItem*)">
- <modify-argument index="this">
- <parent index="1" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="QGraphicsSvgItem(const QString&amp;,QGraphicsItem*)">
- <modify-argument index="this">
- <parent index="2" action="add"/>
- </modify-argument>
- </modify-function>
- </object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtSvgWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtSvgWidgets/CMakeLists.txt
new file mode 100644
index 000000000..e04d5194b
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSvgWidgets/CMakeLists.txt
@@ -0,0 +1,39 @@
+project(QtSvgWidgets)
+
+set(QtSvgWidgets_SRC
+${QtSvgWidgets_GEN_DIR}/qgraphicssvgitem_wrapper.cpp
+${QtSvgWidgets_GEN_DIR}/qsvgwidget_wrapper.cpp
+# module is always needed
+${QtSvgWidgets_GEN_DIR}/qtsvgwidgets_module_wrapper.cpp
+)
+
+set(QtSvgWidgets_include_dirs ${QtSvgWidgets_SOURCE_DIR}
+ ${QtSvgWidgets_BINARY_DIR}
+ ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}Svg_INCLUDE_DIRS}
+ ${Qt${QT_MAJOR_VERSION}SvgWidgets_INCLUDE_DIRS}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtSvg_GEN_DIR}
+ )
+
+set(QtSvgWidgets_libraries pyside2
+ ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}Svg_LIBRARIES}
+ ${Qt${QT_MAJOR_VERSION}SvgWidgets_LIBRARIES}
+ )
+
+set(QtSvgWidgets_deps QtSvg QtWidgets)
+
+create_pyside_module(NAME QtSvgWidgets
+ INCLUDE_DIRS QtSvgWidgets_include_dirs
+ LIBRARIES QtSvgWidgets_libraries
+ DEPS QtSvgWidgets_deps
+ TYPESYSTEM_PATH QtSvgWidgets_SOURCE_DIR
+ SOURCES QtSvgWidgets_SRC)
diff --git a/sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml b/sources/pyside2/PySide2/QtSvgWidgets/typesystem_svgwidgets.xml
index eefa09a54..a6aa5b922 100644
--- a/sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml
+++ b/sources/pyside2/PySide2/QtSvgWidgets/typesystem_svgwidgets.xml
@@ -2,7 +2,7 @@
<!--
/****************************************************************************
**
-** 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.
@@ -39,17 +39,22 @@
**
****************************************************************************/
-->
-<typesystem package="PySide2.QtScriptTools">
- <load-typesystem name="QtScript/typesystem_script.xml" generate="no"/>
- <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
- <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
+<typesystem package="PySide2.QtSvgWidgets">
+ <load-typesystem name="QtSvg/typesystem_svg.xml" generate="no"/>
+ <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
- <object-type name="QScriptEngineDebugger">
- <enum-type name="DebuggerAction"/>
- <enum-type name="DebuggerState" since="4.6"/>
- <enum-type name="DebuggerWidget"/>
- <extra-includes>
- <include file-name="QScriptEngine" location="global"/>
- </extra-includes>
- </object-type>
+ <object-type name="QSvgWidget"/>
+
+ <object-type name="QGraphicsSvgItem">
+ <modify-function signature="QGraphicsSvgItem(QGraphicsItem*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QGraphicsSvgItem(const QString&amp;,QGraphicsItem*)">
+ <modify-argument index="this">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtTest/QtTest_global.pre.h.in b/sources/pyside2/PySide2/QtTest/QtTest_global.pre.h.in
index 65daf1b84..da5534b82 100644
--- a/sources/pyside2/PySide2/QtTest/QtTest_global.pre.h.in
+++ b/sources/pyside2/PySide2/QtTest/QtTest_global.pre.h.in
@@ -1,5 +1,5 @@
// QT_WIDGETS_LIB changes code generation in pysideqtesttouch.h
-#if @Qt5Widgets_FOUND@
+#if @Qt6Widgets_FOUND@
# define QT_WIDGETS_LIB
#endif
diff --git a/sources/pyside2/PySide2/QtTest/typesystem_test.xml b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
index f7facaf7d..eb638befb 100644
--- a/sources/pyside2/PySide2/QtTest/typesystem_test.xml
+++ b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
@@ -89,14 +89,14 @@
The problem that costed my days of bug hunting is the fact that shiboken gives
misleading error messages. The messages that I could not get rid of were
- signature 'generateTouchEvent(QWidget*,QTouchDevice*,bool)' for function modification in 'QTest' not found. Possible candidates:
- signature 'generateTouchEvent(QWindow*,QTouchDevice*,bool)' for function modification in 'QTest' not found. Possible candidates:
+ signature 'generateTouchEvent(QWidget*,QInputDevice*,bool)' for function modification in 'QTest' not found. Possible candidates:
+ signature 'generateTouchEvent(QWindow*,QInputDevice*,bool)' for function modification in 'QTest' not found. Possible candidates:
I always thought that for some reason the functions were not recognized, or the arguments somehow
do not match their declaration. Only late in the project, I learnt that also
a simply missing type name in the argument list leads to this message.
- <object-type name="QTouchDevice">
+ <object-type name="QInputDevice">
<enum-type name="CapabilityFlag" flags="Capabilities"/>
<enum-type name="DeviceType"/>
</object-type>
@@ -151,12 +151,12 @@
</modify-argument>
</modify-function>
</object-type>
- <modify-function signature="generateTouchEvent(QWidget*,QTouchDevice*,bool)" rename="touchEvent" since="4.6">
+ <modify-function signature="generateTouchEvent(QWidget*,QPointingDevice*,bool)" rename="touchEvent" since="4.6">
<modify-argument index="return">
<define-ownership class="target" owner="target"/>
</modify-argument>
</modify-function>
- <modify-function signature="generateTouchEvent(QWindow*,QTouchDevice*,bool)" rename="touchEvent" since="4.6">
+ <modify-function signature="generateTouchEvent(QWindow*,QPointingDevice*,bool)" rename="touchEvent" since="4.6">
<modify-argument index="return">
<define-ownership class="target" owner="target"/>
</modify-argument>
diff --git a/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt b/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt
deleted file mode 100644
index 4220e46bf..000000000
--- a/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-project(QtWebKit)
-
-set(QtWebKit_SRC
-${QtWebKit_GEN_DIR}/webcore_wrapper.cpp
-# module is always needed
-${QtWebKit_GEN_DIR}/qtwebkit_module_wrapper.cpp
-)
-
-set(QtWebKit_include_dirs ${QtWebKit_SOURCE_DIR}
- ${QtWebKit_BINARY_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Network_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}WebKit_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- ${QtGui_GEN_DIR}
- ${QtWidgets_GEN_DIR}
- ${QtNetwork_GEN_DIR}
- )
-set(QtWebKit_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}WebKit_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Network_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- )
-set(QtWebKit_deps QtGui QtNetwork)
-create_pyside_module(NAME QtWebKit
- INCLUDE_DIRS QtWebKit_include_dirs
- LIBRARIES QtWebKit_libraries
- DEPS QtWebKit_deps
- TYPESYSTEM_PATH QtWebKit_SOURCE_DIR
- SOURCES QtWebKit_SRC)
-
diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt
deleted file mode 100644
index 0bf660a62..000000000
--- a/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-project(QtWebKitWidgets)
-
-set(QtWebKitWidgets_SRC
-${QtWebKitWidgets_GEN_DIR}/qgraphicswebview_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebdatabase_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebelement_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebelementcollection_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebframe_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebhistory_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebhistoryinterface_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebhistoryitem_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebhittestresult_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebinspector_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_choosemultiplefilesextensionoption_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_choosemultiplefilesextensionreturn_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_errorpageextensionoption_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_errorpageextensionreturn_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_extensionoption_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_extensionreturn_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_viewportattributes_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpage_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpluginfactory_mimetype_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpluginfactory_plugin_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebpluginfactory_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebsecurityorigin_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebsettings_wrapper.cpp
-${QtWebKitWidgets_GEN_DIR}/qwebview_wrapper.cpp
-# module is always needed
-${QtWebKitWidgets_GEN_DIR}/qtwebkitwidgets_module_wrapper.cpp
-)
-
-set(QtWebKitWidgets_include_dirs
- ${QtWebKitWidgets_SOURCE_DIR}
- ${QtWebKitWidgets_BINARY_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Widgets_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}WebKit_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}PrintSupport_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}Network_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}WebKitWidgets_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- ${QtGui_GEN_DIR}
- ${QtWidgets_GEN_DIR}
- ${QtPrintSupport_GEN_DIR}
- ${QtWebKit_GEN_DIR}
- ${QtNetwork_GEN_DIR}
- )
-set(QtWebKitWidgets_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}WebKit_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}WebKitWidgets_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Network_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Widgets_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- )
-set(QtWebKitWidgets_deps QtWidgets QtPrintSupport QtNetwork)
-create_pyside_module(NAME QtWebKitWidgets
- INCLUDE_DIRS QtWebKitWidgets_include_dirs
- LIBRARIES QtWebKitWidgets_libraries
- DEPS QtWebKitWidgets_deps
- TYPESYSTEM_PATH QtWebKitWidgets_SOURCE_DIR
- SOURCES QtWebKitWidgets_SRC)
-
diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
deleted file mode 100644
index 7760c1c3d..000000000
--- a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
+++ /dev/null
@@ -1,211 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<typesystem package="PySide2.QtWebKitWidgets">
- <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
- <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
- <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
- <load-typesystem name="QtWebKit/typesystem_webkit.xml" generate="no"/>
- <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/>
- <load-typesystem name="QtPrintSupport/typesystem_printsupport.xml" generate="no"/>
- <load-typesystem name="templates/webkitwidgets_common.xml" generate="no"/>
-
- <value-type name="QWebDatabase"/>
-
- <object-type name="QWebPluginFactory">
- <enum-type name="Extension"/>
- <value-type name="Plugin"/>
- <value-type name="MimeType"/>
- <modify-function signature="create(const QString &amp;,const QUrl &amp;,const QStringList &amp;,const QStringList &amp;)const">
- <modify-argument index="return">
- <define-ownership class="native" owner="c++"/>
- <define-ownership class="target" owner="target"/>
- </modify-argument>
- </modify-function>
- </object-type>
-
- <object-type name="QWebHistory"/>
- <object-type name="QWebHistoryInterface"/>
- <value-type name="QWebHistoryItem"/>
-
- <value-type name="QWebSecurityOrigin">
- <enum-type name="SubdomainSetting"/>
- </value-type>
-
- <object-type name="QWebSettings">
- <enum-type name="FontFamily"/>
- <enum-type name="FontSize"/>
- <enum-type name="ThirdPartyCookiePolicy"/>
- <enum-type name="WebAttribute"/>
- <enum-type name="WebGraphic"/>
- </object-type>
-
- <object-type name="QWebView">
- <modify-function signature="setPage(QWebPage*)">
- <modify-argument index="1">
- <reference-count action="set"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="page()const">
- <modify-argument index="return">
- <define-ownership class="target" owner="default"/>
- </modify-argument>
- <inject-code position="end" file="../glue/qtwebkitwidgets.cpp" snippet="qwebview-page"/>
- </modify-function>
- <modify-function signature="print(QPrinter*)const" rename="print_"/>
- </object-type>
-
- <value-type name="QWebElement" since="4.6">
- <enum-type name="StyleResolveStrategy"/>
- </value-type>
-
- <value-type name="QWebElementCollection" since="4.6">
- <add-function signature="__len__">
- <inject-code file="../glue/qtwebkitwidgets.cpp" snippet="qwebelementcollection-len"/>
- </add-function>
- <add-function signature="__getitem__">
- <inject-code file="../glue/qtwebkitwidgets.cpp" snippet="qwebelementcollection-getitem"/>
- </add-function>
- </value-type>
-
- <object-type name="QWebFrame">
- <enum-type name="RenderLayer" flags="RenderLayers" since="4.6"/>
- <enum-type name="ValueOwnership"/>
- <modify-function signature="addToJavaScriptWindowObject(QString,QObject*,QWebFrame::ValueOwnership)">
- <modify-argument index="2">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="print(QPrinter*)const" rename="print_"/>
- <modify-function signature="metaData()const">
- <modify-argument index="return">
- <replace-type modified-type="PyObject"/>
- </modify-argument>
- <inject-code position="end" file="../glue/qtwebkitwidgets.cpp" snippet="qwebframe-metadata" />
- </modify-function>
- </object-type>
-
- <object-type name="QWebPage">
- <enum-type name="ErrorDomain"/>
- <enum-type name="Extension"/>
- <enum-type name="Feature"/>
- <enum-type name="FindFlag" flags="FindFlags"/>
- <enum-type name="LinkDelegationPolicy"/>
- <enum-type name="NavigationType"/>
- <enum-type name="PermissionPolicy" since="4.8" revision="4800"/>
- <enum-type name="VisibilityState"/>
- <enum-type name="WebAction"/>
- <enum-type name="WebWindowType"/>
-
- <value-type name="ChooseMultipleFilesExtensionOption"/>
- <value-type name="ChooseMultipleFilesExtensionReturn"/>
- <value-type name="ErrorPageExtensionOption" since="4.6"/>
- <value-type name="ErrorPageExtensionReturn" since="4.6"/>
- <value-type name="ExtensionOption"/>
- <value-type name="ExtensionReturn"/>
- <value-type name="ViewportAttributes"/>
-
- <modify-function signature="extension(QWebPage::Extension,const QWebPage::ExtensionOption*,QWebPage::ExtensionReturn*)">
- <modify-argument index="2" invalidate-after-use="yes">
- <conversion-rule class="target">
- <insert-template name="qwebpage_extension_argument_conversion">
- <replace from="$TYPE_SUFFIX" to="Option"/>
- </insert-template>
- </conversion-rule>
- </modify-argument>
- <modify-argument index="3" invalidate-after-use="yes">
- <conversion-rule class="target">
- <insert-template name="qwebpage_extension_argument_conversion">
- <replace from="$TYPE_SUFFIX" to="Return"/>
- </insert-template>
- </conversion-rule>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="setNetworkAccessManager(QNetworkAccessManager*)">
- <modify-argument index="1">
- <reference-count action="set"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="networkAccessManager()const">
- <modify-argument index="return">
- <reference-count action="set" variable-name="setNetworkAccessManager(QNetworkAccessManager*)1"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="view()const">
- <modify-argument index="return">
- <define-ownership owner="default"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="pluginFactory()const">
- <modify-argument index="return">
- <define-ownership owner="default"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="javaScriptPrompt(QWebFrame*,const QString &amp;,const QString &amp;,QString*)">
- <modify-argument index="4">
- <remove-argument />
- <conversion-rule class="native">
- <insert-template name="qstring_remove"/>
- </conversion-rule>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="pysequence_qstring"/>
- </conversion-rule>
- <conversion-rule class="target">
- <insert-template name="qstring_pytuple"/>
- </conversion-rule>
- </modify-argument>
- </modify-function>
-
- <add-function signature="qt_metacall()">
- <inject-code class="native" file="../glue/qtwebkitwidgets.cpp" snippet="qwebpage-qt-metacall"/>
- </add-function>
- </object-type>
-
- <value-type name="QWebHitTestResult"/>
-
- <object-type name="QGraphicsWebView" since="4.6"/>
- <object-type name="QWebInspector" since="4.6"/>
-</typesystem>
diff --git a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt
index 506a6fc78..3df3b8d19 100644
--- a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt
@@ -9,8 +9,6 @@ ${QtWidgets_GEN_DIR}/qabstractitemview_wrapper.cpp
${QtWidgets_GEN_DIR}/qabstractscrollarea_wrapper.cpp
${QtWidgets_GEN_DIR}/qabstractslider_wrapper.cpp
${QtWidgets_GEN_DIR}/qabstractspinbox_wrapper.cpp
-${QtWidgets_GEN_DIR}/qaction_wrapper.cpp
-${QtWidgets_GEN_DIR}/qactiongroup_wrapper.cpp
${QtWidgets_GEN_DIR}/qapplication_wrapper.cpp
${QtWidgets_GEN_DIR}/qboxlayout_wrapper.cpp
${QtWidgets_GEN_DIR}/qbuttongroup_wrapper.cpp
@@ -26,11 +24,9 @@ ${QtWidgets_GEN_DIR}/qcompleter_wrapper.cpp
${QtWidgets_GEN_DIR}/qdatawidgetmapper_wrapper.cpp
${QtWidgets_GEN_DIR}/qdateedit_wrapper.cpp
${QtWidgets_GEN_DIR}/qdatetimeedit_wrapper.cpp
-${QtWidgets_GEN_DIR}/qdesktopwidget_wrapper.cpp
${QtWidgets_GEN_DIR}/qdial_wrapper.cpp
${QtWidgets_GEN_DIR}/qdialog_wrapper.cpp
${QtWidgets_GEN_DIR}/qdialogbuttonbox_wrapper.cpp
-${QtWidgets_GEN_DIR}/qdirmodel_wrapper.cpp
${QtWidgets_GEN_DIR}/qdockwidget_wrapper.cpp
${QtWidgets_GEN_DIR}/qdoublespinbox_wrapper.cpp
${QtWidgets_GEN_DIR}/qerrormessage_wrapper.cpp
@@ -92,7 +88,6 @@ ${QtWidgets_GEN_DIR}/qinputdialog_wrapper.cpp
${QtWidgets_GEN_DIR}/qitemdelegate_wrapper.cpp
${QtWidgets_GEN_DIR}/qitemeditorcreatorbase_wrapper.cpp
${QtWidgets_GEN_DIR}/qitemeditorfactory_wrapper.cpp
-${QtWidgets_GEN_DIR}/qkeyeventtransition_wrapper.cpp
${QtWidgets_GEN_DIR}/qkeysequenceedit_wrapper.cpp
${QtWidgets_GEN_DIR}/qlabel_wrapper.cpp
${QtWidgets_GEN_DIR}/qlayout_wrapper.cpp
@@ -108,8 +103,6 @@ ${QtWidgets_GEN_DIR}/qmdisubwindow_wrapper.cpp
${QtWidgets_GEN_DIR}/qmenu_wrapper.cpp
${QtWidgets_GEN_DIR}/qmenubar_wrapper.cpp
${QtWidgets_GEN_DIR}/qmessagebox_wrapper.cpp
-${QtWidgets_GEN_DIR}/qmouseeventtransition_wrapper.cpp
-${QtWidgets_GEN_DIR}/qopenglwidget_wrapper.cpp
${QtWidgets_GEN_DIR}/qpangesture_wrapper.cpp
${QtWidgets_GEN_DIR}/qpinchgesture_wrapper.cpp
${QtWidgets_GEN_DIR}/qplaintextdocumentlayout_wrapper.cpp
@@ -124,7 +117,6 @@ ${QtWidgets_GEN_DIR}/qscrollarea_wrapper.cpp
${QtWidgets_GEN_DIR}/qscrollbar_wrapper.cpp
${QtWidgets_GEN_DIR}/qscroller_wrapper.cpp
${QtWidgets_GEN_DIR}/qscrollerproperties_wrapper.cpp
-${QtWidgets_GEN_DIR}/qshortcut_wrapper.cpp
${QtWidgets_GEN_DIR}/qsizegrip_wrapper.cpp
${QtWidgets_GEN_DIR}/qsizepolicy_wrapper.cpp
${QtWidgets_GEN_DIR}/qslider_wrapper.cpp
@@ -190,9 +182,6 @@ ${QtWidgets_GEN_DIR}/qtreeview_wrapper.cpp
${QtWidgets_GEN_DIR}/qtreewidget_wrapper.cpp
${QtWidgets_GEN_DIR}/qtreewidgetitem_wrapper.cpp
${QtWidgets_GEN_DIR}/qtreewidgetitemiterator_wrapper.cpp
-${QtWidgets_GEN_DIR}/qundocommand_wrapper.cpp
-${QtWidgets_GEN_DIR}/qundogroup_wrapper.cpp
-${QtWidgets_GEN_DIR}/qundostack_wrapper.cpp
${QtWidgets_GEN_DIR}/qundoview_wrapper.cpp
${QtWidgets_GEN_DIR}/qvboxlayout_wrapper.cpp
${QtWidgets_GEN_DIR}/qwhatsthis_wrapper.cpp
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
index 155591b0c..d067e1aba 100644
--- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -235,7 +235,7 @@
<object-type name="QLayoutItem">
- <modify-function signature="widget()">
+ <modify-function signature="widget()const">
<modify-argument index="return">
<define-ownership class="target" owner="default"/>
</modify-argument>
@@ -426,11 +426,6 @@
<reference-count action="set"/>
</modify-argument>
</modify-function>
- <modify-function signature="viewOptions()const">
- <modify-argument index="return">
- <replace-default-expression with="QStyleOptionViewItem()"/>
- </modify-argument>
- </modify-function>
<modify-function signature="model()const">
<modify-argument index="return">
<!-- Defining ownership as "default" avoids the object to be automatically
@@ -461,19 +456,6 @@
<enum-type name="SliderAction"/>
<enum-type name="SliderChange"/>
</object-type>
- <object-type name="QActionGroup">
- <enum-type name="ExclusionPolicy" since="5.14"/>
- <modify-function signature="addAction(QAction*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="removeAction(QAction*)">
- <modify-argument index="1">
- <parent index="this" action="remove"/>
- </modify-argument>
- </modify-function>
- </object-type>
<object-type name="QCheckBox"/>
<object-type name="QCommonStyle">
</object-type>
@@ -525,18 +507,7 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QDirModel" polymorphic-id-expression="qobject_cast&lt;QDirModel*&gt;(%1)">
- <enum-type name="Roles"/>
- <modify-function signature="setIconProvider(QFileIconProvider*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- </object-type>
- <object-type name="QFileIconProvider">
- <enum-type name="IconType"/>
- <enum-type name="Option" flags="Options"/>
- </object-type>
+ <object-type name="QFileIconProvider"/>
<object-type name="QWizard">
<enum-type name="WizardButton"/>
<enum-type name="WizardOption" flags="WizardOptions"/>
@@ -638,8 +609,6 @@
<object-type name="QItemDelegate">
<!-- ### "doLayout(...)" is an internal method. -->
<modify-function signature="doLayout(QStyleOptionViewItem,QRect*,QRect*,QRect*,bool)const" remove="all"/>
- <!-- ### "selected(QPixmap,QPalette,bool)" is an internal method. -->
- <modify-function signature="selected(QPixmap,QPalette,bool)const" remove="all"/>
<!-- ### -->
<modify-function signature="drawCheck(QPainter*,QStyleOptionViewItem,QRect,Qt::CheckState)const">
<modify-argument index="1" invalidate-after-use="yes"/>
@@ -963,15 +932,6 @@
</modify-function>
</object-type>
- <object-type name="QShortcut">
- <add-function signature="QShortcut(QKeySequence&amp;,QWidget*,PyCallable*,Qt::ShortcutContext)">
- <modify-argument index="4">
- <replace-default-expression with="Qt::WindowShortcut"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtwidgets.cpp" snippet="qshortcut-1"/>
- <inject-code class="target" position="end" file="../glue/qtwidgets.cpp" snippet="qshortcut-2"/>
- </add-function>
- </object-type>
<object-type name="QSpacerItem"/>
<object-type name="QStatusBar">
<modify-function signature="addWidget(QWidget*,int)">
@@ -1078,40 +1038,6 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QUndoCommand">
- <modify-function signature="mergeWith(const QUndoCommand*)">
- <modify-argument index="1" invalidate-after-use="yes"/>
- </modify-function>
- </object-type>
- <object-type name="QUndoGroup">
- <modify-function signature="addStack(QUndoStack*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="removeStack(QUndoStack*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- </object-type>
- <object-type name="QUndoStack">
- <modify-function signature="createUndoAction(QObject*,const QString&amp;)const">
- <modify-argument index="return">
- <parent index="1" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="createRedoAction(QObject*,const QString&amp;)const">
- <modify-argument index="return">
- <parent index="1" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="push(QUndoCommand*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- </object-type>
<object-type name="QUndoView">
<modify-function signature="setGroup(QUndoGroup*)">
<modify-argument index="1">
@@ -1252,14 +1178,10 @@
<object-type name="QColorDialog">
<enum-type name="ColorDialogOption" flags="ColorDialogOptions"/>
<modify-function signature="getColor(const QColor&amp;,QWidget*,const QString&amp;,QFlags&lt;QColorDialog::ColorDialogOption>)" allow-thread="yes"/>
- <!-- Qt5: obsolete -->
- <modify-function signature="getRgba(unsigned int,bool*,QWidget*)" remove="all"/>
</object-type>
<object-type name="QLayout">
<inject-code class="native" position="beginning" file="../glue/qtwidgets.cpp" snippet="qlayout-help-functions"/>
- <!-- Becomes a real Q_OPROPERTY in Qt 6 -->
- <property name="contentsMargins" type="QMargins" get="contentsMargins" set="setContentsMargins"/>
<enum-type name="SizeConstraint"/>
<modify-function signature="itemAt(int)const">
@@ -1564,16 +1486,6 @@
</inject-code>
</modify-function>
- <modify-function signature="getDouble(QWidget*,const QString&amp;,const QString&amp;,double,double,double,int,bool*,QFlags&lt;Qt::WindowType&gt;)" allow-thread="yes">
- <modify-argument index="8">
- <remove-default-expression/>
- <remove-argument/>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg"/>
- </inject-code>
- </modify-function>
-
<modify-function signature="getDouble(QWidget*,const QString&amp;,const QString&amp;,double,double,double,int,bool*,QFlags&lt;Qt::WindowType&gt;,double)" allow-thread="yes">
<modify-argument index="8">
<remove-default-expression/>
@@ -2026,7 +1938,7 @@
<object-type name="QWidget" delete-in-main-thread="true">
<!-- see QWindow::nativeEvent(), QAbstractNativeEventFilter::nativeEventFilter() -->
- <modify-function signature="nativeEvent(const QByteArray &amp;,void*,long*)">
+ <modify-function signature="nativeEvent(const QByteArray &amp;,void*,qintptr*)">
<modify-argument index="3">
<remove-argument/>
<conversion-rule class="native">
@@ -2114,7 +2026,7 @@
<rename to="event"/>
</modify-argument>
</modify-function>
- <modify-function signature="enterEvent(QEvent*)">
+ <modify-function signature="enterEvent(QEnterEvent*)">
<modify-argument index="1" invalidate-after-use="yes">
<rename to="event"/>
</modify-argument>
@@ -2227,33 +2139,6 @@
</modify-argument>
</modify-function>
- <modify-function signature="getContentsMargins(int*,int*,int*,int*)const">
- <modify-argument index="0">
- <replace-type modified-type="PyObject"/>
- </modify-argument>
- <modify-argument index="1">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="2">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="4">
- <remove-argument/>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_number*,number*,number*,number*">
- <replace from="$TYPE" to="int"/>
- </insert-template>
- </inject-code>
- <inject-code class="native" position="end">
- <insert-template name="fix_native_return_number*,number*,number*,number*">
- <replace from="$TYPE" to="int"/>
- </insert-template>
- </inject-code>
- </modify-function>
<modify-function signature="insertAction(QAction*,QAction*)">
<modify-argument index="2">
<parent index="this" action="add"/>
@@ -2412,13 +2297,8 @@
</modify-argument>
</modify-function>
- <modify-function signature="pixmap()const">
- <modify-argument index="return">
- <!-- Defining ownership as "default" avoids the object to be automatically
- set as parent of the returned pointer. -->
- <define-ownership class="target" owner="default"/>
- </modify-argument>
- </modify-function>
+ <modify-function signature="pixmap(Qt::ReturnByValueConstant)const" remove="all"/>
+ <modify-function signature="picture(Qt::ReturnByValueConstant)const" remove="all"/>
<modify-function signature="setMovie(QMovie *)">
<modify-argument index="1">
<parent index="this" action="add"/>
@@ -2436,7 +2316,7 @@
<include file-name="QUrl" location="global"/>
<include file-name="QAbstractProxyModel" location="global"/>
</extra-includes>
- <modify-function signature="setIconProvider(QFileIconProvider*)">
+ <modify-function signature="setIconProvider(QAbstractFileIconProvider*)">
<modify-argument index="1">
<parent index="this" action="add"/>
</modify-argument>
@@ -2708,28 +2588,6 @@
</modify-argument>
</modify-function>
<modify-function signature="del()" rename="del_"/>
- <modify-function signature="getTextMargins(int*,int*,int*,int*)const">
- <modify-argument index="0">
- <replace-type modified-type="PyObject*"/>
- </modify-argument>
- <modify-argument index="1">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="2">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="3">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="4">
- <remove-argument/>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_number*,number*,number*,number*">
- <replace from="$TYPE" to="int"/>
- </insert-template>
- </inject-code>
- </modify-function>
<add-function signature="addAction(QAction*)">
<inject-code class="target" position="beginning" file="../glue/qtwidgets.cpp" snippet="qlineedit-addaction"/>
@@ -2740,9 +2598,6 @@
<enum-type name="Mode"/>
<enum-type name="SegmentStyle"/>
</object-type>
- <object-type name="QOpenGLWidget">
- <enum-type name="UpdateBehavior"/>
- </object-type>
<object-type name="QSplashScreen">
<!-- Override QWidget.painter -->
<modify-function signature="repaint()" remove="all"/>
@@ -2763,7 +2618,6 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QDesktopWidget"/>
<object-type name="QFrame">
<enum-type name="Shadow"/>
<enum-type name="Shape"/>
@@ -2784,7 +2638,7 @@
sys.exit(app.exec_())
</inject-documentation>
</modify-function>
- <modify-function signature="valueChanged(QString)">
+ <modify-function signature="textChanged(QString)">
<inject-documentation mode="append" format="target">
::
@@ -2951,20 +2805,8 @@
</modify-function>
<modify-function signature="print(QPagedPaintDevice*)const" rename="print_"/>
</object-type>
- <object-type name="QAction">
- <enum-type name="ActionEvent"/>
- <enum-type name="MenuRole"/>
- <enum-type name="Priority" since="4.6"/>
- <modify-function signature="setMenu(QMenu*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="triggered(bool)" allow-thread="yes"/>
- </object-type>
<object-type name="QApplication">
- <enum-type name="ColorSpec"/>
<extra-includes>
<include file-name="QBasicTimer" location="global"/>
<include file-name="QFont" location="global"/>
@@ -2994,7 +2836,7 @@
<object-type name="QFileSystemModel" polymorphic-id-expression="qobject_cast&lt;QFileSystemModel*&gt;(%1)">
<enum-type name="Roles"/>
<enum-type name="Option" flags="Options" since="5.14"/>
- <modify-function signature="setIconProvider(QFileIconProvider*)">
+ <modify-function signature="setIconProvider(QAbstractFileIconProvider*)">
<modify-argument index="1">
<parent index="this" action="add"/>
</modify-argument>
@@ -3431,8 +3273,6 @@
<object-type name="QGraphicsRotation" since="4.6"/>
<object-type name="QGraphicsScale" since="4.6"/>
<object-type name="QGraphicsTransform" since="4.6"/>
- <object-type name="QKeyEventTransition" since="4.6"/>
- <object-type name="QMouseEventTransition" since="4.6"/>
<object-type name="QPanGesture" since="4.6"/>
<object-type name="QPinchGesture" since="4.6">
<enum-type name="ChangeFlag" flags="ChangeFlags"/>
diff --git a/sources/pyside2/PySide2/QtWinExtras/QtWinExtras_global.pre.h.in b/sources/pyside2/PySide2/QtWinExtras/QtWinExtras_global.pre.h.in
index 3a2b87c3b..21285e301 100644
--- a/sources/pyside2/PySide2/QtWinExtras/QtWinExtras_global.pre.h.in
+++ b/sources/pyside2/PySide2/QtWinExtras/QtWinExtras_global.pre.h.in
@@ -1,5 +1,5 @@
// QT_WIDGETS_LIB must be defined for the widget functions to become visible.
-#if @Qt5Widgets_FOUND@
+#if @Qt6Widgets_FOUND@
# define QT_WIDGETS_LIB
#endif
diff --git a/sources/pyside2/PySide2/QtXml/CMakeLists.txt b/sources/pyside2/PySide2/QtXml/CMakeLists.txt
index eb64b4795..e7b22ca2b 100644
--- a/sources/pyside2/PySide2/QtXml/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtXml/CMakeLists.txt
@@ -18,20 +18,6 @@ ${QtXml_GEN_DIR}/qdomnodelist_wrapper.cpp
${QtXml_GEN_DIR}/qdomnotation_wrapper.cpp
${QtXml_GEN_DIR}/qdomprocessinginstruction_wrapper.cpp
${QtXml_GEN_DIR}/qdomtext_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlattributes_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlcontenthandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmldeclhandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmldefaulthandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmldtdhandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlentityresolver_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlerrorhandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlinputsource_wrapper.cpp
-${QtXml_GEN_DIR}/qxmllexicalhandler_wrapper.cpp
-${QtXml_GEN_DIR}/qxmllocator_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlnamespacesupport_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlparseexception_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlreader_wrapper.cpp
-${QtXml_GEN_DIR}/qxmlsimplereader_wrapper.cpp
# module is always needed
${QtXml_GEN_DIR}/qtxml_module_wrapper.cpp
)
diff --git a/sources/pyside2/PySide2/QtXml/typesystem_xml.xml b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml
index 96d12ea4e..8da1664d5 100644
--- a/sources/pyside2/PySide2/QtXml/typesystem_xml.xml
+++ b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml
@@ -147,42 +147,6 @@
</modify-argument>
<inject-code class="target" position="beginning" file="../glue/qtxml.cpp" snippet="qdomdocument-setcontent" />
</modify-function>
- <modify-function signature="setContent(QXmlInputSource*,bool,QString*,int*,int*)">
- <modify-argument index="3">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="4">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="5">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="(retval, errorMsg, errorLine, errorColumn)"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtxml.cpp" snippet="qdomdocument-setcontent" />
- </modify-function>
- <modify-function signature="setContent(QXmlInputSource*,QXmlReader*,QString*,int*,int*)">
- <modify-argument index="3">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="4">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="5">
- <remove-argument/>
- <remove-default-expression/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="(retval, errorMsg, errorLine, errorColumn)"/>
- </modify-argument>
- <inject-code class="target" position="beginning" file="../glue/qtxml.cpp" snippet="qdomdocument-setcontent" />
- </modify-function>
<modify-function signature="setContent(const QString&amp;,QString*,int*,int*)">
<modify-argument index="2">
<remove-argument/>
@@ -225,12 +189,6 @@
<value-type name="QDomText"/>
- <object-type name="QXmlParseException"/>
-
- <value-type name="QXmlAttributes"/>
-
- <object-type name="QXmlNamespaceSupport"/>
-
<value-type name="QDomElement">
<!-- PYSIDE-1372
We will leave only one for int, and one for float since Python
@@ -253,149 +211,5 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QXmlDTDHandler"/>
- <object-type name="QXmlDeclHandler"/>
- <object-type name="QXmlErrorHandler"/>
- <object-type name="QXmlLexicalHandler"/>
-
-
- <object-type name="QXmlEntityResolver">
- <modify-function signature="resolveEntity(const QString&amp;,const QString&amp;,QXmlInputSource*&amp;)">
- <modify-argument index="3">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="QXmlEntityResolver_resolveEntity_return_conversion_native"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="end" file="../glue/qtxml.cpp" snippet="qxmlentityresolver-resolveentity"/>
- </modify-function>
- </object-type>
- <object-type name="QXmlDefaultHandler">
- <modify-function signature="setDocumentLocator(QXmlLocator*)">
- <modify-argument index="1">
- <define-ownership owner="c++"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="resolveEntity(const QString&amp;,const QString&amp;,QXmlInputSource*&amp;)">
- <modify-argument index="3">
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="QXmlEntityResolver_resolveEntity_return_conversion_native"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="end" file="../glue/qtxml.cpp" snippet="qxmlentityresolver-resolveentity"/>
- </modify-function>
- </object-type>
- <object-type name="QXmlInputSource"/>
- <object-type name="QXmlLocator"/>
-
- <object-type name="QXmlReader">
- <modify-function signature="parse(const QXmlInputSource*)">
- <modify-argument index="1" invalidate-after-use="yes"/>
- </modify-function>
- <modify-function signature="feature(QString,bool*)const">
- <modify-argument index="2">
- <remove-default-expression/>
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="fix_virtual_method_return_value_and_bool*"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_args,bool*"/>
- </inject-code>
- </modify-function>
- <modify-function signature="property(QString,bool*)const">
- <modify-argument index="2">
- <remove-default-expression/>
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="fix_virtual_method_return_value_and_bool*"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_args,bool*"/>
- </inject-code>
- </modify-function>
- </object-type>
- <object-type name="QXmlSimpleReader">
- <modify-function signature="parse(const QXmlInputSource*,bool)">
- <modify-argument index="1" invalidate-after-use="yes"/>
- </modify-function>
-
- <modify-function signature="setContentHandler(QXmlContentHandler*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="setDTDHandler(QXmlDTDHandler*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="setDeclHandler(QXmlDeclHandler*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="setEntityResolver(QXmlEntityResolver*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="setErrorHandler(QXmlErrorHandler*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
- <modify-function signature="setLexicalHandler(QXmlLexicalHandler*)">
- <modify-argument index="1">
- <parent index="this" action="add"/>
- </modify-argument>
- </modify-function>
-
- <modify-function signature="feature(QString,bool*)const">
- <modify-argument index="2">
- <remove-default-expression/>
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="fix_virtual_method_return_value_and_bool*"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_args,bool*"/>
- </inject-code>
- </modify-function>
- <modify-function signature="property(QString,bool*)const">
- <modify-argument index="2">
- <remove-default-expression/>
- <remove-argument/>
- </modify-argument>
- <modify-argument index="return">
- <replace-type modified-type="PySequence"/>
- <conversion-rule class="native">
- <insert-template name="fix_virtual_method_return_value_and_bool*"/>
- </conversion-rule>
- </modify-argument>
- <inject-code class="target" position="beginning">
- <insert-template name="fix_args,bool*"/>
- </inject-code>
- </modify-function>
- </object-type>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt b/sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt
deleted file mode 100644
index adc1be516..000000000
--- a/sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-project(QtXmlPatterns)
-
-set(QtXmlPatterns_SRC
-${QtXmlPatterns_GEN_DIR}/qabstractmessagehandler_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qabstracturiresolver_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qabstractxmlnodemodel_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qabstractxmlreceiver_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qsourcelocation_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlformatter_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlitem_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlnamepool_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlname_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlnodemodelindex_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlquery_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlresultitems_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlschemavalidator_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlschema_wrapper.cpp
-${QtXmlPatterns_GEN_DIR}/qxmlserializer_wrapper.cpp
-## always needed
-${QtXmlPatterns_GEN_DIR}/qtxmlpatterns_module_wrapper.cpp
-)
-
-set(QtXmlPatterns_include_dirs ${QtXmlPatterns_SOURCE_DIR}
- ${QtXmlPatterns_BINARY_DIR}
- ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}
- ${Qt${QT_MAJOR_VERSION}XmlPatterns_INCLUDE_DIRS}
- ${libpyside_SOURCE_DIR}
- ${QtCore_GEN_DIR}
- )
-set(QtXmlPatterns_libraries pyside2
- ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}
- ${Qt${QT_MAJOR_VERSION}XmlPatterns_LIBRARIES})
-set(QtXmlPatterns_deps QtCore)
-
-create_pyside_module(NAME QtXmlPatterns
- INCLUDE_DIRS QtXmlPatterns_include_dirs
- LIBRARIES QtXmlPatterns_libraries
- DEPS QtXmlPatterns_deps
- TYPESYSTEM_PATH QtXmlPatterns_SOURCE_DIR
- SOURCES QtXmlPatterns_SRC)
-
diff --git a/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml b/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml
deleted file mode 100644
index 1e8eec083..000000000
--- a/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<typesystem package="PySide2.QtXmlPatterns">
- <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
-
- <object-type name="QXmlSchema" since="4.6"/> <!-- Qt scoped pointer does not allow declare this as value type -->
- <object-type name="QXmlSchemaValidator" since="4.6">
- <modify-function signature="schema()const">
- <modify-argument index="return">
- <replace-type modified-type="QXmlSchema*"/>
- <define-ownership owner="target"/>
- </modify-argument>
- <inject-code file="../glue/qtxmlpatterns.cpp" snippet="qxmlschemavalidator-schema"/>
- </modify-function>
- </object-type>
- <object-type name="QAbstractMessageHandler"/>
- <object-type name="QAbstractUriResolver"/>
- <object-type name="QAbstractXmlNodeModel">
- <enum-type name="NodeCopySetting"/>
- <enum-type name="SimpleAxis"/>
- </object-type>
- <object-type name="QAbstractXmlReceiver"/>
- <value-type name="QSourceLocation"/>
- <object-type name="QXmlFormatter"/>
- <value-type name="QXmlItem"/>
- <value-type name="QXmlName">
- <primitive-type name="NamespaceCode"/>
- <primitive-type name="PrefixCode"/>
- <primitive-type name="LocalNameCode"/>
- <!-- ### These methods aren't part of Qt public API -->
- <modify-function signature="QXmlName(QXmlName::NamespaceCode,QXmlName::LocalNameCode,QXmlName::PrefixCode)" remove="all"/>
- <modify-function signature="setNamespaceURI(QXmlName::NamespaceCode)" remove="all"/>
- <modify-function signature="localName()const" remove="all"/>
- <modify-function signature="prefix()const" remove="all"/>
- <modify-function signature="hasPrefix()const" remove="all"/>
- <modify-function signature="hasNamespace()const" remove="all"/>
- <modify-function signature="namespaceURI()const" remove="all"/>
- <modify-function signature="isLexicallyEqual(const QXmlName&amp;)const" remove="all"/>
- <modify-function signature="setPrefix(QXmlName::PrefixCode)" remove="all"/>
- <modify-function signature="setLocalName(QXmlName::LocalNameCode)" remove="all"/>
- <modify-function signature="code()const" remove="all"/>
- <!-- ### -->
- </value-type>
- <value-type name="QXmlNamePool"/>
-
- <rejection class="QXmlNodeModelIndex" function-name="type"/>
- <rejection class="QXmlNodeModelIndex" function-name="sequencedTypedValue"/>
- <rejection class="QXmlNodeModelIndex" function-name="iterate"/>
- <!-- ### This enum isn't part of Qt public API -->
- <suppress-warning text="Enum 'QXmlNodeModelIndex::Axis' (class: QXmlNodeModelIndex) does not have a type entry"/>
- <value-type name="QXmlNodeModelIndex">
- <enum-type name="DocumentOrder"/>
- <enum-type name="NodeKind"/>
- <!-- ### Qt internal methods -->
- <modify-function signature="name()const" remove="all"/>
- <modify-function signature="root()const" remove="all"/>
- <modify-function signature="documentUri()const" remove="all"/>
- <modify-function signature="baseUri()const" remove="all"/>
- <modify-function signature="kind()const" remove="all"/>
- <modify-function signature="isDeepEqual(const QXmlNodeModelIndex&amp;)const" remove="all"/>
- <modify-function signature="compareOrder(const QXmlNodeModelIndex &amp;)const" remove="all"/>
- <modify-function signature="sendNamespaces(QAbstractXmlReceiver*const)const" remove="all"/>
- <modify-function signature="namespaceBindings()const" remove="all"/>
- <modify-function signature="namespaceForPrefix(QXmlName::PrefixCode)const" remove="all"/>
- <modify-function signature="stringValue()const" remove="all"/>
- <modify-function signature="is(const QXmlNodeModelIndex &amp;)const" remove="all"/>
- <modify-function signature="reset()" remove="all"/>
- <!-- ### -->
- </value-type>
-
- <value-type name="QXmlQuery">
- <!-- ### TODO: must evaluate if anything other than removal is needed. -->
- <enum-type name="QueryLanguage"/>
- <modify-function signature="evaluateTo(QStringList*)const" remove="all"/>
- <modify-function signature="evaluateTo(QString*)const" remove="all"/>
- <!-- ### -->
- </value-type>
- <object-type name="QXmlResultItems"/>
- <object-type name="QXmlSerializer"/>
-
- <suppress-warning text="class 'QAbstractXmlNodeModel' inherits from unknown base class 'QSharedData'"/>
- <suppress-warning text="class not found for setup inheritance 'QSharedData'"/>
-</typesystem>
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 306a2239c..e9c60aeac 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -46,17 +46,6 @@
#include <limits>
// @snippet include-pyside
-// @snippet pystring-check
-bool py2kStrCheck(PyObject *obj)
-{
-#ifdef IS_PY3K
- return false;
-#else
- return PyString_Check(obj);
-#endif
-}
-// @snippet pystring-check
-
// @snippet qsettings-value
// If we enter the kwds, means that we have a defaultValue or
// at least a type.
@@ -102,15 +91,9 @@ if (typeObj) {
} else if (typeObj == &PyUnicode_Type) {
QByteArray asByteArray = out.toByteArray();
%PYARG_0 = PyUnicode_FromString(asByteArray.data());
-#ifdef IS_PY3K
} else if (typeObj == &PyLong_Type) {
float asFloat = out.toFloat();
pyResult = PyLong_FromDouble(asFloat);
-#else
- } else if (typeObj == &PyInt_Type) {
- float asFloat = out.toFloat();
- pyResult = PyInt_FromLong(long(asFloat));
-#endif
} else if (typeObj == &PyFloat_Type) {
float asFloat = out.toFloat();
%PYARG_0 = PyFloat_FromDouble(asFloat);
@@ -148,7 +131,7 @@ static const char *QVariant_resolveMetaType(PyTypeObject *type, int *typeId)
// Do not convert user type of value
if (valueType && Shiboken::ObjectType::isUserType(type))
return nullptr;
- int obTypeId = QMetaType::type(typeName);
+ int obTypeId = QMetaType::fromName(typeName).id();
if (obTypeId) {
*typeId = obTypeId;
return typeName;
@@ -190,11 +173,11 @@ static QVariant QVariant_convertToValueList(PyObject *list)
QByteArray listTypeName("QList<");
listTypeName += typeName;
listTypeName += '>';
- typeId = QMetaType::type(listTypeName);
+ typeId = QMetaType::fromName(listTypeName).id();
if (typeId > 0) {
Shiboken::Conversions::SpecificConverter converter(listTypeName);
if (converter) {
- QVariant var(typeId, nullptr);
+ QVariant var(static_cast<QVariant::Type>(typeId));
converter.toCpp(list, &var);
return var;
}
@@ -657,8 +640,10 @@ if (%PYARG_0 == Py_None)
// @snippet qline-hash
namespace PySide {
- template<> inline Py_ssize_t hash(const QLine &v) {
- return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2())));
+ template<> inline Py_ssize_t hash(const QLine &l)
+ {
+ const int v[4] = {l.x1(), l.y1(), l.x2(), l.y2()};
+ return qHashRange(v, v + 4);
}
};
// @snippet qline-hash
@@ -683,7 +668,7 @@ if (d) {
// @snippet qdate-topython
if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
+ PyDateTime_IMPORT;
%PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day());
// @snippet qdate-topython
@@ -719,7 +704,8 @@ QTime time(%4, %5, %6);
// @snippet qdatetime-topython
QDate date = %CPPSELF.date();
QTime time = %CPPSELF.time();
-if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
%PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000);
// @snippet qdatetime-topython
@@ -733,8 +719,9 @@ namespace PySide {
// @snippet qrect
namespace PySide {
- template<> inline Py_ssize_t hash(const QRect &v) {
- return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height())));
+ template<> inline Py_ssize_t hash(const QRect &r) {
+ const int v[4] = {r.x(), r.y(), r.width(), r.height()};
+ return qHashRange(v, v + 4);
}
};
// @snippet qrect
@@ -749,7 +736,7 @@ namespace PySide {
// @snippet qtime-topython
if (!PyDateTimeAPI)
- PySideDateTime_IMPORT;
+ PyDateTime_IMPORT;
%PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000);
// @snippet qtime-topython
@@ -811,11 +798,6 @@ static QObject *_findChildHelper(const QObject *parent, const QString &name, PyT
return nullptr;
}
-static inline bool _findChildrenComparator(const QObject *&child, const QRegExp &name)
-{
- return name.indexIn(child->objectName()) != -1;
-}
-
static inline bool _findChildrenComparator(const QObject *&child, const QRegularExpression &name)
{
return name.match(child->objectName()).hasMatch();
@@ -894,13 +876,7 @@ if (PyIndex_Check(_key)) {
}
} else if (PySlice_Check(_key)) {
Py_ssize_t start, stop, step, slicelength, cur;
-
-#ifdef IS_PY3K
- PyObject *key = _key;
-#else
- PySliceObject *key = reinterpret_cast<PySliceObject *>(_key);
-#endif
- if (PySlice_GetIndicesEx(key, %CPPSELF.count(), &start, &stop, &step, &slicelength) < 0) {
+ if (PySlice_GetIndicesEx(_key, %CPPSELF.count(), &start, &stop, &step, &slicelength) < 0) {
return nullptr;
}
@@ -945,15 +921,9 @@ if (PyIndex_Check(_key)) {
}
// Provide more specific error message for bytes/str, bytearray, QByteArray respectively
-#ifdef IS_PY3K
if (PyBytes_Check(_value)) {
if (Py_SIZE(_value) != 1) {
PyErr_SetString(PyExc_ValueError, "bytes must be of size 1");
-#else
- if (PyString_CheckExact(_value)) {
- if (Py_SIZE(_value) != 1) {
- PyErr_SetString(PyExc_ValueError, "str must be of size 1");
-#endif
return -1;
}
} else if (PyByteArray_Check(_value)) {
@@ -967,11 +937,7 @@ if (PyIndex_Check(_key)) {
return -1;
}
} else {
-#ifdef IS_PY3K
PyErr_SetString(PyExc_ValueError, "a bytes, bytearray, QByteArray of size 1 is required");
-#else
- PyErr_SetString(PyExc_ValueError, "a str, bytearray, QByteArray of size 1 is required");
-#endif
return -1;
}
@@ -984,13 +950,7 @@ if (PyIndex_Check(_key)) {
return !result ? -1 : 0;
} else if (PySlice_Check(_key)) {
Py_ssize_t start, stop, step, slicelength, value_length;
-
-#ifdef IS_PY3K
- PyObject *key = _key;
-#else
- PySliceObject *key = reinterpret_cast<PySliceObject *>(_key);
-#endif
- if (PySlice_GetIndicesEx(key, %CPPSELF.count(), &start, &stop, &step, &slicelength) < 0) {
+ if (PySlice_GetIndicesEx(_key, %CPPSELF.count(), &start, &stop, &step, &slicelength) < 0) {
return -1;
}
// The parameter candidates are: bytes/str, bytearray, QByteArray itself.
@@ -1021,11 +981,7 @@ if (PyIndex_Check(_key)) {
for (int j = 0; j < slicelength; j++) {
PyObject *item = PyObject_GetItem(_value, PyLong_FromLong(j));
QByteArray temp;
-#ifdef IS_PY3K
if (PyLong_Check(item)) {
-#else
- if (PyLong_Check(item) || PyInt_Check(item)) {
-#endif
int overflow;
long ival = PyLong_AsLongAndOverflow(item, &overflow);
// Not suppose to bigger than 255 because only bytes, bytearray, QByteArray were accept
@@ -1202,15 +1158,7 @@ if (aux == nullptr) {
return nullptr;
}
QByteArray b(Py_TYPE(%PYSELF)->tp_name);
-#ifdef IS_PY3K
- %PYARG_0 = PyUnicode_FromFormat("%s(%R)", b.constData(), aux);
-#else
- aux = PyObject_Repr(aux);
- b += '(';
- b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux));
- b += ')';
- %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size());
-#endif
+%PYARG_0 = PyUnicode_FromFormat("%s(%R)", b.constData(), aux);
Py_DECREF(aux);
// @snippet qbytearray-repr
@@ -1253,12 +1201,8 @@ PyObject *aux = PyBytes_FromStringAndSize(%CPPSELF.constData(), %CPPSELF.size())
if (aux == nullptr) {
return nullptr;
}
-#ifdef IS_PY3K
- %PYARG_0 = PyObject_Repr(aux);
- Py_DECREF(aux);
-#else
- %PYARG_0 = aux;
-#endif
+%PYARG_0 = PyObject_Repr(aux);
+Py_DECREF(aux);
// @snippet qbytearray-str
// @snippet qbytearray-len
@@ -1408,17 +1352,6 @@ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[qint64](pid));
// @snippet qprocess-startdetached
-// @snippet qprocess-pid
-long result;
-#ifdef WIN32
- _PROCESS_INFORMATION *procInfo = %CPPSELF.%FUNCTION_NAME();
- result = procInfo ? procInfo->dwProcessId : 0;
-#else
- result = %CPPSELF.%FUNCTION_NAME();
-#endif
-%PYARG_0 = %CONVERTTOPYTHON[long](result);
-// @snippet qprocess-pid
-
// @snippet qcoreapplication-init
static void QCoreApplicationConstructor(PyObject *self, PyObject *pyargv, QCoreApplicationWrapper **cptr)
{
@@ -1705,7 +1638,7 @@ Py_END_ALLOW_THREADS
// @snippet conversion-pylong-unsigned
// @snippet conversion-pylong-quintptr
-#if defined(IS_PY3K) && QT_POINTER_SIZE == 8
+#if QT_POINTER_SIZE == 8
%out = %OUTTYPE(PyLong_AsUnsignedLongLong(%in));
#else
%out = %OUTTYPE(PyLong_AsUnsignedLong(%in));
@@ -1736,14 +1669,6 @@ PyMem_Free(temp);
#endif
// @snippet conversion-pyunicode
-// @snippet conversion-pystring
-#ifndef IS_PY3K
-const char * str = %CONVERTTOCPP[const char *](%in);
-//XXX /|\ omitting this space crashes shiboken!
-%out = %OUTTYPE(str);
-#endif
-// @snippet conversion-pystring
-
// @snippet conversion-pynone
%out = %OUTTYPE();
// @snippet conversion-pynone
@@ -1790,7 +1715,7 @@ if (!typeCode || !typeName) {
%out = QVariant::fromValue(PySide::PyObjectWrapper(%in));
}
else {
- QVariant var(typeCode, nullptr);
+ QVariant var(static_cast<QVariant::Type>(typeCode));
Shiboken::Conversions::SpecificConverter converter(typeName);
converter.toCpp(pyIn, var.data());
%out = var;
@@ -1828,15 +1753,18 @@ else if (Py_TYPE(%in) == SbkObjectType_TypeF())
typeName = Shiboken::ObjectType::getOriginalName((SbkObjectType *)%in);
else
typeName = reinterpret_cast<PyTypeObject *>(%in)->tp_name;
-%out = QVariant::nameToType(typeName);
+const int id = QMetaType::fromName(typeName).id();
+%out = QVariant::Type(id);
// @snippet conversion-qvariant-pytypeobject
// @snippet conversion-qvariant-pystring
-%out = QVariant::nameToType(Shiboken::String::toCString(%in));
+const int id = QMetaType::fromName(Shiboken::String::toCString(%in)).id();
+%out = QVariant::Type(id);
// @snippet conversion-qvariant-pystring
// @snippet conversion-qvariant-pydict
-%out = QVariant::nameToType("QVariantMap");
+const int id = QMetaType::fromName("QVariantMap").id();
+%out = QVariant::Type(id);
// @snippet conversion-qvariant-pydict
// @snippet conversion-qvariant-pysequence
@@ -1881,11 +1809,7 @@ int usec = PyDateTime_TIME_GET_MICROSECOND(%in);
// @snippet conversion-qtime-pytime
// @snippet conversion-qbytearray-pybytes
-#ifdef IS_PY3K
%out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in));
-#else
-%out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
-#endif
// @snippet conversion-qbytearray-pybytes
// @snippet conversion-qbytearray-pybytearray
@@ -1904,6 +1828,10 @@ int usec = PyDateTime_TIME_GET_MICROSECOND(%in);
return PyBool_FromLong((bool)%in);
// @snippet return-pybool
+// @snippet return-pybytes
+return PyBytes_FromStringAndSize(%in.constData(), %in.size());
+// @snippet return-pybytes
+
// @snippet return-pylong
return PyLong_FromLong(%in);
// @snippet return-pylong
@@ -1913,7 +1841,7 @@ return PyLong_FromUnsignedLong(%in);
// @snippet return-pylong-unsigned
// @snippet return-pylong-quintptr
-#if defined(IS_PY3K) && QT_POINTER_SIZE == 8
+#if QT_POINTER_SIZE == 8
return PyLong_FromUnsignedLongLong(%in);
#else
return PyLong_FromUnsignedLong(%in);
@@ -1925,15 +1853,6 @@ QByteArray ba = %in.toUtf8();
return PyUnicode_FromStringAndSize(ba.constData(), ba.size());
// @snippet return-pyunicode
-// @snippet return-pyunicode-qstringref
- const int N = %in.length();
- wchar_t *str = new wchar_t[N];
- %in.toString().toWCharArray(str);
- PyObject *%out = PyUnicode_FromWideChar(str, N);
- delete[] str;
- return %out;
-// @snippet return-pyunicode-qstringref
-
// @snippet return-pyunicode-qchar
wchar_t c = (wchar_t)%in.unicode();
return PyUnicode_FromWideChar(&c, 1);
@@ -1968,7 +1887,7 @@ return 0;
// @snippet return-qvariant
// @snippet return-qvariant-type
-const char *typeName = QVariant::typeToName(%in);
+const char *typeName = QMetaType(%in).name();
PyObject *%out;
PyTypeObject *pyType = nullptr;
if (typeName)
@@ -2024,7 +1943,7 @@ pthread_cleanup_pop(0);
// @snippet qthread_pthread_cleanup_uninstall
// @snippet qlibraryinfo_build
-#if defined(IS_PY3K) && defined(Py_LIMITED_API)
+#if defined(Py_LIMITED_API)
auto suffix = PyUnicode_FromString(" [limited API]");
auto oldResult = pyResult;
pyResult = PyUnicode_Concat(pyResult, suffix);
diff --git a/sources/pyside2/PySide2/glue/qtgui.cpp b/sources/pyside2/PySide2/glue/qtgui.cpp
index a6b45b7c0..869fb9dc4 100644
--- a/sources/pyside2/PySide2/glue/qtgui.cpp
+++ b/sources/pyside2/PySide2/glue/qtgui.cpp
@@ -144,7 +144,7 @@ for (int i = 0, i_max = %CPPSELF.count(); i < i_max; ++i){
// @snippet qpixmap
// @snippet qimage-constbits
-%PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.byteCount());
+%PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.sizeInBytes());
// @snippet qimage-constbits
// @snippet qimage-bits
@@ -170,34 +170,34 @@ PyObject *args = PyTuple_GET_ITEM(%1, 1);
switch (%CPPSELF.spec()) {
case QColor::Rgb:
{
- qreal r, g, b, a;
+ float r, g, b, a;
%CPPSELF.getRgbF(&r, &g, &b, &a);
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0),
- "setRgbF", float(r), float(g), float(b), float(a));
+ "setRgbF", r, g, b, a);
break;
}
case QColor::Hsv:
{
- qreal h, s, v, a;
+ float h, s, v, a;
%CPPSELF.getHsvF(&h, &s, &v, &a);
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0),
- "setHsvF", float(h), float(s), float(v), float(a));
+ "setHsvF", h, s, v, a);
break;
}
case QColor::Cmyk:
{
- qreal c, m, y, k, a;
+ float c, m, y, k, a;
%CPPSELF.getCmykF(&c, &m, &y, &k, &a);
%PYARG_0 = Py_BuildValue("(ON(s(fffff)))", Py_TYPE(%PYSELF), PyTuple_New(0),
- "setCmykF", float(c), float(m), float(y), float(k), float(a));
+ "setCmykF", c, m, y, k, a);
break;
}
case QColor::Hsl:
{
- qreal h, s, l, a;
+ float h, s, l, a;
%CPPSELF.getHslF(&h, &s, &l, &a);
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0),
- "setHslF", float(h), float(s), float(l), float(a));
+ "setHslF", h, s, l, a);
break;
}
default:
diff --git a/sources/pyside2/PySide2/glue/qtqml.cpp b/sources/pyside2/PySide2/glue/qtqml.cpp
index 1913204c3..5ff072e09 100644
--- a/sources/pyside2/PySide2/glue/qtqml.cpp
+++ b/sources/pyside2/PySide2/glue/qtqml.cpp
@@ -42,6 +42,26 @@ int %0 = PySide::qmlRegisterType(%ARGUMENT_NAMES);
%PYARG_0 = %CONVERTTOPYTHON[int](%0);
// @snippet qmlregistertype
+// @snippet qmlregistersingletontype_qobject_callback
+int %0 = PySide::qmlRegisterSingletonType(%ARGUMENT_NAMES, true, true);
+%PYARG_0 = %CONVERTTOPYTHON[int](%0);
+// @snippet qmlregistersingletontype_qobject_callback
+
+// @snippet qmlregistersingletontype_qobject_nocallback
+int %0 = PySide::qmlRegisterSingletonType(%ARGUMENT_NAMES, nullptr, true, false);
+%PYARG_0 = %CONVERTTOPYTHON[int](%0);
+// @snippet qmlregistersingletontype_qobject_nocallback
+
+// @snippet qmlregistersingletontype_qjsvalue
+int %0 = PySide::qmlRegisterSingletonType(nullptr, %ARGUMENT_NAMES, false, true);
+%PYARG_0 = %CONVERTTOPYTHON[int](%0);
+// @snippet qmlregistersingletontype_qjsvalue
+
+// @snippet qmlregisteruncreatabletype
+int %0 = PySide::qmlRegisterType(%ARGUMENT_NAMES, false);
+%PYARG_0 = %CONVERTTOPYTHON[int](%0);
+// @snippet qmlregisteruncreatabletype
+
// @snippet init
PySide::initQmlSupport(module);
// @snippet init
diff --git a/sources/pyside2/PySide2/glue/qtuitools.cpp b/sources/pyside2/PySide2/glue/qtuitools.cpp
index d81f6205a..08dc0eb0a 100644
--- a/sources/pyside2/PySide2/glue/qtuitools.cpp
+++ b/sources/pyside2/PySide2/glue/qtuitools.cpp
@@ -116,14 +116,10 @@ Arguments:
%PYARG_1 (uifile)
*/
// 1. Generate the Python code from the UI file
-#ifdef IS_PY3K
PyObject *strObj = PyUnicode_AsUTF8String(%PYARG_1);
char *arg1 = PyBytes_AsString(strObj);
QByteArray uiFileName(arg1);
Py_DECREF(strObj);
-#else
-QByteArray uiFileName(PyBytes_AsString(%PYARG_1));
-#endif
QFile uiFile(uiFileName);
@@ -207,12 +203,7 @@ if (codeUi.isNull()) {
qCritical() << "Error while compiling the generated Python file";
Py_RETURN_NONE;
}
-PyObject *uiObj = nullptr;
-#ifdef IS_PY3K
-uiObj = PyEval_EvalCode(codeUi, loc, loc);
-#else
-uiObj = PyEval_EvalCode(reinterpret_cast<PyCodeObject *>(codeUi.object()), loc, loc);
-#endif
+PyObject *uiObj = PyEval_EvalCode(codeUi, loc, loc);
if (uiObj == nullptr) {
qCritical() << "Error while running exec() on the generated code";
@@ -234,13 +225,8 @@ if (codeBaseClass.isNull()) {
Py_RETURN_NONE;
}
-#ifdef IS_PY3K
PyObject *classObj = PyEval_EvalCode(codeClass, loc, loc);
PyObject *baseClassObj = PyEval_EvalCode(codeBaseClass, loc, loc);
-#else
-PyObject *classObj = PyEval_EvalCode(reinterpret_cast<PyCodeObject *>(codeClass.object()), loc, loc);
-PyObject *baseClassObj = PyEval_EvalCode(reinterpret_cast<PyCodeObject *>(codeBaseClass.object()), loc, loc);
-#endif
%PYARG_0 = PyTuple_New(2);
if (%PYARG_0 == nullptr) {
diff --git a/sources/pyside2/PySide2/pysideqtesttouch.h b/sources/pyside2/PySide2/pysideqtesttouch.h
index 115c7835e..935ab59d6 100644
--- a/sources/pyside2/PySide2/pysideqtesttouch.h
+++ b/sources/pyside2/PySide2/pysideqtesttouch.h
@@ -68,145 +68,133 @@ namespace QTest
}
PySideQTouchEventSequence *press(int touchId, const QPoint &pt, QWindow *window = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointPressed);
+ auto it = m_points.find(touchId);
+ if (it == m_points.end()) {
+ QEventPoint point(touchId, QEventPoint::Pressed, pt, mapToScreen(window, pt));
+ m_points.insert(touchId, point);
+ }
return this;
}
PySideQTouchEventSequence *move(int touchId, const QPoint &pt, QWindow *window = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointMoved);
+ QEventPoint point(touchId, QEventPoint::Updated, pt, mapToScreen(window, pt));
+ m_points[touchId] = point;
return this;
}
PySideQTouchEventSequence *release(int touchId, const QPoint &pt, QWindow *window = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointReleased);
+ auto it = m_points.find(touchId);
+ if (it == m_points.end()) {
+ QEventPoint point(touchId, QEventPoint::Released, pt, mapToScreen(window, pt));
+ m_points.insert(touchId, point);
+ }
return this;
}
PySideQTouchEventSequence *stationary(int touchId)
{
- QTouchEvent::TouchPoint &p = pointOrPreviousPoint(touchId);
- p.setState(Qt::TouchPointStationary);
+ auto it = m_points.find(touchId);
+ if (it == m_points.end()) {
+ auto previous_it = m_previousPoints.find(touchId);
+ const QEventPoint point = previous_it != m_previousPoints.end()
+ ? previous_it.value()
+ : QEventPoint(touchId, QEventPoint::Stationary, QPointF(), QPointF());
+ m_points.insert(touchId, point);
+ }
return this;
}
#ifdef QT_WIDGETS_LIB
PySideQTouchEventSequence *press(int touchId, const QPoint &pt, QWidget *widget = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(widget, pt));
- p.setState(Qt::TouchPointPressed);
+ auto it = m_points.find(touchId);
+ if (it == m_points.end()) {
+ QEventPoint point(touchId, QEventPoint::Pressed, pt, mapToScreen(widget, pt));
+ m_points.insert(touchId, point);
+ }
return this;
}
PySideQTouchEventSequence *move(int touchId, const QPoint &pt, QWidget *widget = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(widget, pt));
- p.setState(Qt::TouchPointMoved);
+ QEventPoint point(touchId, QEventPoint::Updated, pt, mapToScreen(widget, pt));
+ m_points[touchId] = point;
return this;
}
PySideQTouchEventSequence *release(int touchId, const QPoint &pt, QWidget *widget = nullptr)
{
- QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(widget, pt));
- p.setState(Qt::TouchPointReleased);
+ auto it = m_points.find(touchId);
+ if (it == m_points.end()) {
+ QEventPoint point(touchId, QEventPoint::Released, pt, mapToScreen(widget, pt));
+ m_points.insert(touchId, point);
+ }
return this;
}
#endif
void commit(bool processEvents = true)
{
- if (!points.isEmpty()) {
- if (targetWindow)
- {
- qt_handleTouchEvent(targetWindow, device, points.values());
+ if (!m_points.isEmpty()) {
+ if (targetWindow) {
+ qt_handleTouchEvent(targetWindow, device, m_points.values());
}
#ifdef QT_WIDGETS_LIB
- else if (targetWidget)
- {
- qt_handleTouchEvent(targetWidget->windowHandle(), device, points.values());
+ else if (targetWidget) {
+ qt_handleTouchEvent(targetWidget->windowHandle(), device, m_points.values());
}
#endif
}
if (processEvents)
QCoreApplication::processEvents();
- previousPoints = points;
- points.clear();
+ m_previousPoints = m_points;
+ m_points.clear();
}
private:
#ifdef QT_WIDGETS_LIB
- PySideQTouchEventSequence(QWidget *widget, QTouchDevice *aDevice, bool autoCommit)
- : targetWidget(widget), targetWindow(0), device(aDevice), commitWhenDestroyed(autoCommit)
+ PySideQTouchEventSequence(QWidget *widget, QPointingDevice *aDevice, bool autoCommit)
+ : targetWidget(widget), device(aDevice), commitWhenDestroyed(autoCommit)
{
}
#endif
- PySideQTouchEventSequence(QWindow *window, QTouchDevice *aDevice, bool autoCommit)
- :
-#ifdef QT_WIDGETS_LIB
- targetWidget(0),
-#endif
- targetWindow(window), device(aDevice), commitWhenDestroyed(autoCommit)
+ PySideQTouchEventSequence(QWindow *window, QPointingDevice *aDevice, bool autoCommit)
+ : targetWindow(window), device(aDevice), commitWhenDestroyed(autoCommit)
{
}
- QTouchEvent::TouchPoint &point(int touchId)
- {
- if (!points.contains(touchId))
- points[touchId] = QTouchEvent::TouchPoint(touchId);
- return points[touchId];
- }
-
- QTouchEvent::TouchPoint &pointOrPreviousPoint(int touchId)
- {
- if (!points.contains(touchId)) {
- if (previousPoints.contains(touchId))
- points[touchId] = previousPoints.value(touchId);
- else
- points[touchId] = QTouchEvent::TouchPoint(touchId);
- }
- return points[touchId];
- }
-
#ifdef QT_WIDGETS_LIB
- QPoint mapToScreen(QWidget *widget, const QPoint &pt)
+ QPointF mapToScreen(const QWidget *widget, const QPointF &pt)
{
if (widget)
return widget->mapToGlobal(pt);
return targetWidget ? targetWidget->mapToGlobal(pt) : pt;
}
#endif
- QPoint mapToScreen(QWindow *window, const QPoint &pt)
+ QPointF mapToScreen(const QWindow *window, const QPointF &pt)
{
if(window)
return window->mapToGlobal(pt);
return targetWindow ? targetWindow->mapToGlobal(pt) : pt;
}
- QMap<int, QTouchEvent::TouchPoint> previousPoints;
- QMap<int, QTouchEvent::TouchPoint> points;
+ QMap<int, QEventPoint> m_previousPoints;
+ QMap<int, QEventPoint> m_points;
#ifdef QT_WIDGETS_LIB
- QWidget *targetWidget;
+ QWidget *targetWidget = nullptr;
#endif
- QWindow *targetWindow;
- QTouchDevice *device;
- bool commitWhenDestroyed;
+ QWindow *targetWindow = nullptr;
+ QPointingDevice *device = nullptr;
+ bool commitWhenDestroyed = false;
#ifdef QT_WIDGETS_LIB
- friend PySideQTouchEventSequence *generateTouchEvent(QWidget *, QTouchDevice *, bool);
+ friend PySideQTouchEventSequence *generateTouchEvent(QWidget *, QPointingDevice *, bool);
#endif
- friend PySideQTouchEventSequence *generateTouchEvent(QWindow *, QTouchDevice *, bool);
+ friend PySideQTouchEventSequence *generateTouchEvent(QWindow *, QPointingDevice *, bool);
};
#ifdef QT_WIDGETS_LIB
inline
PySideQTouchEventSequence *generateTouchEvent(QWidget *widget,
- QTouchDevice *device,
+ QPointingDevice *device,
bool autoCommit = true)
{
return new PySideQTouchEventSequence(widget, device, autoCommit);
@@ -214,7 +202,7 @@ private:
#endif
inline
PySideQTouchEventSequence *generateTouchEvent(QWindow *window,
- QTouchDevice *device,
+ QPointingDevice *device,
bool autoCommit = true)
{
return new PySideQTouchEventSequence(window, device, autoCommit);
diff --git a/sources/pyside2/PySide2/templates/core_common.xml b/sources/pyside2/PySide2/templates/core_common.xml
index 6d02428ad..a7c9eca3d 100644
--- a/sources/pyside2/PySide2/templates/core_common.xml
+++ b/sources/pyside2/PySide2/templates/core_common.xml
@@ -242,8 +242,8 @@
<!-- Helpers for modifying "bool nativeEventFilter(QByteArray, void*, long *result)"
to return a tuple of bool,long -->
<template name="return_native_eventfilter_conversion_variables">
- long resultVar{0};
- long *%out = &amp;resultVar;
+ qintptr resultVar{0};
+ qintptr *%out = &amp;resultVar;
</template>
<template name="return_native_eventfilter_conversion">
%RETURN_TYPE %out = false;
@@ -343,11 +343,7 @@
<template name="checkPyCapsuleOrPyCObject_func">
static bool checkPyCapsuleOrPyCObject(PyObject* pyObj)
{
- #ifdef IS_PY3K
return PyCapsule_CheckExact(pyObj);
- #else
- return PyCObject_Check(pyObj);
- #endif
}
</template>
@@ -377,15 +373,10 @@
</template>
<template name="pydatetime_importandcheck_function">
- #ifdef IS_PY3K
- #define PySideDateTime_IMPORT PyDateTime_IMPORT
- #else
- #define PySideDateTime_IMPORT \
- (PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \
- (char*)"datetime_CAPI"))
- #endif
- static bool PyDateTime_ImportAndCheck(PyObject *pyIn) {
- if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ static bool PyDateTime_ImportAndCheck(PyObject *pyIn)
+ {
+ if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
return $DATETIMETYPE_Check(pyIn);
}
</template>
diff --git a/sources/pyside2/PySide2/templates/gui_common.xml b/sources/pyside2/PySide2/templates/gui_common.xml
index a139a5fe9..fb8e66881 100644
--- a/sources/pyside2/PySide2/templates/gui_common.xml
+++ b/sources/pyside2/PySide2/templates/gui_common.xml
@@ -88,7 +88,7 @@
switch(%CPPSELF.spec()) {
case QColor::Rgb:
{
- qreal r, g, b, a;
+ float r, g, b, a;
%CPPSELF.getRgbF(&amp;r, &amp;g, &amp;b, &amp;a);
QString repr = QString::asprintf("PySide2.QtGui.QColor.fromRgbF(%.6f, %.6f, %.6f, %.6f)", r, g, b, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
@@ -96,7 +96,7 @@
}
case QColor::Hsv:
{
- qreal h, s, v, a;
+ float h, s, v, a;
%CPPSELF.getHsvF(&amp;h, &amp;s, &amp;v, &amp;a);
QString repr = QString::asprintf("PySide2.QtGui.QColor.fromHsvF(%.6f, %.6f, %.6f, %.6f)", h, s, v, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
@@ -104,7 +104,7 @@
}
case QColor::Cmyk:
{
- qreal c, m, y, k, a;
+ float c, m, y, k, a;
%CPPSELF.getCmykF(&amp;c, &amp;m, &amp;y, &amp;k, &amp;a);
QString repr = QString::asprintf("PySide2.QtGui.QColor.fromCmykF(%.6f, %.6f, %.6f, %.6f, %.6f)", c, m, y, k, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
@@ -112,7 +112,7 @@
}
case QColor::Hsl:
{
- qreal h, s, l, a;
+ float h, s, l, a;
%CPPSELF.getHslF(&amp;h, &amp;s, &amp;l, &amp;a);
QString repr = QString::asprintf("PySide2.QtGui.QColor.fromHslF(%.6f, %.6f, %.6f, %.6f)", h, s, l, a);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
@@ -125,6 +125,15 @@
}
</template>
+ <template name="qkeysequence_repr">
+ QString result;
+ QDebug debug(&amp;result);
+ debug.noquote();
+ debug.nospace();
+ debug &lt;&lt; (*%CPPSELF);
+ %PYARG_0 = Shiboken::String::fromCString(result.toUtf8().constData());
+ </template>
+
<template name="validator_conversionrule">
QValidator::State %out;
diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake
index 14707f964..5022002c9 100644
--- a/sources/pyside2/cmake/Macros/PySideModules.cmake
+++ b/sources/pyside2/cmake/Macros/PySideModules.cmake
@@ -93,7 +93,7 @@ macro(create_pyside_module)
# Contains include directories to pass to shiboken's preprocessor.
# Workaround: Added ${QT_INCLUDE_DIR}/QtCore until
# qtdeclarative/8d560d1bf0a747bf62f73fad6b6774095442d9d2 has reached qt5.git
- string(REPLACE ";" ${PATH_SEP} core_includes "${Qt5Core_INCLUDE_DIRS}")
+ string(REPLACE ";" ${PATH_SEP} core_includes "${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS}")
set(shiboken_include_dirs ${pyside2_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR}${PATH_SEP}${core_includes})
set(shiboken_framework_include_dirs_option "")
if(CMAKE_HOST_APPLE)
diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt
index ab5d694e7..73b90c059 100644
--- a/sources/pyside2/doc/CMakeLists.txt
+++ b/sources/pyside2/doc/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
project(doc)
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.h b/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.h
index bdb7bcf22..d2cda4aa2 100644
--- a/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.h
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.h
@@ -48,7 +48,8 @@
**
****************************************************************************/
-from PySide2.QtWidgets import (QAction, QApplication, QMainWindow, QMenu,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QMainWindow, QMenu,
QPlainTextEdit, QSessionManager)
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
deleted file mode 100644
index 79dc15177..000000000
--- a/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-def wrapInFunction():
-//! [0]
- # ...
- page = QWebPage()
- # ...
-
- inspector = QWebInspector()
- inspector.setPage(page)
-//! [0]
-
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp
deleted file mode 100644
index 268f4344e..000000000
--- a/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-def wrapInFunction():
-//! [0]
- view.page().history()
-//! [0]
-
-
-//! [1]
- view.page().settings()
-//! [1]
-
-
-//! [2]
- view.triggerAction(QWebPage.Copy)
-//! [2]
-
-
-//! [3]
- view.page().triggerPageAction(QWebPage.Stop)
-//! [3]
-
-
-//! [4]
- view.page().triggerPageAction(QWebPage.GoBack)
-//! [4]
-
-
-//! [5]
- view.page().triggerPageAction(QWebPage.GoForward)
-//! [5]
-
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/simple/main.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/simple/main.cpp
deleted file mode 100644
index 1382cd446..000000000
--- a/sources/pyside2/doc/codesnippets/webkitsnippets/simple/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-from PySide2.QtCore import *
-from PySide2.QtGui import *
-from PySide2.QtWebKit import *
-import sys
-
-app = QApplication(sys.argv)
-parent = None
-//! [Using QWebView]
-view = QWebView(parent)
-view.load(QUrl("http://qt-project.org/"))
-view.show()
-//! [Using QWebView]
-sys.exit(app.exec_())
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/webelement/main.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/webelement/main.cpp
deleted file mode 100644
index 67e101ae0..000000000
--- a/sources/pyside2/doc/codesnippets/webkitsnippets/webelement/main.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-def traverse():
-//! [Traversing with QWebElement]
- frame.setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>")
- doc = frame.documentElement()
- body = doc.firstChild()
- firstParagraph = body.firstChild()
- secondParagraph = firstParagraph.nextSibling()
-//! [Traversing with QWebElement]
-
-def findButtonAndClick():
- frame.setHtml("<form name=\"myform\" action=\"submit_form.asp\" method=\"get\">" \
- "<input type=\"text\" name=\"myfield\">" \
- "<input type=\"submit\" value=\"Submit\">" \
- "</form>")
-
-//! [Calling a DOM element method]
-
- document = frame.documentElement()
- # Assume that the document has the following structure:
- #
- # <form name="myform" action="submit_form.asp" method="get">
- # <input type="text" name="myfield">
- # <input type="submit" value="Submit">
- # </form>
-
- button = document.findFirst("input[type=submit]")
- button.evaluateJavaScript("click()")
-
-//! [Calling a DOM element method]
-
-def autocomplete1():
- document = frame.documentElement()
-//! [autocomplete1]
- firstTextInput = document.findFirst("input[type=text]")
- storedText = firstTextInput.attribute("value")
-//! [autocomplete1]
-
-def autocomplete2():
- document = frame.documentElement()
- storedText = "text"
-
-//! [autocomplete2]
- firstTextInput = document.findFirst("input[type=text]")
- textInput.setAttribute("value", storedText)
-//! [autocomplete2]
-
-def findAll():
-//! [FindAll]
- document = frame.documentElement()
- # Assume the document has the following structure:
- #
- # <p class=intro>
- # <span>Intro</span>
- # <span>Snippets</span>
- # </p>
- # <p>
- # <span>Content</span>
- # <span>Here</span>
- # </p>
-
-//! [FindAll intro]
- allSpans = document.findAll("span")
- introSpans = document.findAll("p.intro span")
-//! [FindAll intro] //! [FindAll]
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/webpage/main.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/webpage/main.cpp
deleted file mode 100644
index b64a4f35b..000000000
--- a/sources/pyside2/doc/codesnippets/webkitsnippets/webpage/main.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [0]
-class Thumbnailer (QObject):
- def __init__(self, url):
-//! [1]
- QObject.__init__(self)
- self.page = QWebPage()
- self.page.mainFrame().load(url)
- page.loadFinished[bool].connect(self.render)
-//! [1]
-
- finished = Signal()
-
-//! [2]
- def render(self):
- self.page.setViewportSize(self.page.mainFrame().contentsSize())
- image = QImage(self.page.viewportSize(), QImage.Format_ARGB32)
- painter = QPainter(image)
-
- self.page.mainFrame().render(painter)
- painter.end()
-
- thumbnail = image.scaled(400, 400)
- thumbnail.save("thumbnail.png")
-
- self.finished.emit()
-//! [2]
-//! [0]
-
-app = QApplication(sys.argv)
-
-thumbnail = Thumbnailer(QUrl("http://qt-project.org"))
-thumbnail.finished.connect(app.quit)
-sys.exit(app.exec_())
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst
new file mode 100644
index 000000000..2e0f80762
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst
@@ -0,0 +1,44 @@
+.. currentmodule:: PySide2.QtQml
+.. _qmlRegisterSingletonType:
+
+qmlRegisterSingletonType
+************************
+
+.. py:function:: qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :return: int (the QML type id)
+
+ This function registers a Python type as a singleton in the QML system.
+
+.. py:function:: qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :param object callback: Python callable (to handle Python type)
+ :return: int (the QML type id)
+
+ This function registers a Python type as a singleton in the QML system using
+ the provided callback (which gets a QQmlEngine as a parameter) to generate
+ the singleton.
+
+
+.. py:function:: qmlRegisterSingletonType(uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) -> int
+
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :param object callback: Python callable (to handle QJSValue)
+ :return: int (the QML type id)
+
+ This function registers a QJSValue as a singleton in the QML system using
+ the provided callback (which gets a QQmlEngine as a parameter) to
+ generate the singleton.
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst
new file mode 100644
index 000000000..d8bd3acb1
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst
@@ -0,0 +1,41 @@
+.. currentmodule:: PySide2.QtQml
+.. _qmlRegisterType:
+
+qmlRegisterType
+***************
+
+.. py:function:: qmlRegisterType(pytype: type, uri: str, versionMajor: int, versionMinor: int, qmlName: str) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str qmlName: name exposed to QML
+ :return: int (the QML type id)
+
+ This function registers the Python *type* in the QML system with the
+ name *qmlName*, in the library imported from *uri* having the
+ version number composed from *versionMajor* and *versionMinor*.
+
+ For example, this registers a Python class 'MySliderItem' as a QML
+ type named 'Slider' for version '1.0' of a module called
+ 'com.mycompany.qmlcomponents':
+
+ ::
+
+ qmlRegisterType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider")
+
+ Once this is registered, the type can be used in QML by importing
+ the specified module name and version number:
+
+ ::
+
+ import com.mycompany.qmlcomponents 1.0
+
+ Slider { ... }
+
+ Note that it's perfectly reasonable for a library to register types
+ to older versions than the actual version of the library.
+ Indeed, it is normal for the new library to allow QML written to
+ previous versions to continue to work, even if more advanced
+ versions of some of its types are available.
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst
new file mode 100644
index 000000000..0e73f3d97
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst
@@ -0,0 +1,36 @@
+.. currentmodule:: PySide2.QtQml
+.. _qmlRegisterUncreatableType:
+
+
+qmlRegisterUncreatableType
+**************************
+
+
+.. py:function:: qmlRegisterUncreatableType(pytype: type, uri: str, versionMajor: int, versionMinor: int, qmlName: str, noCreationReason: str) -> int
+
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str qmlName: name exposed to QML
+ :param str noCreationReason: Error message shown when trying to create the QML type
+ :return: int (the QML type id)
+
+ This function registers the Python *type* in the QML system as an uncreatable type with the
+ name *qmlName*, in the library imported from *uri* having the
+ version number composed from *versionMajor* and *versionMinor*,
+ showing *noCreationReason* as an error message when creating the type is attempted.
+
+ For example, this registers a Python class 'MySliderItem' as a QML
+ type named 'Slider' for version '1.0' of a module called
+ 'com.mycompany.qmlcomponents':
+
+ ::
+ qmlRegisterUncreatableType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider", "Slider cannot be created.")
+
+ Note that it's perfectly reasonable for a library to register types
+ to older versions than the actual version of the library.
+ Indeed, it is normal for the new library to allow QML written to
+ previous versions to continue to work, even if more advanced
+ versions of some of its types are available.
diff --git a/sources/pyside2/doc/extras/QtWebKit.rst b/sources/pyside2/doc/extras/QtWebKit.rst
deleted file mode 100644
index 58f9230a7..000000000
--- a/sources/pyside2/doc/extras/QtWebKit.rst
+++ /dev/null
@@ -1,94 +0,0 @@
-QtWebKit provides a Web browser engine that makes it easy to embed content from the World Wide Web into your Qt application. At the same time Web content can be enhanced with native controls.
-
-QtWebKit provides facilities for rendering of HyperText Markup Language (HTML), Extensible HyperText Markup Language (XHTML) and Scalable Vector Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and scripted with JavaScript.
-
-A bridge between the JavaScript execution environment and the Qt object model makes it possible for custom QObjects to be scripted. Integration with the Qt networking module enables Web pages to be transparently loaded from Web servers, the local file system or even the Qt resource system.
-
-In addition to providing pure rendering features, HTML documents can be made fully editable to the user through the use of the contenteditable attribute on HTML elements.
-
-QtWebKit is based on the Open Source WebKit engine. More information about WebKit itself can be found on the _`WebKit Open Source Project <http://webkit.org/>` Web site.
-
-Including In Your Project
--------------------------
-
-To include the definitions of the module's classes, use the following directive:
-
-::
-
- import PySide2.QtWebKit
-
-
-.. note:: Web site icons, also known as "FavIcons", are currently not supported on Windows. We plan to address this in a future release.
-
-Architecture
-------------
-
-The easiest way to render content is through the QWebView class. As a widget it can be embedded into your forms or a graphics view, and it provides convenience functions for downloading and rendering web sites.
-
-::
-
- view = QWebView(parent)
- view.load(QUrl("http://qt.nokia.com/"))
- view.show()
-
-QWebView is used to view Web pages. An instance of QWebView has one QWebPage. QWebPage provides access to the document structure in a page, describing features such as frames, the navigation history, and the undo/redo stack for editable content.
-
-HTML documents can be nested using frames in a frameset. An individual frame in HTML is represented using the QWebFrame class. This class includes the bridge to the JavaScript window object and can be painted using QPainter. Each QWebPage has one QWebFrame object as its main frame, and the main frame may contain many child frames.
-
-Individual elements of an HTML document can be accessed via DOM JavaScript interfaces from within a web page. The equivalent of this API in QtWebKit is represented by QWebElement. QWebElement objects are obtained using QWebFrame's findAllElements() and findFirstElement() functions with CSS selector queries.
-
-Common web browser features, defaults and other settings can be configured through the QWebSettings class. It is possible to provide defaults for all QWebPage instances through the default settings. Individual attributes can be overidden by the page specific settings object.
-
-Netscape Plugin Support
------------------------
-
-.. note:: Netscape plugin support is only available on desktop platforms.
-
-Since WebKit supports the Netscape Plugin API, Qt applications can display Web pages that embed common plugins on platforms for which those plugins are available. To enable plugin support, the user must have the appropriate binary files for those plugins installed and the ``QWebSettings.PluginsEnabled`` attribute must be enabled for the application.
-
-The following locations are searched for plugins:
-
-* Linux/Unix (X11)
- * .mozilla/plugins in the user's home directory
- * .netscape/plugins in the user's home directory
- * System locations, such as
- * /usr/lib/browser/plugins
- * /usr/local/lib/mozilla/plugins
- * /usr/lib/firefox/plugins
- * /usr/lib64/browser-plugins
- * /usr/lib/browser-plugins
- * /usr/lib/mozilla/plugins
- * /usr/local/netscape/plugins
- * /opt/mozilla/plugins
- * /opt/mozilla/lib/plugins
- * /opt/netscape/plugins
- * /opt/netscape/communicator/plugins
- * /usr/lib/netscape/plugins
- * /usr/lib/netscape/plugins-libc5
- * /usr/lib/netscape/plugins-libc6
- * /usr/lib64/netscape/plugins
- * /usr/lib64/mozilla/plugins
- * Locations specified by environment variables:
- * $MOZILLA_HOME/plugins
- * $MOZ_PLUGIN_PATH
- * $QTWEBKIT_PLUGIN_PATH
-* Windows
- * The user's Application Data\Mozilla\plugins directory
- * Standard system locations of plugins for Quicktime, Flash, etc.
-* Mac OS X
- * Library/Internet Plug-Ins in the user's home directory
- * The system /Library/Internet Plug-Ins directory
-
-License Information
--------------------
-
-Qt Commercial Edition licensees that wish to distribute applications that use the QtWebKit module need to be aware of their obligations under the GNU Library General Public License (LGPL).
-
-Developers using the Open Source Edition can choose to redistribute the module under the appropriate version of the GNU LGPL.
-WebKit is licensed under the GNU Library General Public License. Individual contributor names and copyright dates can be found inline in the code.
-
-This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. \ No newline at end of file
diff --git a/sources/pyside2/doc/modules.rst b/sources/pyside2/doc/modules.rst
index bb4b112a1..f42fac636 100644
--- a/sources/pyside2/doc/modules.rst
+++ b/sources/pyside2/doc/modules.rst
@@ -78,10 +78,6 @@ Qt Modules
Provides information about the X display configuration.
- :mod:`Qt Xml <PySide2.QtXml>`
Provides C++ implementations of SAX and DOM.
- * - :mod:`Qt XmlPatterns <PySide2.QtXmlPatterns>`
- Provides support for XPath, XQuery, XSLTi, and XML Schema validation.
- - :mod:`Qt 3D Core <PySide2.Qt3DCore>`
- Contains functionality to support near-realtime simulation systems.
* - :mod:`Qt 3D Extras <PySide2.Qt3DExtras>`
Provides a set of prebuilt elements to help you get started with Qt 3D.
- :mod:`Qt 3D Input <PySide2.Qt3DInput>`
diff --git a/sources/pyside2/doc/qtmodules/pyside-qtxmlpatterns.qdocconf.in b/sources/pyside2/doc/qtmodules/pyside-qtxmlpatterns.qdocconf.in
deleted file mode 100644
index 9e132ff24..000000000
--- a/sources/pyside2/doc/qtmodules/pyside-qtxmlpatterns.qdocconf.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include(@QT_SRC_DIR@/../qtxmlpatterns/src/xmlpatterns/doc/qtxmlpatterns.qdocconf)
-include(../pyside-config.qdocconf)
diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py
index 188e4930e..d97db65aa 100644
--- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py
+++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py
@@ -39,8 +39,8 @@
#############################################################################
from PySide2.QtCore import Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import QMainWindow, QAction
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py
index 6a0374af0..db9517f42 100644
--- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py
+++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py
@@ -39,8 +39,8 @@
#############################################################################
from PySide2.QtCore import Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import QMainWindow, QAction
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py
index 5f9003a92..e8979ab25 100644
--- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py
+++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py
@@ -39,8 +39,8 @@
#############################################################################
from PySide2.QtCore import Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import QMainWindow, QAction
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py
index 5c2c009d2..ef4e06f41 100644
--- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py
+++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py
@@ -39,8 +39,8 @@
#############################################################################
from PySide2.QtCore import Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import QMainWindow, QAction
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
diff --git a/sources/pyside2/doc/tutorials/expenses/main.py b/sources/pyside2/doc/tutorials/expenses/main.py
index c27576029..5dd632301 100644
--- a/sources/pyside2/doc/tutorials/expenses/main.py
+++ b/sources/pyside2/doc/tutorials/expenses/main.py
@@ -40,8 +40,8 @@
import sys
from PySide2.QtCore import Qt, Slot
-from PySide2.QtGui import QPainter
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction, QPainter
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
from PySide2.QtCharts import QtCharts
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/02-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/02-expenses.py
index 0546bc9f3..9ffb2f9d0 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/02-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/02-expenses.py
@@ -39,7 +39,8 @@
#############################################################################
import sys
-from PySide2.QtWidgets import QAction, QApplication, QMainWindow
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QApplication, QMainWindow
class MainWindow(QMainWindow):
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/03-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/03-expenses.py
index bc753309f..1cb2f0035 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/03-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/03-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import QAction, QApplication, QMainWindow
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QApplication, QMainWindow
from PySide2.QtCharts import QtCharts
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/04-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/04-expenses.py
index 78e9b1d1d..80a5cb16f 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/04-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/04-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import QAction, QApplication, QMainWindow, QWidget
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QApplication, QMainWindow, QWidget
class Widget(QWidget):
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/05-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/05-expenses.py
index 6fd515f40..a72f8d990 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/05-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/05-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QMainWindow,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QMainWindow,
QTableWidget, QTableWidgetItem, QWidget)
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/06-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/06-expenses.py
index 38fa881bf..e2c32e5c6 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/06-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/06-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/07-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/07-expenses.py
index 6b915806d..acc7edc7c 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/07-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/07-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/08-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/08-expenses.py
index 2f18dff9f..a6003cb35 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/08-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/08-expenses.py
@@ -40,7 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/09-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/09-expenses.py
index 6b5d87e2e..3f1aed2c9 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/09-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/09-expenses.py
@@ -40,8 +40,8 @@
import sys
from PySide2.QtCore import Slot
-from PySide2.QtGui import QPainter
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction, QPainter
+from PySide2.QtWidgets import (QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
from PySide2.QtCharts import QtCharts
diff --git a/sources/pyside2/doc/tutorials/expenses/steps/10-expenses.py b/sources/pyside2/doc/tutorials/expenses/steps/10-expenses.py
index 6cc911671..2a7bddab0 100644
--- a/sources/pyside2/doc/tutorials/expenses/steps/10-expenses.py
+++ b/sources/pyside2/doc/tutorials/expenses/steps/10-expenses.py
@@ -40,8 +40,8 @@
import sys
from PySide2.QtCore import Qt, Slot
-from PySide2.QtGui import QPainter
-from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
+from PySide2.QtGui import QAction, QPainter
+from PySide2.QtWidgets import (QQApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
QVBoxLayout, QWidget)
from PySide2.QtCharts import QtCharts
diff --git a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py
index 33b92879b..792bcab51 100644
--- a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py
+++ b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py
@@ -40,7 +40,8 @@
from __future__ import print_function, absolute_import
-from PySide2.QtWidgets import (QAction, QAbstractItemView, QDataWidgetMapper,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QAbstractItemView, QDataWidgetMapper,
QHeaderView, QMainWindow, QMessageBox)
from PySide2.QtGui import QKeySequence
from PySide2.QtSql import (QSqlRelation, QSqlRelationalTableModel, QSqlTableModel,
diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp
index 0377f7697..bfaa9ff44 100644
--- a/sources/pyside2/libpyside/globalreceiverv2.cpp
+++ b/sources/pyside2/libpyside/globalreceiverv2.cpp
@@ -100,9 +100,6 @@ DynamicSlotDataV2::DynamicSlotDataV2(PyObject *callback, GlobalReceiverV2 *paren
//Can not store calback pointe because this will be destroyed at the end of the scope
//To avoid increment intance reference keep the callback information
m_callback = PyMethod_GET_FUNCTION(callback);
-#ifndef IS_PY3K
- m_pyClass = PyMethod_GET_CLASS(callback);
-#endif
m_pythonSelf = PyMethod_GET_SELF(callback);
//monitor class from method lifetime
@@ -140,11 +137,7 @@ PyObject *DynamicSlotDataV2::callback()
//create a callback based on method data
if (m_isMethod)
-#ifdef IS_PY3K
callback = PyMethod_New(m_callback, m_pythonSelf);
-#else
- callback = PyMethod_New(m_callback, m_pythonSelf, m_pyClass);
-#endif
else
Py_INCREF(callback);
@@ -283,11 +276,7 @@ int GlobalReceiverV2::refCount(const QObject *link) const
void GlobalReceiverV2::notify()
{
-#if QT_VERSION >= 0x050E00
const QSet<const QObject *> objSet(m_refs.cbegin(), m_refs.cend());
-#else
- const auto objSet = QSet<const QObject *>::fromList(m_refs);
-#endif
Py_BEGIN_ALLOW_THREADS
for (const QObject *o : objSet) {
QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
index 219b99d48..2404788d3 100644
--- a/sources/pyside2/libpyside/pyside.cpp
+++ b/sources/pyside2/libpyside/pyside.cpp
@@ -473,13 +473,11 @@ QString pyStringToQString(PyObject *str) {
if (str == Py_None)
return QString();
-#ifdef IS_PY3K
if (PyUnicode_Check(str)) {
const char *unicodeBuffer = _PepUnicode_AsString(str);
if (unicodeBuffer)
return QString::fromUtf8(unicodeBuffer);
}
-#endif
if (PyBytes_Check(str)) {
const char *asciiBuffer = PyBytes_AS_STRING(str);
if (asciiBuffer)
diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h
index c1a298cc8..e241ac74d 100644
--- a/sources/pyside2/libpyside/pyside.h
+++ b/sources/pyside2/libpyside/pyside.h
@@ -144,9 +144,11 @@ PYSIDE_API PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_t
#ifdef PYSIDE_QML_SUPPORT
// Used by QtQuick module to notify QtQml that custom QtQuick items can be registered.
-typedef bool (*QuickRegisterItemFunction)(PyObject *pyObj, const char *uri, int versionMajor,
- int versionMinor, const char *qmlName,
- QQmlPrivate::RegisterType *);
+using QuickRegisterItemFunction =
+ bool (*)(PyObject *pyObj, const char *uri, int versionMajor,
+ int versionMinor, const char *qmlName,
+ bool creatable, const char *noCreationReason,
+ QQmlPrivate::RegisterType *);
PYSIDE_API QuickRegisterItemFunction getQuickRegisterItemFunction();
PYSIDE_API void setQuickRegisterItemFunction(QuickRegisterItemFunction function);
#endif // PYSIDE_QML_SUPPORT
@@ -169,4 +171,3 @@ PYSIDE_API bool registerInternalQtConf();
#endif // PYSIDE_H
-
diff --git a/sources/pyside2/libpyside/pysidemetafunction.cpp b/sources/pyside2/libpyside/pysidemetafunction.cpp
index afb3dbb1a..0b7799af1 100644
--- a/sources/pyside2/libpyside/pysidemetafunction.cpp
+++ b/sources/pyside2/libpyside/pysidemetafunction.cpp
@@ -176,14 +176,14 @@ bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
Shiboken::Conversions::SpecificConverter converter(typeName);
if (converter) {
- int typeId = QMetaType::type(typeName);
+ int typeId = QMetaType::fromName(typeName).id();
if (!Shiboken::Conversions::pythonTypeIsObjectType(converter)) {
if (!typeId) {
PyErr_Format(PyExc_TypeError, "Value types used on meta functions (including signals) need to be "
"registered on meta type: %s", typeName.data());
break;
}
- methValues[i] = QVariant(typeId, static_cast<const void *>(0));
+ methValues[i] = QVariant(static_cast<QVariant::Type>(typeId));
}
methArgs[i] = methValues[i].data();
if (i == 0) // Don't do this for return type
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
index 443098f2e..d79a46ade 100644
--- a/sources/pyside2/libpyside/pysideproperty.cpp
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -157,17 +157,8 @@ static void qpropertyMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::C
break;
}
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- case QMetaObject::RegisterQPropertyObserver:
- case QMetaObject::SetQPropertyBinding:
-#else
- case QMetaObject::QueryPropertyDesignable:
- case QMetaObject::QueryPropertyScriptable:
- case QMetaObject::QueryPropertyStored:
- case QMetaObject::QueryPropertyEditable:
- case QMetaObject::QueryPropertyUser:
// just to avoid gcc warnings
-#endif
+ case QMetaObject::BindableProperty:
case QMetaObject::InvokeMetaMethod:
case QMetaObject::CreateInstance:
case QMetaObject::IndexOfMethod:
diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp
index b141ce157..b07a73332 100644
--- a/sources/pyside2/libpyside/pysideqflags.cpp
+++ b/sources/pyside2/libpyside/pysideqflags.cpp
@@ -141,21 +141,13 @@ namespace PySide
namespace QFlags
{
static PyType_Slot SbkNewQFlagsType_slots[] = {
-#ifdef IS_PY3K
{Py_nb_bool, 0},
-#else
- {Py_nb_nonzero, 0},
- {Py_nb_long, 0},
-#endif
{Py_nb_invert, 0},
{Py_nb_and, 0},
{Py_nb_xor, 0},
{Py_nb_or, 0},
{Py_nb_int, reinterpret_cast<void*>(qflag_int)},
{Py_nb_index, reinterpret_cast<void*>(qflag_int)},
-#ifndef IS_PY3K
- {Py_nb_long, 0},
-#endif
{Py_tp_new, (void *)PySideQFlagsNew},
{Py_tp_richcompare, (void *)PySideQFlagsRichCompare},
{Py_tp_dealloc, (void *)Sbk_object_dealloc},
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp
index 5c030316e..f3fb4e06d 100644
--- a/sources/pyside2/libpyside/pysidesignal.cpp
+++ b/sources/pyside2/libpyside/pysidesignal.cpp
@@ -227,13 +227,9 @@ static int signalTpInit(PyObject *self, PyObject *args, PyObject *kwds)
Py_ssize_t argument_size = PySequence_Size(argArguments);
for (Py_ssize_t i = 0; i < argument_size; ++i) {
PyObject *item = PySequence_GetItem(argArguments, i);
-#ifdef IS_PY3K
PyObject *strObj = PyUnicode_AsUTF8String(item);
char *s = PyBytes_AsString(strObj);
Py_DECREF(strObj);
-#else
- char *s = PyBytes_AsString(item);
-#endif
Py_DECREF(item);
if (s != nullptr)
data->data->signalArguments->append(QByteArray(s));
diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp
index 93847e066..0992cfcfd 100644
--- a/sources/pyside2/libpyside/signalmanager.cpp
+++ b/sources/pyside2/libpyside/signalmanager.cpp
@@ -66,9 +66,6 @@
#include <private/qv4engine_p.h>
#include <private/qv4context_p.h>
#include <private/qqmldata_p.h>
-#if QT_VERSION < 0x050700
- #include <private/qqmlcontextwrapper_p.h>
-#endif
#endif
#if QSLOT_CODE != 1 || QSIGNAL_CODE != 2
@@ -85,7 +82,6 @@ namespace {
static PyObject *parseArguments(const QList< QByteArray >& paramTypes, void **args);
static bool emitShortCircuitSignal(QObject *source, int signalIndex, PyObject *args);
-#ifdef IS_PY3K
static void destroyMetaObject(PyObject *obj)
{
void *ptr = PyCapsule_GetPointer(obj, 0);
@@ -95,17 +91,6 @@ namespace {
Shiboken::BindingManager::instance().releaseWrapper(wrapper);
delete meta;
}
-
-#else
- static void destroyMetaObject(void *obj)
- {
- auto meta = reinterpret_cast<PySide::MetaObjectBuilder *>(obj);
- SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta);
- if (wrapper)
- Shiboken::BindingManager::instance().releaseWrapper(wrapper);
- delete meta;
- }
-#endif
}
namespace PySide {
@@ -275,9 +260,6 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate)
// Register PyObject type to use in queued signal and slot connections
qRegisterMetaType<PyObjectWrapper>("PyObject");
- qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PyObject");
- qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PyObjectWrapper");
- qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PySide::PyObjectWrapper");
SbkConverter *converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, nullptr);
Shiboken::Conversions::setCppPointerToPythonFunction(converter, PyObject_PTR_CppToPython_PyObject);
@@ -411,13 +393,6 @@ int SignalManager::qt_metacall(QObject *object, QMetaObject::Call call, int id,
case QMetaObject::ReadProperty:
case QMetaObject::WriteProperty:
case QMetaObject::ResetProperty:
-# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- case QMetaObject::QueryPropertyDesignable:
- case QMetaObject::QueryPropertyScriptable:
- case QMetaObject::QueryPropertyStored:
- case QMetaObject::QueryPropertyEditable:
- case QMetaObject::QueryPropertyUser:
-# endif // < Qt 6
pp->d->metaCallHandler(pp, pySelf, call, args);
break;
#endif
@@ -456,15 +431,7 @@ int SignalManager::qt_metacall(QObject *object, QMetaObject::Call call, int id,
if (data && !data->jsWrapper.isNullOrUndefined()) {
QV4::ExecutionEngine *engine = data->jsWrapper.engine();
-#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
if (engine->currentStackFrame != nullptr) {
-#elif QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
- if (engine->currentContext->d() != engine->rootContext()->d()) {
-#else
- QV4::ExecutionContext *ctx = engine->currentContext();
- if (ctx->type == QV4::Heap::ExecutionContext::Type_CallContext ||
- ctx->type == QV4::Heap::ExecutionContext::Type_SimpleCallContext) {
-#endif
PyObject *errType, *errValue, *errTraceback;
PyErr_Fetch(&errType, &errValue, &errTraceback);
// PYSIDE-464: The error is only valid before PyErr_Restore,
@@ -477,7 +444,6 @@ int SignalManager::qt_metacall(QObject *object, QMetaObject::Call call, int id,
PyErr_Print(); // Note: PyErr_Print clears the error.
-#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
if (isSyntaxError) {
return engine->throwSyntaxError(errString);
} else if (isTypeError) {
@@ -485,18 +451,9 @@ int SignalManager::qt_metacall(QObject *object, QMetaObject::Call call, int id,
} else {
return engine->throwError(errString);
}
-#else
- if (isSyntaxError) {
- return ctx->throwSyntaxError(errString);
- } else if (isTypeError) {
- return ctx->throwTypeError(errString);
- } else {
- return ctx->throwError(errString);
- }
-#endif
}
}
-#endif
+#endif // PYSIDE_QML_PRIVATE_API_SUPPORT
int reclimit = Py_GetRecursionLimit();
// Inspired by Python's errors.c: PyErr_GivenExceptionMatches() function.
@@ -572,11 +529,7 @@ static MetaObjectBuilder *metaBuilderFromDict(PyObject *dict)
// PyDict_GetItem would touch PyThreadState_GET and the global error state.
// PyDict_GetItemWithError instead can work without GIL.
PyObject *pyBuilder = PyDict_GetItemWithError(dict, metaObjectAttr);
-#ifdef IS_PY3K
return reinterpret_cast<MetaObjectBuilder *>(PyCapsule_GetPointer(pyBuilder, nullptr));
-#else
- return reinterpret_cast<MetaObjectBuilder *>(PyCObject_AsVoidPtr(pyBuilder));
-#endif
}
int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signature, QMetaMethod::MethodType type)
@@ -602,12 +555,7 @@ int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signa
// Create a instance meta object
if (!dmo) {
dmo = new MetaObjectBuilder(Py_TYPE(pySelf), metaObject);
-#ifdef IS_PY3K
PyObject *pyDmo = PyCapsule_New(dmo, 0, destroyMetaObject);
-#else
- PyObject *pyDmo = PyCObject_FromVoidPtr(dmo, destroyMetaObject);
-#endif
-
PyObject_SetAttr(pySelf, metaObjectAttr, pyDmo);
Py_DECREF(pyDmo);
}
diff --git a/sources/pyside2/plugins/CMakeLists.txt b/sources/pyside2/plugins/CMakeLists.txt
index c9e652800..9be985198 100644
--- a/sources/pyside2/plugins/CMakeLists.txt
+++ b/sources/pyside2/plugins/CMakeLists.txt
@@ -1,21 +1,20 @@
project(plugins)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+
+find_package(Qt6 COMPONENTS Core)
+find_package(Qt6 COMPONENTS Gui)
+find_package(Qt6 COMPONENTS Widgets)
+find_package(Qt6 COMPONENTS UiPlugin)
+
set(ui_plugin_src
customwidgets.cpp
customwidget.cpp
)
-set(ui_plugin_moc
- customwidget.h
- customwidgets.h
-)
-include_directories(${Qt${QT_MAJOR_VERSION}Designer_INCLUDE_DIRS})
-
-if (${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- qt6_wrap_cpp(MOC_FILES ${ui_plugin_moc})
-else()
- qt5_wrap_cpp(MOC_FILES ${ui_plugin_moc})
-endif()
+qt_wrap_cpp(MOC_FILES ${ui_plugin_moc})
add_library(uiplugin STATIC ${ui_plugin_src} ${MOC_FILES})
if(CMAKE_HOST_UNIX AND NOT CYGWIN)
@@ -30,7 +29,10 @@ else()
endif()
target_link_libraries(uiplugin
- ${Qt${QT_MAJOR_VERSION}UiTools_LIBRARY}
+ Qt::Core
+ Qt::Gui
+ Qt::UiPlugin
+ Qt::Widgets
Shiboken2::libshiboken)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_DEBUG_POSTFIX})
diff --git a/sources/pyside2/tests/CMakeLists.txt b/sources/pyside2/tests/CMakeLists.txt
index 285ea872f..86150ac1f 100644
--- a/sources/pyside2/tests/CMakeLists.txt
+++ b/sources/pyside2/tests/CMakeLists.txt
@@ -1,56 +1,52 @@
-if(CMAKE_VERSION VERSION_LESS 2.8)
- message("CMake version greater than 2.8 necessary to run tests")
-else()
- if(NOT CTEST_TESTING_TIMEOUT)
- set(CTEST_TESTING_TIMEOUT 60)
- endif()
-
- # BUILD_DIR and QT_DIR are used by init_paths.py for setting
- # the path to the testbinding module
- get_filename_component(BUILD_DIR "${CMAKE_BINARY_DIR}" DIRECTORY)
- get_filename_component(BUILD_DIR "${CMAKE_BINARY_DIR}" DIRECTORY)
- set(QT_DIR "${_qt5Core_install_prefix}")
+if(NOT CTEST_TESTING_TIMEOUT)
+ set(CTEST_TESTING_TIMEOUT 60)
+endif()
- macro(TEST_QT_MODULE var name)
- if(NOT DISABLE_${name} AND ${var})
- add_subdirectory(${name})
- endif()
- endmacro()
+# BUILD_DIR and QT_DIR are used by init_paths.py for setting
+# the path to the testbinding module
+get_filename_component(BUILD_DIR "${CMAKE_BINARY_DIR}" DIRECTORY)
+get_filename_component(BUILD_DIR "${CMAKE_BINARY_DIR}" DIRECTORY)
+set(QT_DIR "${_qt5Core_install_prefix}")
- macro(PYSIDE_TEST)
- string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" )
- set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
- if (${ARGC} EQUAL 1)
- set(EXPECT_TO_FAIL 0)
- elseif(${ARGC} EQUAL 2)
- set(EXPECT_TO_FAIL ${ARGV1})
- else()
- message(WARNING "Invalid call of macro PYSIDE_TEST")
- endif()
- set(TEST_CMD ${XVFB_EXEC} ${SHIBOKEN_PYTHON_INTERPRETER} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}")
- add_test(${TEST_NAME} ${TEST_CMD})
- # QT_NO_GLIB=1 is required to avoid crashes on CI RHEL 6.6 machines.
- # See QTBUG-64716 for details.
- set_tests_properties(${TEST_NAME} PROPERTIES
- TIMEOUT ${CTEST_TESTING_TIMEOUT}
- WILL_FAIL ${EXPECT_TO_FAIL}
- ENVIRONMENT "BUILD_DIR=${BUILD_DIR};QT_DIR=${QT_DIR};PYSIDE_DISABLE_INTERNAL_QT_CONF=1;QT_NO_GLIB=1")
- endmacro()
+macro(TEST_QT_MODULE var name)
+ if(NOT DISABLE_${name} AND ${var})
+ add_subdirectory(${name})
+ endif()
+endmacro()
- if (NOT DISABLE_QtCore AND NOT DISABLE_QtGui AND NOT DISABLE_QtWidgets)
- add_subdirectory(pysidetest)
+macro(PYSIDE_TEST)
+ string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" )
+ set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
+ if (${ARGC} EQUAL 1)
+ set(EXPECT_TO_FAIL 0)
+ elseif(${ARGC} EQUAL 2)
+ set(EXPECT_TO_FAIL ${ARGV1})
+ else()
+ message(WARNING "Invalid call of macro PYSIDE_TEST")
endif()
- add_subdirectory(registry)
- add_subdirectory(signals)
- add_subdirectory(support)
+ set(TEST_CMD ${XVFB_EXEC} ${SHIBOKEN_PYTHON_INTERPRETER} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}")
+ add_test(${TEST_NAME} ${TEST_CMD})
+ # QT_NO_GLIB=1 is required to avoid crashes on CI RHEL 6.6 machines.
+ # See QTBUG-64716 for details.
+ set_tests_properties(${TEST_NAME} PROPERTIES
+ TIMEOUT ${CTEST_TESTING_TIMEOUT}
+ WILL_FAIL ${EXPECT_TO_FAIL}
+ ENVIRONMENT "BUILD_DIR=${BUILD_DIR};QT_DIR=${QT_DIR};PYSIDE_DISABLE_INTERNAL_QT_CONF=1;QT_NO_GLIB=1")
+endmacro()
- foreach(shortname IN LISTS all_module_shortnames)
- message(STATUS "preparing tests for module 'Qt${shortname}'")
- TEST_QT_MODULE(Qt${QT_MAJOR_VERSION}${shortname}_FOUND Qt${shortname})
- endforeach()
-
- #platform specific
- if (ENABLE_MAC)
- add_subdirectory(mac)
- endif ()
+if (NOT DISABLE_QtCore AND NOT DISABLE_QtGui AND NOT DISABLE_QtWidgets)
+ add_subdirectory(pysidetest)
endif()
+add_subdirectory(registry)
+add_subdirectory(signals)
+add_subdirectory(support)
+
+foreach(shortname IN LISTS all_module_shortnames)
+ message(STATUS "preparing tests for module 'Qt${shortname}'")
+ TEST_QT_MODULE(Qt${QT_MAJOR_VERSION}${shortname}_FOUND Qt${shortname})
+endforeach()
+
+#platform specific
+if (ENABLE_MAC)
+ add_subdirectory(mac)
+endif ()
diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt
index 9d268e079..ee87345db 100644
--- a/sources/pyside2/tests/QtCore/CMakeLists.txt
+++ b/sources/pyside2/tests/QtCore/CMakeLists.txt
@@ -23,7 +23,6 @@ PYSIDE_TEST(bug_953.py)
PYSIDE_TEST(bug_987.py)
PYSIDE_TEST(bug_994.py)
PYSIDE_TEST(bug_1019.py)
-PYSIDE_TEST(bug_1031.py)
PYSIDE_TEST(bug_1063.py)
PYSIDE_TEST(bug_1069.py)
PYSIDE_TEST(bug_1313.py)
@@ -46,10 +45,8 @@ PYSIDE_TEST(multiple_feature_test.py)
PYSIDE_TEST(python_conversion.py)
PYSIDE_TEST(qabs_test.py)
PYSIDE_TEST(qabstractitemmodel_test.py)
-PYSIDE_TEST(qabstracttransition_test.py)
PYSIDE_TEST(qanimationgroup_test.py)
PYSIDE_TEST(qbitarray_test.py)
-PYSIDE_TEST(qbytearray_buffer_protocol_test.py)
PYSIDE_TEST(qbytearray_concatenation_operator_test.py)
PYSIDE_TEST(qbytearray_operator_iadd_test.py)
PYSIDE_TEST(qbytearray_operator_test.py)
@@ -99,7 +96,6 @@ PYSIDE_TEST(qpoint_test.py)
PYSIDE_TEST(qprocess_test.py)
PYSIDE_TEST(qproperty_decorator.py)
PYSIDE_TEST(qrect_test.py)
-PYSIDE_TEST(qregexp_test.py)
PYSIDE_TEST(qregularexpression_test.py)
PYSIDE_TEST(qresource_test.py)
PYSIDE_TEST(qsettings_test.py)
@@ -108,12 +104,9 @@ PYSIDE_TEST(qslot_object_test.py)
PYSIDE_TEST(qsocketnotifier_test.py)
PYSIDE_TEST(qsrand_test.py)
PYSIDE_TEST(qstandardpaths_test.py)
-PYSIDE_TEST(qstatemachine_test.py)
-PYSIDE_TEST(qstate_test.py)
PYSIDE_TEST(qstorageinfo_test.py)
PYSIDE_TEST(qstring_test.py)
PYSIDE_TEST(qsysinfo_test.py)
-PYSIDE_TEST(qtext_codec_test.py)
PYSIDE_TEST(qtextstream_test.py)
PYSIDE_TEST(qthread_prod_cons_test.py)
PYSIDE_TEST(qthread_signal_test.py)
diff --git a/sources/pyside2/tests/QtCore/bug_1031.py b/sources/pyside2/tests/QtCore/bug_1031.py
deleted file mode 100644
index 6a7f248cc..000000000
--- a/sources/pyside2/tests/QtCore/bug_1031.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-
-sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "util"))
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths()
-
-from PySide2.QtCore import QStateMachine, QState
-
-mach = QStateMachine()
-state = QState(mach)
-print(state.machine())
diff --git a/sources/pyside2/tests/QtCore/bug_1063.py b/sources/pyside2/tests/QtCore/bug_1063.py
index 73291bffc..db55dc1e0 100644
--- a/sources/pyside2/tests/QtCore/bug_1063.py
+++ b/sources/pyside2/tests/QtCore/bug_1063.py
@@ -38,7 +38,7 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2 import QtCore
-import py3kcompat as py3k
+
class QTextStreamTestCase(unittest.TestCase):
def setUp(self):
@@ -46,7 +46,7 @@ class QTextStreamTestCase(unittest.TestCase):
self.temp_file.close()
self.f = QtCore.QFile(self.temp_file.name)
self.f.open(QtCore.QIODevice.WriteOnly)
- self.strings = (py3k.unicode_('foo'), py3k.unicode_('bar'))
+ self.strings = ('foo', 'bar')
self.stream = QtCore.QTextStream(self.f)
def testIt(self):
diff --git a/sources/pyside2/tests/QtCore/bug_1313.py b/sources/pyside2/tests/QtCore/bug_1313.py
index a24c53b99..9f7742c84 100644
--- a/sources/pyside2/tests/QtCore/bug_1313.py
+++ b/sources/pyside2/tests/QtCore/bug_1313.py
@@ -37,7 +37,6 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2 import QtCore
-import py3kcompat as py3k
class MyQObject(QtCore.QObject):
@@ -51,11 +50,9 @@ async def demo_coroutine():
"""
-if py3k.IS_PY3K:
- exec(demo_coroutine_definition_code)
+exec(demo_coroutine_definition_code)
-@unittest.skipIf(not py3k.IS_PY3K, "Requires Python 3 due to use of async def")
class CoroutineRaisesStopIterationTestCase(unittest.TestCase):
def setUp(self):
self.coroutine = demo_coroutine()
diff --git a/sources/pyside2/tests/QtCore/bug_938.py b/sources/pyside2/tests/QtCore/bug_938.py
index bbac1845b..4e70a8604 100644
--- a/sources/pyside2/tests/QtCore/bug_938.py
+++ b/sources/pyside2/tests/QtCore/bug_938.py
@@ -35,14 +35,14 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import *
-import py3kcompat as py3k
+
class TestBug938 (unittest.TestCase):
def testIt(self):
b = QBuffer()
b.open(QBuffer.WriteOnly)
- b.write(py3k.b("\x0023\x005"))
+ b.write(bytes("\x0023\x005", "UTF-8"))
b.close()
self.assertEqual(b.buffer().size(), 5)
diff --git a/sources/pyside2/tests/QtCore/bug_994.py b/sources/pyside2/tests/QtCore/bug_994.py
index 1a9649a10..5465f4e01 100644
--- a/sources/pyside2/tests/QtCore/bug_994.py
+++ b/sources/pyside2/tests/QtCore/bug_994.py
@@ -34,16 +34,15 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtCore import QIODevice, QTextStream
class MyIODevice (QIODevice):
def readData(self, amount):
- return py3k.b("\0a" * int(amount/2))
+ return bytes("\0a" * int(amount/2), "UTF-8")
def readLineData(self, maxSize):
- return py3k.b("\0b" * 4)
+ return bytes("\0b" * 4, "UTF-8")
def atEnd(self):
return False
diff --git a/sources/pyside2/tests/QtCore/deepcopy_test.py b/sources/pyside2/tests/QtCore/deepcopy_test.py
index ab17a2e14..2fafea354 100644
--- a/sources/pyside2/tests/QtCore/deepcopy_test.py
+++ b/sources/pyside2/tests/QtCore/deepcopy_test.py
@@ -37,7 +37,6 @@ init_test_paths(False)
from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QDir, QPoint, QPointF
-import py3kcompat as py3k
try:
from PySide2.QtCore import QUuid
HAVE_Q = True
@@ -52,7 +51,7 @@ class DeepCopyHelper:
class QByteArrayDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QByteArray(py3k.b('the quick brown fox jumps over the lazy dog'))
+ self.original = QByteArray(bytes('the quick brown fox jumps over the lazy dog', "UTF-8"))
class QDateDeepCopy(DeepCopyHelper, unittest.TestCase):
diff --git a/sources/pyside2/tests/QtCore/qabstracttransition_test.py b/sources/pyside2/tests/QtCore/qabstracttransition_test.py
deleted file mode 100644
index 063d266d2..000000000
--- a/sources/pyside2/tests/QtCore/qabstracttransition_test.py
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-from sys import getrefcount
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import *
-
-def addStates(transition):
- sx = QState()
- sy = QState()
- transition.setTargetStates([sx, sy])
-
-def addAnimation(transition):
- animation = QParallelAnimationGroup()
- transition.addAnimation(animation)
-
-class QAbstractTransitionTest(unittest.TestCase):
-
- def testBasic(self):
- app = QCoreApplication([])
-
- o = QObject()
- o.setProperty("text", "INdT")
-
- machine = QStateMachine()
- s1 = QState()
- s1.assignProperty(o, "text", "Rocks")
-
- s2 = QFinalState()
- t = s1.addTransition(o, SIGNAL("change()"), s2)
-
- self.assertEqual(t.targetStates(), [s2])
-
- addStates(t)
- self.assertEqual(len(t.targetStates()), 2)
-
- animation = QParallelAnimationGroup()
- t.addAnimation(animation)
-
- self.assertEqual(t.animations(), [animation])
-
- addAnimation(t)
- self.assertEqual(t.animations()[0].parent(), None)
-
- machine.addState(s1)
- machine.addState(s2)
- machine.setInitialState(s1)
- machine.start()
-
- QTimer.singleShot(100, app.quit)
- app.exec_()
-
- def testRefCountOfTargetState(self):
- transition = QEventTransition()
- state1 = QState()
- refcount1 = getrefcount(state1)
-
- transition.setTargetState(state1)
-
- self.assertEqual(transition.targetState(), state1)
- self.assertEqual(getrefcount(transition.targetState()), refcount1 + 1)
-
- state2 = QState()
- refcount2 = getrefcount(state2)
-
- transition.setTargetState(state2)
-
- self.assertEqual(transition.targetState(), state2)
- self.assertEqual(getrefcount(transition.targetState()), refcount2 + 1)
- self.assertEqual(getrefcount(state1), refcount1)
-
- del transition
-
- self.assertEqual(getrefcount(state2), refcount2)
-
- def testRefCountOfTargetStates(self):
- transition = QEventTransition()
- state1 = QState()
- state2 = QState()
- states = [state1, state2]
- refcount1 = getrefcount(state1)
- refcount2 = getrefcount(state2)
-
- transition.setTargetStates(states)
-
- self.assertEqual(transition.targetStates(), states)
- self.assertEqual(transition.targetState(), state1)
- self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1)
- self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1)
-
- del states
- del transition
-
- self.assertEqual(getrefcount(state1), refcount1 - 1)
- self.assertEqual(getrefcount(state2), refcount2 - 1)
-
- def testRefCountOfTargetStatesAfterSingleTargetState(self):
- transition = QEventTransition()
- state0 = QState()
- refcount0 = getrefcount(state0)
-
- transition.setTargetState(state0)
-
- self.assertEqual(transition.targetState(), state0)
- self.assertEqual(getrefcount(transition.targetState()), refcount0 + 1)
-
- state1 = QState()
- state2 = QState()
- states = [state1, state2]
- refcount1 = getrefcount(state1)
- refcount2 = getrefcount(state2)
-
- transition.setTargetStates(states)
-
- self.assertEqual(getrefcount(state0), refcount0)
- self.assertEqual(transition.targetStates(), states)
- self.assertEqual(transition.targetState(), state1)
- self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1)
- self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1)
-
- del states
- del transition
-
- self.assertEqual(getrefcount(state1), refcount1 - 1)
- self.assertEqual(getrefcount(state2), refcount2 - 1)
-
- def testRefCountOfTargetStatesBeforeSingleTargetState(self):
- transition = QEventTransition()
- state1 = QState()
- state2 = QState()
- states = [state1, state2]
- refcount1 = getrefcount(state1)
- refcount2 = getrefcount(state2)
-
- transition.setTargetStates(states)
-
- self.assertEqual(transition.targetStates(), states)
- self.assertEqual(transition.targetState(), state1)
- self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1)
- self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1)
-
- state3 = QState()
- refcount3 = getrefcount(state3)
-
- transition.setTargetState(state3)
-
- self.assertEqual(transition.targetState(), state3)
- self.assertEqual(getrefcount(transition.targetState()), refcount3 + 1)
-
- del states
-
- self.assertEqual(getrefcount(state1), refcount1 - 1)
- self.assertEqual(getrefcount(state2), refcount2 - 1)
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py b/sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py
deleted file mode 100644
index 20f8fa915..000000000
--- a/sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-'''Tests QByteArray implementation of Python buffer protocol'''
-
-import os
-from os.path import isdir
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-import py3kcompat as py3k
-
-from PySide2.QtCore import QByteArray
-
-
-class QByteArrayBufferProtocolTest(unittest.TestCase):
- '''Tests QByteArray implementation of Python buffer protocol'''
-
- def testQByteArrayBufferProtocol(self):
- if py3k.IS_PY3K:
- return
- #Tests QByteArray implementation of Python buffer protocol using the os.path.isdir
- #function which an unicode object or other object implementing the Python buffer protocol
- isdir(QByteArray('/tmp'))
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py b/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
index 1375c3ab3..6d369bf0b 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
@@ -40,25 +40,25 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QByteArray
-import py3kcompat as py3k
+
class QByteArrayConcatenationOperatorTest(unittest.TestCase):
'''Test cases for QByteArray concatenation with '+' operator'''
def testConcatQByteArrayAndPythonString(self):
#Test concatenation of a QByteArray with a Python bytes, in this order
- qba = QByteArray(py3k.b('foo'))
- result = qba + py3k.b('\x00bar')
+ qba = QByteArray(bytes('foo', "UTF-8"))
+ result = qba + bytes('\x00bar', "UTF-8")
self.assertEqual(type(result), QByteArray)
- self.assertEqual(result, py3k.b('foo\x00bar'))
+ self.assertEqual(result, bytes('foo\x00bar', "UTF-8"))
def testConcatPythonStringAndQByteArray(self):
#Test concatenation of a Python bytes with a QByteArray, in this order
concat_python_string_add_qbytearray_worked = True
- qba = QByteArray(py3k.b('foo'))
- result = py3k.b('bar\x00') + qba
+ qba = QByteArray(bytes('foo', "UTF-8"))
+ result = bytes('bar\x00', "UTF-8") + qba
self.assertEqual(type(result), QByteArray)
- self.assertEqual(result, py3k.b('bar\x00foo'))
+ self.assertEqual(result, bytes('bar\x00foo', "UTF-8"))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py b/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
index d0a65465b..da9ca5b38 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
@@ -36,7 +36,7 @@ init_test_paths(False)
from PySide2.QtCore import QByteArray
from helper.docmodifier import DocModifier
-import py3kcompat as py3k
+
class BaseQByteArrayOperatorIAdd(object):
'''Base class for QByteArray += operator tests.
@@ -49,21 +49,21 @@ class BaseQByteArrayOperatorIAdd(object):
def testSingleString(self):
'''QByteArray += bytes of size 1'''
- s = py3k.b('0')
+ s = bytes('0', "UTF-8")
self.obj += s
self.assertEqual(self.obj, self.orig_obj + s)
self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s))
def testString(self):
'''QByteArray += bytes of size > 1'''
- s = bytearray(py3k.b('dummy'))
+ s = bytearray(bytes('dummy', "UTF-8"))
self.obj += s # XXx iadd support abytearray
self.assertEqual(self.obj, self.orig_obj + s)
self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s))
def testQByteArray(self):
'''QByteArray += QByteArray'''
- s = QByteArray(py3k.b('array'))
+ s = QByteArray(bytes('array', "UTF-8"))
self.obj += s
self.assertEqual(self.obj, self.orig_obj + s)
@@ -86,8 +86,8 @@ class ValidQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd)
doc_filter = lambda x: x.startswith('test')
def setUp(self):
- self.obj = QByteArray(py3k.b('some byte array'))
- self.orig_obj = QByteArray(py3k.b('some byte array'))
+ self.obj = QByteArray(bytes('some byte array', "UTF-8"))
+ self.orig_obj = QByteArray(bytes('some byte array', "UTF-8"))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbytearray_operator_test.py b/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
index b19179429..01000341c 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
@@ -39,8 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QByteArray
class QByteArrayOperatorEqual(unittest.TestCase):
@@ -54,12 +52,12 @@ class QByteArrayOperatorEqual(unittest.TestCase):
def testSimple(self):
#QByteArray(some_string) == QByteArray(some_string)
- string = py3k.b('egg snakes')
+ string = bytes('egg snakes', "UTF-8")
self.assertEqual(QByteArray(string), QByteArray(string))
def testPyString(self):
#QByteArray(string) == string
- string = py3k.b('my test string')
+ string = bytes('my test string', "UTF-8")
self.assertEqual(QByteArray(string), string)
class QByteArrayOperatorAt(unittest.TestCase):
@@ -68,30 +66,30 @@ class QByteArrayOperatorAt(unittest.TestCase):
def testInRange(self):
#QByteArray[x] where x is a valid index
string = 'abcdefgh'
- obj = QByteArray(py3k.b(string))
+ obj = QByteArray(bytes(string, "UTF-8"))
for i in range(len(string)):
- self.assertEqual(obj[i], py3k.b(string[i]))
+ self.assertEqual(obj[i], bytes(string[i], "UTF-8"))
def testInRangeReverse(self):
#QByteArray[x] where x is a valid index (reverse order)
string = 'abcdefgh'
- obj = QByteArray(py3k.b(string))
+ obj = QByteArray(bytes(string, "UTF-8"))
for i in range(len(string)-1, 0, -1):
- self.assertEqual(obj[i], py3k.b(string[i]))
+ self.assertEqual(obj[i], bytes(string[i], "UTF-8"))
def testOutOfRange(self):
#QByteArray[x] where x is out of index
- string = py3k.b('1234567')
+ string = bytes('1234567', "UTF-8")
obj = QByteArray(string)
self.assertRaises(IndexError, lambda :obj[len(string)])
def testNullStrings(self):
- ba = QByteArray(py3k.b('\x00'))
+ ba = QByteArray(bytes('\x00', "UTF-8"))
self.assertEqual(ba.at(0), '\x00')
- self.assertEqual(ba[0], py3k.b('\x00'))
+ self.assertEqual(ba[0], bytes('\x00', "UTF-8"))
class QByteArrayOperatorLen(unittest.TestCase):
'''Test case for __len__ operator of QByteArray'''
@@ -99,9 +97,9 @@ class QByteArrayOperatorLen(unittest.TestCase):
def testBasic(self):
'''QByteArray __len__'''
self.assertEqual(len(QByteArray()), 0)
- self.assertEqual(len(QByteArray(py3k.b(''))), 0)
- self.assertEqual(len(QByteArray(py3k.b(' '))), 1)
- self.assertEqual(len(QByteArray(py3k.b('yabadaba'))), 8)
+ self.assertEqual(len(QByteArray(bytes('', "UTF-8"))), 0)
+ self.assertEqual(len(QByteArray(bytes(' ', "UTF-8"))), 1)
+ self.assertEqual(len(QByteArray(bytes('yabadaba', "UTF-8"))), 8)
class QByteArrayOperatorStr(unittest.TestCase):
@@ -110,8 +108,8 @@ class QByteArrayOperatorStr(unittest.TestCase):
def testBasic(self):
'''QByteArray __str__'''
self.assertEqual(QByteArray().__str__(), str(b''))
- self.assertEqual(QByteArray(py3k.b('')).__str__(), str(b''))
- self.assertEqual(QByteArray(py3k.b('aaa')).__str__(), str(b'aaa'))
+ self.assertEqual(QByteArray(bytes('', "UTF-8")).__str__(), str(b''))
+ self.assertEqual(QByteArray(bytes('aaa', "UTF-8")).__str__(), str(b'aaa'))
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtCore/qbytearray_test.py b/sources/pyside2/tests/QtCore/qbytearray_test.py
index c17b7efb1..529941706 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_test.py
@@ -41,32 +41,31 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtCore import QByteArray, QSettings, QObject, QDataStream, QIODevice
class QByteArrayTestToNumber(unittest.TestCase):
def testToNumberInt(self):
- obj = QByteArray(py3k.b('37'))
+ obj = QByteArray(bytes('37', "UTF8"))
self.assertEqual((37, True), obj.toInt())
def testToNumberUShort(self):
- obj = QByteArray(py3k.b('37'))
+ obj = QByteArray(bytes('37', "UTF8"))
self.assertEqual((37, True), obj.toUShort())
def testToNumberFloat(self):
- obj = QByteArray(py3k.b('37.109'))
+ obj = QByteArray(bytes('37.109', "UTF8"))
self.assertEqual((ctypes.c_float(37.109).value, True),
obj.toFloat())
def testToNumberDouble(self):
- obj = QByteArray(py3k.b('37.109'))
+ obj = QByteArray(bytes('37.109', "UTF8"))
self.assertEqual((ctypes.c_double(37.109).value, True),
obj.toDouble())
def testSetNum(self):
b = QByteArray()
- b.setNum(py3k.long(-124124))
+ b.setNum(int(-124124))
self.assertEqual(b, "-124124")
b = QByteArray()
b.setNum(-124124)
@@ -76,7 +75,7 @@ class QByteArrayTestToNumber(unittest.TestCase):
self.assertEqual(b, "-0.5")
def testNumber(self):
- b = QByteArray.number(py3k.long(-124124))
+ b = QByteArray.number(int(-124124))
self.assertEqual(b, "-124124")
b = QByteArray.number(-124124)
self.assertEqual(b, "-124124")
@@ -85,9 +84,9 @@ class QByteArrayTestToNumber(unittest.TestCase):
def testAppend(self):
b = QByteArray()
- b.append(py3k.b("A"))
+ b.append(bytes("A", "UTF8"))
self.assertEqual(b.size(), 1)
- b.append(py3k.b("AB"))
+ b.append(bytes("AB", "UTF8"))
self.assertEqual(b.size(), 3)
@@ -96,7 +95,7 @@ class QByteArraySplit(unittest.TestCase):
def testPathSeparator(self):
#QByteArray.split('/')
- obj = QByteArray(py3k.b(unittest.__file__))
+ obj = QByteArray(bytes(unittest.__file__, "UTF8"))
self.assertEqual(obj.split('/'), unittest.__file__.split('/'))
class QByteArrayData(unittest.TestCase):
@@ -104,14 +103,14 @@ class QByteArrayData(unittest.TestCase):
'''Test case for QByteArray.data'''
def testData(self):
- url = QByteArray(py3k.b("http://pyside.org"))
- self.assertEqual(url.data(), py3k.b("http://pyside.org"))
+ url = QByteArray(bytes("http://pyside.org", "UTF8"))
+ self.assertEqual(url.data(), bytes("http://pyside.org", "UTF8"))
def testDataWithZeros(self):
- s1 = py3k.b("123\000321")
+ s1 = bytes("123\000321", "UTF8")
ba = QByteArray(s1)
s2 = ba.data()
- self.assertEqual(py3k.b(s1), s2)
+ self.assertEqual(s1, s2)
self.assertEqual(s1, ba)
class QByteArrayOperatorAtSetter(unittest.TestCase):
@@ -119,9 +118,9 @@ class QByteArrayOperatorAtSetter(unittest.TestCase):
def testSetterString(self):
'''QByteArray[x] = pythonstring'''
- obj = QByteArray(py3k.b('123456'))
- obj[1] = py3k.b('0')
- self.assertEqual(obj, QByteArray(py3k.b('103456')))
+ obj = QByteArray(bytes('123456', "UTF8"))
+ obj[1] = bytes('0', "UTF8")
+ self.assertEqual(obj, QByteArray(bytes('103456', "UTF8")))
class QByteArrayOnQDataStream(unittest.TestCase):
'''
@@ -139,11 +138,9 @@ class TestBug664(unittest.TestCase):
QByteArray.data() should return correct data
'''
def testIt(self):
- a = QByteArray(py3k.unicode_('hi 猫').encode('utf-8'))
- if py3k.IS_PY3K:
- self.assertEqual(repr(a), "PySide2.QtCore.QByteArray(b'hi \\xe7\\x8c\\xab')")
- else:
- self.assertEqual(repr(a), "PySide2.QtCore.QByteArray('hi \\xe7\\x8c\\xab')")
+ a = QByteArray(bytes('hi 猫', "UTF-8"))
+ self.assertEqual(repr(a), "PySide2.QtCore.QByteArray(b'hi \\xe7\\x8c\\xab')")
+
class QByteArrayOnQVariant(unittest.TestCase):
def testQByteArrayOnQVariant(self):
@@ -155,7 +152,7 @@ class TestBug567(unittest.TestCase):
QByteArray should support slices
'''
def testIt(self):
- ba = QByteArray(py3k.b('1234567890'))
+ ba = QByteArray(bytes('1234567890', "UTF8"))
self.assertEqual(ba[2:4], '34')
self.assertEqual(ba[:4], '1234')
self.assertEqual(ba[4:], '567890')
@@ -165,123 +162,114 @@ class TestBug567(unittest.TestCase):
self.assertEqual(ba[::-2], '08642')
self.assertEqual(ba[2:8:3], '36')
-class QByteArrayBug514(unittest.TestCase):
- def testIt(self):
- data = py3k.b("foobar")
- a = QByteArray.fromRawData(data)
- self.assertEqual(type(a), QByteArray)
- self.assertEqual(a.data(), data)
class TestPickler(unittest.TestCase):
def testIt(self):
- ba = QByteArray(py3k.b("321\x00123"))
+ ba = QByteArray(bytes("321\x00123", "UTF8"))
output = pickle.dumps(str(ba))
ba2 = pickle.loads(output)
self.assertEqual(str(ba), str(ba2))
class QByteArrayBug720(unittest.TestCase):
def testIt(self):
- ba = QByteArray(py3k.b("32\"1\x00123"))
- self.assertEqual(str(ba), str(py3k.b("32\"1\x00123")))
- if py3k.IS_PY3K:
- self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray(b'32\"1\\x00123')")
- else:
- self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray('32\"1\\x00123')")
+ ba = QByteArray(bytes("32\"1\x00123", "UTF8"))
+ self.assertEqual(str(ba), str(bytes("32\"1\x00123", "UTF-8")))
+ self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray(b'32\"1\\x00123')")
class QByteArrayImplicitConvert(unittest.TestCase):
def testString(self):
# No implicit conversions from QByteArray to python string
- ba = QByteArray(py3k.b("object name"))
+ ba = QByteArray(bytes("object name", "UTF8"))
obj = QObject()
self.assertRaises(TypeError, obj.setObjectName, ba)
class QByteArraySliceAssignment(unittest.TestCase):
def testIndexAssignment(self):
- a = QByteArray(py3k.b('abc'))
- a[0] = py3k.b('x')
- self.assertEqual(a[0], py3k.b('x'))
+ a = QByteArray(bytes('abc', "UTF8"))
+ a[0] = bytes('x', "UTF8")
+ self.assertEqual(a[0], bytes('x', "UTF8"))
def test_1():
- a[0] = py3k.b('xy')
+ a[0] = bytes('xy', "UTF8")
self.assertRaises(ValueError, test_1)
def testSliceAssignmentBytes(self):
- b = QByteArray(py3k.b('0123456789'))
- b[2:8] = py3k.b('abcdef')
- self.assertEqual(b[2:8], py3k.b('abcdef'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
+ b[2:8] = bytes('abcdef', "UTF8")
+ self.assertEqual(b[2:8], bytes('abcdef', "UTF8"))
# Delete behavior
b[2:8] = None
- self.assertEqual(b, py3k.b('0189'))
+ self.assertEqual(b, bytes('0189', "UTF8"))
# number of slots and number of values doesn't match
def test_2():
- b[2:8:2] = py3k.b('')
+ b[2:8:2] = bytes('', "UTF8")
self.assertRaises(ValueError, test_2)
- b = QByteArray(py3k.b('0123456789'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
# reverse slice
- b[5:2:-1] = py3k.b('ABC')
- self.assertEqual(b, py3k.b('012CBA6789'))
+ b[5:2:-1] = bytes('ABC', "UTF8")
+ self.assertEqual(b, bytes('012CBA6789', "UTF8"))
# step is not 1
- b[2:9:3] = py3k.b('XYZ')
- self.assertEqual(b, py3k.b('01XCBY67Z9'))
- b = QByteArray(py3k.b('0123456789'))
- b[9:2:-3] = py3k.b('XYZ')
- self.assertEqual(b, py3k.b('012Z45Y78X'))
+ b[2:9:3] = bytes('XYZ', "UTF8")
+ self.assertEqual(b, bytes('01XCBY67Z9', "UTF8"))
+ b = QByteArray(bytes('0123456789', "UTF8"))
+ b[9:2:-3] = bytes('XYZ', "UTF8")
+ self.assertEqual(b, bytes('012Z45Y78X', "UTF8"))
def testSliceAssignmentQByteArray(self):
- b = QByteArray(py3k.b('0123456789'))
- b[2:8] = QByteArray(py3k.b('abcdef'))
- self.assertEqual(b[2:8], py3k.b('abcdef'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
+ b[2:8] = QByteArray(bytes('abcdef', "UTF8"))
+ self.assertEqual(b[2:8], bytes('abcdef', "UTF8"))
# shrink
- b[2:8] = QByteArray(py3k.b('aaa'))
- self.assertEqual(b, py3k.b('01aaa89'))
+ b[2:8] = QByteArray(bytes('aaa', "UTF8"))
+ self.assertEqual(b, bytes('01aaa89', "UTF8"))
# expanse
- b[2:5] = QByteArray(py3k.b('uvwxyz'))
- self.assertEqual(b, py3k.b('01uvwxyz89'))
+ b[2:5] = QByteArray(bytes('uvwxyz', "UTF8"))
+ self.assertEqual(b, bytes('01uvwxyz89', "UTF8"))
# Delete behavior
b[2:8] = QByteArray()
- self.assertEqual(b, py3k.b('0189'))
+ self.assertEqual(b, bytes('0189', "UTF8"))
- b = QByteArray(py3k.b('0123456789'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
# reverse assginment
- b[5:2:-1] = QByteArray(py3k.b('ABC'))
- self.assertEqual(b, py3k.b('012CBA6789'))
+ b[5:2:-1] = QByteArray(bytes('ABC', "UTF8"))
+ self.assertEqual(b, bytes('012CBA6789', "UTF8"))
# step is not 1
- b[2:9:3] = QByteArray(py3k.b('XYZ'))
- self.assertEqual(b, py3k.b('01XCBY67Z9'))
- b = QByteArray(py3k.b('0123456789'))
- b[9:2:-3] = QByteArray(py3k.b('XYZ'))
- self.assertEqual(b, py3k.b('012Z45Y78X'))
+ b[2:9:3] = QByteArray(bytes('XYZ', "UTF8"))
+ self.assertEqual(b, bytes('01XCBY67Z9', "UTF8"))
+ b = QByteArray(bytes('0123456789', "UTF8"))
+ b[9:2:-3] = QByteArray(bytes('XYZ', "UTF8"))
+ self.assertEqual(b, bytes('012Z45Y78X', "UTF8"))
def testSliceAssignmentByteArray(self):
- b = QByteArray(py3k.b('0123456789'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
# replace
- b[2:8] = bytearray(py3k.b('abcdef'))
- self.assertEqual(b[2:8], py3k.b('abcdef'))
+ b[2:8] = bytearray(bytes('abcdef', "UTF8"))
+ self.assertEqual(b[2:8], bytes('abcdef', "UTF8"))
# shrink
- b[2:8] = bytearray(py3k.b('aaa'))
- self.assertEqual(b, py3k.b('01aaa89'))
+ b[2:8] = bytearray(bytes('aaa', "UTF8"))
+ self.assertEqual(b, bytes('01aaa89', "UTF8"))
# expanse
- b[2:5] = bytearray(py3k.b('uvwxyz'))
- self.assertEqual(b, py3k.b('01uvwxyz89'))
+ b[2:5] = bytearray(bytes('uvwxyz', "UTF8"))
+ self.assertEqual(b, bytes('01uvwxyz89', "UTF8"))
# Delete behavior
- b[2:8] = bytearray(py3k.b(''))
- self.assertEqual(b, py3k.b('0189'))
+ b[2:8] = bytearray(bytes('', "UTF8"))
+ self.assertEqual(b, bytes('0189', "UTF8"))
- b = QByteArray(py3k.b('0123456789'))
+ b = QByteArray(bytes('0123456789', "UTF8"))
# reverse assginment
- b[5:2:-1] = bytearray(py3k.b('ABC'))
- self.assertEqual(b, py3k.b('012CBA6789'))
+ b[5:2:-1] = bytearray(bytes('ABC', "UTF8"))
+ self.assertEqual(b, bytes('012CBA6789', "UTF8"))
# step is not 1
- b[2:9:3] = bytearray(py3k.b('XYZ'))
- self.assertEqual(b, py3k.b('01XCBY67Z9'))
- b = QByteArray(py3k.b('0123456789'))
- b[9:2:-3] = bytearray(py3k.b('XYZ'))
- self.assertEqual(b, py3k.b('012Z45Y78X'))
+ b[2:9:3] = bytearray(bytes('XYZ', "UTF8"))
+ self.assertEqual(b, bytes('01XCBY67Z9', "UTF8"))
+ b = QByteArray(bytes('0123456789', "UTF8"))
+ b[9:2:-3] = bytearray(bytes('XYZ', "UTF8"))
+ self.assertEqual(b, bytes('012Z45Y78X', "UTF8"))
def testBufferProtocol(self):
- orig_bytes = py3k.b('0123456789')
+ orig_bytes = bytes('0123456789', "UTF8")
byte_array = QByteArray(orig_bytes)
actual_bytes = bytes(byte_array)
self.assertEqual(orig_bytes, actual_bytes)
diff --git a/sources/pyside2/tests/QtCore/qdatastream_test.py b/sources/pyside2/tests/QtCore/qdatastream_test.py
index a2d2908b2..2ea3460af 100644
--- a/sources/pyside2/tests/QtCore/qdatastream_test.py
+++ b/sources/pyside2/tests/QtCore/qdatastream_test.py
@@ -38,8 +38,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QBitArray, QByteArray, QIODevice, QDataStream, QDate, QTime, QDateTime
def create_bitarray(string):
@@ -48,6 +46,14 @@ def create_bitarray(string):
array.setBit(i, char != '0')
return array
+
+def serialize_bitarray(bit_array):
+ buffer = QByteArray()
+ stream = QDataStream(buffer, QIODevice.WriteOnly)
+ stream << bit_array
+ return buffer
+
+
class QDataStreamWrite(unittest.TestCase):
'''Test case for QDatastream write* functions'''
@@ -115,32 +121,32 @@ class QDataStreamShift(unittest.TestCase):
self.stream.writeQChar(42)
res = self.read_stream.readQChar()
- self.assertEqual(res, py3k.unichr(42))
+ self.assertEqual(res, chr(42))
def testQCharNull(self):
'''QDataStream <<>> QChar - null'''
self.stream.writeQChar(None)
res = self.read_stream.readQChar()
- self.assertEqual(res, py3k.unicode_('\x00'))
+ self.assertEqual(res, '\x00')
def testQByteArrayValid(self):
'''QDataStream <<>> QByteArray - valid'''
- self.stream << QByteArray(py3k.b("hello"))
+ self.stream << QByteArray(bytes("hello", "UTF-8"))
res = QByteArray()
self.read_stream >> res
- self.assertEqual(res, QByteArray(py3k.b("hello")))
+ self.assertEqual(res, QByteArray(bytes("hello", "UTF-8")))
def testQByteArrayEmpty(self):
'''QDataStream <<>> QByteArray - empty'''
- self.stream << QByteArray(py3k.b(""))
+ self.stream << QByteArray(bytes("", "UTF-8"))
res = QByteArray()
self.read_stream >> res
- self.assertEqual(res, QByteArray(py3k.b("")))
+ self.assertEqual(res, QByteArray(bytes("", "UTF-8")))
self.assertTrue(res.isEmpty())
self.assertFalse(res.isNull())
@@ -160,21 +166,21 @@ class QDataStreamShift(unittest.TestCase):
self.stream.writeQString('Ka-boom')
res = self.read_stream.readQString()
- self.assertEqual(res, py3k.unicode_('Ka-boom'))
+ self.assertEqual(res, 'Ka-boom')
def testQStringEmpty(self):
'''QDataStream <<>> QString - empty'''
self.stream.writeQString('')
res = self.read_stream.readQString()
- self.assertEqual(res, py3k.unicode_(''))
+ self.assertEqual(res, '')
def testQStringNull(self):
'''QDataStream <<>> QString - null'''
self.stream.writeQString(None)
res = self.read_stream.readQString()
- self.assertEqual(res, py3k.unicode_(''))
+ self.assertEqual(res, '')
def testQBitArrayNull(self):
'''QDataStream <<>> QBitArray - null'''
@@ -282,67 +288,23 @@ class QDataStreamShiftBitArray(unittest.TestCase):
def testOk(self):
'''QDataStream with valid QBitArray'''
- data = []
-
- data.append((QByteArray(py3k.b('\x00\x00\x00\x00')), QDataStream.Ok,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x00')), QDataStream.Ok,
- create_bitarray('0')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x01')), QDataStream.Ok,
- create_bitarray('1')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x02\x03')), QDataStream.Ok,
- create_bitarray('11')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x03\x07')), QDataStream.Ok,
- create_bitarray('111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x04\x0f')), QDataStream.Ok,
- create_bitarray('1111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x05\x1f')), QDataStream.Ok,
- create_bitarray('11111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x06\x3f')), QDataStream.Ok,
- create_bitarray('111111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x7f')), QDataStream.Ok,
- create_bitarray('1111111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x7e')), QDataStream.Ok,
- create_bitarray('0111111')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x00')), QDataStream.Ok,
- create_bitarray('0000000')))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x39')), QDataStream.Ok,
- create_bitarray('1001110')))
+ test_set = [QBitArray()]
+ for i in range(1, 7):
+ test_set.append(create_bitarray(i * '1'))
+ for s in ['0111111', '0000000', '1001110']:
+ test_set.append(create_bitarray(s))
+ data = []
+ for expected in test_set:
+ data.append((serialize_bitarray(expected), QDataStream.Ok, expected))
self._check_bitarray(data)
def testPastEnd(self):
'''QDataStream >> QBitArray reading past the end of the data'''
- data = []
+ serialized = serialize_bitarray(create_bitarray('1001110'))
+ serialized.resize(serialized.size() - 2)
+ self._check_bitarray([(serialized, QDataStream.ReadPastEnd, QBitArray())])
- data.append((QByteArray(), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x01')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x02')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x03')), QDataStream.ReadPastEnd,
- QBitArray()))
- data.append((QByteArray(py3k.b('\x00\x00\x00\x04')), QDataStream.ReadPastEnd,
- QBitArray()))
-
- self._check_bitarray(data)
-
- def testCorruptData(self):
- '''QDataStream reading corrupt data'''
- data = []
-
- data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x02')),
- QDataStream.ReadCorruptData,
- QBitArray()))
-
- self._check_bitarray(data)
class QDataStreamRawData(unittest.TestCase):
def testRawData(self):
@@ -352,10 +314,10 @@ class QDataStreamRawData(unittest.TestCase):
ba = QByteArray()
data = QDataStream(ba, QIODevice.WriteOnly)
data.writeRawData('AB\x00C')
- self.assertEqual(ba.data(), py3k.b('AB\x00C'))
+ self.assertEqual(ba.data(), bytes('AB\x00C', "UTF-8"))
data = QDataStream(ba)
- self.assertEqual(data.readRawData(4), py3k.b('AB\x00C'))
+ self.assertEqual(data.readRawData(4), bytes('AB\x00C', "UTF-8"))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qfile_test.py b/sources/pyside2/tests/QtCore/qfile_test.py
index 960d0d1d8..57f9f4ee8 100644
--- a/sources/pyside2/tests/QtCore/qfile_test.py
+++ b/sources/pyside2/tests/QtCore/qfile_test.py
@@ -35,8 +35,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QDir, QFile, QIODevice, QSaveFile, QTemporaryDir
class GetCharTest(unittest.TestCase):
@@ -45,7 +43,7 @@ class GetCharTest(unittest.TestCase):
def setUp(self):
'''Acquire resources'''
handle, self.filename = tempfile.mkstemp()
- os.write(handle, py3k.b('a'))
+ os.write(handle, bytes('a', "UTF-8"))
os.close(handle)
def tearDown(self):
@@ -71,7 +69,7 @@ class GetCharTest(unittest.TestCase):
if sys.version_info[0] >= 3:
self.assertEqual(memory[0], ord('a'))
else:
- self.assertEqual(memory[0], py3k.b('a'))
+ self.assertEqual(memory[0], bytes('a', "UTF-8"))
# now memory points to wild bytes... :-)
# uncommenting this must cause a segfault.
# self.assertEqual(memory[0], 'a')
@@ -84,7 +82,7 @@ class GetCharTest(unittest.TestCase):
self.assertTrue(dir.isValid())
saveFile = QSaveFile(dir.path() + "/test.dat")
self.assertTrue(saveFile.open(QIODevice.WriteOnly))
- saveFile.write(py3k.b("Test"))
+ saveFile.write(bytes("Test", "UTF-8"))
self.assertTrue(saveFile.commit())
self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName())))
diff --git a/sources/pyside2/tests/QtCore/qfileread_test.py b/sources/pyside2/tests/QtCore/qfileread_test.py
index 1a9afd1ab..291bf6f54 100644
--- a/sources/pyside2/tests/QtCore/qfileread_test.py
+++ b/sources/pyside2/tests/QtCore/qfileread_test.py
@@ -35,7 +35,7 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QIODevice, QTemporaryFile
-import py3kcompat as py3k
+
class FileChild1(QTemporaryFile):
pass
@@ -53,11 +53,11 @@ class readDataTest(unittest.TestCase):
'''Acquire resources'''
self.filename1 = FileChild1()
self.assertTrue(self.filename1.open())
- self.filename1.write(py3k.b('Test text for testing'))
+ self.filename1.write(bytes('Test text for testing', "UTF-8"))
self.filename2 = FileChild2()
self.assertTrue(self.filename2.open())
- self.filename2.write(py3k.b('Test text for testing'))
+ self.filename2.write(bytes('Test text for testing', "UTF-8"))
def tearDown(self):
'''release resources'''
diff --git a/sources/pyside2/tests/QtCore/qjsondocument_test.py b/sources/pyside2/tests/QtCore/qjsondocument_test.py
index 3f8a9c848..8ce56d6b9 100644
--- a/sources/pyside2/tests/QtCore/qjsondocument_test.py
+++ b/sources/pyside2/tests/QtCore/qjsondocument_test.py
@@ -39,24 +39,18 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QJsonDocument
-import py3kcompat as py3k
+
class QJsonDocumentTest(unittest.TestCase):
def testToVariant(self):
a = QJsonDocument.fromJson(b'{"test": null}')
self.assertIsInstance(a, QJsonDocument)
- if py3k.IS_PY3K:
- self.assertEqual(str(a.toVariant()), "{'test': None}")
- else:
- self.assertEqual(str(a.toVariant()), "{u'test': None}")
+ self.assertEqual(str(a.toVariant()), "{'test': None}")
b = QJsonDocument.fromJson(b'{"test": [null]}')
self.assertIsInstance(b, QJsonDocument)
- if py3k.IS_PY3K:
- self.assertEqual(str(b.toVariant()), "{'test': [None]}")
- else:
- self.assertEqual(str(b.toVariant()), "{u'test': [None]}")
+ self.assertEqual(str(b.toVariant()), "{'test': [None]}")
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtCore/qlinef_test.py b/sources/pyside2/tests/QtCore/qlinef_test.py
index 084937c06..3d7a42296 100644
--- a/sources/pyside2/tests/QtCore/qlinef_test.py
+++ b/sources/pyside2/tests/QtCore/qlinef_test.py
@@ -44,7 +44,7 @@ class TestQLineF (unittest.TestCase):
def testIntersect(self):
l1 = QLineF(0, 0, 1, 0)
l2 = QLineF(1, -1, 1, 1)
- tuple_ = l1.intersect(l2)
+ tuple_ = l1.intersects(l2)
self.assertEqual(tuple, tuple_.__class__)
(value, p) = tuple_
self.assertEqual(QLineF.BoundedIntersection, value)
diff --git a/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
index 225807b9e..52838c95e 100644
--- a/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
+++ b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
@@ -39,11 +39,10 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QCryptographicHash, QMessageAuthenticationCode
-import py3kcompat as py3k
class TestQMessageAuthenticationCode (unittest.TestCase):
def test(self):
- code = QMessageAuthenticationCode(QCryptographicHash.Sha1, py3k.b('bla'))
+ code = QMessageAuthenticationCode(QCryptographicHash.Sha1, bytes('bla', "UTF-8"))
result = code.result()
self.assertTrue(result.size() > 0)
print(result.toHex())
diff --git a/sources/pyside2/tests/QtCore/qobject_parent_test.py b/sources/pyside2/tests/QtCore/qobject_parent_test.py
index 0a02fbc26..386209e8a 100644
--- a/sources/pyside2/tests/QtCore/qobject_parent_test.py
+++ b/sources/pyside2/tests/QtCore/qobject_parent_test.py
@@ -148,10 +148,6 @@ class ParentCase(unittest.TestCase):
res = parent.findChildren(QObject, QRegularExpression("^fo+"))
self.assertEqual(res, test_children)
- # test findChildren with a QRegExp (deprecated)
- res = parent.findChildren(QObject, QRegExp("^fo+"))
- self.assertEqual(res, test_children)
-
def testParentEquality(self):
#QObject.parent() == parent
parent = QObject()
diff --git a/sources/pyside2/tests/QtCore/qobject_test.py b/sources/pyside2/tests/QtCore/qobject_test.py
index dd577ecdc..47a9869d7 100644
--- a/sources/pyside2/tests/QtCore/qobject_test.py
+++ b/sources/pyside2/tests/QtCore/qobject_test.py
@@ -39,8 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QObject, Signal, Qt
class Obj(QObject):
@@ -73,7 +71,7 @@ class ObjectNameCase(unittest.TestCase):
self.assertEqual('', obj.objectName())
def testUnicode(self):
- name = py3k.unicode_('não')
+ name = 'não'
#FIXME Strange error on upstream when using equal(name, obj)
obj = QObject()
obj.setObjectName(name)
diff --git a/sources/pyside2/tests/QtCore/qprocess_test.py b/sources/pyside2/tests/QtCore/qprocess_test.py
index ec0c9251d..1667f37b3 100644
--- a/sources/pyside2/tests/QtCore/qprocess_test.py
+++ b/sources/pyside2/tests/QtCore/qprocess_test.py
@@ -38,21 +38,19 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import *
class TestQProcess (unittest.TestCase):
def testStartDetached(self):
value, pid = QProcess.startDetached("dir", [], os.getcwd())
self.assertTrue(isinstance(value, bool))
- self.assertTrue(isinstance(pid, py3k.long))
+ self.assertTrue(isinstance(pid, int))
def testPid(self):
p = QProcess()
p.start("dir", [])
p.waitForStarted()
- pid = p.pid()
+ pid = p.processId()
# We can't test the pid method result because it returns 0 when the
# process isn't running
if p.state() == QProcess.Running:
diff --git a/sources/pyside2/tests/QtCore/qregexp_test.py b/sources/pyside2/tests/QtCore/qregexp_test.py
deleted file mode 100644
index a031137fd..000000000
--- a/sources/pyside2/tests/QtCore/qregexp_test.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QRegExp
-
-class QRegExpTest(unittest.TestCase):
-
- def testReplace1(self):
- re = QRegExp('a[mn]')
- string = re.replace('Banana', 'ox')
- self.assertEqual(string, 'Boxoxa')
-
- def testReplace2(self):
- re = QRegExp('<i>([^<]*)</i>')
- string = re.replace('A <i>bon mot</i>.', '\\emph{\\1}')
- self.assertEqual(string, 'A \\emph{bon mot}.')
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtCore/qregularexpression_test.py b/sources/pyside2/tests/QtCore/qregularexpression_test.py
index fb2e9c24c..50c755d0e 100644
--- a/sources/pyside2/tests/QtCore/qregularexpression_test.py
+++ b/sources/pyside2/tests/QtCore/qregularexpression_test.py
@@ -48,6 +48,7 @@ class QRegularExpressionTest(unittest.TestCase):
match = re.match('word1 word2 word3')
self.assertTrue(match.isValid())
self.assertEqual(match.captured(1), 'word2')
+ self.assertEqual(match.capturedView(1), 'word2')
def testMatchIterator(self):
re = QRegularExpression('(\w+)')
diff --git a/sources/pyside2/tests/QtCore/qsettings_test.py b/sources/pyside2/tests/QtCore/qsettings_test.py
index 639f6d276..814053a85 100644
--- a/sources/pyside2/tests/QtCore/qsettings_test.py
+++ b/sources/pyside2/tests/QtCore/qsettings_test.py
@@ -37,7 +37,6 @@ from init_paths import init_test_paths
init_test_paths(False)
from helper.helper import adjust_filename
-import py3kcompat as py3k
from PySide2.QtCore import QSettings
class TestQSettings(unittest.TestCase):
@@ -49,10 +48,7 @@ class TestQSettings(unittest.TestCase):
self.assertEqual(type(r), list)
r = settings.value('var2')
- if py3k.IS_PY3K:
- self.assertEqual(type(r), str)
- else:
- self.assertEqual(type(r), unicode)
+ self.assertEqual(type(r), str)
r = settings.value('var2', type=list)
self.assertEqual(type(r), list)
diff --git a/sources/pyside2/tests/QtCore/qstate_test.py b/sources/pyside2/tests/QtCore/qstate_test.py
deleted file mode 100644
index 4c97fecca..000000000
--- a/sources/pyside2/tests/QtCore/qstate_test.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import *
-
-
-class QStateTest(unittest.TestCase):
- def testBasic(self):
- app = QCoreApplication([])
-
- o = QObject()
- o.setProperty("text", "INdT")
-
- machine = QStateMachine()
- s1 = QState()
- s1.assignProperty(o, "text", "Rocks");
-
- s2 = QFinalState()
- t = s1.addTransition(o, SIGNAL("change()"), s2);
- self.assertTrue(isinstance(t, QSignalTransition))
-
- machine.addState(s1)
- machine.addState(s2)
- machine.setInitialState(s1)
- machine.start()
-
- o.emit(SIGNAL("change()"))
-
- QTimer.singleShot(100, app.quit)
- app.exec_()
-
- txt = o.property("text")
- self.assertTrue(txt, "Rocks")
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qstatemachine_test.py b/sources/pyside2/tests/QtCore/qstatemachine_test.py
deleted file mode 100644
index 19dcb1e81..000000000
--- a/sources/pyside2/tests/QtCore/qstatemachine_test.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QObject, QState, QFinalState, SIGNAL
-from PySide2.QtCore import QTimer, QStateMachine
-from PySide2.QtCore import QParallelAnimationGroup
-
-from helper.usesqcoreapplication import UsesQCoreApplication
-
-
-class StateMachineTest(unittest.TestCase):
- '''Check presence of State Machine classes'''
-
- def testBasic(self):
- '''State machine classes'''
- import PySide2.QtCore
- PySide2.QtCore.QSignalTransition
- PySide2.QtCore.QPropertyAnimation
-
-
-
-class QStateMachineTest(UsesQCoreApplication):
-
- def cb(self, *args):
- self.assertEqual(self.machine.defaultAnimations(), [self.anim])
-
- def testBasic(self):
- self.machine = QStateMachine()
- s1 = QState()
- s2 = QState()
- s3 = QFinalState()
-
- QObject.connect(self.machine, SIGNAL("started()"), self.cb)
-
- self.anim = QParallelAnimationGroup()
-
- self.machine.addState(s1)
- self.machine.addState(s2)
- self.machine.addState(s3)
- self.machine.setInitialState(s1)
- self.machine.addDefaultAnimation(self.anim)
- self.machine.start()
-
- QTimer.singleShot(100, self.app.quit)
- self.app.exec_()
-
-
-class QSetConverterTest(UsesQCoreApplication):
- '''Test converter of QSet toPython using QStateAnimation.configuration'''
-
- def testBasic(self):
- '''QStateMachine.configuration converting QSet to python set'''
- machine = QStateMachine()
- s1 = QState()
- machine.addState(s1)
- machine.setInitialState(s1)
- machine.start()
-
- QTimer.singleShot(100, self.app.quit)
- self.app.exec_()
-
- configuration = machine.configuration()
-
- self.assertTrue(isinstance(configuration, set))
- self.assertTrue(s1 in configuration)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qstring_test.py b/sources/pyside2/tests/QtCore/qstring_test.py
index c415fdc3d..59512b5a3 100644
--- a/sources/pyside2/tests/QtCore/qstring_test.py
+++ b/sources/pyside2/tests/QtCore/qstring_test.py
@@ -39,7 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtCore import QObject
class QStringConstructor(unittest.TestCase):
@@ -48,11 +47,11 @@ class QStringConstructor(unittest.TestCase):
def testQStringDefault(self):
obj = QObject()
obj.setObjectName('foo')
- self.assertEqual(obj.objectName(), py3k.unicode_('foo'))
- obj.setObjectName(py3k.unicode_('áâãà'))
- self.assertEqual(obj.objectName(), py3k.unicode_('áâãà'))
+ self.assertEqual(obj.objectName(), 'foo')
+ obj.setObjectName('áâãà')
+ self.assertEqual(obj.objectName(), 'áâãà')
obj.setObjectName(None)
- self.assertEqual(obj.objectName(), py3k.unicode_(''))
+ self.assertEqual(obj.objectName(), '')
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qtext_codec_test.py b/sources/pyside2/tests/QtCore/qtext_codec_test.py
deleted file mode 100644
index 9e41c38c6..000000000
--- a/sources/pyside2/tests/QtCore/qtext_codec_test.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import gc
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QTextCodec
-
-class TestCodecGetters(unittest.TestCase):
-
- def testCodecsNames(self):
- for codec_name in QTextCodec.availableCodecs():
- codec = QTextCodec.codecForName(codec_name)
- self.assertTrue(type(codec), QTextCodec)
-
- def testCodecsMibs(self):
- for codec_num in QTextCodec.availableMibs():
- codec = QTextCodec.codecForMib(codec_num)
- self.assertTrue(type(codec), QTextCodec)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qtextstream_test.py b/sources/pyside2/tests/QtCore/qtextstream_test.py
index bd25367c3..99c231eec 100644
--- a/sources/pyside2/tests/QtCore/qtextstream_test.py
+++ b/sources/pyside2/tests/QtCore/qtextstream_test.py
@@ -36,9 +36,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
-from PySide2.QtCore import QByteArray, QTextStream, QIODevice, QTextCodec, QFile
+from PySide2.QtCore import QByteArray, QTextStream, QIODevice, QFile
class QTextStreamShiftTest(unittest.TestCase):
@@ -53,7 +51,7 @@ class QTextStreamShiftTest(unittest.TestCase):
self.write << '4'
self.write.flush()
res = self.read.readLine()
- self.assertTrue(isinstance(res, py3k.unicode))
+ self.assertTrue(isinstance(res, str))
self.assertEqual(res, '4')
class QTextStreamGetSet(unittest.TestCase):
@@ -61,14 +59,6 @@ class QTextStreamGetSet(unittest.TestCase):
def setUp(self):
self.obj = QTextStream()
-
- def testCodec(self):
- '''QTextStream set/get Codec'''
-
- codec = QTextCodec.codecForName('ISO8859-1')
- self.obj.setCodec(codec)
- self.assertEqual(codec, self.obj.codec())
-
def testDevice(self):
'''QTextStream get/set Device'''
device = QFile()
@@ -83,7 +73,6 @@ class QTextStreamInitialization(unittest.TestCase):
'''QTextStream construction'''
obj = QTextStream()
- self.assertEqual(obj.codec(), QTextCodec.codecForLocale())
self.assertEqual(obj.device(), None)
self.assertEqual(obj.string(), None)
@@ -109,12 +98,12 @@ class QTextStreamReadLinesFromDevice(unittest.TestCase):
data = []
data.append((QByteArray(), []))
- data.append((QByteArray(py3k.b('\n')), ['']))
- data.append((QByteArray(py3k.b('\r\n')), ['']))
- data.append((QByteArray(py3k.b('ole')), ['ole']))
- data.append((QByteArray(py3k.b('ole\n')), ['ole']))
- data.append((QByteArray(py3k.b('ole\r\n')), ['ole']))
- data.append((QByteArray(py3k.b('ole\r\ndole\r\ndoffen')), ['ole', 'dole', 'doffen']))
+ data.append((QByteArray(bytes('\n', "UTF-8")), ['']))
+ data.append((QByteArray(bytes('\r\n', "UTF-8")), ['']))
+ data.append((QByteArray(bytes('ole', "UTF-8")), ['ole']))
+ data.append((QByteArray(bytes('ole\n', "UTF-8")), ['ole']))
+ data.append((QByteArray(bytes('ole\r\n', "UTF-8")), ['ole']))
+ data.append((QByteArray(bytes('ole\r\ndole\r\ndoffen', "UTF-8")), ['ole', 'dole', 'doffen']))
self._check_data(data)
diff --git a/sources/pyside2/tests/QtCore/qtimezone_test.py b/sources/pyside2/tests/QtCore/qtimezone_test.py
index 8c960371f..f22ce73f9 100644
--- a/sources/pyside2/tests/QtCore/qtimezone_test.py
+++ b/sources/pyside2/tests/QtCore/qtimezone_test.py
@@ -35,11 +35,10 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QTimeZone
-import py3kcompat as py3k
class TestQTimeZone (unittest.TestCase):
def testTimeZone(self):
- id = py3k.b('Europe/Berlin')
+ id = bytes('Europe/Berlin', "UTF-8")
timeZone = QTimeZone(id)
self.assertTrue(timeZone.isValid())
self.assertEqual(timeZone.id(), id)
diff --git a/sources/pyside2/tests/QtCore/qurlquery_test.py b/sources/pyside2/tests/QtCore/qurlquery_test.py
index ac7ab69b0..6e538c919 100644
--- a/sources/pyside2/tests/QtCore/qurlquery_test.py
+++ b/sources/pyside2/tests/QtCore/qurlquery_test.py
@@ -45,8 +45,6 @@ class QUrlQueryTest(unittest.TestCase):
def testConstructing(self):
empty = QUrlQuery()
self.assertTrue(empty.isEmpty())
- self.assertEqual(empty.queryPairDelimiter(), QUrlQuery.defaultQueryPairDelimiter())
- self.assertEqual(empty.queryValueDelimiter(), QUrlQuery.defaultQueryValueDelimiter())
empty.clear();
self.assertTrue(empty.isEmpty())
diff --git a/sources/pyside2/tests/QtCore/quuid_test.py b/sources/pyside2/tests/QtCore/quuid_test.py
index da34429f9..ecb4a9562 100644
--- a/sources/pyside2/tests/QtCore/quuid_test.py
+++ b/sources/pyside2/tests/QtCore/quuid_test.py
@@ -43,7 +43,8 @@ from PySide2.QtCore import QUuid
class QUuidTest(unittest.TestCase):
def testFromString(self):
uuidString = '{fc69b59e-cc34-4436-a43c-ee95d128b8c5}'
- uuid = QUuid(uuidString)
+# testing overload QUUid::fromString(QStringView)
+ uuid = QUuid.fromString(uuidString)
self.assertTrue(not uuid.isNull())
self.assertEqual(uuid.toString(), uuidString)
diff --git a/sources/pyside2/tests/QtCore/repr_test.py b/sources/pyside2/tests/QtCore/repr_test.py
index 71bab8330..8a3a1519a 100644
--- a/sources/pyside2/tests/QtCore/repr_test.py
+++ b/sources/pyside2/tests/QtCore/repr_test.py
@@ -37,7 +37,6 @@ init_test_paths(False)
import PySide2
from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QPoint, QPointF
-import py3kcompat as py3k
try:
from PySide2.QtCore import QUuid
HAVE_Q = True
@@ -52,7 +51,7 @@ class ReprCopyHelper:
class QByteArrayReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QByteArray(py3k.b('the quick brown fox jumps over the lazy dog'))
+ self.original = QByteArray(bytes('the quick brown fox jumps over the lazy dog', "UTF-8"))
class QDateReprCopy(ReprCopyHelper, unittest.TestCase):
diff --git a/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py b/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py
index e149f8ffb..2d208cb69 100644
--- a/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py
+++ b/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py
@@ -36,13 +36,13 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import *
+from PySide2.QtCore import QTimer
class SetPropOnCtorTest(unittest.TestCase):
def testIt(self):
- obj = QEventTransition(targetStates = [QState()])
- self.assertEqual(len(obj.targetStates()), 1);
+ timer = QTimer(interval = 42)
+ self.assertEqual(timer.interval(), 42);
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/translation_test.py b/sources/pyside2/tests/QtCore/translation_test.py
index 0f36067bd..beca3a717 100644
--- a/sources/pyside2/tests/QtCore/translation_test.py
+++ b/sources/pyside2/tests/QtCore/translation_test.py
@@ -39,7 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtCore import QObject, QTranslator, QCoreApplication
from helper.usesqcoreapplication import UsesQCoreApplication
@@ -59,7 +58,7 @@ class TranslationTest(UsesQCoreApplication):
obj = QObject()
obj.setObjectName(obj.tr('Hello World!'))
- self.assertEqual(obj.objectName(), py3k.unicode_('Orbis, te saluto!'))
+ self.assertEqual(obj.objectName(), 'Orbis, te saluto!')
def testRussian(self):
#Set string value to Russian
@@ -69,7 +68,7 @@ class TranslationTest(UsesQCoreApplication):
obj = QObject()
obj.setObjectName(obj.tr('Hello World!'))
- self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
+ self.assertEqual(obj.objectName(), 'привет мир!')
def testUtf8(self):
translator = QTranslator()
@@ -78,12 +77,12 @@ class TranslationTest(UsesQCoreApplication):
obj = QObject()
obj.setObjectName(obj.tr('Hello World!'))
- self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
+ self.assertEqual(obj.objectName(), 'привет мир!')
def testTranslateWithNoneDisambiguation(self):
value = 'String here'
obj = QCoreApplication.translate('context', value, None)
- self.assertTrue(isinstance(obj, py3k.unicode))
+ self.assertTrue(isinstance(obj, str))
self.assertEqual(obj, value)
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtCore/unicode_test.py b/sources/pyside2/tests/QtCore/unicode_test.py
index 3f1a4d8dc..28bbafbb0 100644
--- a/sources/pyside2/tests/QtCore/unicode_test.py
+++ b/sources/pyside2/tests/QtCore/unicode_test.py
@@ -39,8 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QObject
from PySide2.QtCore import QByteArray
@@ -57,13 +55,13 @@ class UnicodeConversion(unittest.TestCase):
#Set regular Python string retrieve unicode
obj = QObject()
obj.setObjectName('test')
- self.assertEqual(obj.objectName(), py3k.unicode_('test'))
+ self.assertEqual(obj.objectName(), 'test')
def testSetUnicodeRetrieveUnicode(self):
#Set Python unicode string and retrieve unicode
obj = QObject()
- obj.setObjectName(py3k.unicode_('ümlaut'))
- self.assertEqual(obj.objectName(), py3k.unicode_('ümlaut'))
+ obj.setObjectName('ümlaut')
+ self.assertEqual(obj.objectName(), 'ümlaut')
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtGui/CMakeLists.txt b/sources/pyside2/tests/QtGui/CMakeLists.txt
index 172703ab9..179e88fd6 100644
--- a/sources/pyside2/tests/QtGui/CMakeLists.txt
+++ b/sources/pyside2/tests/QtGui/CMakeLists.txt
@@ -26,8 +26,6 @@ PYSIDE_TEST(qfontmetrics_test.py)
PYSIDE_TEST(qguiapplication_test.py)
PYSIDE_TEST(qicon_test.py)
PYSIDE_TEST(qitemselection_test.py)
-PYSIDE_TEST(qmatrix_test.py)
-PYSIDE_TEST(qopenglbuffer_test.py)
PYSIDE_TEST(qpainter_test.py)
PYSIDE_TEST(qpdfwriter_test.py)
PYSIDE_TEST(qpixelformat_test.py)
@@ -37,7 +35,6 @@ PYSIDE_TEST(qpolygonf_test.py)
PYSIDE_TEST(qkeysequence_test.py)
PYSIDE_TEST(qradialgradient_test.py)
PYSIDE_TEST(qrasterwindow_test.py)
-PYSIDE_TEST(qopenglwindow_test.py)
PYSIDE_TEST(qregion_test.py)
PYSIDE_TEST(qstylehints_test.py)
PYSIDE_TEST(qtextdocument_functions.py)
diff --git a/sources/pyside2/tests/QtGui/bug_660.py b/sources/pyside2/tests/QtGui/bug_660.py
index 058364d1d..066387498 100644
--- a/sources/pyside2/tests/QtGui/bug_660.py
+++ b/sources/pyside2/tests/QtGui/bug_660.py
@@ -34,7 +34,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtGui import QStandardItemModel, QStandardItem
class MyItemModel(QStandardItemModel):
@@ -44,12 +43,12 @@ class MyItemModel(QStandardItemModel):
def mimeTypes(self):
mtypes = super(MyItemModel,self).mimeTypes()
- mtypes.append(py3k.unicode_('application/my-form'))
+ mtypes.append('application/my-form')
return mtypes
def mimeData(self,indexes):
self.__mimedata = super(MyItemModel,self).mimeData(indexes)
- self.__mimedata.setData(py3k.unicode_('application/my-form'), py3k.b('hi'))
+ self.__mimedata.setData('application/my-form',bytes('hi', "UTF-8"))
return self.__mimedata
class TestBug660(unittest.TestCase):
diff --git a/sources/pyside2/tests/QtGui/bug_740.py b/sources/pyside2/tests/QtGui/bug_740.py
index a4db6e5a8..456749eaa 100644
--- a/sources/pyside2/tests/QtGui/bug_740.py
+++ b/sources/pyside2/tests/QtGui/bug_740.py
@@ -34,14 +34,13 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from helper.usesqapplication import UsesQApplication
from PySide2.QtCore import QSize
from PySide2.QtGui import QBitmap, QImage
class TestQBitmap(UsesQApplication):
def testFromDataMethod(self):
- dataBits = py3k.b('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10')
+ dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8")
bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtGui/deepcopy_test.py b/sources/pyside2/tests/QtGui/deepcopy_test.py
index d4dcdd64c..0fa82150f 100644
--- a/sources/pyside2/tests/QtGui/deepcopy_test.py
+++ b/sources/pyside2/tests/QtGui/deepcopy_test.py
@@ -36,7 +36,6 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QPoint
-from PySide2.QtGui import QMatrix
from PySide2.QtGui import QMatrix2x2, QMatrix2x3, QMatrix2x4
from PySide2.QtGui import QMatrix3x2, QMatrix3x3, QMatrix3x4
from PySide2.QtGui import QMatrix4x2, QMatrix4x3, QMatrix4x4
@@ -81,7 +80,7 @@ class QColorCMYKDeepCopy(DeepCopyColorHelperF, unittest.TestCase):
class QTransformDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8)
+ self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9)
class QKeySequenceDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
@@ -107,10 +106,6 @@ class QPolygonDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
self.original = QPolygon([QPoint(1, 2), QPoint(3, 4), QPoint(5, 6)])
-class QMatrixDeepCopy(DeepCopyHelper, unittest.TestCase):
- def setUp(self):
- self.original = QMatrix(1, 2, 3, 4, 5, 6)
-
# Avoid these tests until get gcc fixed
# Related bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247
diff --git a/sources/pyside2/tests/QtGui/pyside_reload_test.py b/sources/pyside2/tests/QtGui/pyside_reload_test.py
index f3c7c3e8d..75994f4e4 100644
--- a/sources/pyside2/tests/QtGui/pyside_reload_test.py
+++ b/sources/pyside2/tests/QtGui/pyside_reload_test.py
@@ -26,6 +26,8 @@
##
#############################################################################
+import importlib
+import importlib.util
import os
import shutil
import sys
@@ -35,7 +37,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
orig_path = os.path.join(os.path.dirname(__file__))
workdir = os.getcwd()
@@ -45,11 +46,8 @@ shutil.copyfile(src, dst)
sys.path.append(workdir)
def reload_module(moduleName):
- if py3k.IS_PY3K:
- import importlib
- importlib.reload(moduleName)
- else:
- reload(moduleName)
+ importlib.reload(moduleName)
+
def increment_module_value():
modfile = open(dst, 'a')
@@ -57,11 +55,8 @@ def increment_module_value():
modfile.flush()
modfile.close()
if not sys.dont_write_bytecode:
- if py3k.IS_PY3K:
- import importlib.util
- cacheFile = importlib.util.cache_from_source(dst)
- else:
- cacheFile = dst + 'c'
+ import importlib.util
+ cacheFile = importlib.util.cache_from_source(dst)
os.remove(cacheFile)
class TestModuleReloading(unittest.TestCase):
diff --git a/sources/pyside2/tests/QtGui/qmatrix_test.py b/sources/pyside2/tests/QtGui/qmatrix_test.py
deleted file mode 100644
index 48380faf6..000000000
--- a/sources/pyside2/tests/QtGui/qmatrix_test.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QPoint
-from PySide2.QtGui import QMatrix, QMatrix2x2, QMatrix4x4
-
-
-def qpointTimesQMatrix(point, matrix):
- '''As seen in "QPoint QMatrix::map(const QPoint &p) const" C++ implementation.'''
- return QPoint(matrix.m11() * point.x() + matrix.m21() * point.y() + matrix.dx(),
- matrix.m12() * point.x() + matrix.m22() * point.y() + matrix.dy())
-
-class QMatrixTest(unittest.TestCase):
-
- def testMatrix(self):
- matrix = QMatrix(11, 12, 21, 22, 100, 200)
- point = QPoint(3, 3)
- self.assertEqual(matrix.map(point), qpointTimesQMatrix(point, matrix))
-
- def testMatrixWithWrongType(self):
- matrix = QMatrix(11, 12, 21, 22, 100, 200)
- point = QPoint(3, 3)
- # This exception may move from a TypeError to a ValueError.
- self.assertRaises((TypeError, ValueError), matrix.__mul__, point)
-
- def testMatrix2x2(self):
- matrix = QMatrix2x2([1.0, 2.0, 3.0, 4.0])
-
- expectedTransposed = QMatrix2x2([1.0, 3.0, 2.0, 4.0])
- self.assertEqual(matrix.transposed(), expectedTransposed)
-
- expectedMultiplied = QMatrix2x2([2.0, 4.0, 6.0, 8.0])
- matrix *= 2.0
- self.assertEqual(matrix, expectedMultiplied)
-
- matrix.setToIdentity()
- self.assertTrue(matrix.isIdentity())
-
- def testMatrix4x4(self):
- self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 3.0])
- self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 'I',
- 4.0, 5.0, 6.0, 7.0,
- 8.0, 9.0, 'N', 11.0,
- 12.0, 'd', 14.0, 'T'])
-
- my_data = [0.0, 1.0, 2.0, 3.0,
- 4.0, 5.0, 6.0, 7.0,
- 8.0, 9.0, 10.0, 11.0,
- 12.0, 13.0, 14.0, 15.0]
- my_datac = [0.0, 4.0, 8.0, 12.0,
- 1.0, 5.0, 9.0, 13.0,
- 2.0, 6.0, 10.0, 14.0,
- 3.0, 7.0, 11.0, 15.0]
-
- m = QMatrix4x4(my_data)
- d = m.data()
- self.assertTrue(my_datac, d)
-
- d = m.copyDataTo()
- self.assertTrue(my_data == list(d))
-
- def testMatrixMapping(self):
- m = QMatrix(1.0, 2.0, 1.0, 3.0, 100.0, 200.0)
- res = m.map(5, 5)
- self.assertAlmostEqual(res[0], 5 * 1.0 + 5 * 1.0 + 100.0)
- self.assertAlmostEqual(res[1], 5 * 2.0 + 5 * 3.0 + 200.0)
- res = m.map(5.0, 5.0)
- self.assertAlmostEqual(res[0], 5.0 * 1.0 + 5.0 * 1.0 + 100.0)
- self.assertAlmostEqual(res[1], 5.0 * 2.0 + 5.0 * 3.0 + 200.0)
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtGui/qtextdocument_functions.py b/sources/pyside2/tests/QtGui/qtextdocument_functions.py
index 765a6b5b7..bd1462049 100644
--- a/sources/pyside2/tests/QtGui/qtextdocument_functions.py
+++ b/sources/pyside2/tests/QtGui/qtextdocument_functions.py
@@ -35,7 +35,6 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtGui import Qt
-from PySide2.QtCore import QTextCodec
class QTextDocumentFunctions(unittest.TestCase):
@@ -45,8 +44,6 @@ class QTextDocumentFunctions(unittest.TestCase):
self.assertTrue(Qt.mightBeRichText('<html><head/><body><p>bla</p></body></html>'))
html = Qt.convertFromPlainText("A & B", Qt.WhiteSpaceNormal)
self.assertEqual(html, '<p>A &amp; B</p>')
- codec = Qt.codecForHtml(b'bla')
- self.assertTrue(codec)
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
index d9d96dd34..7c825b62f 100644
--- a/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
+++ b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
@@ -36,7 +36,7 @@ init_test_paths(False)
from PySide2.QtGui import QTextDocumentWriter, QTextDocument
from PySide2.QtCore import QBuffer
-import py3kcompat as py3k
+
class QTextDocumentWriterTest(unittest.TestCase):
@@ -45,7 +45,7 @@ class QTextDocumentWriterTest(unittest.TestCase):
doc = QTextDocument(text)
b = QBuffer()
b.open(QBuffer.ReadWrite)
- writer = QTextDocumentWriter(b, py3k.b("plaintext"));
+ writer = QTextDocumentWriter(b, bytes("plaintext", "UTF-8"));
writer.write(doc);
b.close()
self.assertEqual(b.buffer(), text)
diff --git a/sources/pyside2/tests/QtGui/repr_test.py b/sources/pyside2/tests/QtGui/repr_test.py
index e06f4d487..6e632b68d 100644
--- a/sources/pyside2/tests/QtGui/repr_test.py
+++ b/sources/pyside2/tests/QtGui/repr_test.py
@@ -36,7 +36,6 @@ init_test_paths(False)
import PySide2
from PySide2.QtCore import QPoint
-from PySide2.QtGui import QMatrix
from PySide2.QtGui import QMatrix2x2, QMatrix2x3, QMatrix2x4
from PySide2.QtGui import QMatrix3x2, QMatrix3x3, QMatrix3x4
from PySide2.QtGui import QMatrix4x2, QMatrix4x3, QMatrix4x4
@@ -52,11 +51,7 @@ class ReprCopyHelper:
class QTransformReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8)
-
-class QKeySequenceReprCopy(ReprCopyHelper, unittest.TestCase):
- def setUp(self):
- self.original = QKeySequence("Ctrl+P")
+ self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9)
class QQuaternionReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
@@ -74,10 +69,6 @@ class QVector4DReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
self.original = QVector4D(1, 2, 3, 4)
-class QMatrixReprCopy(ReprCopyHelper, unittest.TestCase):
- def setUp(self):
- self.original = QMatrix(1, 2, 3, 4, 5, 6)
-
# Avoid these tests until get gcc fixed
# Related bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247
diff --git a/sources/pyside2/tests/QtNetwork/bug_1084.py b/sources/pyside2/tests/QtNetwork/bug_1084.py
index d2c273fca..cd8dd7621 100644
--- a/sources/pyside2/tests/QtNetwork/bug_1084.py
+++ b/sources/pyside2/tests/QtNetwork/bug_1084.py
@@ -37,7 +37,7 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2 import QtNetwork
-import py3kcompat as py3k
+
class QTcpSocketTestCase(unittest.TestCase):
def setUp(self):
@@ -45,7 +45,7 @@ class QTcpSocketTestCase(unittest.TestCase):
self.sock.connectToHost('127.0.0.1', 25)
def testIt(self):
- self.sock.write(py3k.b('quit'))
+ self.sock.write(bytes('quit', "UTF-8"))
if __name__ == "__main__":
unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/bug_446.py b/sources/pyside2/tests/QtNetwork/bug_446.py
index f15ff01f9..7e7242515 100644
--- a/sources/pyside2/tests/QtNetwork/bug_446.py
+++ b/sources/pyside2/tests/QtNetwork/bug_446.py
@@ -38,18 +38,18 @@ from PySide2.QtCore import *
from PySide2.QtNetwork import *
from helper.usesqcoreapplication import UsesQCoreApplication
-import py3kcompat as py3k
+
class HttpSignalsCase(UsesQCoreApplication):
'''Test case for launching QHttp signals'''
- DATA = py3k.b("PySide rocks")
+ DATA = bytes("PySide rocks", "UTF-8")
def onError(self):
self.assertTrue(False)
def onNewConnection(self):
self.serverConnection = self.server.nextPendingConnection()
- self.serverConnection.error.connect(self.onError)
+ self.serverConnection.errorOccurred.connect(self.onError)
self.serverConnection.write(HttpSignalsCase.DATA)
self.server.close()
diff --git a/sources/pyside2/tests/QtNetwork/udpsocket_test.py b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
index da5a21c29..7ef567294 100644
--- a/sources/pyside2/tests/QtNetwork/udpsocket_test.py
+++ b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
@@ -38,7 +38,7 @@ init_test_paths(False)
from PySide2.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer
from PySide2.QtNetwork import QUdpSocket, QHostAddress
-import py3kcompat as py3k
+
class HttpSignalsCase(unittest.TestCase):
'''Test case for bug #124 - readDatagram signature
@@ -64,7 +64,7 @@ class HttpSignalsCase(unittest.TestCase):
def sendPackage(self):
addr = QHostAddress(QHostAddress.LocalHost)
- self.socket.writeDatagram(py3k.b('datagram'), addr, 45454)
+ self.socket.writeDatagram(bytes('datagram', "UTF-8"), addr, 45454)
def callback(self):
while self.server.hasPendingDatagrams():
diff --git a/sources/pyside2/tests/QtOpenGL/CMakeLists.txt b/sources/pyside2/tests/QtOpenGL/CMakeLists.txt
index b37a9ddce..92b4afbac 100644
--- a/sources/pyside2/tests/QtOpenGL/CMakeLists.txt
+++ b/sources/pyside2/tests/QtOpenGL/CMakeLists.txt
@@ -1,2 +1,2 @@
-PYSIDE_TEST(qglbuffer_test.py)
-PYSIDE_TEST(qglwidget_test.py)
+PYSIDE_TEST(qopenglbuffer_test.py)
+PYSIDE_TEST(qopenglwindow_test.py)
diff --git a/sources/pyside2/tests/QtOpenGL/qglwidget_test.py b/sources/pyside2/tests/QtOpenGL/qglwidget_test.py
deleted file mode 100644
index c3bb7e27d..000000000
--- a/sources/pyside2/tests/QtOpenGL/qglwidget_test.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtGui import *
-from PySide2.QtWidgets import *
-from PySide2.QtOpenGL import *
-
-class TestQGLWidget (unittest.TestCase):
- def testIt(self):
- """Just test if the bindTexture(*, GLenum, GLint) methods overloads exists"""
- app = QApplication([])
- img = QImage()
- w = QGLWidget()
- a = w.bindTexture(img, 0, 0) # ok if it throws nothing.. :-)
-
-
-
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qopenglbuffer_test.py b/sources/pyside2/tests/QtOpenGL/qopenglbuffer_test.py
index a5d8385c9..5500c7c57 100644
--- a/sources/pyside2/tests/QtGui/qopenglbuffer_test.py
+++ b/sources/pyside2/tests/QtOpenGL/qopenglbuffer_test.py
@@ -38,50 +38,50 @@ from init_paths import init_test_paths
init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-from PySide2.QtGui import QOpenGLBuffer
-from PySide2 import QtGui
+from PySide2.QtGui import QOffscreenSurface, QOpenGLContext, QSurface, QWindow
+from PySide2.QtOpenGL import QOpenGLBuffer
def createSurface(surfaceClass):
- if surfaceClass == QtGui.QSurface.Window:
- window = QtGui.QWindow()
- window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ if surfaceClass == QSurface.Window:
+ window = QWindow()
+ window.setSurfaceType(QWindow.OpenGLSurface)
window.setGeometry(0, 0, 10, 10)
window.create()
return window
- elif surfaceClass == QtGui.QSurface.Offscreen:
+ elif surfaceClass == QSurface.Offscreen:
# Create a window and get the format from that. For example, if an EGL
# implementation provides 565 and 888 configs for PBUFFER_BIT but only
# 888 for WINDOW_BIT, we may end up with a pbuffer surface that is
# incompatible with the context since it could choose the 565 while the
# window and the context uses a config with 888.
- format = QtGui.QSurfaceFormat
+ format = QSurfaceFormat
if format.redBufferSize() == -1:
- window = QtGui.QWindow()
- window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ window = QWindow()
+ window.setSurfaceType(QWindow.OpenGLSurface)
window.setGeometry(0, 0, 10, 10)
window.create()
format = window.format()
- offscreenSurface = QtGui.QOffscreenSurface()
+ offscreenSurface = QOffscreenSurface()
offscreenSurface.setFormat(format)
offscreenSurface.create()
return offscreenSurface
return 0
-class QOpenGLBuffer(UsesQApplication):
+class QOpenGLBufferTest(UsesQApplication):
def testBufferCreate(self):
- surface = createSurface(QtGui.QSurface.Window)
- ctx = QtGui.QOpenGLContext()
+ surface = createSurface(QSurface.Window)
+ ctx = QOpenGLContext()
ctx.create()
ctx.makeCurrent(surface)
- buf = QtGui.QOpenGLBuffer()
+ buf = QOpenGLBuffer()
self.assertTrue(not buf.isCreated())
self.assertTrue(buf.create())
self.assertTrue(buf.isCreated())
- self.assertEqual(buf.type(), QtGui.QOpenGLBuffer.VertexBuffer)
+ self.assertEqual(buf.type(), QOpenGLBuffer.VertexBuffer)
buf.bind()
buf.allocate(128)
diff --git a/sources/pyside2/tests/QtGui/qopenglwindow_test.py b/sources/pyside2/tests/QtOpenGL/qopenglwindow_test.py
index e39cfb19c..22f7fd202 100644
--- a/sources/pyside2/tests/QtGui/qopenglwindow_test.py
+++ b/sources/pyside2/tests/QtOpenGL/qopenglwindow_test.py
@@ -40,7 +40,9 @@ from helper.usesqapplication import UsesQApplication
from PySide2.QtCore import QSize, QTimer, Qt
from PySide2.QtGui import (QColor, QGuiApplication, QImage, QOpenGLContext,
- QOpenGLTexture, QSurfaceFormat, QOpenGLWindow)
+ QSurfaceFormat)
+from PySide2.QtOpenGL import (QOpenGLTexture, QOpenGLWindow)
+
try:
from OpenGL import GL
diff --git a/sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt b/sources/pyside2/tests/QtOpenGLWidgets/CMakeLists.txt
index 2f7cb08b9..2f7cb08b9 100644
--- a/sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt
+++ b/sources/pyside2/tests/QtOpenGLWidgets/CMakeLists.txt
diff --git a/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
index 573ca9940..1c9ee918d 100644
--- a/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
+++ b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py
@@ -71,12 +71,6 @@ class ReturnsQuadruplesOfNumbers(UsesQApplication):
obj = GraphicsLayoutItem()
self.assertTrue(self.compareTuples(obj.getContentsMargins(), (0.0, 0.0, 0.0, 0.0)))
- def testQWidgetGetContentsMargins(self):
- obj = QWidget()
- values = (10, 20, 30, 40)
- obj.setContentsMargins(*values)
- self.assertTrue(self.compareTuples(obj.getContentsMargins(), values))
-
def testQLayoutGetContentsMargins(self):
obj = Layout()
values = (10, 20, 30, 40)
@@ -87,25 +81,6 @@ class ReturnsQuadruplesOfNumbers(UsesQApplication):
obj = QTextCursor()
self.assertEqual(obj.selectedTableCells(), (-1, -1, -1, -1))
- def testQPrinterGetPageMargins(self):
- # Bug #742. Find a printer like PDF/XPS on which arbitrary margins can be set.
- printer = None
- for printerInfo in QPrinterInfo.availablePrinters():
- name = printerInfo.printerName().lower()
- if "xps" in name or "pdf" in name:
- printer = QPrinter(printerInfo)
- break
- if not printer:
- printer = QPrinter()
- printer.setPrinterName("Print to PDF")
- printer.setOutputFormat(QPrinter.PdfFormat)
- # On macOS the minimum margin of a page is ~12, setting something lower than that will
- # actually fail to set all the margins.
- values = (15.0, 16.0, 17.0, 18.0, QPrinter.Point)
- printer.setPageMargins(*values)
- actual = printer.getPageMargins(QPrinter.Point)
- print(printer.printerName(), actual, values[:-1])
- self.assertTrue(self.compareTuples(actual, values[:-1]))
if __name__ == "__main__":
unittest.main()
diff --git a/sources/pyside2/tests/QtQml/CMakeLists.txt b/sources/pyside2/tests/QtQml/CMakeLists.txt
index e2beb951e..e35831f25 100644
--- a/sources/pyside2/tests/QtQml/CMakeLists.txt
+++ b/sources/pyside2/tests/QtQml/CMakeLists.txt
@@ -11,10 +11,13 @@ PYSIDE_TEST(bug_951.py)
PYSIDE_TEST(bug_995.py)
PYSIDE_TEST(bug_997.py)
PYSIDE_TEST(bug_1029.py)
+PYSIDE_TEST(listproperty.py)
PYSIDE_TEST(qqmlnetwork_test.py)
PYSIDE_TEST(qquickview_test.py)
PYSIDE_TEST(connect_python_qml.py)
PYSIDE_TEST(registertype.py)
+PYSIDE_TEST(registeruncreatabletype.py)
+PYSIDE_TEST(registersingletontype.py)
PYSIDE_TEST(javascript_exceptions.py)
PYSIDE_TEST(qqmlincubator_incubateWhile.py)
PYSIDE_TEST(qquickitem_grabToImage.py)
diff --git a/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py b/sources/pyside2/tests/QtQml/listproperty.py
index e633d6ee2..6337e5fa4 100644
--- a/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
+++ b/sources/pyside2/tests/QtQml/listproperty.py
@@ -1,8 +1,6 @@
-#!/usr/bin/python
-
#############################################################################
##
-## 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.
@@ -28,51 +26,56 @@
##
#############################################################################
-'''Unit tests for QGLBuffer'''
-
-import os
-import sys
import unittest
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
+from PySide2.QtCore import QObject
+from PySide2.QtQml import ListProperty
-from PySide2.QtCore import QByteArray
-from PySide2.QtOpenGL import QGLBuffer, QGLWidget
-import py3kcompat as py3k
-from helper.usesqapplication import UsesQApplication
+class InheritsQObject(QObject):
+ pass
-class QGLBufferTest(UsesQApplication):
+def dummyFunc():
+ pass
+
+class TestListProperty(unittest.TestCase):
def testIt(self):
- w = QGLWidget()
- w.makeCurrent()
-
- b = QGLBuffer()
- b.setUsagePattern(QGLBuffer.DynamicDraw)
-
- self.assertTrue(b.create())
- self.assertTrue(b.bufferId() != 0)
- self.assertTrue(b.bind())
-
- data = QByteArray(py3k.b("12345"))
- b.allocate(data)
- self.assertEqual(b.size(), data.size())
-
- m = b.map(QGLBuffer.ReadOnly)
- if m:
- self.assertEqual(m, py3k.buffer(py3k.b(data.data())))
- b.unmap()
-
- m = b.map(QGLBuffer.ReadWrite)
- m[3] = py3k.b('A')[0]
- b.unmap()
- result, rdata = b.read(3, 1)
- self.assertTrue(result)
- self.assertEqual(py3k.b('A'), rdata.data())
- else:
- print(" memory mapping is not possible in this OpenGL implementation.")
- b.release()
+
+ # Verify that type checking works properly
+ type_check_error = False
+
+ try:
+ ListProperty(QObject)
+ ListProperty(InheritsQObject)
+ except:
+ type_check_error = True
+
+ self.assertFalse(type_check_error)
+
+ try:
+ ListProperty(int)
+ except TypeError:
+ type_check_error = True
+
+ self.assertTrue(type_check_error)
+
+ # Verify that method validation works properly
+ method_check_error = False
+
+ try:
+ ListProperty(QObject, append=None, at=None, count=None, replace=None, clear=None, removeLast=None) # Explicitly setting None
+ ListProperty(QObject, append=dummyFunc)
+ ListProperty(QObject, count=dummyFunc, at=dummyFunc)
+ except:
+ method_check_error = True
+
+ self.assertFalse(method_check_error)
+
+ try:
+ ListPropery(QObject, append=QObject())
+ except:
+ method_check_error = True
+
+ self.assertTrue(method_check_error)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtQml/qquickview_test.py b/sources/pyside2/tests/QtQml/qquickview_test.py
index 0b723612e..9694cf56e 100644
--- a/sources/pyside2/tests/QtQml/qquickview_test.py
+++ b/sources/pyside2/tests/QtQml/qquickview_test.py
@@ -40,7 +40,7 @@ from helper.helper import adjust_filename
from helper.timedqapplication import TimedQApplication
from PySide2.QtCore import QUrl, QObject, Property, Slot
-from PySide2.QtQml import QtQml
+from PySide2.QtQml import QtQml, QQmlEngine
from PySide2.QtQuick import QQuickView
class MyObject(QObject):
@@ -76,8 +76,9 @@ class TestQQuickView(TimedQApplication):
self.assertEqual(view.status(), QQuickView.Ready)
rootObject = view.rootObject()
self.assertTrue(rootObject)
- self.assertTrue(QtQml.qmlEngine(rootObject))
- self.assertTrue(QtQml.qmlContext(rootObject))
+ context = QQmlEngine.contextForObject(rootObject)
+ self.assertTrue(context)
+ self.assertTrue(context.engine())
def testModelExport(self):
view = QQuickView()
diff --git a/sources/pyside2/tests/QtScript/property_test.py b/sources/pyside2/tests/QtQml/registersingletontype.py
index 372bba2ba..fe3f749f5 100644
--- a/sources/pyside2/tests/QtScript/property_test.py
+++ b/sources/pyside2/tests/QtQml/registersingletontype.py
@@ -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.
@@ -34,63 +34,53 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import QObject, Property, QCoreApplication
-from PySide2.QtScript import QScriptEngine
+from helper.helper import adjust_filename
-class MyObject(QObject):
+from PySide2.QtCore import Property, Signal, QTimer, QUrl, QObject
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import qmlRegisterSingletonType
+from PySide2.QtQuick import QQuickView
+
+finalResult = 0
+
+class SingletonQObject(QObject):
def __init__(self, parent = None):
QObject.__init__(self, parent)
- self._p = 100
-
- def setX(self, value):
- self._p = value
-
- def getX(self):
- return self._p
-
- def resetX(self):
- self._p = 100
-
- def delX(self):
- self._p = 0
-
- x = Property(int, getX, setX, resetX, delX)
-
-
-class QPropertyTest(unittest.TestCase):
-
- def testSimple(self):
- o = MyObject()
- self.assertEqual(o.x, 100)
- o.x = 42
- self.assertEqual(o.x, 42)
-
- def testHasProperty(self):
- o = MyObject()
- o.setProperty("x", 10)
- self.assertEqual(o.x, 10)
- self.assertEqual(o.property("x"), 10)
-
- def testMetaProperty(self):
- o = MyObject()
- m = o.metaObject()
- found = False
- for i in range(m.propertyCount()):
- mp = m.property(i)
- if mp.name() == "x":
- found = True
- break
- self.assertTrue(found)
-
- def testScriptQProperty(self):
- qapp = QCoreApplication([])
- myEngine = QScriptEngine()
- obj = MyObject()
- scriptObj = myEngine.newQObject(obj)
- myEngine.globalObject().setProperty("obj", scriptObj)
- myEngine.evaluate("obj.x = 42")
- self.assertEqual(scriptObj.property("x").toInt32(), 42)
- self.assertEqual(obj.property("x"), 42)
+ self._data = 100
+
+ def getData(self):
+ return self._data
+
+ def setData(self, data):
+ global finalResult
+ finalResult = self._data = data
+
+ data = Property(int, getData, setData)
+
+def singletonQObjectCallback(engine):
+ obj = SingletonQObject()
+ obj.setData(50)
+ return obj
+
+def singletonQJSValueCallback(engine):
+ return engine.evaluate("new Object({data: 50})")
+
+class TestQmlSupport(unittest.TestCase):
+ def testIt(self):
+ app = QGuiApplication([])
+
+ qmlRegisterSingletonType(SingletonQObject, 'Singletons', 1, 0, 'SingletonQObjectNoCallback')
+ qmlRegisterSingletonType(SingletonQObject, 'Singletons', 1, 0, 'SingletonQObjectCallback',
+ singletonQObjectCallback)
+
+ qmlRegisterSingletonType('Singletons', 1, 0, 'SingletonQJSValue', singletonQJSValueCallback)
+
+ view = QQuickView()
+ view.setSource(QUrl.fromLocalFile(adjust_filename('registersingletontype.qml', __file__)))
+ view.show()
+ QTimer.singleShot(250, view.close)
+ app.exec_()
+ self.assertEqual(finalResult, 200)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtQml/registersingletontype.qml b/sources/pyside2/tests/QtQml/registersingletontype.qml
new file mode 100644
index 000000000..c8b34e69a
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/registersingletontype.qml
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Singletons 1.0
+
+Item {
+ Component.onCompleted: {
+ SingletonQObjectCallback.data += SingletonQObjectNoCallback.data + SingletonQJSValue.data
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/registertype.py b/sources/pyside2/tests/QtQml/registertype.py
index 7e6fe8d29..e4dcd36f9 100644
--- a/sources/pyside2/tests/QtQml/registertype.py
+++ b/sources/pyside2/tests/QtQml/registertype.py
@@ -36,7 +36,7 @@ init_test_paths(False)
from helper.helper import adjust_filename
-from PySide2.QtCore import Property, QTimer, QUrl
+from PySide2.QtCore import Property, QObject, QTimer, QUrl
from PySide2.QtGui import QGuiApplication, QPen, QColor, QPainter
from PySide2.QtQml import qmlRegisterType, ListProperty
from PySide2.QtQuick import QQuickView, QQuickItem, QQuickPaintedItem
@@ -108,8 +108,8 @@ class TestQmlSupport(unittest.TestCase):
def testIt(self):
app = QGuiApplication([])
- qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');
- qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice");
+ self.assertTrue(qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart') != -1)
+ self.assertTrue(qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") != -1)
view = QQuickView()
view.setSource(QUrl.fromLocalFile(adjust_filename('registertype.qml', __file__)))
diff --git a/sources/pyside2/tests/QtQml/registeruncreatable.qml b/sources/pyside2/tests/QtQml/registeruncreatable.qml
new file mode 100644
index 000000000..bebf68d82
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/registeruncreatable.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Charts 1.0
+
+Item {
+ width: 300; height: 200
+
+ Uncreatable {
+ name : 'uncreatable'
+ }
+}
diff --git a/sources/pyside2/tests/QtWebKit/webframe_test.py b/sources/pyside2/tests/QtQml/registeruncreatabletype.py
index d46c1b229..820dc6cc1 100644
--- a/sources/pyside2/tests/QtWebKit/webframe_test.py
+++ b/sources/pyside2/tests/QtQml/registeruncreatabletype.py
@@ -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.
@@ -34,34 +34,47 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import QObject, SIGNAL, QUrl
-from PySide2.QtWebKit import *
-from PySide2.QtNetwork import QNetworkRequest
-
from helper.helper import adjust_filename
-from helper.usesqapplication import UsesQApplication
+from PySide2.QtCore import Property, QObject, QUrl
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import qmlRegisterUncreatableType, QQmlEngine, QQmlComponent
+
+noCreationReason = 'Cannot create an item of type: Uncreatable (expected)';
+
+class Uncreatable(QObject):
+ def __init__(self, parent = None):
+ QObject.__init__(self, parent)
+ self._name = 'uncreatable'
+
+ def getName(self):
+ return self._name
+
+ def setName(self, value):
+ self._name = value
-class TestWebFrame(UsesQApplication):
- def load_finished(self, ok):
- self.assertTrue(ok)
- page = self.view.page()
- self.assertTrue(page)
- frame = page.mainFrame()
- self.assertTrue(frame)
- meta = frame.metaData()
- self.assertEqual(meta['description'], ['PySide Test METADATA.'])
- self.app.quit()
+ name = Property(str, getName, setName)
- def testMetaData(self):
- self.view = QWebView()
- QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
- self.load_finished)
- url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
- self.view.setUrl(url)
- self.app.exec_()
+class TestQmlSupport(unittest.TestCase):
+
+ def testIt(self):
+ app = QGuiApplication([])
+
+ self.assertTrue(qmlRegisterUncreatableType(Uncreatable, 'Charts', 1, 0,
+ 'Uncreatable', noCreationReason) != -1);
+
+ engine = QQmlEngine()
+ component = QQmlComponent(engine, QUrl.fromLocalFile(adjust_filename('registeruncreatable.qml', __file__)))
+
+ # Check that the uncreatable item produces the correct error
+ self.assertEqual(component.status(), QQmlComponent.Error)
+ errorFound = False
+ for e in component.errors():
+ if noCreationReason in e.toString():
+ errorFound = True
+ break
+ self.assertTrue(errorFound)
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/pyside2/tests/QtScript/CMakeLists.txt b/sources/pyside2/tests/QtScript/CMakeLists.txt
deleted file mode 100644
index dfea68df0..000000000
--- a/sources/pyside2/tests/QtScript/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-PYSIDE_TEST(base_test.py)
-PYSIDE_TEST(bug_1022.py)
-PYSIDE_TEST(engine_test.py)
-PYSIDE_TEST(property_test.py)
-PYSIDE_TEST(qscriptvalue_test.py)
diff --git a/sources/pyside2/tests/QtScript/base_test.py b/sources/pyside2/tests/QtScript/base_test.py
deleted file mode 100644
index 3cde8ad83..000000000
--- a/sources/pyside2/tests/QtScript/base_test.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2 import QtScript
-
-
-#only test if the module import works fine bug #278
diff --git a/sources/pyside2/tests/QtScript/bug_1022.py b/sources/pyside2/tests/QtScript/bug_1022.py
deleted file mode 100644
index 2c2699de6..000000000
--- a/sources/pyside2/tests/QtScript/bug_1022.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import *
-from PySide2.QtScript import *
-
-class QScriptValueTest(unittest.TestCase):
- def testQScriptValue(self):
- app = QCoreApplication([])
- engine = QScriptEngine()
- repr(engine.evaluate('1 + 1'))
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtScript/engine_test.py b/sources/pyside2/tests/QtScript/engine_test.py
deleted file mode 100644
index f88b98d69..000000000
--- a/sources/pyside2/tests/QtScript/engine_test.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QObject
-from PySide2.QtScript import QScriptEngine
-
-class QScriptEngineTest(unittest.TestCase):
-
- def testQScriptEngine(self):
- engine = QScriptEngine()
- obj = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })")
- toKelvin = obj.property("toKelvin")
- result = toKelvin.call(obj, [100])
- self.assertEqual(result.toNumber(), 373)
diff --git a/sources/pyside2/tests/QtScript/qscriptvalue_test.py b/sources/pyside2/tests/QtScript/qscriptvalue_test.py
deleted file mode 100644
index 06a029232..000000000
--- a/sources/pyside2/tests/QtScript/qscriptvalue_test.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-from __future__ import print_function
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtScript import *
-
-# Required for eval() to work
-import PySide2.QtScript
-
-from helper.usesqapplication import UsesQApplication
-
-class TestQScriptValue (UsesQApplication):
-
- def testOperator(self):
- engine = QScriptEngine()
- value = engine.evaluate('x = {"a": 1, "b":2}')
- self.assertEqual(value['a'], 1)
- self.assertRaises(KeyError, value.__getitem__, 'c')
- value = engine.evaluate('x = ["x", "y", "z"]')
- self.assertEqual(value[2], 'z')
- self.assertRaises(IndexError, value.__getitem__, 23)
-
- def testRepr(self):
- value = QScriptValue("somePerson = { firstName: 'John', lastName: 'Doe' }")
- print(repr(value))
- value2 = eval(repr(value))
- self.assertEqual(value.toString(), value2.toString())
- self.assertEqual(value.toVariant(), value2.toVariant())
-
- def testIteratorProtocol(self):
- engine = QScriptEngine()
- value = engine.evaluate('x = {"a": 1, "b":2}')
- d = {}
- for k, v in QScriptValueIterator(value):
- d[k] = v
- self.assertEqual(d, {'a': 1, 'b': 2})
-
- d = {}
- for k, v in value:
- d[k] = v
- self.assertEqual(d, {'a': 1, 'b': 2})
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtScriptTools/CMakeLists.txt b/sources/pyside2/tests/QtScriptTools/CMakeLists.txt
deleted file mode 100644
index ee22737c6..000000000
--- a/sources/pyside2/tests/QtScriptTools/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-PYSIDE_TEST(debugger_test.py)
diff --git a/sources/pyside2/tests/QtScriptTools/debugger_test.py b/sources/pyside2/tests/QtScriptTools/debugger_test.py
deleted file mode 100644
index cefe48f5b..000000000
--- a/sources/pyside2/tests/QtScriptTools/debugger_test.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import SIGNAL, QTimer
-from PySide2.QtScript import QScriptEngine
-from PySide2.QtScriptTools import QScriptEngineDebugger
-
-from helper.usesqapplication import UsesQApplication
-
-class DebuggerTest(UsesQApplication):
-
- def setUp(self):
- UsesQApplication.setUp(self)
- self.engine = QScriptEngine()
- self.debugger = QScriptEngineDebugger()
- self.has_suspended = 0
- self.has_resumed = 0
- self.count = 3
-
- def suspended(self):
- self.has_suspended += 1
- # Will emit evaluationResumed until there are more instructions to be run
- QTimer.singleShot(100, self.debugger.action(QScriptEngineDebugger.StepIntoAction).trigger)
-
- def resumed(self):
- # Will be called when debugger.state() change from Suspended to Running
- # except for the first time.
- self.has_resumed += 1
-
- def testBasic(self):
- '''Interrupt and resume evaluation with QScriptEngineDebugger'''
-
- self.debugger.attachTo(self.engine)
- self.debugger.setAutoShowStandardWindow(False)
- self.debugger.connect(SIGNAL('evaluationSuspended()'), self.suspended)
- self.debugger.connect(SIGNAL('evaluationResumed()'), self.resumed)
-
- # For some reason StepIntoAction does not actually continue execution, and thus interrupting
- # causes the test to hang. The same behavior is present in a Qt5.6 C++ code equivalent. It
- # seems like a bug in QtScript, thus the interruption is commented out for now, which will
- # force the test to fail.
- #self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger()
- self.engine.evaluate("3+4\n2+1\n5+1")
- self.assertTrue(self.has_resumed >= 1)
- self.assertTrue(self.has_suspended >= 1)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtSql/qvarianttype_test.py b/sources/pyside2/tests/QtSql/qvarianttype_test.py
index 3175a178f..05d456e28 100644
--- a/sources/pyside2/tests/QtSql/qvarianttype_test.py
+++ b/sources/pyside2/tests/QtSql/qvarianttype_test.py
@@ -35,16 +35,15 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtSql import QSqlField
class QVariantTypeTest(unittest.TestCase):
def testQVariantType(self):
f = QSqlField("name", str)
- self.assertEqual(f.type(), py3k.unicode)
+ self.assertEqual(f.type(), str)
f = QSqlField("name", "QString")
- self.assertEqual(f.type(), py3k.unicode)
+ self.assertEqual(f.type(), str)
f = QSqlField("name", "double")
self.assertEqual(f.type(), float)
@@ -55,13 +54,6 @@ class QVariantTypeTest(unittest.TestCase):
f = QSqlField("name", int)
self.assertEqual(f.type(), int)
- if not py3k.IS_PY3K:
- f = QSqlField("name", long)
- self.assertEqual(f.type(), int) # long isn't registered in QVariant:Type, just in QMetaType::Type
-
- #f = QSqlField("name", QObject)
- #self.assertEqual(f.type(), None)
-
f = QSqlField("name", None)
self.assertEqual(f.type(), None)
diff --git a/sources/pyside2/tests/QtSvg/CMakeLists.txt b/sources/pyside2/tests/QtSvg/CMakeLists.txt
index 4f5e2805f..53d15e857 100644
--- a/sources/pyside2/tests/QtSvg/CMakeLists.txt
+++ b/sources/pyside2/tests/QtSvg/CMakeLists.txt
@@ -1,3 +1,2 @@
PYSIDE_TEST(qsvggenerator_test.py)
PYSIDE_TEST(qsvgrenderer_test.py)
-PYSIDE_TEST(qsvgwidget_test.py)
diff --git a/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py b/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py
index 88537edfe..3dd5b61f6 100644
--- a/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py
+++ b/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py
@@ -2,7 +2,7 @@
#############################################################################
##
-## 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.
@@ -36,15 +36,15 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import *
-from PySide2.QtWidgets import *
-from PySide2.QtSvg import *
+from PySide2.QtCore import QFile
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtSvg import QSvgRenderer
class QSvgRendererTest(unittest.TestCase):
def testLoad(self):
tigerPath = os.path.join(os.path.dirname(__file__), 'tiger.svg')
- app = QApplication([])
+ app = QGuiApplication([])
fromFile = QSvgRenderer(tigerPath)
self.assertTrue(fromFile.isValid())
diff --git a/sources/pyside2/tests/QtSvgWidgets/CMakeLists.txt b/sources/pyside2/tests/QtSvgWidgets/CMakeLists.txt
new file mode 100644
index 000000000..61952169a
--- /dev/null
+++ b/sources/pyside2/tests/QtSvgWidgets/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(qsvgwidget_test.py)
diff --git a/sources/pyside2/tests/QtSvg/qsvgwidget_test.py b/sources/pyside2/tests/QtSvgWidgets/qsvgwidget_test.py
index 17bf6527b..a3749c0ee 100644
--- a/sources/pyside2/tests/QtSvg/qsvgwidget_test.py
+++ b/sources/pyside2/tests/QtSvgWidgets/qsvgwidget_test.py
@@ -2,7 +2,7 @@
#############################################################################
##
-## 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.
@@ -36,14 +36,16 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import *
-from PySide2.QtWidgets import *
-from PySide2.QtSvg import *
+from PySide2.QtCore import QFile, QFileInfo, QDir
+from PySide2.QtWidgets import QApplication
+from PySide2.QtSvgWidgets import QSvgWidget
class QSvgWidgetTest(unittest.TestCase):
def testLoad(self):
- tigerPath = os.path.join(os.path.dirname(__file__), 'tiger.svg')
+ dir = os.path.dirname(__file__)
+ tigerPath = QDir.cleanPath("{}/../QtSvg/tiger.svg".format(dir))
+ self.assertTrue(QFileInfo.exists(tigerPath))
app = QApplication([])
fromFile = QSvgWidget()
diff --git a/sources/pyside2/tests/QtUiTools/bug_392.py b/sources/pyside2/tests/QtUiTools/bug_392.py
index 2439e7203..1a049b89e 100644
--- a/sources/pyside2/tests/QtUiTools/bug_392.py
+++ b/sources/pyside2/tests/QtUiTools/bug_392.py
@@ -36,29 +36,31 @@ init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-from PySide2 import QtWidgets
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QComboBox, QWidget
from PySide2.QtUiTools import QUiLoader
-class MyWidget(QtWidgets.QComboBox):
+class MyWidget(QComboBox):
def __init__(self, parent=None):
- QtWidgets.QComboBox.__init__(self, parent)
+ QComboBox.__init__(self, parent)
def isPython(self):
return True
class BugTest(UsesQApplication):
def testCase(self):
- w = QtWidgets.QWidget()
+ w = QWidget()
loader = QUiLoader()
filePath = os.path.join(os.path.dirname(__file__), 'action.ui')
result = loader.load(filePath, w)
- self.assertTrue(isinstance(result.actionFoo, QtWidgets.QAction))
+ self.assertTrue(isinstance(result.actionFoo, QAction))
def testPythonCustomWidgets(self):
- w = QtWidgets.QWidget()
+ w = QWidget()
loader = QUiLoader()
loader.registerCustomWidget(MyWidget)
+ self.assertTrue('MyWidget' in loader.availableWidgets())
filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget.ui')
result = loader.load(filePath, w)
@@ -66,9 +68,10 @@ class BugTest(UsesQApplication):
self.assertTrue(result.custom.isPython())
def testPythonCustomWidgetsTwice(self):
- w = QtWidgets.QWidget()
+ w = QWidget()
loader = QUiLoader()
loader.registerCustomWidget(MyWidget)
+ self.assertTrue('MyWidget' in loader.availableWidgets())
filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget2.ui')
result = loader.load(filePath, w)
diff --git a/sources/pyside2/tests/QtUiTools/bug_426.py b/sources/pyside2/tests/QtUiTools/bug_426.py
index e84da0382..488ba5c8d 100644
--- a/sources/pyside2/tests/QtUiTools/bug_426.py
+++ b/sources/pyside2/tests/QtUiTools/bug_426.py
@@ -34,19 +34,22 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2 import QtCore, QtWidgets
+from PySide2.QtCore import QTimer
+from PySide2.QtGui import QAction, QActionGroup
+from PySide2.QtWidgets import QApplication, QWidget
from PySide2.QtUiTools import QUiLoader
+
class Window(object):
def __init__(self):
loader = QUiLoader()
filePath = os.path.join(os.path.dirname(__file__), 'bug_426.ui')
self.widget = loader.load(filePath)
- self.group = QtWidgets.QActionGroup(self.widget)
+ self.group = QActionGroup(self.widget)
self.widget.show()
- QtCore.QTimer.singleShot(0, self.widget.close)
+ QTimer.singleShot(0, self.widget.close)
if __name__ == "__main__":
- app = QtWidgets.QApplication(sys.argv)
+ app = QApplication(sys.argv)
win = Window()
sys.exit(app.exec_())
diff --git a/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
index 190810edb..9604e957c 100644
--- a/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
+++ b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
@@ -42,7 +42,6 @@ from PySide2.QtWebEngine import QtWebEngine
from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile
from PySide2.QtWebEngineCore import (QWebEngineUrlScheme,
QWebEngineUrlSchemeHandler)
-import py3kcompat as py3k
class TestSchemeHandler(QWebEngineUrlSchemeHandler):
def requestStarted(self, request):
@@ -51,9 +50,9 @@ class TestSchemeHandler(QWebEngineUrlSchemeHandler):
return
self.buffer = QBuffer()
- self.buffer.setData(py3k.b("Really nice goodbye text."))
+ self.buffer.setData(bytes("Really nice goodbye text.", "UTF-8"))
self.buffer.aboutToClose.connect(self.buffer.deleteLater)
- request.reply(py3k.b("text/plain;charset=utf-8"), self.buffer)
+ request.reply(bytes("text/plain;charset=utf-8", "UTF-8"), self.buffer)
class MainTest(unittest.TestCase):
@@ -64,7 +63,7 @@ class MainTest(unittest.TestCase):
QtWebEngine.initialize()
app = QApplication([])
- scheme_name = py3k.b("testpy")
+ scheme_name = bytes("testpy", "UTF-8")
scheme = QWebEngineUrlScheme(scheme_name)
scheme.setSyntax(QWebEngineUrlScheme.Syntax.Path)
QWebEngineUrlScheme.registerScheme(scheme)
diff --git a/sources/pyside2/tests/QtWebKit/CMakeLists.txt b/sources/pyside2/tests/QtWebKit/CMakeLists.txt
deleted file mode 100644
index 7fab64773..000000000
--- a/sources/pyside2/tests/QtWebKit/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-PYSIDE_TEST(bug_448.py)
-PYSIDE_TEST(bug_694.py)
-PYSIDE_TEST(bug_803.py)
-PYSIDE_TEST(bug_899.py)
-PYSIDE_TEST(bug_959.py)
-PYSIDE_TEST(qvariantlist_property_test.py)
-PYSIDE_TEST(qml_plugin_test.py)
-PYSIDE_TEST(shouldInterruptjavascript_test.py)
-PYSIDE_TEST(webpage_test.py)
-PYSIDE_TEST(webview_test.py)
-PYSIDE_TEST(webframe_test.py)
diff --git a/sources/pyside2/tests/QtWebKit/bug_448.py b/sources/pyside2/tests/QtWebKit/bug_448.py
deleted file mode 100644
index 98ebb1958..000000000
--- a/sources/pyside2/tests/QtWebKit/bug_448.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-'''Test cases for bug: http://bugs.openbossa.org/show_bug.cgi?id=448'''
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtWidgets import QApplication
-from PySide2.QtWebKit import QWebView
-
-class Bug448(unittest.TestCase):
- def onError(self, erros):
- pass
-
- def testReturnOwnership(self):
- app = QApplication(sys.argv)
- webview = QWebView()
- webview.page().networkAccessManager().sslErrors.connect(self.onError)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/bug_694.py b/sources/pyside2/tests/QtWebKit/bug_694.py
deleted file mode 100644
index b18d658f6..000000000
--- a/sources/pyside2/tests/QtWebKit/bug_694.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import *
-from PySide2.QtWidgets import *
-from PySide2.QtWebKit import *
-
-class ErrorPage (QWebPage):
-
- def __init__(self):
- QWebPage.__init__(self)
- self.rcv_extension = None
- self.rcv_url = None
- self.rcv_url_copy = None
- self.rcv_option_type = None
- self.rcv_output_type = None
-
-
- def supportsExtension(self, extension):
- return extension == QWebPage.ErrorPageExtension
-
- def extension(self, extension, option, output):
- self.rcv_extension = extension
- self.rcv_url = option.url
- self.rcv_url_copy = QUrl(option.url)
- self.rcv_option_type = type(option)
- self.rcv_output_type = type(output)
- return True
-
-class TestWebPageExtension(unittest.TestCase):
- def testIt(self):
- app = QApplication([])
- ep = ErrorPage()
- view = QWebView()
- view.setPage(ep)
- view.load("foo://bar") # Some malformmed url
- view.show()
-
- # If the timeout is 0 the webpage isn't even loaded on Qt4.6-i386, so we use 100 :-)
- QTimer.singleShot(100, app.quit)
- app.exec_()
-
- self.assertEqual(ep.rcv_extension, QWebPage.ErrorPageExtension)
- self.assertRaises(RuntimeError, ep.rcv_url.__str__)
-
- self.assertEqual(ep.rcv_url_copy, "foo://bar")
- self.assertEqual(ep.rcv_option_type, QWebPage.ErrorPageExtensionOption)
- self.assertEqual(ep.rcv_output_type, QWebPage.ErrorPageExtensionReturn)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/bug_803.py b/sources/pyside2/tests/QtWebKit/bug_803.py
deleted file mode 100644
index ec6f93c33..000000000
--- a/sources/pyside2/tests/QtWebKit/bug_803.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtWidgets import *
-from PySide2.QtWebKit import *
-
-class TestBug803 (unittest.TestCase):
-
- def testIt(self):
- app = QApplication([])
- page = QWebPage()
- frame = page.mainFrame()
- frame.setHtml("<html><head></head><body><p>1</p><p>2</p></body></html>")
- elems = frame.findAllElements("p")
- self.assertEqual(len(elems), 2)
- self.assertEqual(elems[0].toPlainText(), "1")
- self.assertEqual(elems[1].toPlainText(), "2")
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/bug_899.py b/sources/pyside2/tests/QtWebKit/bug_899.py
deleted file mode 100644
index cb8e76784..000000000
--- a/sources/pyside2/tests/QtWebKit/bug_899.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import Property, QObject
-from PySide2.QtWebKit import QWebView
-from helper.timedqapplication import TimedQApplication
-
-class TestLambdaPropery(TimedQApplication):
-
- def testBug899(self):
- html = '''
- <html><body>
- <script type="text/javascript">
- document.write("<p>"+py_obj.list1+"</p>")
- document.write("<p>"+py_obj.list2+"</p>")
- </script>
- </body></html>
- '''
-
- class Obj(object):
- list1 = ['foo', 'bar', 'baz']
- list2 = ['fi', 'fo', 'fum']
-
- obj = Obj()
-
- wrapper_dict = {}
- for name in ('list1', 'list2'):
- getter = lambda arg=None, name=name: getattr(obj, name)
- wrapper_dict[name] = Property('QVariantList', getter)
- wrapper = type('PyObj', (QObject,), wrapper_dict)
-
- view = QWebView()
- view.page().mainFrame().addToJavaScriptWindowObject('py_obj', wrapper())
- view.setHtml(html)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/bug_959.py b/sources/pyside2/tests/QtWebKit/bug_959.py
deleted file mode 100644
index 5214ee1e1..000000000
--- a/sources/pyside2/tests/QtWebKit/bug_959.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-from PySide2.QtCore import QObject, Slot, QTimer
-from PySide2.QtWebKit import QWebView
-from PySide2.QtWidgets import QApplication
-from PySide2 import QtCore
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from helper.usesqapplication import UsesQApplication
-
-functionID = -1
-currentWebView = None
-
-class JSFuncs(QObject):
- @Slot(str,result=str)
- def slot_str_str(self, x):
- global functionID
- functionID = 0
- return x.upper()
-
- @Slot(str,result='QVariant')
- def slot_str_list(self, x):
- global functionID
- functionID = 1
- return [x, x]
-
- @Slot('QStringList',result=str)
- def slot_strlist_str(self, x):
- global functionID
- functionID = 2
- return x[-1]
-
- @Slot('QVariant',result=str)
- def slot_variant_str(self, x):
- global functionID
- functionID = 3
- return str(x)
-
- @Slot('QVariantList',result=str)
- def slot_variantlist_str(self, x):
- global functionID
- functionID = 4
- return str(x[-1])
-
- @Slot('QVariantMap',result=str)
- def slot_variantmap_str(self, x):
- global functionID
- functionID = 5
- return str(x["foo"])
-
-
-
-PAGE_DATA = "data:text/html,<!doctype html><html><body onload='%s'></body></html>"
-FUNCTIONS_LIST = ['jsfuncs.slot_str_str("hello")',
- 'jsfuncs.slot_str_list("hello")',
- 'jsfuncs.slot_strlist_str(["hello","world"])',
- 'jsfuncs.slot_variant_str("hello")',
- 'jsfuncs.slot_variantlist_str(["hello","world"])',
- 'jsfuncs.slot_variantmap_str({"foo": "bar"})']
-
-
-def onLoadFinished( result ):
- QTimer.singleShot( 100, createNextWebView )
-
-def createNextWebView():
- global functionID
-
- nListCount = len(FUNCTIONS_LIST) - 1
- functionID = functionID + 1
- print functionID
-
- if functionID < nListCount:
- createWebView( functionID )
- else:
- QTimer.singleShot(300, QApplication.instance().quit)
-
-
-def createWebView( nIndex ):
- global functionID
- global currentWebView
-
- functionID = nIndex
- currentWebView = QWebView()
- currentWebView._jsfuncs = JSFuncs()
- currentWebView.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", currentWebView._jsfuncs)
- QObject.connect( currentWebView, QtCore.SIGNAL('loadFinished( bool )'), onLoadFinished )
- currentWebView.load(PAGE_DATA % FUNCTIONS_LIST[ nIndex ])
- currentWebView.show()
-
-class Bug959(UsesQApplication):
-
- def testJavaScriptInWebViewForCrash( self ):
- # wait for the webview load to be finished before creating the next webview
- # don't create the webview inside of onLoadFinished
- # also call onLoadFinished with the correct number of variables
- createNextWebView()
- self.app.exec_()
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/fox.html b/sources/pyside2/tests/QtWebKit/fox.html
deleted file mode 100644
index da873b1cc..000000000
--- a/sources/pyside2/tests/QtWebKit/fox.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<title>Title</title>
-<meta name="description" content="PySide Test METADATA." />
-<body>
-<p>The quick <b>brown</b> fox <i>jumps</i> over the lazy dog.</p>
-</body>
-</html>
diff --git a/sources/pyside2/tests/QtWebKit/qml_plugin_test.py b/sources/pyside2/tests/QtWebKit/qml_plugin_test.py
deleted file mode 100644
index 33497bdc1..000000000
--- a/sources/pyside2/tests/QtWebKit/qml_plugin_test.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QUrl, QTimer
-from PySide2.QtWidgets import QApplication, QLabel
-from PySide2.QtWebKit import QWebPluginFactory, QWebView, QWebSettings
-
-from helper.usesqapplication import UsesQApplication
-
-class PluginFactory(QWebPluginFactory):
-
- def plugins(self):
- plugins = []
-
- mime = self.MimeType()
- mime.name = 'DummyFile'
- mime.fileExtensions = ['.pys']
-
- plugin = self.Plugin()
- plugin.name = 'DummyPlugin'
- plugin.mimeTypes = [mime]
-
- plugins.append(plugin)
-
- return plugins
-
- def create(self, mimeType, url, argumentNames, argumentValues):
- if mimeType != 'application/x-dummy':
- return None
-
- for name, value in zip(argumentNames, argumentValues):
- if name == 'text':
- text = value
- else:
- text = "Webkit plugins!"
-
- widget = QLabel(text)
- return widget
-
-class TestPlugin(UsesQApplication):
-
- def testPlugin(self):
- view = QWebView()
- fac = PluginFactory()
- view.page().setPluginFactory(fac)
- QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
-
- view.load(QUrl(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'qmlplugin', 'index.html')))
-
- view.resize(840, 600)
- view.show()
-
- QTimer.singleShot(500, self.app.quit)
-
- self.app.exec_()
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/qmlplugin/dummy.pys b/sources/pyside2/tests/QtWebKit/qmlplugin/dummy.pys
deleted file mode 100644
index 0b7469da4..000000000
--- a/sources/pyside2/tests/QtWebKit/qmlplugin/dummy.pys
+++ /dev/null
@@ -1 +0,0 @@
-Foobar!
diff --git a/sources/pyside2/tests/QtWebKit/qmlplugin/index.html b/sources/pyside2/tests/QtWebKit/qmlplugin/index.html
deleted file mode 100644
index db0d6b5b2..000000000
--- a/sources/pyside2/tests/QtWebKit/qmlplugin/index.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html><body>
- <h1>Custom Plugin</h1>
- <object type="application/x-dummy" data="./dummy.pys" text="My text">
- </object>
-</body></html>
diff --git a/sources/pyside2/tests/QtWebKit/qvariantlist_property_test.py b/sources/pyside2/tests/QtWebKit/qvariantlist_property_test.py
deleted file mode 100644
index 6a51a6488..000000000
--- a/sources/pyside2/tests/QtWebKit/qvariantlist_property_test.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import Property, QObject
-from PySide2.QtWebKit import QWebView
-from helper.timedqapplication import TimedQApplication
-
-class TestLoadFinished(TimedQApplication):
-
- def setUp(self):
- TimedQApplication.setUp(self, timeout=1000)
-
- def tearDown(self):
- TimedQApplication.tearDown(self)
-
- def testQVariantListProperty(self):
- class Obj(object):
- list = ['foo', 'bar', 'baz']
-
- obj = Obj()
-
- wrapper_dict = {}
- for name in ['list']:
- getter = lambda arg=None, name=name: getattr(obj, name)
- wrapper_dict[name] = Property('QVariantList', getter)
- wrapper = type('PyObj', (QObject,), wrapper_dict)
-
- view = QWebView()
- frame = view.page().mainFrame()
- frame.addToJavaScriptWindowObject('py_obj', wrapper())
-
- html = '''
- <html><body>
- <script type="text/javascript">
- document.write(py_obj.list)
- </script>
- </body></html>
- '''
- view.setHtml(html)
- view.show()
- self.app.exec_()
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py b/sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py
deleted file mode 100644
index 4db5adbb5..000000000
--- a/sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2 import QtCore, QtWebKit
-
-from helper.usesqapplication import UsesQApplication
-
-class QWebPageHeadless(QtWebKit.QWebPage):
- # FIXME: This is not working, the slot is not overriden!
- # http://doc.qt.nokia.com/4.7-snapshot/qwebpage.html#shouldInterruptJavaScript
- @QtCore.Slot()
- def shouldInterruptJavaScript(self):
- self._interrupted = True
- QtCore.QTimer.singleShot(300, self._app.quit)
- return True
-
-class TestSlotOverride(UsesQApplication):
- def testFunctionCall(self):
- page = QWebPageHeadless()
- page._interrupted = False
- page._app = self.app
- page.mainFrame().setHtml('<script>while(1);</script>')
- self.app.exec_()
- self.assertTrue(page._interrupted)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/webpage_test.py b/sources/pyside2/tests/QtWebKit/webpage_test.py
deleted file mode 100644
index 0c37befa2..000000000
--- a/sources/pyside2/tests/QtWebKit/webpage_test.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-'''Test cases for QWebPage'''
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import QObject, SIGNAL, QUrl
-from PySide2.QtWebKit import QWebPage
-from PySide2.QtNetwork import QNetworkAccessManager
-
-from helper.helper import adjust_filename
-from helper.timedqapplication import TimedQApplication
-
-#Define a global timeout because TimedQApplication uses a singleton!
-#Use a value big enough to run all the tests.
-TIMEOUT = 1000
-
-class TestFindText(TimedQApplication):
- '''Test cases for finding text'''
-
- def setUp(self):
- TimedQApplication.setUp(self, timeout=TIMEOUT)
- self.page = QWebPage()
- QObject.connect(self.page, SIGNAL('loadFinished(bool)'),
- self.load_finished)
- self.called = False
-
- def tearDown(self):
- #Release resources
- del self.page
- self.called = False
- TimedQApplication.tearDown(self)
-
- def testFindSelectText(self):
- url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
- self.page.mainFrame().load(url)
- self.app.exec_()
- self.assertTrue(self.called)
-
- def load_finished(self, ok):
- #Callback to check if load was successful
- if ok:
- self.called = True
- self.assertTrue(self.page.findText('fox'))
- self.assertEqual(self.page.selectedText(), 'fox')
- self.app.quit()
-
-class SetNetworkAccessManagerCase(TimedQApplication):
-
- def setUp(self):
- TimedQApplication.setUp(self, timeout=TIMEOUT)
-
- def testSetNetworkAccessManager(self):
- page = QWebPage()
- manager = QNetworkAccessManager()
- page.setNetworkAccessManager(manager)
-
- def testNetWorkAccessManager(self):
- page = QWebPage()
- a = page.networkAccessManager()
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWebKit/webview_test.py b/sources/pyside2/tests/QtWebKit/webview_test.py
deleted file mode 100644
index 5ecac5387..000000000
--- a/sources/pyside2/tests/QtWebKit/webview_test.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-'''Test cases for QWebView'''
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-import py3kcompat as py3k
-
-from PySide2.QtCore import QObject, SIGNAL, QUrl
-from PySide2.QtWebKit import QWebPage, QWebView
-from PySide2.QtNetwork import QNetworkRequest
-
-from helper.helper import adjust_filename
-from helper.timedqapplication import TimedQApplication
-
-
-class testWebPage(QWebPage):
- def sayMyName(self):
- return 'testWebPage'
-
-class TestLoadFinished(TimedQApplication):
- '''Test case for signal QWebView.loadFinished(bool)'''
-
- def setUp(self):
- #Acquire resources
- TimedQApplication.setUp(self, timeout=1000)
- self.view = QWebView()
- QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
- self.load_finished)
- self.called = False
-
- def tearDown(self):
- #Release resources
- del self.view
- self.called = False
- TimedQApplication.tearDown(self)
-
- def testLoadFinishedFromFile(self):
- url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
- self.view.setUrl(url)
- self.app.exec_()
-
- self.assertTrue(self.called)
-
- def testSetPageAndGetPage(self):
- twp = testWebPage()
- self.view.setPage(twp)
- del twp
- p = self.view.page()
- self.assertEqual(p.sayMyName(), 'testWebPage')
-
- # Setting the same webpage should not incref the python obj
- refCount = sys.getrefcount(p)
- self.view.setPage(p)
- self.assertEqual(sys.getrefcount(p), refCount)
-
- # Changing the webpage obj should decref the old one
- twp2 = testWebPage()
- self.view.setPage(twp2)
- self.assertEqual(sys.getrefcount(p), refCount - 1)
-
- def load_finished(self, ok):
- #Callback to check if load was successful
- self.app.quit()
- if ok:
- self.called = True
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
index 28372f437..afa5eae0a 100644
--- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt
+++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
@@ -9,10 +9,8 @@ PYSIDE_TEST(bug_243.py)
PYSIDE_TEST(bug_307.py)
PYSIDE_TEST(bug_324.py)
PYSIDE_TEST(bug_338.py)
-PYSIDE_TEST(bug_363.py)
PYSIDE_TEST(bug_389.py)
PYSIDE_TEST(bug_400.py)
-PYSIDE_TEST(bug_416.py)
PYSIDE_TEST(bug_429.py)
PYSIDE_TEST(bug_430.py)
PYSIDE_TEST(bug_433.py)
@@ -28,7 +26,6 @@ PYSIDE_TEST(bug_575.py)
PYSIDE_TEST(bug_576.py)
PYSIDE_TEST(bug_585.py)
PYSIDE_TEST(bug_589.py)
-PYSIDE_TEST(bug_632.py)
PYSIDE_TEST(bug_635.py)
PYSIDE_TEST(bug_640.py)
PYSIDE_TEST(bug_653.py)
@@ -41,7 +38,6 @@ PYSIDE_TEST(bug_688.py)
PYSIDE_TEST(bug_693.py)
PYSIDE_TEST(bug_696.py)
PYSIDE_TEST(bug_711.py)
-PYSIDE_TEST(bug_714.py)
PYSIDE_TEST(bug_722.py)
PYSIDE_TEST(bug_728.py)
PYSIDE_TEST(bug_736.py)
diff --git a/sources/pyside2/tests/QtWidgets/add_action_test.py b/sources/pyside2/tests/QtWidgets/add_action_test.py
index c8a7c2269..d4af8b5d1 100644
--- a/sources/pyside2/tests/QtWidgets/add_action_test.py
+++ b/sources/pyside2/tests/QtWidgets/add_action_test.py
@@ -37,7 +37,8 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import SLOT
-from PySide2.QtWidgets import QMenuBar, QAction, QPushButton
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QMenuBar, QPushButton
from helper.usesqapplication import UsesQApplication
diff --git a/sources/pyside2/tests/QtWidgets/bug_363.py b/sources/pyside2/tests/QtWidgets/bug_363.py
deleted file mode 100644
index 910525fed..000000000
--- a/sources/pyside2/tests/QtWidgets/bug_363.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-''' Test bug 363: http://bugs.openbossa.org/show_bug.cgi?id=363'''
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from helper.usesqapplication import UsesQApplication
-from PySide2 import QtCore, QtWidgets
-
-# Check for desktop object lifetime
-class BugTest(UsesQApplication):
- def mySlot(self):
- pass
-
- # test if it is possible to connect with a desktop object after storing that on an auxiliar variable
- def testCase1(self):
- desktop = QtWidgets.QApplication.desktop()
- desktop.resized[int].connect(self.mySlot)
- self.assertTrue(True)
-
- # test if it is possible to connect with a desktop object without storing that on an auxiliar variable
- def testCase2(self):
- QtWidgets.QApplication.desktop().resized[int].connect(self.mySlot)
- self.assertTrue(True)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_416.py b/sources/pyside2/tests/QtWidgets/bug_416.py
deleted file mode 100644
index 092abebaf..000000000
--- a/sources/pyside2/tests/QtWidgets/bug_416.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from helper.timedqapplication import TimedQApplication
-from PySide2.QtCore import QSignalTransition, QState, Qt, QStateMachine
-from PySide2.QtWidgets import QCheckBox
-
-class CheckedTransition(QSignalTransition):
- def __init__(self, check):
- QSignalTransition.__init__(self, check.stateChanged[int])
- self.eventTested = False
-
- def eventTest(self, event):
- self.eventTested = True
- if not QSignalTransition.eventTest(self, event):
- return False
- return event.arguments()[0] == Qt.Checked
-
-class TestBug(TimedQApplication):
- def testCase(self):
- check = QCheckBox()
- check.setTristate(True)
-
- s1 = QState()
- s2 = QState()
-
- t1 = CheckedTransition(check)
- t1.setTargetState(s2)
- s1.addTransition(t1)
-
- machine = QStateMachine()
- machine.addState(s1)
- machine.addState(s2)
- machine.setInitialState(s1)
- machine.start()
-
- check.stateChanged[int].emit(1)
- check.show()
- self.app.exec_()
- self.assertTrue(t1.eventTested)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_632.py b/sources/pyside2/tests/QtWidgets/bug_632.py
deleted file mode 100644
index d836b2ff6..000000000
--- a/sources/pyside2/tests/QtWidgets/bug_632.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtWidgets import QLineEdit, QApplication
-
-
-class Bug589(unittest.TestCase):
- def testWrongSignature(self):
- text = QLineEdit("PySide bug 632")
- a = b = c = d = 0
- self.assertRaises(TypeError, text.getTextMargins, (a, b, c, d))
-
- def testTupleReturn(self):
- text = QLineEdit("PySide bug 632")
- text.setTextMargins(10, 20, 30, 40)
- (a, b, c, d) = text.getTextMargins()
- self.assertTrue((a, b, c, d), (10, 20, 30, 40))
-
-if __name__ == "__main__":
- app = QApplication(sys.argv)
- unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_711.py b/sources/pyside2/tests/QtWidgets/bug_711.py
index 43e4b7bb2..3898e23f5 100644
--- a/sources/pyside2/tests/QtWidgets/bug_711.py
+++ b/sources/pyside2/tests/QtWidgets/bug_711.py
@@ -34,7 +34,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtWidgets import QToolBar, QApplication, QAction, QToolButton
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QToolBar, QApplication, QToolButton
try:
xrange
diff --git a/sources/pyside2/tests/QtWidgets/bug_714.py b/sources/pyside2/tests/QtWidgets/bug_714.py
deleted file mode 100644
index 76cf0295b..000000000
--- a/sources/pyside2/tests/QtWidgets/bug_714.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtGui import QPixmap
-from PySide2.QtWidgets import QLabel, QApplication
-
-class TestLabelPixmap(unittest.TestCase):
- def testReference(self):
- l = QLabel()
- p = QPixmap()
- l.setPixmap(p) # doesn't increment pixmap ref because this makes a copy
- self.assertEqual(sys.getrefcount(p), 2)
-
- p = l.pixmap()
- # this used to increment the reference because this is
- # an internal pointer, but not anymore since we don't create
- # a copy
- # self.assertEqual(sys.getrefcount(p), 3)
- self.assertEqual(sys.getrefcount(p), 2)
-
- p2 = l.pixmap()
- self.assertEqual(p, p2)
-
-if __name__ == '__main__':
- app = QApplication([])
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtWidgets/bug_860.py b/sources/pyside2/tests/QtWidgets/bug_860.py
index 8cdab2e45..483973fdb 100644
--- a/sources/pyside2/tests/QtWidgets/bug_860.py
+++ b/sources/pyside2/tests/QtWidgets/bug_860.py
@@ -52,7 +52,7 @@ class MultipleSlotTest(UsesQApplication):
box.stateChanged.connect(checkboxMapper.map)
checkboxMapper.setMapping(box, box.text())
- checkboxMapper.mapped[str].connect(self.cb_changed)
+ checkboxMapper.mappedString[str].connect(self.cb_changed)
self._changed = False
box.setChecked(True)
self.assertTrue(self._changed)
diff --git a/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py b/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py
index 8e291bb63..8699c7971 100644
--- a/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py
+++ b/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py
@@ -34,8 +34,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
-
from PySide2.QtCore import QSizeF, QTimer
from PySide2.QtGui import QTextFormat, QTextCharFormat, QPyTextObject
from PySide2.QtWidgets import QTextEdit
@@ -60,7 +58,7 @@ class QAbstractTextDocumentLayoutTest(UsesQApplication):
fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)
cursor = self.textEdit.textCursor()
- cursor.insertText(py3k.unichr(0xfffc), fmt)
+ cursor.insertText(chr(0xfffc), fmt)
self.textEdit.setTextCursor(cursor)
self.textEdit.close()
diff --git a/sources/pyside2/tests/QtWidgets/qaction_test.py b/sources/pyside2/tests/QtWidgets/qaction_test.py
index 8fc8f6c05..d587a59b1 100644
--- a/sources/pyside2/tests/QtWidgets/qaction_test.py
+++ b/sources/pyside2/tests/QtWidgets/qaction_test.py
@@ -34,7 +34,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtWidgets import QAction, QWidget
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QWidget
from helper.usesqapplication import UsesQApplication
class QPainterDrawText(UsesQApplication):
diff --git a/sources/pyside2/tests/QtWidgets/qimage_test.py b/sources/pyside2/tests/QtWidgets/qimage_test.py
index 8bb83c51a..11b9d2193 100644
--- a/sources/pyside2/tests/QtWidgets/qimage_test.py
+++ b/sources/pyside2/tests/QtWidgets/qimage_test.py
@@ -36,7 +36,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from helper.helper import adjust_filename
@@ -292,17 +291,11 @@ class QImageTest(UsesQApplication):
data2 = img1.scanLine(0)
self.assertEqual(data1, data2)
- # PySide python 3.x does not support slice yet
- if not py3k.IS_PY3K:
- buff = py3k.buffer(img0.bits()[:img0.bytesPerLine()])
- self.assertEqual(data1, buff)
- self.assertEqual(data2, buff)
-
def testEmptyBuffer(self):
- img = QImage(py3k.buffer(''), 100, 100, QImage.Format_ARGB32)
+ img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format_ARGB32)
def testEmptyStringAsBuffer(self):
- img = QImage(py3k.b(''), 100, 100, QImage.Format_ARGB32)
+ img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format_ARGB32)
def testXpmConstructor(self):
label = QLabel()
diff --git a/sources/pyside2/tests/QtWidgets/qshortcut_test.py b/sources/pyside2/tests/QtWidgets/qshortcut_test.py
index 18aec285d..dbe99167c 100644
--- a/sources/pyside2/tests/QtWidgets/qshortcut_test.py
+++ b/sources/pyside2/tests/QtWidgets/qshortcut_test.py
@@ -38,11 +38,13 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2 import QtCore, QtGui, QtWidgets
+from PySide2.QtCore import Qt, QTimer
+from PySide2.QtGui import QKeySequence, QShortcut
+from PySide2.QtWidgets import QApplication, QWidget
-class Foo(QtWidgets.QWidget):
+class Foo(QWidget):
def __init__(self):
- QtWidgets.QWidget.__init__(self)
+ QWidget.__init__(self)
self.ok = False
self.copy = False
@@ -52,22 +54,22 @@ class Foo(QtWidgets.QWidget):
def slot_of_copy(self):
self.copy = True
-class MyShortcut(QtWidgets.QShortcut):
+class MyShortcut(QShortcut):
def __init__(self, keys, wdg, slot):
- QtWidgets.QShortcut.__init__(self, keys, wdg, slot)
+ QShortcut.__init__(self, keys, wdg, slot)
def emit_signal(self):
- self.emit(QtCore.SIGNAL("activated()"))
+ self.activated.emit()
class QAppPresence(unittest.TestCase):
def testQShortcut(self):
- self.qapp = QtWidgets.QApplication([])
+ self.qapp = QApplication([])
f = Foo()
- self.sc = MyShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), f, f.slot_of_foo)
- self.scstd = MyShortcut(QtGui.QKeySequence.Copy, f, f.slot_of_copy)
- QtCore.QTimer.singleShot(0, self.init);
+ self.sc = MyShortcut(QKeySequence(Qt.Key_Return), f, f.slot_of_foo)
+ self.scstd = MyShortcut(QKeySequence.Copy, f, f.slot_of_copy)
+ QTimer.singleShot(0, self.init);
self.qapp.exec_()
self.assertEqual(f.ok, True)
self.assertEqual(f.copy, True)
diff --git a/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py b/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py
index 0321b69a4..a8b572d05 100644
--- a/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py
+++ b/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py
@@ -39,11 +39,10 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from helper.usesqapplication import UsesQApplication
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import QAction
+from PySide2.QtGui import QAction, QKeySequence
+
class QStringQKeySequenceTest(UsesQApplication):
'''Tests conversions of QString to and from QKeySequence.'''
@@ -56,7 +55,7 @@ class QStringQKeySequenceTest(UsesQApplication):
def testPythonStringAsQKeySequence(self):
'''Passes a Python string to an argument expecting a QKeySequence.'''
- keyseq = py3k.unicode_('Ctrl+A')
+ keyseq = 'Ctrl+A'
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
diff --git a/sources/pyside2/tests/QtWidgets/qtoolbar_test.py b/sources/pyside2/tests/QtWidgets/qtoolbar_test.py
index 856bf07f3..a70305c4a 100644
--- a/sources/pyside2/tests/QtWidgets/qtoolbar_test.py
+++ b/sources/pyside2/tests/QtWidgets/qtoolbar_test.py
@@ -36,7 +36,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtWidgets import QToolBar, QMainWindow, QAction
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import QToolBar, QMainWindow
from helper.usesqapplication import UsesQApplication
diff --git a/sources/pyside2/tests/QtWidgets/wrong_return_test.py b/sources/pyside2/tests/QtWidgets/wrong_return_test.py
index d95ae7639..27b5309e9 100644
--- a/sources/pyside2/tests/QtWidgets/wrong_return_test.py
+++ b/sources/pyside2/tests/QtWidgets/wrong_return_test.py
@@ -37,7 +37,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-import py3kcompat as py3k
from PySide2 import QtWidgets
from helper.usesqapplication import UsesQApplication
@@ -56,10 +55,7 @@ class testCase(UsesQApplication):
def testVirtualReturn(self):
w = MyWidget()
- if py3k.IS_PY3K:
- self.assertWarns(RuntimeWarning, w.show)
- else:
- self.assertRaises(RuntimeWarning, w.show)
+ self.assertWarns(RuntimeWarning, w.show)
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtXml/CMakeLists.txt b/sources/pyside2/tests/QtXml/CMakeLists.txt
index 2c21bf87d..feb230af3 100644
--- a/sources/pyside2/tests/QtXml/CMakeLists.txt
+++ b/sources/pyside2/tests/QtXml/CMakeLists.txt
@@ -1,2 +1 @@
PYSIDE_TEST(qdomdocument_test.py)
-PYSIDE_TEST(qxmlsimplereader_test.py)
diff --git a/sources/pyside2/tests/QtXml/qdomdocument_test.py b/sources/pyside2/tests/QtXml/qdomdocument_test.py
index 67da9952c..37774288c 100644
--- a/sources/pyside2/tests/QtXml/qdomdocument_test.py
+++ b/sources/pyside2/tests/QtXml/qdomdocument_test.py
@@ -38,25 +38,25 @@ init_test_paths(False)
from PySide2.QtCore import QByteArray
from PySide2.QtXml import QDomDocument, QDomElement
-import py3kcompat as py3k
+
class QDomDocumentTest(unittest.TestCase):
def setUp(self):
self.dom = QDomDocument()
- self.goodXmlData = QByteArray(py3k.b('''
+ self.goodXmlData = QByteArray(bytes('''
<typesystem package="PySide2.QtXml">
<value-type name="QDomDocument"/>
<value-type name="QDomElement"/>
</typesystem>
- '''))
+ ''', "UTF-8"))
- self.badXmlData = QByteArray(py3k.b('''
+ self.badXmlData = QByteArray(bytes('''
<typesystem package="PySide2.QtXml">
<value-type name="QDomDocument">
</typesystem>
- '''))
+ ''', "UTF-8"))
def tearDown(self):
del self.dom
@@ -67,7 +67,7 @@ class QDomDocumentTest(unittest.TestCase):
'''Sets invalid xml as the QDomDocument contents.'''
ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.badXmlData, True)
self.assertFalse(ok)
- self.assertEqual(errorStr, 'tag mismatch')
+ self.assertEqual(errorStr, 'Opening and ending tag mismatch.')
self.assertEqual(errorLine, 4)
self.assertEqual(errorColumn, 21)
diff --git a/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py b/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py
deleted file mode 100644
index a30d68cde..000000000
--- a/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtXml import QXmlSimpleReader
-
-class QXmlSimpleReaderTest(unittest.TestCase):
-
- def testQXmlSimpleReaderInstatiation(self):
- '''QXmlSimpleReader must be a concrete class not an abstract one.'''
- reader = QXmlSimpleReader()
-
- def testQXmlSimpleReaderFeatures(self):
- '''Calls the QXmlSimpleReader.features method. The features checked
- (at least the first two) can be found in the QXmlSimpleReader documentation:
- http://qt.nokia.com/doc/4.6/qxmlsimplereader.html#setFeature
- '''
- reader = QXmlSimpleReader()
- hasFeature, ok = reader.feature('http://xml.org/sax/features/namespaces')
- self.assertEqual((hasFeature, ok), (True, True))
-
- hasFeature, ok = reader.feature('http://xml.org/sax/features/namespace-prefixes')
- self.assertEqual((hasFeature, ok), (False, True))
-
- hasFeature, ok = reader.feature('foobar')
- self.assertEqual((hasFeature, ok), (False, False))
-
- def testQXmlSimpleReaderProperty(self):
- '''Tries to get a non existent property.'''
- reader = QXmlSimpleReader()
- prop, ok = reader.property('foo')
- self.assertEqual((prop, ok), (None, False))
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt b/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt
deleted file mode 100644
index 7f570f156..000000000
--- a/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-PYSIDE_TEST(import_test.py)
diff --git a/sources/pyside2/tests/QtXmlPatterns/import_test.py b/sources/pyside2/tests/QtXmlPatterns/import_test.py
deleted file mode 100644
index 09032909f..000000000
--- a/sources/pyside2/tests/QtXmlPatterns/import_test.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from init_paths import init_test_paths
-init_test_paths(False)
-
-from PySide2.QtCore import *
-from PySide2.QtXmlPatterns import QXmlSchema
-from helper.usesqcoreapplication import UsesQCoreApplication
-import py3kcompat as py3k
-
-class QXmlPatternsTest(UsesQCoreApplication):
-
- def testSchema(self):
- data = QByteArray(py3k.b('''<?xml version=\"1.0\" encoding=\"UTF-8\"?>
- <xsd:schema
- xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
- xmlns=\"http://qt.nokia.com/xmlschematest\"
- targetNamespace=\"http://qt.nokia.com/xmlschematest\"
- version=\"1.0\"
- elementFormDefault=\"qualified\">
- </xsd:schema>'''))
-
- buf = QBuffer(data)
- buf.open(QIODevice.ReadOnly)
-
- schema = QXmlSchema()
- schema.load(buf)
- self.assertTrue(schema.isValid())
-
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt
index 0dbd2b7cf..361f7d541 100644
--- a/sources/pyside2/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt
@@ -1,11 +1,14 @@
project(pysidetest)
project(testbinding)
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
set(QT_USE_QTCORE 1)
# no more supported: include(${QT_USE_FILE})
-add_definitions(${Qt${QT_MAJOR_VERSION}Core_DEFINITIONS})
+
+# removed after qtbase/054b66a65748c9ebfafeca88bf31669a24994237, is this required?
+# add_definitions(${Qt${QT_MAJOR_VERSION}Core_DEFINITIONS})
+
add_definitions(-DQT_SHARED)
add_definitions(-DRXX_ALLOCATOR_INIT_0)
@@ -25,11 +28,7 @@ testview.h
hiddenobject.h
)
-if (${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- qt6_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
-else()
- qt5_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
-endif()
+qt_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
set(testbinding_SRC
${CMAKE_CURRENT_BINARY_DIR}/testbinding/flagsnamespace_classforenum_wrapper.cpp
@@ -51,9 +50,9 @@ ${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
# Thus we use the second direct path, which contains the actual header files.
if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- set(Qt6Core_DIRECT_INCLUDE_DIR Qt6Core_INCLUDE_DIRS)
- set(Qt6Gui_DIRECT_INCLUDE_DIR Qt6Gui_INCLUDE_DIRS)
- set(Qt6Widgets_DIRECT_INCLUDE_DIR Qt6Widgets_INCLUDE_DIRS)
+ set(Qt6Core_DIRECT_INCLUDE_DIR ${Qt6Core_INCLUDE_DIRS})
+ set(Qt6Gui_DIRECT_INCLUDE_DIR ${Qt6Gui_INCLUDE_DIRS})
+ set(Qt6Widgets_DIRECT_INCLUDE_DIR ${Qt6Widgets_INCLUDE_DIRS})
else()
list(GET Qt5Core_INCLUDE_DIRS 1 Qt5Core_DIRECT_INCLUDE_DIR)
list(GET Qt5Gui_INCLUDE_DIRS 1 Qt5Gui_DIRECT_INCLUDE_DIR)
diff --git a/sources/pyside2/tests/pysidetest/modelview_test.py b/sources/pyside2/tests/pysidetest/modelview_test.py
index a4ae9dd40..e9d376801 100644
--- a/sources/pyside2/tests/pysidetest/modelview_test.py
+++ b/sources/pyside2/tests/pysidetest/modelview_test.py
@@ -36,7 +36,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(True)
-import py3kcompat as py3k
from testbinding import TestView
from PySide2.QtCore import QAbstractListModel, QObject, QModelIndex
@@ -98,7 +97,7 @@ class ModelViewTest(unittest.TestCase):
model = ListModelThatReturnsString()
view = TestView(model)
obj = view.getData()
- self.assertEqual(type(obj), py3k.unicode)
+ self.assertEqual(type(obj), str)
self.assertEqual(obj, 'string')
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
index 81a764986..55953ad69 100644
--- a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
+++ b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
@@ -57,7 +57,6 @@ new_functions = """
"""
new_functions += """
- PySide2.QtGui.QBitmap().transformed(qMatrix,transformationMode)
PySide2.QtGui.QStandardItemModel().insertColumn(int,qModelIndex)
PySide2.QtGui.QStandardItemModel().parent()
# PySide2.QtGui.QTextList(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
@@ -71,8 +70,6 @@ new_functions += """
PySide2.QtWidgets.QApplication.setPalette(qPalette)
PySide2.QtWidgets.QBoxLayout(direction).addWidget(qWidget)
PySide2.QtWidgets.QColorDialog().open()
- PySide2.QtWidgets.QDirModel().index(int,int,qModelIndex)
- PySide2.QtWidgets.QDirModel().parent()
PySide2.QtWidgets.QFileDialog().open()
PySide2.QtWidgets.QFileSystemModel().index(int,int,qModelIndex)
PySide2.QtWidgets.QFileSystemModel().parent()
@@ -145,7 +142,6 @@ class MainTest(unittest.TestCase):
try:
PySide2.QtGui
#qPaintDevice = PySide2.QtGui.QPaintDevice() # NotImplementedError
- qMatrix = PySide2.QtGui.QMatrix()
qTextDocument = PySide2.QtGui.QTextDocument()
qTextFormat = PySide2.QtGui.QTextFormat()
quintptr = long(42) if sys.version_info[0] < 3 else 42
@@ -158,7 +154,7 @@ class MainTest(unittest.TestCase):
direction = PySide2.QtWidgets.QBoxLayout.Direction()
qWidget = PySide2.QtWidgets.QWidget()
qStyleOptionFrame = PySide2.QtWidgets.QStyleOptionFrame()
- qAction = PySide2.QtWidgets.QAction(qObject)
+ qAction = PySide2.QtGui.QAction(qObject)
renderFlags = PySide2.QtWidgets.QWidget.RenderFlags
except AttributeError:
pass
diff --git a/sources/pyside2/tests/pysidetest/qvariant_test.py b/sources/pyside2/tests/pysidetest/qvariant_test.py
index 0efece889..547cca441 100644
--- a/sources/pyside2/tests/pysidetest/qvariant_test.py
+++ b/sources/pyside2/tests/pysidetest/qvariant_test.py
@@ -45,7 +45,7 @@ class QVariantTest(UsesQApplication):
def testQKeySequenceQVariantOperator(self):
# bug #775
ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
- self.assertEqual(TestObject.checkType(ks), 75)
+ self.assertEqual(TestObject.checkType(ks), 4107)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_enum_test.py b/sources/pyside2/tests/signals/signal_enum_test.py
index 3a24b919d..d48aa10cf 100644
--- a/sources/pyside2/tests/signals/signal_enum_test.py
+++ b/sources/pyside2/tests/signals/signal_enum_test.py
@@ -26,6 +26,7 @@
##
#############################################################################
+from enum import Enum
import os
import sys
import unittest
@@ -36,47 +37,44 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2.QtCore import QObject, Signal, Slot
-import py3kcompat as py3k
-if py3k.IS_PY3K:
- from enum import Enum
+class Colors(Enum):
+ red = 1
+ green = 2
+ blue = 3
- class Colors(Enum):
- red = 1
- green = 2
- blue = 3
+class Obj(QObject):
+ enum_signal = Signal(Colors)
+ object_signal = Signal(object)
- class Obj(QObject):
- enum_signal = Signal(Colors)
- object_signal = Signal(object)
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self.enum_signal.connect(self.get_result)
+ self.object_signal.connect(self.get_result)
+ self.value = -1
- def __init__(self, parent=None):
- QObject.__init__(self, parent)
- self.enum_signal.connect(self.get_result)
- self.object_signal.connect(self.get_result)
- self.value = -1
+ @Slot()
+ def get_result(self, i):
+ self.value = i
- @Slot()
- def get_result(self, i):
- self.value = i
+class SignalEnumTests(unittest.TestCase):
+ '''Test Signal with enum.Enum'''
- class SignalEnumTests(unittest.TestCase):
- '''Test Signal with enum.Enum'''
+ def testSignal(self):
+ o = Obj()
+ # Default value
+ self.assertEqual(o.value, -1)
- def testSignal(self):
- o = Obj()
- # Default value
- self.assertEqual(o.value, -1)
+ # Enum Signal
+ o.enum_signal.emit(Colors.green)
+ self.assertEqual(o.value, Colors.green)
- # Enum Signal
- o.enum_signal.emit(Colors.green)
- self.assertEqual(o.value, Colors.green)
+ # object Signal
+ o.object_signal.emit(Colors.red)
+ self.assertEqual(o.value, Colors.red)
- # object Signal
- o.object_signal.emit(Colors.red)
- self.assertEqual(o.value, Colors.red)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/support/voidptr_test.py b/sources/pyside2/tests/support/voidptr_test.py
index 9e3668eb1..367d250da 100644
--- a/sources/pyside2/tests/support/voidptr_test.py
+++ b/sources/pyside2/tests/support/voidptr_test.py
@@ -53,7 +53,7 @@ class PySide2Support(unittest.TestCase):
self.assertIsInstance(vp, shiboken.VoidPtr)
# Create QByteArray from voidptr byte interpretation
- nba = QByteArray.fromRawData(vp.toBytes())
+ nba = QByteArray(vp.toBytes())
# Compare original bytes to toBytes()
self.assertTrue(b, vp.toBytes())
# Compare original with new QByteArray data
diff --git a/sources/pyside2/tests/tools/list-class-hierarchy.py b/sources/pyside2/tests/tools/list-class-hierarchy.py
index b734ae69e..70075b27e 100755
--- a/sources/pyside2/tests/tools/list-class-hierarchy.py
+++ b/sources/pyside2/tests/tools/list-class-hierarchy.py
@@ -87,7 +87,6 @@ if __name__=='__main__':
'QtSvg',
'QtTest',
#'QtUiTools',
- 'QtWebKit',
'QtXml',
'QtXmlPatterns' ]
diff --git a/sources/pyside2/tests/util/httpd.py b/sources/pyside2/tests/util/httpd.py
index 41ac126fb..82bec337d 100644
--- a/sources/pyside2/tests/util/httpd.py
+++ b/sources/pyside2/tests/util/httpd.py
@@ -26,23 +26,17 @@
##
#############################################################################
+import http.server as BaseHTTPServer
import os
import random
import select
import sys
+import socketserver as SocketServer
import tempfile
import threading
sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "util"))
-import py3kcompat as py3k
-
-if py3k.IS_PY3K:
- import socketserver as SocketServer
- import http.server as BaseHTTPServer
-else:
- import SocketServer
- import BaseHTTPServer
class TestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
DATA = "PySide Server"
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py
deleted file mode 100644
index bffc79968..000000000
--- a/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py
+++ /dev/null
@@ -1,2 +0,0 @@
-
-from PyQt4.QtWebKit import *
diff --git a/sources/pyside2/tests/util/py3kcompat.py b/sources/pyside2/tests/util/py3kcompat.py
deleted file mode 100644
index bd90973ec..000000000
--- a/sources/pyside2/tests/util/py3kcompat.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## 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$
-##
-#############################################################################
-
-# Copy of ../../../shiboken2/tests/py3kcompat.py
-
-import sys
-
-IS_PY3K = sys.version_info[0] == 3
-
-if IS_PY3K:
- def b(s):
- if type(s) == bytes:
- return s
- return bytes(s, "UTF8")
-
- def buffer_(s):
- if s == None:
- return None
- elif type(s) == str:
- return bytes(s, "UTF8")
- elif type(s) == bytes:
- return s
- else:
- memoryview(s)
-
- def l(n):
- return n
-
- def unicode_(s):
- return s
-
- unicode = str
- unichr = chr
- long = int
- unichr = chr
- buffer = buffer_
-else:
- def b(s):
- return s
-
- def l(n):
- return long(n)
-
- def unicode_(s):
- if type(s) == str:
- import codecs
- c = codecs.lookup('utf-8')
- s2 = c.decode(s, 'ignore')
- return s2[0]
- return u'%s' % s
-
- unicode = unicode
- unichr = unichr
- long = long
- buffer = buffer
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt
index b081beda9..cbe3310a4 100644
--- a/sources/shiboken2/ApiExtractor/CMakeLists.txt
+++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt
@@ -1,7 +1,7 @@
project(apiextractor)
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
set(CMAKE_AUTOMOC ON)
@@ -32,7 +32,6 @@ parser/enumvalue.cpp
xmlutils.cpp
)
-find_package(Qt${QT_MAJOR_VERSION}XmlPatterns 5.12)
find_package(Qt${QT_MAJOR_VERSION}Xml 5.12)
find_package(LibXml2 2.6.32)
find_package(LibXslt 1.1.19)
@@ -42,7 +41,7 @@ if (LIBXSLT_FOUND AND LIBXML2_FOUND)
set(HAS_LIBXSLT 1)
endif()
-if(NOT Qt${QT_MAJOR_VERSION}XmlPatterns_FOUND AND NOT HAS_LIBXSLT)
+if(NOT HAS_LIBXSLT)
set(DISABLE_DOCSTRINGS TRUE)
message(WARNING
"Documentation will not be built due to missing dependency (no Qt5XmlPatterns found).")
@@ -52,12 +51,12 @@ endif()
set(DISABLE_DOCSTRINGS ${DISABLE_DOCSTRINGS} PARENT_SCOPE)
add_library(apiextractor STATIC ${apiextractor_SRC})
-target_include_directories(apiextractor PRIVATE ${CLANG_EXTRA_INCLUDES}
+target_include_directories(apiextractor PRIVATE ${CLANG_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/parser)
target_link_libraries(apiextractor PUBLIC Qt${QT_MAJOR_VERSION}::Core)
-target_link_libraries(apiextractor PRIVATE ${CLANG_EXTRA_LIBRARIES})
+target_link_libraries(apiextractor PRIVATE libclang)
if (HAS_LIBXSLT)
target_compile_definitions(apiextractor PUBLIC HAVE_LIBXSLT)
@@ -68,20 +67,10 @@ if (HAS_LIBXSLT)
PRIVATE ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES})
endif()
-if (Qt${QT_MAJOR_VERSION}XmlPatterns_FOUND)
- target_compile_definitions(apiextractor PUBLIC HAVE_QTXMLPATTERNS)
- target_sources(apiextractor PRIVATE xmlutils_qt.cpp)
- target_link_libraries(apiextractor PUBLIC Qt${QT_MAJOR_VERSION}::Xml Qt${QT_MAJOR_VERSION}::XmlPatterns)
-endif()
-
if (NOT DISABLE_DOCSTRINGS)
target_sources(apiextractor PRIVATE docparser.cpp
doxygenparser.cpp
qtdocparser.cpp)
- if (NOT HAS_LIBXSLT)
- message(WARNING
- "libxslt and/or libxml not found, falling back to QtXmlPatterns (QTBUG-66925)")
- endif()
endif()
target_compile_definitions(apiextractor PRIVATE CMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}")
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 8ef2866c2..c8b9c173b 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1494,11 +1494,7 @@ void AbstractMetaBuilderPrivate::traverseEnums(const ScopeModelItem &scopeItem,
const QStringList &enumsDeclarations)
{
const EnumList &enums = scopeItem->enums();
-#if QT_VERSION >= 0x050E00
const QSet<QString> enumsDeclarationSet(enumsDeclarations.cbegin(), enumsDeclarations.cend());
-#else
- const QSet<QString> enumsDeclarationSet = QSet<QString>::fromList(enumsDeclarations);
-#endif
for (const EnumModelItem &enumItem : enums) {
AbstractMetaEnum* metaEnum = traverseEnum(enumItem, metaClass, enumsDeclarationSet);
if (metaEnum) {
@@ -1899,6 +1895,17 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
return nullptr;
}
+ // Add view substitution for simple view types of function arguments
+ // std::string_view -> std::string for foo(std::string_view)
+ auto viewOnTypeEntry = metaType->typeEntry()->viewOn();
+ if (viewOnTypeEntry != nullptr && metaType->indirections() == 0
+ && metaType->arrayElementType() == nullptr
+ && !metaType->hasInstantiations()) {
+ auto viewOn = new AbstractMetaType(*metaType);
+ viewOn->setTypeEntry(viewOnTypeEntry);
+ metaType->setViewOn(viewOn);
+ }
+
auto *metaArgument = new AbstractMetaArgument;
metaArgument->setType(metaType);
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 458e54626..2f68dd743 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -195,10 +195,13 @@ AbstractMetaType::AbstractMetaType(const TypeEntry *t) :
{
}
+AbstractMetaType::AbstractMetaType(const AbstractMetaType &rhs) = default;
+
AbstractMetaType::~AbstractMetaType()
{
qDeleteAll(m_children);
m_instantiations.clear();
+ delete m_viewOn;
}
QString AbstractMetaType::package() const
@@ -460,6 +463,8 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at)
}
}
d << '>';
+ if (at->viewOn())
+ d << ", views " << at->viewOn()->name();
}
} else {
d << '0';
@@ -1370,16 +1375,12 @@ QDebug operator<<(QDebug d, const AbstractMetaFunction *af)
d.nospace();
d << "AbstractMetaFunction(";
if (af) {
-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
if (d.verbosity() > 2) {
af->formatDebugVerbose(d);
} else {
-#endif
d << "signature=";
formatMetaFunctionBrief(d, af);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
}
-#endif
} else {
d << '0';
}
@@ -2545,11 +2546,11 @@ AbstractMetaEnum *AbstractMetaClass::findEnum(const AbstractMetaClassList &class
AbstractMetaEnumValue *AbstractMetaClass::findEnumValue(const AbstractMetaClassList &classes,
const QString &name)
{
- const QVector<QStringRef> lst = name.splitRef(QLatin1String("::"));
+ const auto lst = QStringView{name}.split(u"::");
if (lst.size() > 1) {
- const QStringRef &prefixName = lst.at(0);
- const QStringRef &enumName = lst.at(1);
+ const auto &prefixName = lst.at(0);
+ const auto &enumName = lst.at(1);
if (AbstractMetaClass *cl = findClass(classes, prefixName.toString()))
return cl->findEnumValue(enumName.toString());
}
@@ -2730,8 +2731,8 @@ AbstractMetaEnumValue *AbstractMetaEnum::findEnumValue(const QString &value) con
const int sepPos = value.indexOf(QLatin1String("::"));
if (sepPos == -1)
return findMatchingEnumValue(m_enumValues, value);
- return name() == value.leftRef(sepPos)
- ? findMatchingEnumValue(m_enumValues, value.rightRef(value.size() - sepPos - 2))
+ return name() == QStringView{value}.left(sepPos)
+ ? findMatchingEnumValue(m_enumValues, QStringView{value}.right(value.size() - sepPos - 2))
: nullptr;
}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 988815dd3..154314d69 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -304,6 +304,7 @@ public:
Q_DECLARE_FLAGS(ComparisonFlags, ComparisonFlag);
explicit AbstractMetaType(const TypeEntry *t = nullptr);
+ AbstractMetaType(const AbstractMetaType &);
~AbstractMetaType();
QString package() const;
@@ -533,6 +534,12 @@ public:
bool compare(const AbstractMetaType &rhs, ComparisonFlags = {}) const;
+ // View on: Type to use for function argument conversion, fex
+ // std::string_view -> std::string for foo(std::string_view);
+ // cf TypeEntry::viewOn()
+ const AbstractMetaType *viewOn() const { return m_viewOn; }
+ void setViewOn(const AbstractMetaType *v) { m_viewOn = v; }
+
static AbstractMetaType *createVoid();
private:
@@ -550,6 +557,7 @@ private:
int m_arrayElementCount = -1;
const AbstractMetaType *m_arrayElementType = nullptr;
const AbstractMetaType *m_originalTemplateType = nullptr;
+ const AbstractMetaType *m_viewOn = nullptr;
Indirections m_indirections;
TypeUsagePattern m_pattern = InvalidPattern;
@@ -560,8 +568,6 @@ private:
ReferenceType m_referenceType = NoReference;
AbstractMetaTypeList m_children;
-
- Q_DISABLE_COPY(AbstractMetaType)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaType::ComparisonFlags);
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
index 73b1aca63..944445579 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
@@ -31,6 +31,7 @@
#include "clangutils.h"
#include <codemodel.h>
+#include <reporthandler.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -43,10 +44,6 @@
#include <cstring>
#include <ctype.h>
-#if QT_VERSION < 0x050800
-# define Q_FALLTHROUGH() (void)0
-#endif
-
namespace clang {
static inline QString colonColon() { return QStringLiteral("::"); }
@@ -174,8 +171,10 @@ public:
bool addClass(const CXCursor &cursor, CodeModel::ClassType t);
FunctionModelItem createFunction(const CXCursor &cursor,
- CodeModel::FunctionType t = CodeModel::Normal);
- FunctionModelItem createMemberFunction(const CXCursor &cursor);
+ CodeModel::FunctionType t = CodeModel::Normal,
+ bool isTemplateCode = false);
+ FunctionModelItem createMemberFunction(const CXCursor &cursor,
+ bool isTemplateCode = false);
void qualifyConstructor(const CXCursor &cursor);
TypeInfo createTypeInfoHelper(const CXType &type) const; // uncashed
TypeInfo createTypeInfo(const CXType &type) const;
@@ -263,12 +262,54 @@ bool BuilderPrivate::addClass(const CXCursor &cursor, CodeModel::ClassType t)
return true;
}
-static inline ExceptionSpecification exceptionSpecificationFromClang(int ce)
+static QString msgCannotDetermineException(const std::string_view &snippetV)
+{
+ const auto newLine = snippetV.find('\n'); // Multiline noexcept specifications have been found in Qt
+ const bool truncate = newLine != std::string::npos;
+ const qsizetype length = qsizetype(truncate ? newLine : snippetV.size());
+ QString snippet = QString::fromUtf8(snippetV.data(), length);
+ if (truncate)
+ snippet += QStringLiteral("...");
+
+ return QLatin1String("Cannot determine exception specification: \"")
+ + snippet + QLatin1Char('"');
+}
+
+// Return whether noexcept(<value>) throws. noexcept() takes a constexpr value.
+// Try to determine the simple cases (true|false) via code snippet.
+static ExceptionSpecification computedExceptionSpecificationFromClang(BaseVisitor *bv,
+ const CXCursor &cursor,
+ bool isTemplateCode)
{
+ const std::string_view snippet = bv->getCodeSnippet(cursor);
+ if (snippet.empty())
+ return ExceptionSpecification::Unknown; // Macro expansion, cannot tell
+ if (snippet.find("noexcept(false)") != std::string::npos)
+ return ExceptionSpecification::Throws;
+ if (snippet.find("noexcept(true)") != std::string::npos)
+ return ExceptionSpecification::NoExcept;
+ // Warn about it unless it is some form of template code where it is common
+ // to have complicated code, which is of no concern to shiboken, like:
+ // "QList::emplace(T) noexcept(is_pod<T>)".
+ if (!isTemplateCode && ReportHandler::isDebug(ReportHandler::FullDebug)) {
+ const Diagnostic d(msgCannotDetermineException(snippet), cursor, CXDiagnostic_Warning);
+ qWarning() << d;
+ bv->appendDiagnostic(d);
+ }
+ return ExceptionSpecification::Unknown;
+}
+
+static ExceptionSpecification exceptionSpecificationFromClang(BaseVisitor *bv,
+ const CXCursor &cursor,
+ bool isTemplateCode)
+{
+ const auto ce = clang_getCursorExceptionSpecificationType(cursor);
switch (ce) {
- case CXCursor_ExceptionSpecificationKind_BasicNoexcept:
case CXCursor_ExceptionSpecificationKind_ComputedNoexcept:
+ return computedExceptionSpecificationFromClang(bv, cursor, isTemplateCode);
+ case CXCursor_ExceptionSpecificationKind_BasicNoexcept:
case CXCursor_ExceptionSpecificationKind_DynamicNone: // throw()
+ case CXCursor_ExceptionSpecificationKind_NoThrow:
return ExceptionSpecification::NoExcept;
case CXCursor_ExceptionSpecificationKind_Dynamic: // throw(t1..)
case CXCursor_ExceptionSpecificationKind_MSAny: // throw(...)
@@ -283,7 +324,8 @@ static inline ExceptionSpecification exceptionSpecificationFromClang(int ce)
}
FunctionModelItem BuilderPrivate::createFunction(const CXCursor &cursor,
- CodeModel::FunctionType t)
+ CodeModel::FunctionType t,
+ bool isTemplateCode)
{
QString name = getCursorSpelling(cursor);
// Apply type fixes to "operator X &" -> "operator X&"
@@ -295,7 +337,7 @@ FunctionModelItem BuilderPrivate::createFunction(const CXCursor &cursor,
result->setFunctionType(t);
result->setScope(m_scope);
result->setStatic(clang_Cursor_getStorageClass(cursor) == CX_SC_Static);
- result->setExceptionSpecification(exceptionSpecificationFromClang(clang_getCursorExceptionSpecificationType(cursor)));
+ result->setExceptionSpecification(exceptionSpecificationFromClang(m_baseVisitor, cursor, isTemplateCode));
switch (clang_getCursorAvailability(cursor)) {
case CXAvailability_Available:
break;
@@ -332,13 +374,15 @@ static inline CodeModel::FunctionType functionTypeFromCursor(const CXCursor &cur
return result;
}
-FunctionModelItem BuilderPrivate::createMemberFunction(const CXCursor &cursor)
+FunctionModelItem BuilderPrivate::createMemberFunction(const CXCursor &cursor,
+ bool isTemplateCode)
{
const CodeModel::FunctionType functionType =
m_currentFunctionType == CodeModel::Signal || m_currentFunctionType == CodeModel::Slot
? m_currentFunctionType // by annotation
: functionTypeFromCursor(cursor);
- FunctionModelItem result = createFunction(cursor, functionType);
+ isTemplateCode |= m_currentClass->name().endsWith(QLatin1Char('>'));
+ auto result = createFunction(cursor, functionType, isTemplateCode);
result->setAccessPolicy(accessPolicy(clang_getCXXAccessSpecifier(cursor)));
result->setConstant(clang_CXXMethod_isConst(cursor) != 0);
result->setStatic(clang_CXXMethod_isStatic(cursor) != 0);
@@ -387,14 +431,6 @@ void BuilderPrivate::addField(const CXCursor &cursor)
m_scopeStack.back()->addVariable(field);
}
-// Array helpers: Parse "a[2][4]" into a list of dimensions
-
-struct ArrayDimensionResult
-{
- QVector<QStringRef> dimensions;
- int position;
-};
-
// Create qualified name "std::list<std::string>" -> ("std", "list<std::string>")
static QStringList qualifiedName(const QString &t)
{
@@ -451,7 +487,7 @@ bool BuilderPrivate::addTemplateInstantiationsRecursion(const CXType &type, Type
return true;
}
-static void dummyTemplateArgumentHandler(int, const QStringRef &) {}
+static void dummyTemplateArgumentHandler(int, QStringView) {}
void BuilderPrivate::addTemplateInstantiations(const CXType &type,
QString *typeName,
@@ -580,44 +616,15 @@ void BuilderPrivate::endTemplateTypeAlias(const CXCursor &typeAliasCursor)
// CXCursor_EnumConstantDecl, ParmDecl (a = Flag1 | Flag2)
QString BuilderPrivate::cursorValueExpression(BaseVisitor *bv, const CXCursor &cursor) const
{
- BaseVisitor::CodeSnippet snippet = bv->getCodeSnippet(cursor);
- const char *equalSign = std::find(snippet.first, snippet.second, '=');
- if (equalSign == snippet.second)
+ const std::string_view snippet = bv->getCodeSnippet(cursor);
+ auto equalSign = snippet.find('=');
+ if (equalSign == std::string::npos)
return QString();
++equalSign;
- return QString::fromLocal8Bit(equalSign, int(snippet.second - equalSign)).trimmed();
-}
-
-// A hacky reimplementation of clang_EnumDecl_isScoped() for Clang < 5.0
-// which simply checks for a blank-delimited " class " keyword in the enum snippet.
-
-#define CLANG_NO_ENUMDECL_ISSCOPED \
- (CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR < 43)
-
-#if CLANG_NO_ENUMDECL_ISSCOPED
-static const char *indexOf(const BaseVisitor::CodeSnippet &snippet, const char *needle)
-{
- const size_t snippetLength = snippet.first ? size_t(snippet.second - snippet.first) : 0;
- const size_t needleLength = strlen(needle);
- if (needleLength > snippetLength)
- return nullptr;
- for (const char *c = snippet.first, *end = snippet.second - needleLength; c < end; ++c) {
- if (memcmp(c, needle, needleLength) == 0)
- return c;
- }
- return nullptr;
+ return QString::fromLocal8Bit(snippet.data() + equalSign,
+ qsizetype(snippet.size() - equalSign)).trimmed();
}
-long clang_EnumDecl_isScoped4(BaseVisitor *bv, const CXCursor &cursor)
-{
- BaseVisitor::CodeSnippet snippet = bv->getCodeSnippet(cursor);
- const char *classSpec = indexOf(snippet, "class");
- const bool isClass = classSpec && classSpec > snippet.first
- && isspace(*(classSpec - 1)) && isspace(*(classSpec + 5));
- return isClass ? 1 : 0;
-}
-#endif // CLANG_NO_ENUMDECL_ISSCOPED
-
// Resolve declaration and type of a base class
struct TypeDeclaration
@@ -996,7 +1003,7 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor)
// Skip inline member functions outside class, only go by declarations inside class
if (!withinClassDeclaration(cursor))
return Skip;
- d->m_currentFunction = d->createMemberFunction(cursor);
+ d->m_currentFunction = d->createMemberFunction(cursor, false);
d->m_scopeStack.back()->addFunction(d->m_currentFunction);
break;
// Not fully supported, currently, seen as normal function
@@ -1005,16 +1012,18 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor)
const CXCursor semParent = clang_getCursorSemanticParent(cursor);
if (isClassCursor(semParent)) {
if (semParent == clang_getCursorLexicalParent(cursor)) {
- d->m_currentFunction = d->createMemberFunction(cursor);
+ d->m_currentFunction = d->createMemberFunction(cursor, true);
d->m_scopeStack.back()->addFunction(d->m_currentFunction);
break;
}
return Skip; // inline member functions outside class
}
}
- Q_FALLTHROUGH(); // fall through to free template function.
+ d->m_currentFunction = d->createFunction(cursor, CodeModel::Normal, true);
+ d->m_scopeStack.back()->addFunction(d->m_currentFunction);
+ break;
case CXCursor_FunctionDecl:
- d->m_currentFunction = d->createFunction(cursor);
+ d->m_currentFunction = d->createFunction(cursor, CodeModel::Normal, false);
d->m_scopeStack.back()->addFunction(d->m_currentFunction);
break;
case CXCursor_Namespace: {
@@ -1130,10 +1139,10 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor)
// how it is defined, and qdoc).
if (clang_isDeclaration(cursor.kind) && !d->m_currentClass.isNull()) {
auto snippet = getCodeSnippet(cursor);
- const auto length = snippet.second - snippet.first;
- if (length > 12 && *(snippet.second - 1) == ')'
- && std::strncmp(snippet.first, "Q_PROPERTY(", 11) == 0) {
- const QString qProperty = QString::fromUtf8(snippet.first + 11, length - 12);
+ const auto length = snippet.size();
+ if (length > 12 && *snippet.rbegin() == ')'
+ && snippet.compare(0, 11, "Q_PROPERTY(") == 0) {
+ const QString qProperty = QString::fromUtf8(snippet.data() + 11, length - 12);
d->m_currentClass->addPropertyDeclaration(qProperty);
}
}
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp
index d6915daab..7123c22d8 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.cpp
@@ -147,4 +147,16 @@ QDebug operator<<(QDebug s, const CXSourceLocation &location)
return s;
}
+QDebug operator<<(QDebug s, const std::string_view &v)
+{
+ QDebugStateSaver saver(s);
+ s.nospace();
+ s.noquote();
+ s << '"';
+ for (auto c : v)
+ s << c;
+ s << '"';
+ return s;
+}
+
#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h
index 2bbe526f7..ae3840fb4 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangdebugutils.h
@@ -33,6 +33,8 @@
#include <clang-c/Index.h>
+#include <string_view>
+
QT_FORWARD_DECLARE_CLASS(QDebug)
QT_FORWARD_DECLARE_CLASS(QString)
@@ -43,6 +45,7 @@ QDebug operator<<(QDebug s, CX_CXXAccessSpecifier ac);
QDebug operator<<(QDebug s, const CXType &t);
QDebug operator<<(QDebug s, const CXCursor &cursor);
QDebug operator<<(QDebug s, const CXSourceLocation &location);
+QDebug operator<<(QDebug s, const std::string_view &v); // for code snippets
#endif // !QT_NO_DEBUG_STREAM
#endif // CLANGDEBUGUTILS_H
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp
index d0c5bc1b8..d27c87828 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -48,10 +48,10 @@ QString SourceFileCache::getFileName(CXFile file)
return it.value();
}
-SourceFileCache::Snippet SourceFileCache::getCodeSnippet(const CXCursor &cursor,
- QString *errorMessage)
+std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor,
+ QString *errorMessage)
{
- Snippet result(nullptr, nullptr);
+ static const char empty[] = "";
if (errorMessage)
errorMessage->clear();
@@ -60,12 +60,12 @@ SourceFileCache::Snippet SourceFileCache::getCodeSnippet(const CXCursor &cursor,
// Quick check for equal locations: Frequently happens if the code is
// the result of a macro expansion
if (range.first == range.second)
- return result;
+ return std::string_view(empty, 0);
if (range.first.file != range.second.file) {
if (errorMessage)
*errorMessage = QStringLiteral("Range spans several files");
- return result;
+ return std::string_view(empty, 0);
}
auto it = m_fileBufferCache.find(range.first.file);
@@ -74,7 +74,7 @@ SourceFileCache::Snippet SourceFileCache::getCodeSnippet(const CXCursor &cursor,
if (fileName.isEmpty()) {
if (errorMessage)
*errorMessage = QStringLiteral("Range has no file");
- return result;
+ return std::string_view(empty, 0);
}
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
@@ -83,7 +83,7 @@ SourceFileCache::Snippet SourceFileCache::getCodeSnippet(const CXCursor &cursor,
str << "Cannot open \"" << QDir::toNativeSeparators(fileName)
<< "\": " << file.errorString();
}
- return result;
+ return std::string_view(empty, 0);
}
it = m_fileBufferCache.insert(range.first.file, file.readAll());
}
@@ -99,11 +99,10 @@ SourceFileCache::Snippet SourceFileCache::getCodeSnippet(const CXCursor &cursor,
<< QDir::toNativeSeparators(getFileName(range.first.file))
<< "\" (" << contents.size() << ')';
}
- return result;
+ return std::string_view(empty, 0);
}
- result.first = contents.constData() + pos;
- result.second = contents.constData() + end;
- return result;
+
+ return std::string_view(contents.constData() + pos, end - pos);
}
BaseVisitor::BaseVisitor() = default;
@@ -135,11 +134,11 @@ bool BaseVisitor::cbHandleEndToken(const CXCursor &cursor, StartTokenResult star
return result;
}
-BaseVisitor::CodeSnippet BaseVisitor::getCodeSnippet(const CXCursor &cursor)
+std::string_view BaseVisitor::getCodeSnippet(const CXCursor &cursor)
{
QString errorMessage;
- CodeSnippet result = m_fileCache.getCodeSnippet(cursor, &errorMessage);
- if (result.first == nullptr && !errorMessage.isEmpty()) {
+ const std::string_view result = m_fileCache.getCodeSnippet(cursor, &errorMessage);
+ if (result.empty() && !errorMessage.isEmpty()) {
QString message;
QTextStream str(&message);
str << "Unable to retrieve code snippet \"" << getCursorSpelling(cursor)
@@ -151,10 +150,10 @@ BaseVisitor::CodeSnippet BaseVisitor::getCodeSnippet(const CXCursor &cursor)
QString BaseVisitor::getCodeSnippetString(const CXCursor &cursor)
{
- CodeSnippet result = getCodeSnippet(cursor);
- return result.first != nullptr
- ? QString::fromUtf8(result.first, int(result.second - result.first))
- : QString();
+ const std::string_view result = getCodeSnippet(cursor);
+ return result.empty()
+ ? QString()
+ : QString::fromUtf8(result.data(), qsizetype(result.size()));
}
static CXChildVisitResult
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h
index 825de331c..7e918263a 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h
@@ -37,15 +37,15 @@
#include <QtCore/QString>
#include <QtCore/QVector>
+#include <string_view>
+
namespace clang {
struct Diagnostic;
class SourceFileCache {
public:
- using Snippet = QPair<const char *, const char *>;
-
- Snippet getCodeSnippet(const CXCursor &cursor, QString *errorMessage = nullptr);
+ std::string_view getCodeSnippet(const CXCursor &cursor, QString *errorMessage = nullptr);
QString getFileName(CXFile file);
private:
@@ -60,7 +60,6 @@ class BaseVisitor {
Q_DISABLE_COPY(BaseVisitor)
public:
using Diagnostics = QVector<Diagnostic>;
- using CodeSnippet = SourceFileCache::Snippet;
enum StartTokenResult { Error, Skip, Recurse };
@@ -78,8 +77,7 @@ public:
bool cbHandleEndToken(const CXCursor &cursor, StartTokenResult startResult);
QString getFileName(CXFile file) { return m_fileCache.getFileName(file); }
-
- CodeSnippet getCodeSnippet(const CXCursor &cursor);
+ std::string_view getCodeSnippet(const CXCursor &cursor);
QString getCodeSnippetString(const CXCursor &cursor);
Diagnostics diagnostics() const;
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
index 6bf2e3ab0..f3d45faa7 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
@@ -196,7 +196,7 @@ QPair<int, int> parseTemplateArgumentList(const QString &l,
switch (c) {
case ',':
case '>':
- handler(level, l.midRef(startPos, p - startPos).trimmed());
+ handler(level, QStringView{l}.mid(startPos, p - startPos).trimmed());
++p;
if (c == '>') {
if (--level == 0)
@@ -207,7 +207,7 @@ QPair<int, int> parseTemplateArgumentList(const QString &l,
startPos = p;
break;
case '<':
- handler(level, l.midRef(startPos, p - startPos).trimmed());
+ handler(level, QStringView{l}.mid(startPos, p - startPos).trimmed());
++level;
startPos = ++p;
break;
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
index 41d0af460..fba10206c 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
@@ -109,7 +109,7 @@ CXDiagnosticSeverity maxSeverity(const QVector<Diagnostic> &ds);
// Parse a template argument list "a<b<c,d>,e>" and invoke a handler
// with each match (level and string). Return begin and end of the list.
-using TemplateArgumentHandler = std::function<void (int, const QStringRef &)>;
+using TemplateArgumentHandler = std::function<void (int, QStringView)>;
QPair<int, int> parseTemplateArgumentList(const QString &l,
const TemplateArgumentHandler &handler,
diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
index dac511003..659324f8c 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp
@@ -307,7 +307,8 @@ QByteArrayList emulatedCompilerOptions()
QByteArrayList result;
#if defined(Q_CC_MSVC)
HeaderPaths headerPaths;
- result.append(QByteArrayLiteral("-fms-compatibility-version=19"));
+ result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806"));
+ result.append(QByteArrayLiteral("-fdelayed-template-parsing"));
result.append(QByteArrayLiteral("-Wno-microsoft-enum-value"));
// Fix yvals_core.h: STL1000: Unexpected compiler version, expected Clang 7 or newer (MSVC2017 update)
result.append(QByteArrayLiteral("-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"));
@@ -356,16 +357,7 @@ QByteArrayList emulatedCompilerOptions()
LanguageLevel emulatedCompilerLanguageLevel()
{
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return LanguageLevel::Cpp17;
-#else
-# if defined(Q_CC_MSVC) && _MSC_VER > 1900
- // Fixes constexpr errors in MSVC2017 library headers with Clang 4.1..5.X (0.45 == Clang 6).
- if (libClangVersion() < QVersionNumber(0, 45))
- return LanguageLevel::Cpp1Z;
-# endif // Q_CC_MSVC && _MSC_VER > 1900
- return LanguageLevel::Cpp14; // otherwise, t.h is parsed as "C"
-#endif // Qt 5
}
struct LanguageLevelMapping
diff --git a/sources/shiboken2/ApiExtractor/fileout.cpp b/sources/shiboken2/ApiExtractor/fileout.cpp
index ba5bf19de..10b9747ab 100644
--- a/sources/shiboken2/ApiExtractor/fileout.cpp
+++ b/sources/shiboken2/ApiExtractor/fileout.cpp
@@ -30,9 +30,6 @@
#include "messages.h"
#include "reporthandler.h"
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-# include <QtCore/QTextCodec>
-#endif
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QDebug>
@@ -221,10 +218,6 @@ FileOut::State FileOut::done(QString *errorMessage)
*errorMessage = msgCannotOpenForWriting(fileWrite);
return Failure;
}
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- QTextCodec *codec = QTextCodec::codecForName("UTF-8");
- stream.setCodec(codec);
-#endif
stream.setDevice(&fileWrite);
stream << tmp;
}
diff --git a/sources/shiboken2/ApiExtractor/messages.cpp b/sources/shiboken2/ApiExtractor/messages.cpp
index 95dcda558..a660f7e76 100644
--- a/sources/shiboken2/ApiExtractor/messages.cpp
+++ b/sources/shiboken2/ApiExtractor/messages.cpp
@@ -439,7 +439,7 @@ QString msgXpathDocModificationError(const DocModificationList& mods,
str << '"' << mod.xpath() << "\" -> \"";
const QString simplified = mod.code().simplified();
if (simplified.size() > 20)
- str << simplified.leftRef(20) << "...";
+ str << QStringView{simplified}.left(20) << "...";
else
str << simplified;
str << '"';
@@ -621,7 +621,7 @@ QString msgRejectReason(const TypeRejection &r, const QString &needle)
// typesystem.cpp
QString msgCannotFindNamespaceToExtend(const QString &name,
- const QStringRef &extendsPackage)
+ const QString &extendsPackage)
{
return QLatin1String("Cannot find namespace ") + name
+ QLatin1String(" in package ") + extendsPackage;
@@ -649,6 +649,12 @@ QString msgIncorrectlyNestedName(const QString &name)
+ name + QLatin1String(").");
}
+QString msgCannotFindView(const QString &viewedName, const QString &name)
+{
+ return QLatin1String("Unable to find viewed type ") + viewedName
+ + QLatin1String(" for ") + name;
+}
+
// qtdocgenerator.cpp
QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
@@ -657,7 +663,7 @@ QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
QString result;
QTextStream str(&result);
str << "While handling <";
- const QStringRef currentTag = reader.name();
+ const auto currentTag = reader.name();
if (currentTag.isEmpty())
str << tag;
else
diff --git a/sources/shiboken2/ApiExtractor/messages.h b/sources/shiboken2/ApiExtractor/messages.h
index 3f1a8650b..55481270c 100644
--- a/sources/shiboken2/ApiExtractor/messages.h
+++ b/sources/shiboken2/ApiExtractor/messages.h
@@ -169,7 +169,7 @@ QString msgLeftOverArguments(const QMap<QString, QString> &remainingArgs);
QString msgInvalidVersion(const QString &package, const QString &version);
QString msgCannotFindNamespaceToExtend(const QString &name,
- const QStringRef &extendsPackage);
+ const QString &extendsPackage);
QString msgExtendingNamespaceRequiresPattern(const QString &name);
@@ -179,6 +179,8 @@ QString msgNoRootTypeSystemEntry();
QString msgIncorrectlyNestedName(const QString &name);
+QString msgCannotFindView(const QString &viewedName, const QString &name);
+
QString msgCyclicDependency(const QString &funcName, const QString &graphName,
const QVector<const AbstractMetaFunction *> &involvedConversions);
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
index 9995fc71a..76ce333ed 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
@@ -224,7 +224,7 @@ public:
m_parseStack.append(t);
}
- void operator()(int level, const QStringRef &name)
+ void operator()(int level, QStringView name)
{
if (level > m_parseStack.size()) {
Q_ASSERT(!top()->m_instantiations.isEmpty());
@@ -240,12 +240,12 @@ public:
private:
TypeInfo *top() const { return m_parseStack.back(); }
- static QStringList qualifiedName(const QStringRef &name)
+ static QStringList qualifiedName(QStringView name)
{
QStringList result;
- const QVector<QStringRef> nameParts = name.split(QLatin1String("::"));
+ const auto nameParts = name.split(u"::");
result.reserve(nameParts.size());
- for (const QStringRef &p : nameParts)
+ for (const auto &p : nameParts)
result.append(p.toString());
return result;
}
@@ -494,11 +494,7 @@ void TypeInfo::formatDebug(QDebug &d) const
QDebug operator<<(QDebug d, const TypeInfo &t)
{
QDebugStateSaver s(d);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
const int verbosity = d.verbosity();
-#else
- const int verbosity = 0;
-#endif
d.noquote();
d.nospace();
d << "TypeInfo(";
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.cpp b/sources/shiboken2/ApiExtractor/reporthandler.cpp
index 2c6ab444b..f0c5bf31e 100644
--- a/sources/shiboken2/ApiExtractor/reporthandler.cpp
+++ b/sources/shiboken2/ApiExtractor/reporthandler.cpp
@@ -129,7 +129,7 @@ void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &cont
return;
if (auto db = TypeDatabase::instance()) {
const bool suppressed = fileLocationPos >= 0
- ? db->isSuppressedWarning(text.midRef(fileLocationPos + 2))
+ ? db->isSuppressedWarning(QStringView{text}.mid(fileLocationPos + 2))
: db->isSuppressedWarning(text);
if (suppressed) {
++m_suppressedCount;
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
index 4fd4269f6..debe25be6 100644
--- a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
@@ -335,7 +335,11 @@ struct Base {
struct A : public Base {
void unspecified();
void nonThrowing() noexcept;
+# if __cplusplus >= 201703L // C++ 17
+ void throwing() noexcept(false);
+#else
void throwing() throw(int);
+#endif
};
)CPP";
@@ -374,7 +378,7 @@ struct A : public Base {
<object-type name='Base'/>
<object-type name='A'>
<modify-function signature='unspecified()' exception-handling='auto-on'/>
- <modify-function signature='throwing()' exception-handling='off'/>
+ <modify-function signature='throwing()' exception-handling='no'/>
</object-type>
</typesystem>)XML")
<< true << false << false // exception
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp
index 9fcf474c6..6b56d362e 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp
@@ -568,8 +568,7 @@ bool TypeDatabase::addSuppressedWarning(const QString &warning, QString *errorMe
return true;
}
-template <class String> // QString, QStringRef
-bool TypeDatabase::isSuppressedWarningHelper(const String &s) const
+bool TypeDatabase::isSuppressedWarning(QStringView s) const
{
if (!m_suppressWarnings)
return false;
@@ -579,16 +578,6 @@ bool TypeDatabase::isSuppressedWarningHelper(const String &s) const
});
}
-bool TypeDatabase::isSuppressedWarning(const QString &s) const
-{
- return isSuppressedWarningHelper(s);
-}
-
-bool TypeDatabase::isSuppressedWarning(const QStringRef &s) const
-{
- return isSuppressedWarningHelper(s);
-}
-
QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile, const QString &currentPath) const
{
const QFileInfo tsFi(tsFile);
@@ -904,6 +893,8 @@ void TypeEntry::formatDebug(QDebug &d) const
FORMAT_BOOL("stream", m_stream)
FORMAT_LIST_SIZE("codeSnips", m_codeSnips)
FORMAT_NONEMPTY_STRING("conversionRule", m_conversionRule)
+ if (m_viewOn)
+ d << ", views=" << m_viewOn->name();
if (!m_version.isNull() && m_version > QVersionNumber(0, 0))
d << ", version=" << m_version;
if (m_revision)
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.h b/sources/shiboken2/ApiExtractor/typedatabase.h
index 7981febf3..fff301c6e 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.h
+++ b/sources/shiboken2/ApiExtractor/typedatabase.h
@@ -162,8 +162,7 @@ public:
bool addSuppressedWarning(const QString &warning, QString *errorMessage);
- bool isSuppressedWarning(const QString &s) const;
- bool isSuppressedWarning(const QStringRef &s) const;
+ bool isSuppressedWarning(QStringView s) const;
static QString globalNamespaceClassName(const TypeEntry *te);
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index 5634aa515..0c84cc980 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -232,16 +232,14 @@ void CodeSnipAbstract::addCode(const QString &code)
codeList.append(CodeSnipFragment(fixSpaces(code)));
}
-template <class String> // QString, QStringRef
-static inline int firstNonBlank(const String &s)
+static inline int firstNonBlank(QStringView s)
{
const auto it = std::find_if(s.cbegin(), s.cend(),
[] (QChar c) { return !c.isSpace(); });
return int(it - s.cbegin());
}
-template <class String> // QString, QStringRef
-static inline bool isEmpty(const String &s)
+static inline bool isEmpty(QStringView s)
{
return s.isEmpty()
|| std::all_of(s.cbegin(), s.cend(),
@@ -255,7 +253,7 @@ QString CodeSnipAbstract::dedent(const QString &code)
// Right trim if indent=0, or trim if single line
if (!code.at(0).isSpace() || !code.contains(QLatin1Char('\n')))
return code.trimmed();
- const auto lines = code.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{code}.split(QLatin1Char('\n'));
int spacesToRemove = std::numeric_limits<int>::max();
for (const auto &line : lines) {
if (!isEmpty(line)) {
@@ -369,7 +367,7 @@ static AddedFunction::TypeInfo parseType(const QString& signature,
int length = signature.length();
int start = signature.indexOf(regex, startPos);
if (start == -1) {
- if (signature.midRef(startPos + 1, 3) == QLatin1String("...")) { // varargs
+ if (QStringView{signature}.mid(startPos + 1, 3) == QLatin1String("...")) { // varargs
if (endPos)
*endPos = startPos + 4;
result.name = QLatin1String("...");
@@ -468,7 +466,7 @@ AddedFunction::AddedFunction(QString signature, const QString &returnType) :
break;
}
// is const?
- m_isConst = signature.rightRef(signatureLength - endPos).contains(QLatin1String("const"));
+ m_isConst = QStringView{signature}.right(signatureLength - endPos).contains(QLatin1String("const"));
}
}
@@ -490,7 +488,7 @@ QDebug operator<<(QDebug d, const CodeSnip &s)
d << "CodeSnip(language=" << s.language << ", position=" << s.position << ", \"";
for (const auto &f : s.codeList) {
const QString &code = f.code();
- const auto lines = code.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{code}.split(QLatin1Char('\n'));
for (int i = 0, size = lines.size(); i < size; ++i) {
if (i)
d << "\\n";
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 6635b501e..d3ef2c629 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -117,7 +117,7 @@ public:
QString code() const;
void addCode(const QString &code);
- void addCode(const QStringRef &code) { addCode(code.toString()); }
+ void addCode(QStringView code) { addCode(code.toString()); }
void addTemplateInstance(TemplateInstance *ti)
{
@@ -520,7 +520,7 @@ public:
m_signature(signature), m_mode(mode) {}
void setCode(const QString& code);
- void setCode(const QStringRef& code) { setCode(code.toString()); }
+ void setCode(QStringView code) { setCode(code.toString()); }
QString code() const
{
@@ -859,6 +859,12 @@ public:
void setCustomConversion(CustomConversion* customConversion);
CustomConversion* customConversion() const;
+ // View on: Type to use for function argument conversion, fex
+ // std::string_view -> std::string for foo(std::string_view).
+ // cf AbstractMetaType::viewOn()
+ TypeEntry *viewOn() const { return m_viewOn; }
+ void setViewOn(TypeEntry *v) { m_viewOn = v; }
+
virtual TypeEntry *clone() const;
void useAsTypedef(const TypeEntry *source);
@@ -894,6 +900,7 @@ private:
CustomConversion *m_customConversion = nullptr;
SourceLocation m_sourceLocation; // XML file
CodeGeneration m_codeGeneration = GenerateCode;
+ TypeEntry *m_viewOn = nullptr;
int m_revision = 0;
int m_sbkIndex = 0;
Type m_type;
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
index d2648d0b4..9ad9322b2 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
@@ -143,8 +143,8 @@ static QString extractSnippet(const QString &code, const QString &snippetLabel)
bool useLine = false;
QString result;
- const auto lines = code.splitRef(QLatin1Char('\n'));
- for (const QStringRef &line : lines) {
+ const auto lines = QStringView{code}.split(QLatin1Char('\n'));
+ for (const auto &line : lines) {
if (snippetRe.match(line).hasMatch()) {
useLine = !useLine;
if (!useLine)
@@ -429,7 +429,7 @@ static QString msgInvalidAttributeValue(const QXmlStreamAttribute &attribute)
return result;
}
-static QString msgUnusedAttributes(const QStringRef &tag, const QXmlStreamAttributes &attributes)
+static QString msgUnusedAttributes(QStringView tag, const QXmlStreamAttributes &attributes)
{
QString result;
QTextStream str(&result);
@@ -545,18 +545,20 @@ static QString msgReaderError(const QXmlStreamReader &reader, const QString &wha
}
static QString msgUnimplementedElementWarning(const QXmlStreamReader &reader,
- const QStringRef &name)
+ QStringView name)
{
- const QString message = QLatin1String("The element \"") +
- name + QLatin1String("\" is not implemented.");
+ QString message;
+ QTextStream(&message) << "The element \"" << name
+ << "\" is not implemented.";
return msgReaderMessage(reader, "Warning", message);
}
static QString msgUnimplementedAttributeWarning(const QXmlStreamReader &reader,
- const QStringRef &name)
+ QStringView name)
{
- const QString message = QLatin1String("The attribute \"") +
- name + QLatin1String("\" is not implemented.");
+ QString message;
+ QTextStream(&message) << "The attribute \"" << name
+ << "\" is not implemented.";
return msgReaderMessage(reader, "Warning", message);
}
@@ -600,7 +602,7 @@ static bool addRejection(TypeDatabase *database, QXmlStreamAttributes *attribute
return false;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
const TypeRejection::MatchType type = typeRejectionFromAttribute(name);
switch (type) {
case TypeRejection::Function:
@@ -746,7 +748,7 @@ bool TypeSystemParser::setupSmartPointerInstantiations()
return true;
}
-bool TypeSystemParser::endElement(const QStringRef &localName)
+bool TypeSystemParser::endElement(QStringView localName)
{
if (m_ignoreDepth) {
--m_ignoreDepth;
@@ -992,11 +994,11 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts)
}
}
- const QStringRef quoteFrom = atts.value(quoteAfterLineAttribute());
+ const auto quoteFrom = atts.value(quoteAfterLineAttribute());
bool foundFromOk = quoteFrom.isEmpty();
bool from = quoteFrom.isEmpty();
- const QStringRef quoteTo = atts.value(quoteBeforeLineAttribute());
+ const auto quoteTo = atts.value(quoteBeforeLineAttribute());
bool foundToOk = quoteTo.isEmpty();
bool to = true;
@@ -1123,16 +1125,44 @@ bool TypeSystemParser::checkRootElement()
return ok;
}
-void TypeSystemParser::applyCommonAttributes(const QXmlStreamReader &reader, TypeEntry *type,
- QXmlStreamAttributes *attributes) const
+static TypeEntry *findViewedType(const QString &name)
+{
+ const auto range = TypeDatabase::instance()->entries().equal_range(name);
+ for (auto i = range.first; i != range.second; ++i) {
+ switch (i.value()->type()) {
+ case TypeEntry::BasicValueType:
+ case TypeEntry::PrimitiveType:
+ case TypeEntry::ContainerType:
+ case TypeEntry::ObjectType:
+ return i.value();
+ default:
+ break;
+ }
+ }
+ return nullptr;
+}
+
+bool TypeSystemParser::applyCommonAttributes(const QXmlStreamReader &reader, TypeEntry *type,
+ QXmlStreamAttributes *attributes)
{
type->setSourceLocation(SourceLocation(m_currentFile,
reader.lineNumber()));
type->setCodeGeneration(m_generate);
- const int revisionIndex =
- indexOfAttribute(*attributes, u"revision");
- if (revisionIndex != -1)
- type->setRevision(attributes->takeAt(revisionIndex).value().toInt());
+ for (int i = attributes->size() - 1; i >= 0; --i) {
+ const auto name = attributes->at(i).qualifiedName();
+ if (name == u"revision") {
+ type->setRevision(attributes->takeAt(i).value().toInt());
+ } else if (name == u"view-on") {
+ const QString name = attributes->takeAt(i).value().toString();
+ TypeEntry *views = findViewedType(name);
+ if (views == nullptr) {
+ m_error = msgCannotFindView(name, type->name());
+ return false;
+ }
+ type->setViewOn(views);
+ }
+ }
+ return true;
}
FlagsTypeEntry *
@@ -1157,7 +1187,8 @@ FlagsTypeEntry *
}
ftype->setOriginalName(flagName);
- applyCommonAttributes(reader, ftype, attributes);
+ if (!applyCommonAttributes(reader, ftype, attributes))
+ return nullptr;
QStringList lst = flagName.split(colonColon());
const QString targetLangFlagName = QStringList(lst.mid(0, lst.size() - 1)).join(QLatin1Char('.'));
@@ -1194,7 +1225,7 @@ SmartPointerTypeEntry *
QString refCountMethodName;
QString instantiations;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("type")) {
smartPointerType = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("getter")) {
@@ -1236,7 +1267,8 @@ SmartPointerTypeEntry *
auto *type = new SmartPointerTypeEntry(name, getter, smartPointerType,
refCountMethodName, since, currentParentTypeEntry());
- applyCommonAttributes(reader, type, attributes);
+ if (!applyCommonAttributes(reader, type, attributes))
+ return nullptr;
m_smartPointerInstantiations.insert(type, instantiations);
return type;
}
@@ -1249,9 +1281,10 @@ PrimitiveTypeEntry *
if (!checkRootElement())
return nullptr;
auto *type = new PrimitiveTypeEntry(name, since, currentParentTypeEntry());
- applyCommonAttributes(reader, type, attributes);
+ if (!applyCommonAttributes(reader, type, attributes))
+ return nullptr;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == targetLangNameAttribute()) {
type->setTargetLangName(attributes->takeAt(i).value().toString());
} else if (name == QLatin1String("target-lang-api-name")) {
@@ -1286,14 +1319,15 @@ ContainerTypeEntry *
m_error = QLatin1String("no 'type' attribute specified");
return nullptr;
}
- const QStringRef typeName = attributes->takeAt(typeIndex).value();
+ const auto typeName = attributes->takeAt(typeIndex).value();
ContainerTypeEntry::ContainerKind containerType = containerTypeFromAttribute(typeName);
if (containerType == ContainerTypeEntry::NoContainer) {
m_error = QLatin1String("there is no container of type ") + typeName.toString();
return nullptr;
}
auto *type = new ContainerTypeEntry(name, containerType, since, currentParentTypeEntry());
- applyCommonAttributes(reader, type, attributes);
+ if (!applyCommonAttributes(reader, type, attributes))
+ return nullptr;
return type;
}
@@ -1310,7 +1344,7 @@ EnumTypeEntry *
QString flagNames;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("upper-bound")) {
qCWarning(lcShiboken, "%s",
qPrintable(msgUnimplementedAttributeWarning(reader, name)));
@@ -1349,7 +1383,7 @@ NamespaceTypeEntry *
auto visibility = TypeSystem::Visibility::Unspecified;
applyCommonAttributes(reader, result.data(), attributes);
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef attributeName = attributes->at(i).qualifiedName();
+ const auto attributeName = attributes->at(i).qualifiedName();
if (attributeName == QLatin1String("files")) {
const QString pattern = attributes->takeAt(i).value().toString();
QRegularExpression re(pattern);
@@ -1366,7 +1400,7 @@ NamespaceTypeEntry *
return e->targetLangPackage() == extendsPackageName;
});
if (extendsIt == allEntries.cend()) {
- m_error = msgCannotFindNamespaceToExtend(name, extendsPackageName);
+ m_error = msgCannotFindNamespaceToExtend(name, extendsPackageName.toString());
return nullptr;
}
result->setExtends(*extendsIt);
@@ -1483,7 +1517,7 @@ void TypeSystemParser::applyComplexTypeAttributes(const QXmlStreamReader &reader
QString package = m_defaultPackage;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == streamAttribute()) {
ctype->setStream(convertBoolean(attributes->takeAt(i).value(), streamAttribute(), false));
} else if (name == generateAttribute()) {
@@ -1564,7 +1598,7 @@ bool TypeSystemParser::parseRenameFunction(const QXmlStreamReader &,
QString signature;
QString rename;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == signatureAttribute()) {
// Do not remove as it is needed for the type entry later on
signature = attributes->at(i).value().toString();
@@ -1619,16 +1653,17 @@ bool TypeSystemParser::parseInjectDocumentation(const QXmlStreamReader &,
TypeSystem::DocModificationMode mode = TypeSystem::DocModificationReplace;
TypeSystem::Language lang = TypeSystem::NativeCode;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("mode")) {
- const QStringRef modeName = attributes->takeAt(i).value();
+ const auto modeName = attributes->takeAt(i).value();
mode = docModificationFromAttribute(modeName);
if (mode == TypeSystem::DocModificationInvalid) {
- m_error = QLatin1String("Unknown documentation injection mode: ") + modeName;
+ m_error = QLatin1String("Unknown documentation injection mode: ");
+ m_error += modeName;
return false;
}
} else if (name == formatAttribute()) {
- const QStringRef format = attributes->takeAt(i).value();
+ const auto format = attributes->takeAt(i).value();
lang = languageFromAttribute(format);
if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) {
m_error = QStringLiteral("unsupported class attribute: '%1'").arg(format);
@@ -1676,7 +1711,7 @@ TypeSystemTypeEntry *TypeSystemParser::parseRootElement(const QXmlStreamReader &
QXmlStreamAttributes *attributes)
{
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == packageAttribute()) {
m_defaultPackage = attributes->takeAt(i).value().toString();
} else if (name == defaultSuperclassAttribute()) {
@@ -1726,7 +1761,7 @@ bool TypeSystemParser::loadTypesystem(const QXmlStreamReader &,
QString typeSystemName;
bool generateChild = true;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == nameAttribute())
typeSystemName = attributes->takeAt(i).value().toString();
else if (name == generateAttribute())
@@ -1795,9 +1830,9 @@ bool TypeSystemParser::parseCustomConversion(const QXmlStreamReader &,
QString snippetLabel;
TypeSystem::Language lang = TypeSystem::NativeCode;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == classAttribute()) {
- const QStringRef languageAttribute = attributes->takeAt(i).value();
+ const auto languageAttribute = attributes->takeAt(i).value();
lang = languageFromAttribute(languageAttribute);
if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) {
m_error = QStringLiteral("unsupported class attribute: '%1'").arg(languageAttribute);
@@ -1880,7 +1915,7 @@ bool TypeSystemParser::parseAddConversion(const QXmlStreamReader &,
if (!readFileSnippet(attributes, &snip))
return false;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("type"))
sourceTypeName = attributes->takeAt(i).value().toString();
else if (name == QLatin1String("check"))
@@ -1932,7 +1967,7 @@ bool TypeSystemParser::parseModifyArgument(const QXmlStreamReader &,
QString replaceValue;
bool resetAfterUse = false;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
index = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("replace-value")) {
@@ -1997,9 +2032,9 @@ bool TypeSystemParser::parseDefineOwnership(const QXmlStreamReader &,
TypeSystem::Language lang = TypeSystem::TargetLangCode;
QString ownership;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == classAttribute()) {
- const QStringRef className = attributes->takeAt(i).value();
+ const auto className = attributes->takeAt(i).value();
lang = languageFromAttribute(className);
if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) {
m_error = QStringLiteral("unsupported class attribute: '%1'").arg(className);
@@ -2030,7 +2065,7 @@ bool TypeSystemParser::parseArgumentMap(const QXmlStreamReader &,
int pos = 1;
QString metaName;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
if (!parseIndex(attributes->takeAt(i).value().toString(), &pos, &m_error))
return false;
@@ -2067,7 +2102,7 @@ bool TypeSystemParser::parseRemoval(const QXmlStreamReader &,
TypeSystem::Language lang = TypeSystem::All;
const int classIndex = indexOfAttribute(*attributes, classAttribute());
if (classIndex != -1) {
- const QStringRef value = attributes->takeAt(classIndex).value();
+ const auto value = attributes->takeAt(classIndex).value();
lang = languageFromAttribute(value);
if (lang == TypeSystem::TargetLangCode) // "target" means TargetLangAndNativeCode here
lang = TypeSystem::TargetLangAndNativeCode;
@@ -2118,7 +2153,7 @@ bool TypeSystemParser::parseRename(const QXmlStreamReader &reader,
m_error = msgMissingAttribute(modifierAttribute());
return false;
}
- const QStringRef modifier = attributes->takeAt(modifierIndex).value();
+ const auto modifier = attributes->takeAt(modifierIndex).value();
modifierFlag = modifierFromAttribute(modifier);
if (modifierFlag == Modification::InvalidModifier) {
m_error = QStringLiteral("Unknown access modifier: '%1'").arg(modifier);
@@ -2141,7 +2176,7 @@ bool TypeSystemParser::parseModifyField(const QXmlStreamReader &reader,
FieldModification fm;
fm.modifiers = FieldModification::Readable | FieldModification::Writable;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == nameAttribute()) {
fm.name = attributes->takeAt(i).value().toString();
} else if (name == removeAttribute()) {
@@ -2194,7 +2229,7 @@ bool TypeSystemParser::parseAddFunction(const QXmlStreamReader &,
QString access;
int overloadNumber = TypeSystem::OverloadNumberUnset;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("signature")) {
originalSignature = attributes->takeAt(i).value().toString();
} else if (name == QLatin1String("return-type")) {
@@ -2305,7 +2340,7 @@ bool TypeSystemParser::parseModifyFunction(const QXmlStreamReader &reader,
TypeSystem::ExceptionHandling exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
TypeSystem::AllowThread allowThread = TypeSystem::AllowThread::Unspecified;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("signature")) {
originalSignature = attributes->takeAt(i).value().toString();
} else if (name == accessAttribute()) {
@@ -2433,7 +2468,7 @@ CustomFunction *
? QLatin1String("_create") : QLatin1String("_delete"));
QString paramName = QLatin1String("copy");
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == nameAttribute())
functionName = attributes->takeAt(i).value().toString();
else if (name == QLatin1String("param-name"))
@@ -2455,14 +2490,15 @@ bool TypeSystemParser::parseReferenceCount(const QXmlStreamReader &reader,
ReferenceCount rc;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == actionAttribute()) {
const QXmlStreamAttribute attribute = attributes->takeAt(i);
rc.action = referenceCountFromAttribute(attribute.value());
switch (rc.action) {
case ReferenceCount::Invalid:
- m_error = QLatin1String("unrecognized value '") + attribute.value()
- + QLatin1String("' for action attribute.");
+ m_error = QLatin1String("unrecognized value '");
+ m_error += attribute.value();
+ m_error += QLatin1String("' for action attribute.");
return false;
case ReferenceCount::AddAll:
case ReferenceCount::Ignore:
@@ -2491,16 +2527,18 @@ bool TypeSystemParser::parseParentOwner(const QXmlStreamReader &,
}
ArgumentOwner ao;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == indexAttribute()) {
const QString index = attributes->takeAt(i).value().toString();
if (!parseArgumentIndex(index, &ao.index, &m_error))
return false;
} else if (name == actionAttribute()) {
- const QStringRef action = attributes->takeAt(i).value();
+ const auto action = attributes->takeAt(i).value();
ao.action = argumentOwnerActionFromAttribute(action);
if (ao.action == ArgumentOwner::Invalid) {
- m_error = QLatin1String("Invalid parent actionr '") + action + QLatin1String("'.");
+ m_error = QLatin1String("Invalid parent action '");
+ m_error += action;
+ m_error += QLatin1String("'.");
return false;
}
}
@@ -2514,7 +2552,7 @@ bool TypeSystemParser::readFileSnippet(QXmlStreamAttributes *attributes, CodeSni
QString fileName;
QString snippetLabel;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("file")) {
fileName = attributes->takeAt(i).value().toString();
} else if (name == snippetAttribute()) {
@@ -2567,16 +2605,16 @@ bool TypeSystemParser::parseInjectCode(const QXmlStreamReader &,
if (!readFileSnippet(attributes, &snip))
return false;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == classAttribute()) {
- const QStringRef className = attributes->takeAt(i).value();
+ const auto className = attributes->takeAt(i).value();
lang = languageFromAttribute(className);
if (lang == TypeSystem::NoLanguage) {
m_error = QStringLiteral("Invalid class specifier: '%1'").arg(className);
return false;
}
} else if (name == positionAttribute()) {
- const QStringRef value = attributes->takeAt(i).value();
+ const auto value = attributes->takeAt(i).value();
position = codeSnipPositionFromAttribute(value);
if (position == TypeSystem::CodeSnipPositionInvalid) {
m_error = QStringLiteral("Invalid position: '%1'").arg(value);
@@ -2610,7 +2648,7 @@ bool TypeSystemParser::parseInclude(const QXmlStreamReader &,
QString fileName;
QString location;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == fileNameAttribute())
fileName = attributes->takeAt(i).value().toString();
else if (name == locationAttribute())
@@ -2682,7 +2720,7 @@ bool TypeSystemParser::parseReplace(const QXmlStreamReader &,
QString from;
QString to;
for (int i = attributes->size() - 1; i >= 0; --i) {
- const QStringRef name = attributes->at(i).qualifiedName();
+ const auto name = attributes->at(i).qualifiedName();
if (name == QLatin1String("from"))
from = attributes->takeAt(i).value().toString();
else if (name == toAttribute())
@@ -2710,12 +2748,12 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
return true;
}
- const QStringRef tagName = reader.name();
+ const auto tagName = reader.name();
QXmlStreamAttributes attributes = reader.attributes();
VersionRange versionRange;
for (int i = attributes.size() - 1; i >= 0; --i) {
- const QStringRef name = attributes.at(i).qualifiedName();
+ const auto name = attributes.at(i).qualifiedName();
if (name == sinceAttribute()) {
if (!parseVersion(attributes.takeAt(i).value().toString(),
m_defaultPackage, &versionRange.since, &m_error)) {
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.h b/sources/shiboken2/ApiExtractor/typesystemparser.h
index a36063f54..130d8d3d2 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.h
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.h
@@ -161,7 +161,7 @@ private:
const QString &name,
const QVersionNumber &since,
QXmlStreamAttributes *attributes);
- bool endElement(const QStringRef& localName);
+ bool endElement(QStringView localName);
template <class String> // QString/QStringRef
bool characters(const String &ch);
@@ -169,8 +169,8 @@ private:
const TypeEntry *currentParentTypeEntry() const;
bool checkRootElement();
- void applyCommonAttributes(const QXmlStreamReader &reader, TypeEntry *type,
- QXmlStreamAttributes *attributes) const;
+ bool applyCommonAttributes(const QXmlStreamReader &reader, TypeEntry *type,
+ QXmlStreamAttributes *attributes);
PrimitiveTypeEntry *
parsePrimitiveTypeEntry(const QXmlStreamReader &, const QString &name,
const QVersionNumber &since, QXmlStreamAttributes *);
diff --git a/sources/shiboken2/ApiExtractor/xmlutils.cpp b/sources/shiboken2/ApiExtractor/xmlutils.cpp
index a179412a7..6edca2fa5 100644
--- a/sources/shiboken2/ApiExtractor/xmlutils.cpp
+++ b/sources/shiboken2/ApiExtractor/xmlutils.cpp
@@ -28,7 +28,6 @@
#include "xmlutils.h"
-#include "xmlutils_qt.h"
#include "xmlutils_libxslt.h"
XQuery::XQuery() = default;
@@ -47,8 +46,6 @@ QSharedPointer<XQuery> XQuery::create(const QString &focus, QString *errorMessag
{
#if defined(HAVE_LIBXSLT)
return libXml_createXQuery(focus, errorMessage);
-#elif defined(HAVE_QTXMLPATTERNS)
- return qt_createXQuery(focus, errorMessage);
#else
*errorMessage = QLatin1String(__FUNCTION__) + QLatin1String(" is not implemented.");
return QSharedPointer<XQuery>();
@@ -59,8 +56,6 @@ QString xsl_transform(const QString &xml, const QString &xsl, QString *errorMess
{
#if defined(HAVE_LIBXSLT)
return libXslt_transform(xml, xsl, errorMessage);
-#elif defined(HAVE_QTXMLPATTERNS)
- return qt_xsl_transform(xml, xsl, errorMessage);
#else
*errorMessage = QLatin1String(__FUNCTION__) + QLatin1String(" is not implemented.");
return xml;
diff --git a/sources/shiboken2/ApiExtractor/xmlutils_qt.cpp b/sources/shiboken2/ApiExtractor/xmlutils_qt.cpp
deleted file mode 100644
index f703bc5f9..000000000
--- a/sources/shiboken2/ApiExtractor/xmlutils_qt.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part 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$
-**
-****************************************************************************/
-
-#include "xmlutils.h"
-#include "xmlutils_qt.h"
-
-#include <QtXmlPatterns/QXmlQuery>
-
-#include <QtCore/QDir>
-#include <QtCore/QUrl>
-
-class QtXQuery : public XQuery
-{
-public:
- QtXQuery() = default;
-
- bool setFocus(const QString &fileName)
- { return m_xquery.setFocus(QUrl::fromLocalFile(fileName)); }
-
-protected:
- QString doEvaluate(const QString &xPathExpression, QString *errorMessage) override;
-
-private:
- QXmlQuery m_xquery;
-};
-
-QString QtXQuery::doEvaluate(const QString &xPathExpression, QString *errorMessage)
-{
- m_xquery.setQuery(xPathExpression);
- if (!m_xquery.isValid()) {
- *errorMessage = QLatin1String("QXmlQuery: Bad query: \"") + xPathExpression
- + QLatin1Char('"');
- return QString();
- }
-
- QString result;
- m_xquery.evaluateTo(&result);
- return result;
-}
-
-QSharedPointer<XQuery> qt_createXQuery(const QString &focus, QString *errorMessage)
-{
- QSharedPointer<QtXQuery> result(new QtXQuery);
- if (!result->setFocus(focus)) {
- *errorMessage = QLatin1String("QXmlQuery: Cannot set focus to ") + QDir::toNativeSeparators(focus);
- result.reset();
- }
- return std::move(result);
-}
-
-// XSLT transformation
-
-static const char xsltPrefix[] = R"(<?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-)";
-
-QString qt_xsl_transform(const QString &xml, QString xsl, QString *errorMessage)
-{
- QXmlQuery query(QXmlQuery::XSLT20);
- if (!xsl.startsWith(QLatin1String("<?xml"))) {
- xsl.prepend(QLatin1String(xsltPrefix));
- xsl.append(QLatin1String("</xsl:stylesheet>"));
- }
- query.setFocus(xml);
- query.setQuery(xsl);
- if (!query.isValid()) {
- *errorMessage = QLatin1String("QXmlQuery: Invalid query \"") + xsl
- + QLatin1String("\".");
- return xml;
- }
- QString result;
- if (!query.evaluateTo(&result)) {
- *errorMessage = QLatin1String("QXmlQuery: evaluate() failed.");
- return xml;
- }
- return result.trimmed();
-}
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
index 3de5d3223..80e9e3ee9 100644
--- a/sources/shiboken2/CMakeLists.txt
+++ b/sources/shiboken2/CMakeLists.txt
@@ -1,7 +1,7 @@
Include(icecc.cmake)
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build Type")
@@ -18,7 +18,7 @@ option(BUILD_TESTS "Build tests." TRUE)
option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "")
option(DISABLE_DOCSTRINGS "Disable documentation extraction." FALSE)
-set (QT_MAJOR_VERSION 5)
+set (QT_MAJOR_VERSION 6)
message(STATUS "Using Qt ${QT_MAJOR_VERSION}")
find_package(Qt${QT_MAJOR_VERSION} 5.12 REQUIRED COMPONENTS Core)
@@ -91,9 +91,7 @@ if (NOT PYTHON_CONFIG_SUFFIX)
set_python_config_suffix()
endif()
-if (NOT PYTHON_SHARED_LIBRARY_SUFFIX)
- set_python_shared_library_suffix()
-endif()
+set(PYTHON_SHARED_LIBRARY_SUFFIX "${PYTHON_CONFIG_SUFFIX}")
if (NOT PYTHON_CONFIG_SUFFIX)
message(FATAL_ERROR
@@ -112,13 +110,8 @@ endif()
set_cmake_cxx_flags()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII")
-# Force usage of the C++11 standard, without a silent fallback
-# to C++98 if the compiler does not support C++11.
-if(${QT_MAJOR_VERSION} GREATER_EQUAL 6)
- set(CMAKE_CXX_STANDARD 17)
-else()
- set(CMAKE_CXX_STANDARD 11)
-endif()
+# Force usage of the C++17 standard
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake
index 5e0c6ea72..9cb9f9514 100644
--- a/sources/shiboken2/data/shiboken_helpers.cmake
+++ b/sources/shiboken2/data/shiboken_helpers.cmake
@@ -1,15 +1,5 @@
include(CMakeParseArguments)
-macro(set_python_shared_library_suffix)
- set(PYTHON_SHARED_LIBRARY_SUFFIX "${PYTHON_CONFIG_SUFFIX}")
-
- # Append a "v" to disambiguate the python version and the shiboken version in the
- # shared library file name.
- if (APPLE AND PYTHON_VERSION_MAJOR EQUAL 2)
- set(PYTHON_SHARED_LIBRARY_SUFFIX "${PYTHON_SHARED_LIBRARY_SUFFIX}v")
- endif()
-endmacro()
-
macro(set_limited_api)
if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
@@ -103,105 +93,35 @@ macro(set_python_site_packages)
endmacro()
macro(set_python_config_suffix)
- if (PYTHON_VERSION_MAJOR EQUAL 2)
- set(PYTHON_CONFIG_SUFFIX "-python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
- if (PYTHON_EXTENSION_SUFFIX)
- set(PYTHON_CONFIG_SUFFIX "${PYTHON_CONFIG_SUFFIX}${PYTHON_EXTENSION_SUFFIX}")
- endif()
- elseif (PYTHON_VERSION_MAJOR EQUAL 3)
- if (PYTHON_LIMITED_API)
- if(WIN32)
- set(PYTHON_EXTENSION_SUFFIX "")
- else()
- set(PYTHON_EXTENSION_SUFFIX ".abi3")
- endif()
- set(PYTHON_CONFIG_SUFFIX ".abi3")
- else()
- set(PYTHON_CONFIG_SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
- endif()
- endif()
-endmacro()
-
-macro(setup_clang)
- set(CLANG_DIR "")
- set(CLANG_DIR_SOURCE "")
-
- set(clang_not_found_message "Unable to detect CLANG location by checking LLVM_INSTALL_DIR, \
- CLANG_INSTALL_DIR or running llvm-config.")
-
- if (DEFINED ENV{LLVM_INSTALL_DIR})
- set(CLANG_DIR $ENV{LLVM_INSTALL_DIR})
- string(REPLACE "_ARCH_" "${PYTHON_ARCH}" CLANG_DIR "${CLANG_DIR}")
- set(CLANG_DIR_SOURCE "LLVM_INSTALL_DIR")
- elseif (DEFINED ENV{CLANG_INSTALL_DIR})
- set(CLANG_DIR $ENV{CLANG_INSTALL_DIR})
- string(REPLACE "_ARCH_" "${PYTHON_ARCH}" CLANG_DIR "${CLANG_DIR}")
- set(CLANG_DIR_SOURCE "CLANG_INSTALL_DIR")
- else ()
- if (NOT LLVM_CONFIG)
- get_llvm_config()
- endif()
- set(CLANG_DIR_SOURCE "${LLVM_CONFIG}")
- if ("${CLANG_DIR_SOURCE}" STREQUAL "")
- message(FATAL_ERROR "${clang_not_found_message}")
- endif()
-
- EXEC_PROGRAM("${LLVM_CONFIG}" ARGS "--prefix" OUTPUT_VARIABLE CLANG_DIR)
- if (NOT "${CLANG_DIR}" STREQUAL "")
- EXEC_PROGRAM("${LLVM_CONFIG}" ARGS "--version" OUTPUT_VARIABLE CLANG_VERSION)
- if (CLANG_VERSION VERSION_LESS 3.9)
- message(FATAL_ERROR "libclang version 3.9 or higher is required \
- (${LLVM_CONFIG} detected ${CLANG_VERSION} at ${CLANG_DIR}).")
- endif()
+ if (PYTHON_LIMITED_API)
+ if(WIN32)
+ set(PYTHON_EXTENSION_SUFFIX "")
+ else()
+ set(PYTHON_EXTENSION_SUFFIX ".abi3")
endif()
+ set(PYTHON_CONFIG_SUFFIX ".abi3")
+ else()
+ set(PYTHON_CONFIG_SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
endif()
+endmacro()
- if ("${CLANG_DIR}" STREQUAL "")
- message(FATAL_ERROR "${clang_not_found_message}")
- elseif (NOT IS_DIRECTORY ${CLANG_DIR})
- message(FATAL_ERROR "${CLANG_DIR} detected by ${CLANG_DIR_SOURCE} does not exist.")
- endif()
-
- # The non-development Debian / Ubuntu packages (e.g. libclang1-6.0) do not ship a
- # libclang.so symlink, but only libclang-6.0.so.1 and libclang.so.1 (adjusted for version number).
- # Thus searching for libclang would not succeed.
- # The "libclang.so" symlink is shipped as part of the development package (libclang-6.0-dev) which
- # we need anyway because of the headers. Thus we will search for libclang.so.1 also, and complain
- # about the headers not being found in a check further down. This is more friendly to the user,
- # so they don't scratch their head thinking that they have already installed the necessary package.
- set(CLANG_LIB_NAMES clang libclang.so libclang.so.1)
- if(MSVC)
- set(CLANG_LIB_NAMES libclang)
- endif()
-
- find_library(CLANG_LIBRARY NAMES ${CLANG_LIB_NAMES} HINTS ${CLANG_DIR}/lib)
- if (NOT EXISTS ${CLANG_LIBRARY})
- string(REPLACE ";" ", " CLANG_LIB_NAMES_STRING "${CLANG_LIB_NAMES}")
- message(FATAL_ERROR "Unable to find the Clang library in ${CLANG_DIR}.\
- Names tried: ${CLANG_LIB_NAMES_STRING}.")
+macro(setup_clang)
+ # Find libclang using the environment variables LLVM_INSTALL_DIR,
+ # CLANG_INSTALL_DIR using standard cmake.
+ # Use CLANG_INCLUDE_DIRS and link to libclang.
+ if(DEFINED ENV{LLVM_INSTALL_DIR})
+ list(PREPEND CMAKE_PREFIX_PATH "$ENV{LLVM_INSTALL_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "$ENV{LLVM_INSTALL_DIR}")
+ elseif(DEFINED ENV{CLANG_INSTALL_DIR})
+ list(PREPEND CMAKE_PREFIX_PATH "$ENV{CLANG_INSTALL_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "$ENV{CLANG_INSTALL_DIR}")
endif()
- message(STATUS "CLANG: ${CLANG_DIR}, ${CLANG_LIBRARY} detected by ${CLANG_DIR_SOURCE}")
-
- set(CLANG_EXTRA_INCLUDES ${CLANG_DIR}/include)
- set(CLANG_EXTRA_LIBRARIES ${CLANG_LIBRARY})
-
- # Check if one of the required clang headers is found. Error out early at CMake time instead of
- # compile time if not found.
- # It can happen that a user uses a distro-provided libclang.so, but no development header package
- # was installed (e.g. libclang-6.0-dev on Ubuntu).
- set(CMAKE_REQUIRED_INCLUDES ${CLANG_EXTRA_INCLUDES})
- set(CLANG_HEADER_FILE_TO_CHECK "clang-c/Index.h")
- check_include_file_cxx(${CLANG_HEADER_FILE_TO_CHECK} CLANG_INCLUDE_FOUND)
- unset(CMAKE_REQUIRED_INCLUDES)
- if (NOT CLANG_INCLUDE_FOUND)
- # Need to unset so that when installing the package, CMake doesn't complain that the header
- # still isn't found.
- unset(CLANG_INCLUDE_FOUND CACHE)
- message(FATAL_ERROR "Unable to find required Clang header file ${CLANG_HEADER_FILE_TO_CHECK} \
- in ${CLANG_DIR}/include. Perhaps you forgot to install the clang development header \
- package? (e.g. libclang-6.0-dev)")
- endif()
+ find_package(Clang CONFIG REQUIRED)
+ # CLANG_LIBRARY is read out from the cmake cache to deploy libclang
+ get_target_property(CLANG_LIBRARY_NAME libclang IMPORTED_LOCATION_RELEASE)
+ set(CLANG_LIBRARY "${CLANG_LIBRARY_NAME}" CACHE FILEPATH "libclang")
+ message(STATUS "CLANG: ${Clang_DIR}, ${CLANG_LIBRARY} detected")
endmacro()
macro(set_quiet_build)
@@ -247,22 +167,6 @@ macro(get_python_extension_suffix)
message(STATUS "PYTHON_EXTENSION_SUFFIX: " ${PYTHON_EXTENSION_SUFFIX})
endmacro()
-macro(get_llvm_config)
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
- import os
- import sys
- sys.path.append(os.path.realpath(os.path.join('${CMAKE_CURRENT_LIST_DIR}', '..', '..')))
- from build_scripts.utils import find_llvm_config
- llvmConfig = find_llvm_config()
- if llvmConfig:
- print(llvmConfig)
- "
- OUTPUT_VARIABLE LLVM_CONFIG
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- message(STATUS "LLVM_CONFIG: " ${LLVM_CONFIG})
-endmacro()
-
macro(get_python_arch)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "if True:
@@ -331,10 +235,9 @@ macro(shiboken_find_required_python)
endmacro()
macro(shiboken_validate_python_version)
- if((PYTHON_VERSION_MAJOR EQUAL "2" AND PYTHON_VERSION_MINOR LESS "7") OR
- (PYTHON_VERSION_MAJOR EQUAL "3" AND PYTHON_VERSION_MINOR LESS "5"))
+ if(PYTHON_VERSION_MAJOR EQUAL "3" AND PYTHON_VERSION_MINOR LESS "5")
message(FATAL_ERROR
- "Shiboken requires Python 2.7+ or Python 3.5+.")
+ "Shiboken requires Python 3.5+.")
endif()
endmacro()
@@ -367,7 +270,7 @@ endmacro()
# Given a list of the following form:
# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
-# choose the correpsonding library to use, based on the current configuration type.
+# choose the corresponding library to use, based on the current configuration type.
function(shiboken_get_library_for_current_config library_list current_config out_var)
list(FIND library_list "optimized" optimized_found)
list(FIND library_list "general" general_found)
diff --git a/sources/shiboken2/doc/CMakeLists.txt b/sources/shiboken2/doc/CMakeLists.txt
index ae4858f95..5f59bfbf0 100644
--- a/sources/shiboken2/doc/CMakeLists.txt
+++ b/sources/shiboken2/doc/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
if(FULLDOCSBUILD EQUAL 0)
project(shiboken2_doc)
diff --git a/sources/shiboken2/doc/typesystem_specifying_types.rst b/sources/shiboken2/doc/typesystem_specifying_types.rst
index 221519541..3b40ef236 100644
--- a/sources/shiboken2/doc/typesystem_specifying_types.rst
+++ b/sources/shiboken2/doc/typesystem_specifying_types.rst
@@ -108,6 +108,7 @@ primitive-type
target-name="..."
default-constructor="..."
preferred-conversion="yes | no" />
+ view-on="..."
</typesystem>
The **name** attribute is the name of the primitive in C++, the optional,
@@ -139,6 +140,13 @@ primitive-type
used only for classes declared as primitive types and not for primitive C++
types, but that depends on the application using *ApiExtractor*.
+ The *optional* **view-on** attribute specifies that the type is a view
+ class like std::string_view or QStringView which has a constructor
+ accepting another type like std::string or QString. Since typically
+ no values can be assigned to view classes, no target-to-native conversion
+ can be generated for them. Instead, an instance of the viewed class should
+ be instantiated and passed to functions using the view class
+ for argument types.
.. _namespace:
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index dd56ab7cd..2418f51fe 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -551,7 +551,7 @@ void Generator::replaceTemplateVariables(QString &code, const AbstractMetaFuncti
QTextStream &formatCode(QTextStream &s, const QString &code, Indentor &indentor)
{
- const auto lines= code.splitRef(QLatin1Char('\n'));
+ const auto lines= QStringView{code}.split(QLatin1Char('\n'));
for (const auto &line : lines) {
// Do not indent preprocessor lines
if (!line.isEmpty() && !line.startsWith(QLatin1Char('#')))
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index 8d819c763..3c5c5876c 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -79,7 +79,7 @@ static void printOptions(QTextStream &s, const OptionDescriptions &options)
s << ", ";
} else {
s << Qt::endl;
- const auto lines = od.second.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{od.second}.split(QLatin1Char('\n'));
for (const auto &line : lines)
s << " " << line << Qt::endl;
s << Qt::endl;
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 5e75cbf87..81b404239 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -149,12 +149,12 @@ static int writeEscapedRstText(QTextStream &str, const String &s)
class escape
{
public:
- explicit escape(const QStringRef &s) : m_string(s) {}
+ explicit escape(QStringView s) : m_string(s) {}
void write(QTextStream &str) const { writeEscapedRstText(str, m_string); }
private:
- const QStringRef m_string;
+ const QStringView m_string;
};
inline QTextStream &operator<<(QTextStream &str, const escape &e)
@@ -410,7 +410,7 @@ QString QtXmlToSphinx::expandFunction(const QString& function) const
const int firstDot = function.indexOf(QLatin1Char('.'));
const AbstractMetaClass *metaClass = nullptr;
if (firstDot != -1) {
- const QStringRef className = function.leftRef(firstDot);
+ const auto className = QStringView{function}.left(firstDot);
for (const AbstractMetaClass *cls : m_generator->classes()) {
if (cls->name() == className) {
metaClass = cls;
@@ -427,7 +427,7 @@ QString QtXmlToSphinx::expandFunction(const QString& function) const
QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const
{
- const QStringRef currentClass = m_context.splitRef(QLatin1Char('.')).constLast();
+ const auto currentClass = QStringView{m_context}.split(QLatin1Char('.')).constLast();
const AbstractMetaClass *metaClass = nullptr;
for (const AbstractMetaClass *cls : m_generator->classes()) {
@@ -483,7 +483,7 @@ QString QtXmlToSphinx::transform(const QString& doc)
}
if (token == QXmlStreamReader::StartElement) {
- QStringRef tagName = reader.name();
+ const auto tagName = reader.name();
TagHandler handler = m_handlerMap.value(tagName.toString(), &QtXmlToSphinx::handleUnknownTag);
if (!m_handlers.isEmpty() && ( (m_handlers.top() == &QtXmlToSphinx::handleIgnoredTag) ||
(m_handlers.top() == &QtXmlToSphinx::handleRawTag)) )
@@ -630,7 +630,7 @@ void QtXmlToSphinx::handleParaTag(QXmlStreamReader& reader)
m_output << INDENT << result << Qt::endl << Qt::endl;
} else if (token == QXmlStreamReader::Characters) {
- const QStringRef text = reader.text();
+ const auto text = reader.text();
const QChar end = lastChar(m_output);
if (!text.isEmpty() && INDENT.indent == 0 && !end.isNull()) {
QChar start = text[0];
@@ -675,7 +675,7 @@ void QtXmlToSphinx::handleArgumentTag(QXmlStreamReader& reader)
static inline QString functionLinkType() { return QStringLiteral("function"); }
static inline QString classLinkType() { return QStringLiteral("class"); }
-static inline QString fixLinkType(const QStringRef &type)
+static inline QString fixLinkType(QStringView type)
{
// TODO: create a flag PROPERTY-AS-FUNCTION to ask if the properties
// are recognized as such or not in the binding
@@ -709,7 +709,7 @@ void QtXmlToSphinx::handleSeeAlsoTag(QXmlStreamReader& reader)
break;
case QXmlStreamReader::Characters: {
// Direct embedded link: <see-also>rootIsDecorated()</see-also>
- const QStringRef textR = reader.text().trimmed();
+ const auto textR = reader.text().trimmed();
if (!textR.isEmpty()) {
const QString text = textR.toString();
if (m_seeAlsoContext.isNull()) {
@@ -743,8 +743,8 @@ static inline bool snippetComparison()
template <class Indent> // const char*/class Indentor
void formatSnippet(QTextStream &str, Indent indent, const QString &snippet)
{
- const QVector<QStringRef> lines = snippet.splitRef(QLatin1Char('\n'));
- for (const QStringRef &line : lines) {
+ const auto lines = QStringView{snippet}.split(QLatin1Char('\n'));
+ for (const auto &line : lines) {
if (!line.trimmed().isEmpty())
str << indent << line;
str << Qt::endl;
@@ -902,7 +902,7 @@ void QtXmlToSphinx::handleRowTag(QXmlStreamReader& reader)
enum ListType { BulletList, OrderedList, EnumeratedList };
-static inline ListType webXmlListType(const QStringRef &t)
+static inline ListType webXmlListType(QStringView t)
{
if (t == QLatin1String("enum"))
return EnumeratedList;
@@ -934,7 +934,7 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
const char *separator = listType == BulletList ? "* " : "#. ";
const char *indent = listType == BulletList ? " " : " ";
for (const TableCell &cell : m_currentTable.constFirst()) {
- const QVector<QStringRef> itemLines = cell.data.splitRef(QLatin1Char('\n'));
+ const auto itemLines = QStringView{cell.data}.split(QLatin1Char('\n'));
m_output << INDENT << separator << itemLines.constFirst() << Qt::endl;
for (int i = 1, max = itemLines.count(); i < max; ++i)
m_output << INDENT << indent << itemLines[i] << Qt::endl;
@@ -991,7 +991,7 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
if (type == functionLinkType() && !m_context.isEmpty()) {
result->type = LinkContext::Method;
- const QVector<QStringRef> rawlinklist = result->linkRef.splitRef(QLatin1Char('.'));
+ const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.'));
if (rawlinklist.size() == 1 || rawlinklist.constFirst() == m_context) {
QString context = resolveContextForMethod(rawlinklist.constLast().toString());
if (!result->linkRef.startsWith(context))
@@ -1006,7 +1006,7 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
if (const TypeEntry *type = TypeDatabase::instance()->findType(result->linkRef)) {
result->linkRef = type->qualifiedTargetLangName();
} else { // fall back to the old heuristic if the type wasn't found.
- const QVector<QStringRef> rawlinklist = result->linkRef.splitRef(QLatin1Char('.'));
+ const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.'));
QStringList splittedContext = m_context.split(QLatin1Char('.'));
if (rawlinklist.size() == 1 || rawlinklist.constFirst() == splittedContext.constLast()) {
splittedContext.removeLast();
@@ -1176,8 +1176,8 @@ void QtXmlToSphinx::handleRawTag(QXmlStreamReader& reader)
QString format = reader.attributes().value(QLatin1String("format")).toString();
m_output << INDENT << ".. raw:: " << format.toLower() << Qt::endl << Qt::endl;
} else if (token == QXmlStreamReader::Characters) {
- const QVector<QStringRef> lst(reader.text().split(QLatin1Char('\n')));
- for (const QStringRef &row : lst)
+ const auto lst(reader.text().split(QLatin1Char('\n')));
+ for (const auto &row : lst)
m_output << INDENT << INDENT << row << Qt::endl;
} else if (token == QXmlStreamReader::EndElement) {
m_output << Qt::endl << Qt::endl;
@@ -1191,8 +1191,8 @@ void QtXmlToSphinx::handleCodeTag(QXmlStreamReader& reader)
m_output << INDENT << "::\n\n";
INDENT.indent++;
} else if (token == QXmlStreamReader::Characters) {
- const QVector<QStringRef> lst(reader.text().split(QLatin1Char('\n')));
- for (const QStringRef &row : lst)
+ const auto lst(reader.text().split(QLatin1Char('\n')));
+ for (const auto &row : lst)
m_output << INDENT << INDENT << row << Qt::endl;
} else if (token == QXmlStreamReader::EndElement) {
m_output << Qt::endl << Qt::endl;
@@ -1226,11 +1226,11 @@ void QtXmlToSphinx::handlePageTag(QXmlStreamReader &reader)
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QStringRef title = reader.attributes().value(titleAttribute());
+ const auto title = reader.attributes().value(titleAttribute());
if (!title.isEmpty())
m_output << rstLabel(title.toString());
- const QStringRef fullTitle = reader.attributes().value(fullTitleAttribute());
+ const auto fullTitle = reader.attributes().value(fullTitleAttribute());
const int size = fullTitle.isEmpty()
? writeEscapedRstText(m_output, title)
: writeEscapedRstText(m_output, fullTitle);
@@ -1242,7 +1242,7 @@ void QtXmlToSphinx::handleTargetTag(QXmlStreamReader &reader)
{
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QStringRef name = reader.attributes().value(nameAttribute());
+ const auto name = reader.attributes().value(nameAttribute());
if (!name.isEmpty())
m_output << INDENT << rstLabel(name.toString());
}
@@ -1367,7 +1367,7 @@ void QtXmlToSphinx::Table::normalize()
newCell.rowSpan = -1;
int targetRow = row + 1;
const int targetEndRow =
- std::min(targetRow + cell.rowSpan - 1, m_rows.count());
+ std::min(targetRow + cell.rowSpan - 1, int(m_rows.count()));
cell.rowSpan = 0;
for ( ; targetRow < targetEndRow; ++targetRow)
m_rows[targetRow].insert(col, newCell);
@@ -1402,10 +1402,10 @@ void QtXmlToSphinx::Table::format (QTextStream& s) const
for (int i = 0, maxI = m_rows.count(); i < maxI; ++i) {
const QtXmlToSphinx::TableRow& row = m_rows.at(i);
for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) {
- const QVector<QStringRef> rowLines = row[j].data.splitRef(QLatin1Char('\n')); // cache this would be a good idea
- for (const QStringRef &str : rowLines)
- colWidths[j] = std::max(colWidths[j], str.count());
- rowHeights[i] = std::max(rowHeights[i], row[j].data.count(QLatin1Char('\n')) + 1);
+ const auto rowLines = QStringView{row[j].data}.split(QLatin1Char('\n')); // cache this would be a good idea
+ for (const auto &str : rowLines)
+ colWidths[j] = std::max(colWidths[j], int(str.size()));
+ rowHeights[i] = std::max(rowHeights[i], int(row[j].data.count(QLatin1Char('\n')) + 1));
}
}
@@ -1441,9 +1441,9 @@ void QtXmlToSphinx::Table::format (QTextStream& s) const
// Print the table cells
for (int rowLine = 0; rowLine < rowHeights[i]; ++rowLine) { // for each line in a row
int j = 0;
- for (int maxJ = std::min(row.count(), headerColumnCount); j < maxJ; ++j) { // for each column
+ for (int maxJ = std::min(int(row.count()), headerColumnCount); j < maxJ; ++j) { // for each column
const QtXmlToSphinx::TableCell& cell = row[j];
- const QVector<QStringRef> rowLines = cell.data.splitRef(QLatin1Char('\n')); // FIXME: Cache this!!!
+ const auto rowLines = QStringView{cell.data}.split(QLatin1Char('\n')); // FIXME: Cache this!!!
if (!j) // First column, so we need print the identation
s << INDENT;
@@ -1548,10 +1548,10 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc
s << x;
} else {
const QString &value = doc.value(docType);
- const QVector<QStringRef> lines = value.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{value}.split(QLatin1Char('\n'));
int typesystemIndentation = std::numeric_limits<int>::max();
// check how many spaces must be removed from the beginning of each line
- for (const QStringRef &line : lines) {
+ for (const auto &line : lines) {
const auto it = std::find_if(line.cbegin(), line.cend(),
[] (QChar c) { return !c.isSpace(); });
if (it != line.cend())
@@ -1559,7 +1559,7 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc
}
if (typesystemIndentation == std::numeric_limits<int>::max())
typesystemIndentation = 0;
- for (const QStringRef &line : lines) {
+ for (const auto &line : lines) {
s << INDENT
<< (typesystemIndentation > 0 && typesystemIndentation < line.size()
? line.right(line.size() - typesystemIndentation) : line)
@@ -1938,7 +1938,7 @@ void QtDocGenerator::writeDocSnips(QTextStream &s,
break;
}
}
- s << row.midRef(offset) << Qt::endl;
+ s << QStringView{row}.mid(offset) << Qt::endl;
currentRow++;
}
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 906e82c93..434b03dc7 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -292,7 +292,7 @@ static bool isStdSetterName(QString setterName, QString propertyName)
{
return setterName.size() == propertyName.size() + 3
&& setterName.startsWith(QLatin1String("set"))
- && setterName.endsWith(propertyName.rightRef(propertyName.size() - 1))
+ && setterName.endsWith(QStringView{propertyName}.right(propertyName.size() - 1))
&& setterName.at(3) == propertyName.at(0).toUpper();
}
@@ -904,11 +904,7 @@ QString CppGenerator::virtualMethodReturn(QTextStream &s,
const QRegularExpressionMatch match = regex.match(expr, offset);
if (!match.hasMatch())
break;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const int argId = match.capturedView(1).toInt() - 1;
-#else
- const int argId = match.capturedRef(1).toInt() - 1;
-#endif
if (argId < 0 || argId > func->arguments().count()) {
qCWarning(lcShiboken, "The expression used in return value contains an invalid index.");
break;
@@ -2383,6 +2379,8 @@ void CppGenerator::writeTypeCheck(QTextStream &s, const OverloadData *overloadDa
// This condition trusts that the OverloadData object will arrange for
// PyInt type to come after the more precise numeric types (e.g. float and bool)
const AbstractMetaType *argType = overloadData->argType();
+ if (auto viewOn = argType->viewOn())
+ argType = viewOn;
bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType);
QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : QString());
bool rejectNull = shouldRejectNullPointerArgument(overloadData->referenceFunction(), overloadData->argPos());
@@ -2413,12 +2411,15 @@ const AbstractMetaType *CppGenerator::getArgumentType(const AbstractMetaFunction
return nullptr;
}
- const AbstractMetaType *argType = nullptr;
QString typeReplaced = func->typeReplaced(argPos);
- if (typeReplaced.isEmpty())
- argType = (argPos == 0) ? func->type() : func->arguments().at(argPos-1)->type();
- else
- argType = buildAbstractMetaTypeFromString(typeReplaced);
+ if (typeReplaced.isEmpty()) {
+ if (argPos == 0)
+ return func->type();
+ auto argType = func->arguments().at(argPos - 1)->type();
+ return argType->viewOn() ? argType->viewOn() : argType;
+ }
+
+ auto argType = buildAbstractMetaTypeFromString(typeReplaced);
if (!argType && !m_knownPythonTypes.contains(typeReplaced)) {
qCWarning(lcShiboken).noquote().nospace()
<< QString::fromLatin1("Unknown type '%1' used as argument type replacement "\
@@ -4264,11 +4265,7 @@ void CppGenerator::writeTypeAsSequenceDefinition(QTextStream &s, const AbstractM
const QString &sqName = it.key();
if (funcs[sqName].isEmpty())
continue;
- if (it.value() == QLatin1String("sq_slice"))
- s << "#ifndef IS_PY3K\n";
s << INDENT << "{Py_" << it.value() << ", (void *)" << funcs[sqName] << "},\n";
- if (it.value() == QLatin1String("sq_slice"))
- s << "#endif\n";
}
}
@@ -4349,26 +4346,17 @@ void CppGenerator::writeTypeAsNumberDefinition(QTextStream &s, const AbstractMet
if (nb[nbName].isEmpty())
continue;
- // bool is special because the field name differs on Python 2 and 3 (nb_nonzero vs nb_bool)
- // so a shiboken macro is used.
if (nbName == QLatin1String("bool")) {
- s << "#ifdef IS_PY3K\n";
s << INDENT << "{Py_nb_bool, (void *)" << nb[nbName] << "},\n";
- s << "#else\n";
- s << INDENT << "{Py_nb_nonzero, (void *)" << nb[nbName] << "},\n";
- s << "#endif\n";
} else {
bool excludeFromPy3K = nbName == QLatin1String("__div__") || nbName == QLatin1String("__idiv__");
if (!excludeFromPy3K)
s << INDENT << "{Py_" << it.value() << ", (void *)" << nb[nbName] << "},\n";
}
}
- if (!nb[QLatin1String("__div__")].isEmpty()) {
+ if (!nb[QLatin1String("__div__")].isEmpty())
s << INDENT << "{Py_nb_true_divide, (void *)" << nb[QLatin1String("__div__")] << "},\n";
- s << "#ifndef IS_PY3K\n";
- s << INDENT << "{Py_nb_divide, (void *)" << nb[QLatin1String("__div__")] << "},\n";
- s << "#endif\n";
- }
+
if (!nb[QLatin1String("__idiv__")].isEmpty()) {
s << INDENT << "// This function is unused in Python 3. We reference it here.\n";
s << INDENT << "{0, (void *)" << nb[QLatin1String("__idiv__")] << "},\n";
@@ -4817,7 +4805,10 @@ void CppGenerator::writeSignatureInfo(QTextStream &s, const AbstractMetaFunction
args << QLatin1String("self");
const AbstractMetaArgumentList &arguments = f->arguments();
for (const AbstractMetaArgument *arg : arguments) {
- QString strArg = arg->type()->pythonSignature();
+ const auto *metaType = arg->type();
+ if (auto viewOn = metaType->viewOn())
+ metaType = viewOn;
+ QString strArg = metaType->pythonSignature();
if (!arg->defaultValueExpression().isEmpty()) {
strArg += QLatin1Char('=');
QString e = arg->defaultValueExpression();
@@ -5056,21 +5047,13 @@ void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream &s, const Abstr
QString cpythonName = cpythonEnumName(cppEnum);
s << "static PyType_Slot " << cpythonName << "_number_slots[] = {\n";
- s << "#ifdef IS_PY3K\n";
s << INDENT << "{Py_nb_bool, reinterpret_cast<void *>(" << cpythonName << "__nonzero)},\n";
- s << "#else\n";
- s << INDENT << "{Py_nb_nonzero, reinterpret_cast<void *>(" << cpythonName << "__nonzero)},\n";
- s << INDENT << "{Py_nb_long, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#endif\n";
s << INDENT << "{Py_nb_invert, reinterpret_cast<void *>(" << cpythonName << "___invert__)},\n";
s << INDENT << "{Py_nb_and, reinterpret_cast<void *>(" << cpythonName << "___and__)},\n";
s << INDENT << "{Py_nb_xor, reinterpret_cast<void *>(" << cpythonName << "___xor__)},\n";
s << INDENT << "{Py_nb_or, reinterpret_cast<void *>(" << cpythonName << "___or__)},\n";
s << INDENT << "{Py_nb_int, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
s << INDENT << "{Py_nb_index, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#ifndef IS_PY3K\n";
- s << INDENT << "{Py_nb_long, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#endif\n";
s << INDENT << "{0, " << NULL_PTR << "} // sentinel\n";
s << "};\n\n";
}
@@ -5097,17 +5080,10 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn
AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << "::" << flagsEntry->originalName() << " cppResult, " << CPP_SELF_VAR << ", cppArg;\n";
- s << "#ifdef IS_PY3K\n";
s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
<< ">(int(PyLong_AsLong(self)));\n";
s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName() << ">(int(PyLong_AsLong("
- << PYTHON_ARG << ")));\n";
- s << "#else\n";
- s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
- << ">(int(PyInt_AsLong(self)));\n";
- s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName()
- << ">(int(PyInt_AsLong(" << PYTHON_ARG << ")));\n";
- s << "#endif\n\n";
+ << PYTHON_ARG << ")));\n\n";
s << INDENT << "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;\n";
s << INDENT << "return ";
writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
@@ -5984,7 +5960,6 @@ bool CppGenerator::finishGeneration()
s << Qt::endl;
}
- s << "#ifdef IS_PY3K\n";
s << "static struct PyModuleDef moduledef = {\n";
s << " /* m_base */ PyModuleDef_HEAD_INIT,\n";
s << " /* m_name */ \"" << moduleName() << "\",\n";
@@ -5996,14 +5971,14 @@ bool CppGenerator::finishGeneration()
s << " /* m_clear */ nullptr,\n";
s << " /* m_free */ nullptr\n";
s << "};\n\n";
- s << "#endif\n\n";
// PYSIDE-510: Create a signatures string for the introspection feature.
writeSignatureStrings(s, signatureStream, moduleName(), "global functions");
- s << "SBK_MODULE_INIT_FUNCTION_BEGIN(" << moduleName() << ")\n";
+ s << "extern \"C\" LIBSHIBOKEN_EXPORT PyObject *PyInit_"
+ << moduleName() << "()\n{\n";
- ErrorCode errorCode(QLatin1String("SBK_MODULE_INIT_ERROR"));
+ ErrorCode errorCode(QLatin1String("nullptr"));
// module inject-code target/beginning
if (!snips.isEmpty())
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode);
@@ -6012,7 +5987,7 @@ bool CppGenerator::finishGeneration()
s << INDENT << "{\n" << indent(INDENT)
<< INDENT << "Shiboken::AutoDecRef requiredModule(Shiboken::Module::import(\"" << requiredModule << "\"));\n"
<< INDENT << "if (requiredModule.isNull())\n" << indent(INDENT)
- << INDENT << "return SBK_MODULE_INIT_ERROR;\n" << outdent(INDENT)
+ << INDENT << "return nullptr;\n" << outdent(INDENT)
<< INDENT << cppApiVariableName(requiredModule)
<< " = Shiboken::Module::getTypes(requiredModule);\n"
<< INDENT << convertersVariableName(requiredModule)
@@ -6031,12 +6006,7 @@ bool CppGenerator::finishGeneration()
s << INDENT << "static SbkConverter *sbkConverters[SBK_" << moduleName() << "_CONVERTERS_IDX_COUNT" << "];\n";
s << INDENT << convertersVariableName() << " = sbkConverters;\n\n";
- s << "#ifdef IS_PY3K\n";
- s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);\n";
- s << "#else\n";
- s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", ";
- s << moduleName() << "_methods);\n";
- s << "#endif\n\n";
+ s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);\n\n";
s << INDENT << "// Make module available from global scope\n";
s << INDENT << pythonModuleObjectName() << " = module;\n\n";
@@ -6120,10 +6090,8 @@ bool CppGenerator::finishGeneration()
// finish the rest of __signature__ initialization.
s << INDENT << "FinishSignatureInitialization(module, " << moduleName()
- << "_SignatureStrings);\n";
-
- s << Qt::endl;
- s << "SBK_MODULE_INIT_FUNCTION_END\n";
+ << "_SignatureStrings);\n"
+ << INDENT << "\nreturn module;\n}\n";
return file.done() != FileOut::Failure;
}
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
index 107e28a4a..c780df01a 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -373,7 +373,7 @@ static void formatTypeDefEntries(QTextStream &s)
for (const auto e : entries) {
const QString name = e->qualifiedCppName();
// Fixme: simplify by using nested namespaces in C++ 17.
- const auto components = name.splitRef(QLatin1String("::"));
+ const auto components = QStringView{name}.split(u"::");
const int nameSpaceCount = components.size() - 1;
for (int n = 0; n < nameSpaceCount; ++n)
s << "namespace " << components.at(n) << " {\n";
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 4ff3e8408..97aecf529 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -2779,7 +2779,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type) const
if (type->isNamespace()) {
QString package = type->targetLangPackage();
const int dot = package.lastIndexOf(QLatin1Char('.'));
- result += package.rightRef(package.size() - (dot + 1));
+ result += QStringView{package}.right(package.size() - (dot + 1));
}
result += _fixedCppTypeName(type->qualifiedCppName()).toUpper();
appendIndexSuffix(&result);
diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt
index a209dc711..752613417 100644
--- a/sources/shiboken2/libshiboken/CMakeLists.txt
+++ b/sources/shiboken2/libshiboken/CMakeLists.txt
@@ -60,7 +60,6 @@ shibokenbuffer.cpp
qapp_macro.cpp
pep384impl.cpp
voidptr.cpp
-typespec.cpp
bufferprocs_py37.cpp
embed/signature_bootstrap_inc.h
@@ -144,7 +143,6 @@ install(FILES
pep384impl.h
qapp_macro.h
voidptr.h
- typespec.h
bufferprocs_py37.h
"${CMAKE_CURRENT_BINARY_DIR}/sbkversion.h"
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index d866d133c..9dfd87208 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -652,14 +652,6 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb
for (int i=0, i_max=PyTuple_GET_SIZE(pyBases); i < i_max; i++) {
PyObject *baseType = PyTuple_GET_ITEM(pyBases, i);
-#ifndef IS_PY3K
- if (PyClass_Check(baseType)) {
- PyErr_Format(PyExc_TypeError, "Invalid base class used in type %s. "
- "PySide only supports multiple inheritance from Python new style classes.",
- metatype->tp_name);
- return 0;
- }
-#endif
if (reinterpret_cast<PyTypeObject *>(baseType)->tp_new == SbkDummyNew) {
// PYSIDE-595: A base class does not allow inheritance.
return SbkDummyNew(metatype, args, kwds);
@@ -769,12 +761,6 @@ PyObject *SbkQAppTpNew(PyTypeObject *subtype, PyObject *, PyObject *)
// PYSIDE-560:
// We avoid to use this in Python 3, because we have a hard time to get
// write access to these flags
-#ifndef IS_PY3K
- if (PyType_HasFeature(subtype, Py_TPFLAGS_HAVE_GC)) {
- subtype->tp_flags &= ~Py_TPFLAGS_HAVE_GC;
- subtype->tp_free = PyObject_Del;
- }
-#endif
auto self = reinterpret_cast<SbkObject *>(MakeQAppWrapper(subtype));
return self == nullptr ? nullptr : _setupNew(self, subtype);
}
diff --git a/sources/shiboken2/libshiboken/helper.cpp b/sources/shiboken2/libshiboken/helper.cpp
index b0f909d39..cad48951e 100644
--- a/sources/shiboken2/libshiboken/helper.cpp
+++ b/sources/shiboken2/libshiboken/helper.cpp
@@ -119,13 +119,8 @@ static void formatPyObject(PyObject *obj, std::ostream &str)
str << PyLong_AsLong(obj);
else if (PyFloat_Check(obj))
str << PyFloat_AsDouble(obj);
-#ifdef IS_PY3K
else if (PyUnicode_Check(obj))
str << '"' << _PepUnicode_AsString(obj) << '"';
-#else
- else if (PyString_Check(obj))
- str << '"' << PyString_AsString(obj) << '"';
-#endif
else if (PySequence_Check(obj))
formatPySequence(obj, str);
else
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
index cb8042561..fa31ce43f 100644
--- a/sources/shiboken2/libshiboken/pep384impl.cpp
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp
@@ -49,11 +49,7 @@ extern "C"
/*
* The documentation is located in pep384impl_doc.rst
- */
-#if PY_VERSION_HEX < 0x03000000
-#define IS_PY2
-#endif // PY_VERSION_HEX < 0x03000000
-/*
+
* Here is the verification code for PyTypeObject.
* We create a type object and check if its fields
* appear at the right offsets.
@@ -526,40 +522,6 @@ static PyTypeObject *getFunctionType(void)
*
*/
-// PYSIDE-803, PYSIDE-813: We need that GIL-free version from Python 2.7.12 .
-#ifdef IS_PY2
-
-/* Variant of PyDict_GetItem() that doesn't suppress exceptions.
- This returns NULL *with* an exception set if an exception occurred.
- It returns NULL *without* an exception set if the key wasn't present.
-*/
-PyObject *
-PyDict_GetItemWithError(PyObject *op, PyObject *key)
-{
- long hash;
- PyDictObject *mp = reinterpret_cast<PyDictObject *>(op);
- PyDictEntry *ep;
- if (!PyDict_Check(op)) {
- PyErr_BadInternalCall();
- return nullptr;
- }
- if (!PyString_CheckExact(key) ||
- (hash = (reinterpret_cast<PyStringObject *>(key))->ob_shash) == -1)
- {
- hash = PyObject_Hash(key);
- if (hash == -1) {
- return nullptr;
- }
- }
-
- ep = (mp->ma_lookup)(mp, key, hash);
- if (ep == nullptr) {
- return nullptr;
- }
- return ep->me_value;
-}
-#endif // IS_PY2
-
/*****************************************************************************
*
* Extra support for signature.cpp
@@ -599,18 +561,6 @@ PyStaticMethod_New(PyObject *callable)
}
#endif // Py_LIMITED_API
-#ifdef IS_PY2
-PyTypeObject *PepMethodDescr_TypePtr = nullptr;
-
-static PyTypeObject *
-getMethodDescrType(void)
-{
- static const char prog[] =
- "result = type(str.split)\n";
- return reinterpret_cast<PyTypeObject *>(PepRun_GetResult(prog));
-}
-#endif // IS_PY2
-
/*****************************************************************************
*
* Common newly needed functions
@@ -721,20 +671,6 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
* This function is modelled after _Py_Mangle, but is optimized
* a little for our purpose.
*/
-#ifdef IS_PY2
- const char *namestr = PyString_AsString(name);
- if (namestr == nullptr || namestr[0] != '_' || namestr[1] != '_') {
- Py_INCREF(name);
- return name;
- }
- size_t nlen = strlen(namestr);
- /* Don't mangle __id__ or names with dots. */
- if ((namestr[nlen-1] == '_' && namestr[nlen-2] == '_')
- || strchr(namestr, '.')) {
- Py_INCREF(name);
- return name;
- }
-#else
if (PyUnicode_READ_CHAR(name, 0) != '_' ||
PyUnicode_READ_CHAR(name, 1) != '_') {
Py_INCREF(name);
@@ -748,7 +684,6 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
Py_INCREF(name);
return name;
}
-#endif // IS_PY2
Shiboken::AutoDecRef privateobj(PyObject_GetAttr(
reinterpret_cast<PyObject *>(Py_TYPE(self)), Shiboken::PyMagicName::name()));
#ifndef Py_LIMITED_API
@@ -826,10 +761,6 @@ Pep384_Init()
PepFunction_TypePtr = getFunctionType();
PepStaticMethod_TypePtr = getStaticMethodType();
#endif // Py_LIMITED_API
-
-#ifdef IS_PY2
- PepMethodDescr_TypePtr = getMethodDescrType();
-#endif // IS_PY2
}
} // extern "C"
diff --git a/sources/shiboken2/libshiboken/qt_attribution.json b/sources/shiboken2/libshiboken/qt_attribution.json
index 071870780..1efc24a97 100644
--- a/sources/shiboken2/libshiboken/qt_attribution.json
+++ b/sources/shiboken2/libshiboken/qt_attribution.json
@@ -3,7 +3,7 @@
"Name": "Python",
"QDocModule": "QtForPython",
"QtUsage": "Used for Qt for Python in the signature extension.",
- "Description": "Qt for Python is an add-on for Python. The libshiboken packages of PySide uses certain parts of the source files (typespec.cpp, typespec.h, bufferprocs_py37.cpp, bufferprocs_py37.h). See the folder sources/shiboken2/libshiboken .",
+ "Description": "Qt for Python is an add-on for Python. The libshiboken packages of PySide uses certain parts of the source files (bufferprocs_py37.cpp, bufferprocs_py37.h). See the folder sources/shiboken2/libshiboken .",
"Homepage": "http://www.python.org/",
"Version": "3.7.0",
"License": "PSF LICENSE AGREEMENT FOR PYTHON 3.7.0",
diff --git a/sources/shiboken2/libshiboken/sbkarrayconverter.cpp b/sources/shiboken2/libshiboken/sbkarrayconverter.cpp
index fd09efdae..d94d03b34 100644
--- a/sources/shiboken2/libshiboken/sbkarrayconverter.cpp
+++ b/sources/shiboken2/libshiboken/sbkarrayconverter.cpp
@@ -104,11 +104,7 @@ SbkArrayConverter *unimplementedArrayConverter()
static inline bool intCheck(PyObject *pyIn)
{
-#ifdef IS_PY3K
return PyLong_Check(pyIn);
-#else
- return PyInt_Check(pyIn);
-#endif
}
static short toShort(PyObject *pyIn) { return short(PyLong_AsLong(pyIn)); }
diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h
index d87162071..7508d98a4 100644
--- a/sources/shiboken2/libshiboken/sbkconverter_p.h
+++ b/sources/shiboken2/libshiboken/sbkconverter_p.h
@@ -335,7 +335,6 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
}
static void toCpp(PyObject *pyIn, void *cppOut)
{
-#if PY_MAJOR_VERSION >= 3
if (PyLong_Check(pyIn)) {
unsigned PY_LONG_LONG result = PyLong_AsUnsignedLongLong(pyIn);
if (OverFlowChecker<unsigned PY_LONG_LONG, unsigned PY_LONG_LONG>::check(result, pyIn))
@@ -345,22 +344,6 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
else {
PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion");
}
-#else
- if (PyInt_Check(pyIn)) {
- long result = PyInt_AsLong(pyIn);
- if (OverFlowChecker<unsigned PY_LONG_LONG>::check(result, pyIn))
- PyErr_SetObject(PyExc_OverflowError, 0);
- *reinterpret_cast<unsigned PY_LONG_LONG * >(cppOut) =
- static_cast<unsigned PY_LONG_LONG>(result);
- } else if (PyLong_Check(pyIn)) {
- unsigned PY_LONG_LONG result = PyLong_AsUnsignedLongLong(pyIn);
- if (OverFlowChecker<unsigned PY_LONG_LONG, unsigned PY_LONG_LONG>::check(result, pyIn))
- PyErr_SetObject(PyExc_OverflowError, 0);
- *reinterpret_cast<unsigned PY_LONG_LONG * >(cppOut) = result;
- } else {
- PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion");
- }
-#endif // Python 2
}
static PythonToCppFunc isConvertible(PyObject *pyIn)
{
diff --git a/sources/shiboken2/libshiboken/sbkdbg.h b/sources/shiboken2/libshiboken/sbkdbg.h
index 02ea773ac..2a3211489 100644
--- a/sources/shiboken2/libshiboken/sbkdbg.h
+++ b/sources/shiboken2/libshiboken/sbkdbg.h
@@ -93,11 +93,9 @@ inline std::ostream &operator<<(std::ostream &out, PyObject *obj)
{
PyObject *repr = Shiboken::Object::isValid(obj, false) ? PyObject_Repr(obj) : 0;
if (repr) {
-#ifdef IS_PY3K
PyObject *str = PyUnicode_AsUTF8String(repr);
Py_DECREF(repr);
repr = str;
-#endif
out << PyBytes_AS_STRING(repr);
Py_DECREF(repr);
} else {
diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp
index 369b264e7..e5b7bd743 100644
--- a/sources/shiboken2/libshiboken/sbkenum.cpp
+++ b/sources/shiboken2/libshiboken/sbkenum.cpp
@@ -204,13 +204,6 @@ static PyObject *enum_multiply(PyObject *self, PyObject *v)
return enum_op(PyNumber_Multiply, self, v);
}
-#ifndef IS_PY3K
-static PyObject *enum_divide(PyObject *self, PyObject *v)
-{
- return enum_op(PyNumber_Divide, self, v);
-}
-#endif
-
static PyObject *enum_richcompare(PyObject *self, PyObject *other, int op)
{
PyObject *valA = self;
@@ -287,16 +280,8 @@ static PyType_Slot SbkEnumType_Type_slots[] = {
{Py_nb_add, (void *)enum_add},
{Py_nb_subtract, (void *)enum_subtract},
{Py_nb_multiply, (void *)enum_multiply},
-#ifndef IS_PY3K
- {Py_nb_divide, (void *)enum_divide},
-#endif
{Py_nb_positive, (void *)enum_int},
-#ifdef IS_PY3K
{Py_nb_bool, (void *)enum_bool},
-#else
- {Py_nb_nonzero, (void *)enum_bool},
- {Py_nb_long, (void *)enum_int},
-#endif
{Py_nb_and, (void *)enum_and},
{Py_nb_xor, (void *)enum_xor},
{Py_nb_or, (void *)enum_or},
@@ -634,16 +619,8 @@ static PyType_Slot SbkNewType_slots[] = {
{Py_nb_add, (void *)enum_add},
{Py_nb_subtract, (void *)enum_subtract},
{Py_nb_multiply, (void *)enum_multiply},
-#ifndef IS_PY3K
- {Py_nb_divide, (void *)enum_divide},
-#endif
{Py_nb_positive, (void *)enum_int},
-#ifdef IS_PY3K
{Py_nb_bool, (void *)enum_bool},
-#else
- {Py_nb_nonzero, (void *)enum_bool},
- {Py_nb_long, (void *)enum_int},
-#endif
{Py_nb_and, (void *)enum_and},
{Py_nb_xor, (void *)enum_xor},
{Py_nb_or, (void *)enum_or},
@@ -676,11 +653,7 @@ copyNumberMethods(PyTypeObject *flagsType,
PUT_SLOT(Py_nb_absolute);
PUT_SLOT(Py_nb_add);
PUT_SLOT(Py_nb_and);
-#ifdef IS_PY3K
PUT_SLOT(Py_nb_bool);
-#else
- PUT_SLOT(Py_nb_nonzero);
-#endif
PUT_SLOT(Py_nb_divmod);
PUT_SLOT(Py_nb_float);
PUT_SLOT(Py_nb_floor_divide);
@@ -710,10 +683,6 @@ copyNumberMethods(PyTypeObject *flagsType,
PUT_SLOT(Py_nb_subtract);
PUT_SLOT(Py_nb_true_divide);
PUT_SLOT(Py_nb_xor);
-#ifndef IS_PY3K
- PUT_SLOT(Py_nb_long);
- PUT_SLOT(Py_nb_divide);
-#endif
#undef PUT_SLOT
*pidx = idx;
}
diff --git a/sources/shiboken2/libshiboken/sbkmodule.cpp b/sources/shiboken2/libshiboken/sbkmodule.cpp
index 9321725d6..e5f4e2f88 100644
--- a/sources/shiboken2/libshiboken/sbkmodule.cpp
+++ b/sources/shiboken2/libshiboken/sbkmodule.cpp
@@ -75,11 +75,7 @@ PyObject *import(const char *moduleName)
PyObject *create(const char *moduleName, void *moduleData)
{
Shiboken::init();
-#ifndef IS_PY3K
- return Py_InitModule(moduleName, reinterpret_cast<PyMethodDef *>(moduleData));
-#else
return PyModule_Create(reinterpret_cast<PyModuleDef *>(moduleData));
-#endif
}
void registerTypes(PyObject *module, PyTypeObject **types)
diff --git a/sources/shiboken2/libshiboken/sbkmodule.h b/sources/shiboken2/libshiboken/sbkmodule.h
index caaf3de5f..02e4a2706 100644
--- a/sources/shiboken2/libshiboken/sbkmodule.h
+++ b/sources/shiboken2/libshiboken/sbkmodule.h
@@ -43,22 +43,6 @@
#include "sbkpython.h"
#include "shibokenmacros.h"
-#if PY_MAJOR_VERSION >= 3
- #define SBK_MODULE_INIT_ERROR 0
- #define SBK_MODULE_INIT_FUNCTION_BEGIN(ModuleName) \
- extern "C" LIBSHIBOKEN_EXPORT PyObject *PyInit_##ModuleName() {
-
- #define SBK_MODULE_INIT_FUNCTION_END \
- return module; }
-#else
- #define SBK_MODULE_INIT_ERROR
- #define SBK_MODULE_INIT_FUNCTION_BEGIN(ModuleName) \
- extern "C" LIBSHIBOKEN_EXPORT void init##ModuleName() {
-
- #define SBK_MODULE_INIT_FUNCTION_END \
- }
-#endif
-
extern "C"
{
struct SbkConverter;
diff --git a/sources/shiboken2/libshiboken/sbkpython.h b/sources/shiboken2/libshiboken/sbkpython.h
index 6755e945d..abdb02eba 100644
--- a/sources/shiboken2/libshiboken/sbkpython.h
+++ b/sources/shiboken2/libshiboken/sbkpython.h
@@ -75,7 +75,6 @@ extern "C" {
# include "shibokenmacros.h"
// "pep384impl.h" may nowhere be included but in this file.
# include "pep384impl.h"
-# include "typespec.h"
# pragma pop_macro("slots")
#else
@@ -102,44 +101,30 @@ extern "C" {
# include "shibokenmacros.h"
// "pep384impl.h" may nowhere be included but in this file.
# include "pep384impl.h"
-# include "typespec.h"
#endif
-#if PY_MAJOR_VERSION >= 3
- #define IS_PY3K
-
- #define PyInt_Type PyLong_Type
- #define PyInt_Check PyLong_Check
- #define PyInt_CheckExact PyLong_CheckExact
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsUnsignedLongLongMask PyLong_AsLongLong
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_AsLong PyLong_AsLong
- #define SbkNumber_Check PyNumber_Check
- #define Py_TPFLAGS_CHECKTYPES 0
-
- #define SBK_NB_BOOL(x) (x).nb_bool
- #define SBK_PyMethod_New PyMethod_New
- #define PyInt_AsSsize_t(x) PyLong_AsSsize_t(x)
- #define PyString_Type PyUnicode_Type
-
- // In Python 3, Py_TPFLAGS_DEFAULT contains Py_TPFLAGS_HAVE_VERSION_TAG,
- // which will trigger the attribute cache, which is not intended in Qt for Python.
- // Use a customized Py_TPFLAGS_DEFAULT by defining Py_TPFLAGS_HAVE_VERSION_TAG = 0.
- #undef Py_TPFLAGS_HAVE_VERSION_TAG
- #define Py_TPFLAGS_HAVE_VERSION_TAG (0)
-
-#else
- // Note: if there wasn't for the old-style classes, only a PyNumber_Check would suffice.
- #define SbkNumber_Check(X) \
- (PyNumber_Check(X) && (!PyInstance_Check(X) || PyObject_HasAttrString(X, "__trunc__")))
- #define SBK_NB_BOOL(x) (x).nb_nonzero
- #define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, reinterpret_cast<PyObject *>(Py_TYPE(Y)))
-
- #define Py_hash_t long
-#endif
+#define PyInt_Type PyLong_Type
+#define PyInt_Check PyLong_Check
+#define PyInt_CheckExact PyLong_CheckExact
+#define PyInt_FromString PyLong_FromString
+#define PyInt_FromSsize_t PyLong_FromSsize_t
+#define PyInt_FromSize_t PyLong_FromSize_t
+#define PyInt_AS_LONG PyLong_AS_LONG
+#define PyInt_AsUnsignedLongLongMask PyLong_AsLongLong
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_AsLong PyLong_AsLong
+#define SbkNumber_Check PyNumber_Check
+#define Py_TPFLAGS_CHECKTYPES 0
+
+#define SBK_NB_BOOL(x) (x).nb_bool
+#define SBK_PyMethod_New PyMethod_New
+#define PyInt_AsSsize_t(x) PyLong_AsSsize_t(x)
+#define PyString_Type PyUnicode_Type
+
+// In Python 3, Py_TPFLAGS_DEFAULT contains Py_TPFLAGS_HAVE_VERSION_TAG,
+// which will trigger the attribute cache, which is not intended in Qt for Python.
+// Use a customized Py_TPFLAGS_DEFAULT by defining Py_TPFLAGS_HAVE_VERSION_TAG = 0.
+#undef Py_TPFLAGS_HAVE_VERSION_TAG
+#define Py_TPFLAGS_HAVE_VERSION_TAG (0)
#endif
diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp
index 918aae756..ca32f5919 100644
--- a/sources/shiboken2/libshiboken/sbkstring.cpp
+++ b/sources/shiboken2/libshiboken/sbkstring.cpp
@@ -58,20 +58,12 @@ bool checkIterable(PyObject *obj)
bool checkType(PyTypeObject *type)
{
- return type == &PyUnicode_Type
-#if PY_MAJOR_VERSION < 3
- || type == &PyString_Type
-#endif
- ;
+ return type == &PyUnicode_Type;
}
bool check(PyObject *obj)
{
- return obj == Py_None ||
-#if PY_MAJOR_VERSION < 3
- PyString_Check(obj) ||
-#endif
- PyUnicode_Check(obj);
+ return obj == Py_None || PyUnicode_Check(obj);
}
bool checkChar(PyObject *pyobj)
@@ -86,20 +78,12 @@ bool isConvertible(PyObject *obj)
PyObject *fromCString(const char *value)
{
-#ifdef IS_PY3K
return PyUnicode_FromString(value);
-#else
- return PyBytes_FromString(value);
-#endif
}
PyObject *fromCString(const char *value, int len)
{
-#ifdef IS_PY3K
return PyUnicode_FromStringAndSize(value, len);
-#else
- return PyBytes_FromStringAndSize(value, len);
-#endif
}
const char *toCString(PyObject *str, Py_ssize_t *len)
@@ -112,17 +96,9 @@ const char *toCString(PyObject *str, Py_ssize_t *len)
Shiboken::AutoDecRef uniStr(PyUnicode_AsUTF8String(str));
*len = PyBytes_GET_SIZE(uniStr.object());
}
-#ifdef IS_PY3K
// Return unicode from str instead of uniStr, because the lifetime of the returned pointer
// depends on the lifetime of str.
return _PepUnicode_AsString(str);
-#else
- str = PyUnicode_AsUTF8String(str);
- if (str == NULL) {
- return NULL;
- }
- return PyString_AsString(str);
-#endif
}
if (PyBytes_Check(str)) {
if (len)
@@ -146,12 +122,6 @@ bool concat(PyObject **val1, PyObject *val2)
return true;
}
-#if PY_MAJOR_VERSION < 3
- if (PyString_Check(*val1) && PyString_Check(val2)) {
- PyString_Concat(val1, val2);
- return true;
- }
-#endif
return false;
}
@@ -160,39 +130,20 @@ PyObject *fromFormat(const char *format, ...)
va_list argp;
va_start(argp, format);
PyObject *result = nullptr;
-#ifdef IS_PY3K
result = PyUnicode_FromFormatV(format, argp);
-#else
- result = PyString_FromFormatV(format, argp);
-#endif
va_end(argp);
return result;
}
PyObject *fromStringAndSize(const char *str, Py_ssize_t size)
{
-#ifdef IS_PY3K
return PyUnicode_FromStringAndSize(str, size);
-#else
- return PyString_FromStringAndSize(str, size);
-#endif
}
int compare(PyObject *val1, const char *val2)
{
if (PyUnicode_Check(val1))
-#ifdef IS_PY3K
return PyUnicode_CompareWithASCIIString(val1, val2);
-#else
- {
- PyObject *uVal2 = PyUnicode_FromString(val2);
- bool result = PyUnicode_Compare(val1, uVal2);
- Py_XDECREF(uVal2);
- return result;
- }
- if (PyString_Check(val1))
- return strcmp(PyString_AS_STRING(val1), val2);
-#endif
return 0;
}
diff --git a/sources/shiboken2/libshiboken/shibokenbuffer.cpp b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
index dd6e46320..5bae38aa5 100644
--- a/sources/shiboken2/libshiboken/shibokenbuffer.cpp
+++ b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
@@ -43,42 +43,25 @@
bool Shiboken::Buffer::checkType(PyObject *pyObj)
{
-#ifdef IS_PY3K
return PyObject_CheckBuffer(pyObj) != 0;
-#else
- return PyObject_CheckReadBuffer(pyObj) != 0;
-#endif
}
void *Shiboken::Buffer::getPointer(PyObject *pyObj, Py_ssize_t *size)
{
- const void *buffer = nullptr;
-#ifdef IS_PY3K
Py_buffer view;
if (PyObject_GetBuffer(pyObj, &view, PyBUF_ND) == 0) {
if (size)
*size = view.len;
- buffer = view.buf;
PyBuffer_Release(&view);
return view.buf;
}
return nullptr;
-#else
- Py_ssize_t bufferSize = 0;
-
- PyObject_AsReadBuffer(pyObj, &buffer, &bufferSize);
-
- if (size)
- *size = bufferSize;
-#endif
- return const_cast<void *>(buffer);
}
PyObject *Shiboken::Buffer::newObject(void *memory, Py_ssize_t size, Type type)
{
if (size == 0)
Py_RETURN_NONE;
-#ifdef IS_PY3K
Py_buffer view;
memset(&view, 0, sizeof(Py_buffer));
view.buf = memory;
@@ -92,9 +75,6 @@ PyObject *Shiboken::Buffer::newObject(void *memory, Py_ssize_t size, Type type)
//return PyMemoryView_FromBuffer(&view);
return PyMemoryView_FromMemory(reinterpret_cast<char *>(view.buf),
size, type == ReadOnly ? PyBUF_READ : PyBUF_WRITE);
-#else
- return type == ReadOnly ? PyBuffer_FromMemory(memory, size) : PyBuffer_FromReadWriteMemory(memory, size);
-#endif
}
PyObject *Shiboken::Buffer::newObject(const void *memory, Py_ssize_t size)
diff --git a/sources/shiboken2/libshiboken/typespec.cpp b/sources/shiboken2/libshiboken/typespec.cpp
deleted file mode 100644
index 902ed55af..000000000
--- a/sources/shiboken2/libshiboken/typespec.cpp
+++ /dev/null
@@ -1,777 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "sbkpython.h"
-#include "typespec.h"
-#include "sbkstaticstrings.h"
-#include <structmember.h>
-
-#if PY_MAJOR_VERSION < 3
-
-extern "C"
-{
-
-// for some reason python 2.7 needs this on Windows
-#ifdef WIN32
-static PyGC_Head *_PyGC_generation0;
-#endif
-
-// from pymacro.h
-#ifndef Py_PYMACRO_H
-#define Py_PYMACRO_H
-
-/* Minimum value between x and y */
-#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))
-
-/* Maximum value between x and y */
-#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y))
-
-/* Absolute value of the number x */
-#define Py_ABS(x) ((x) < 0 ? -(x) : (x))
-
-#define _Py_XSTRINGIFY(x) #x
-
-/* Convert the argument to a string. For example, Py_STRINGIFY(123) is replaced
- with "123" by the preprocessor. Defines are also replaced by their value.
- For example Py_STRINGIFY(__LINE__) is replaced by the line number, not
- by "__LINE__". */
-#define Py_STRINGIFY(x) _Py_XSTRINGIFY(x)
-
-/* Get the size of a structure member in bytes */
-#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
-
-/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
-#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
-
-/* Assert a build-time dependency, as an expression.
-
- Your compile will fail if the condition isn't true, or can't be evaluated
- by the compiler. This can be used in an expression: its value is 0.
-
- Example:
-
- #define foo_to_char(foo) \
- ((char *)(foo) \
- + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
-
- Written by Rusty Russell, public domain, http://ccodearchive.net/ */
-#define Py_BUILD_ASSERT_EXPR(cond) \
- (sizeof(char [1 - 2*!(cond)]) - 1)
-
-#define Py_BUILD_ASSERT(cond) do { \
- (void)Py_BUILD_ASSERT_EXPR(cond); \
- } while (0)
-
-/* Get the number of elements in a visible array
-
- This does not work on pointers, or arrays declared as [], or function
- parameters. With correct compiler support, such usage will cause a build
- error (see Py_BUILD_ASSERT_EXPR).
-
- Written by Rusty Russell, public domain, http://ccodearchive.net/
-
- Requires at GCC 3.1+ */
-// Simplified by "0 &&"
-#if 0 && (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \
- (((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4)))
-/* Two gcc extensions.
- &a[0] degrades to a pointer: a different type from an array */
-#define Py_ARRAY_LENGTH(array) \
- (sizeof(array) / sizeof((array)[0]) \
- + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \
- typeof(&(array)[0]))))
-#else
-#define Py_ARRAY_LENGTH(array) \
- (sizeof(array) / sizeof((array)[0]))
-#endif
-
-
-/* Define macros for inline documentation. */
-#define PyDoc_VAR(name) static char name[]
-#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
-#ifdef WITH_DOC_STRINGS
-#define PyDoc_STR(str) str
-#else
-#define PyDoc_STR(str) ""
-#endif
-
-/* Below "a" is a power of 2. */
-/* Round down size "n" to be a multiple of "a". */
-#define _Py_SIZE_ROUND_DOWN(n, a) ((size_t)(n) & ~(size_t)((a) - 1))
-/* Round up size "n" to be a multiple of "a". */
-#define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \
- (size_t)((a) - 1)) & ~(size_t)((a) - 1))
-/* Round pointer "p" down to the closest "a"-aligned address <= "p". */
-#define _Py_ALIGN_DOWN(p, a) ((void *)((uintptr_t)(p) & ~(uintptr_t)((a) - 1)))
-/* Round pointer "p" up to the closest "a"-aligned address >= "p". */
-#define _Py_ALIGN_UP(p, a) ((void *)(((uintptr_t)(p) + \
- (uintptr_t)((a) - 1)) & ~(uintptr_t)((a) - 1)))
-/* Check if pointer "p" is aligned to "a"-bytes boundary. */
-#define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1)))
-
-#ifdef __GNUC__
-#define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
-#else
-#define Py_UNUSED(name) _unused_ ## name
-#endif
-
-#endif /* Py_PYMACRO_H */
-
-// from typeobject.c
-static int
-extra_ivars(PyTypeObject *type, PyTypeObject *base)
-{
- size_t t_size = type->tp_basicsize;
- size_t b_size = base->tp_basicsize;
-
- assert(t_size >= b_size); /* Else type smaller than base! */
- if (type->tp_itemsize || base->tp_itemsize) {
- /* If itemsize is involved, stricter rules */
- return t_size != b_size ||
- type->tp_itemsize != base->tp_itemsize;
- }
- if (type->tp_weaklistoffset && base->tp_weaklistoffset == 0 &&
- type->tp_weaklistoffset + sizeof(PyObject *) == t_size &&
- type->tp_flags & Py_TPFLAGS_HEAPTYPE)
- t_size -= sizeof(PyObject *);
- if (type->tp_dictoffset && base->tp_dictoffset == 0 &&
- type->tp_dictoffset + sizeof(PyObject *) == t_size &&
- type->tp_flags & Py_TPFLAGS_HEAPTYPE)
- t_size -= sizeof(PyObject *);
-
- return t_size != b_size;
-}
-
-static void
-clear_slots(PyTypeObject *type, PyObject *self)
-{
- Py_ssize_t i, n;
- PyMemberDef *mp;
-
- n = Py_SIZE(type);
- mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
- for (i = 0; i < n; i++, mp++) {
- if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) {
- char *addr = (char *)self + mp->offset;
- PyObject *obj = *(PyObject **)addr;
- if (obj != NULL) {
- *(PyObject **)addr = NULL;
- Py_DECREF(obj);
- }
- }
- }
-}
-
-static void
-subtype_dealloc(PyObject *self)
-{
- PyTypeObject *type, *base;
- destructor basedealloc;
- PyThreadState *tstate = PyThreadState_GET();
-
- /* Extract the type; we expect it to be a heap type */
- type = Py_TYPE(self);
- assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
-
- /* Test whether the type has GC exactly once */
-
- if (!PyType_IS_GC(type)) {
- /* It's really rare to find a dynamic type that doesn't have
- GC; it can only happen when deriving from 'object' and not
- adding any slots or instance variables. This allows
- certain simplifications: there's no need to call
- clear_slots(), or DECREF the dict, or clear weakrefs. */
-
- /* Maybe call finalizer; exit early if resurrected */
- if (type->tp_del) {
- type->tp_del(self);
- if (self->ob_refcnt > 0)
- return;
- }
-
- /* Find the nearest base with a different tp_dealloc */
- base = type;
- while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
- assert(Py_SIZE(base) == 0);
- base = base->tp_base;
- assert(base);
- }
-
- /* Extract the type again; tp_del may have changed it */
- type = Py_TYPE(self);
-
- /* Call the base tp_dealloc() */
- assert(basedealloc);
- basedealloc(self);
-
- /* Can't reference self beyond this point */
- Py_DECREF(type);
-
- /* Done */
- return;
- }
-
- /* We get here only if the type has GC */
-
- /* UnTrack and re-Track around the trashcan macro, alas */
- /* See explanation at end of function for full disclosure */
- PyObject_GC_UnTrack(self);
- ++_PyTrash_delete_nesting;
- ++ tstate->trash_delete_nesting;
- Py_TRASHCAN_SAFE_BEGIN(self);
- --_PyTrash_delete_nesting;
- -- tstate->trash_delete_nesting;
- /* DO NOT restore GC tracking at this point. weakref callbacks
- * (if any, and whether directly here or indirectly in something we
- * call) may trigger GC, and if self is tracked at that point, it
- * will look like trash to GC and GC will try to delete self again.
- */
-
- /* Find the nearest base with a different tp_dealloc */
- base = type;
- while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
- base = base->tp_base;
- assert(base);
- }
-
- /* If we added a weaklist, we clear it. Do this *before* calling
- the finalizer (__del__), clearing slots, or clearing the instance
- dict. */
-
- if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
- PyObject_ClearWeakRefs(self);
-
- /* Maybe call finalizer; exit early if resurrected */
- if (type->tp_del) {
- _PyObject_GC_TRACK(self);
- type->tp_del(self);
- if (self->ob_refcnt > 0)
- goto endlabel; /* resurrected */
- else
- _PyObject_GC_UNTRACK(self);
- /* New weakrefs could be created during the finalizer call.
- If this occurs, clear them out without calling their
- finalizers since they might rely on part of the object
- being finalized that has already been destroyed. */
- if (type->tp_weaklistoffset && !base->tp_weaklistoffset) {
- /* Modeled after GET_WEAKREFS_LISTPTR() */
- PyWeakReference **list = (PyWeakReference **) \
- PyObject_GET_WEAKREFS_LISTPTR(self);
- while (*list)
- _PyWeakref_ClearRef(*list);
- }
- }
-
- /* Clear slots up to the nearest base with a different tp_dealloc */
- base = type;
- while (base->tp_dealloc == subtype_dealloc) {
- if (Py_SIZE(base))
- clear_slots(base, self);
- base = base->tp_base;
- assert(base);
- }
-
- /* If we added a dict, DECREF it */
- if (type->tp_dictoffset && !base->tp_dictoffset) {
- PyObject **dictptr = _PyObject_GetDictPtr(self);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- if (dict != NULL) {
- Py_DECREF(dict);
- *dictptr = NULL;
- }
- }
- }
-
- /* Extract the type again; tp_del may have changed it */
- type = Py_TYPE(self);
-
- /* Call the base tp_dealloc(); first retrack self if
- * basedealloc knows about gc.
- */
- if (PyType_IS_GC(base))
- _PyObject_GC_TRACK(self);
- assert(basedealloc);
- basedealloc(self);
-
- /* Can't reference self beyond this point */
- Py_DECREF(type);
-
- endlabel:
- ++_PyTrash_delete_nesting;
- ++ tstate->trash_delete_nesting;
- Py_TRASHCAN_SAFE_END(self);
- --_PyTrash_delete_nesting;
- -- tstate->trash_delete_nesting;
-
- /* Explanation of the weirdness around the trashcan macros:
-
- Q. What do the trashcan macros do?
-
- A. Read the comment titled "Trashcan mechanism" in object.h.
- For one, this explains why there must be a call to GC-untrack
- before the trashcan begin macro. Without understanding the
- trashcan code, the answers to the following questions don't make
- sense.
-
- Q. Why do we GC-untrack before the trashcan and then immediately
- GC-track again afterward?
-
- A. In the case that the base class is GC-aware, the base class
- probably GC-untracks the object. If it does that using the
- UNTRACK macro, this will crash when the object is already
- untracked. Because we don't know what the base class does, the
- only safe thing is to make sure the object is tracked when we
- call the base class dealloc. But... The trashcan begin macro
- requires that the object is *untracked* before it is called. So
- the dance becomes:
-
- GC untrack
- trashcan begin
- GC track
-
- Q. Why did the last question say "immediately GC-track again"?
- It's nowhere near immediately.
-
- A. Because the code *used* to re-track immediately. Bad Idea.
- self has a refcount of 0, and if gc ever gets its hands on it
- (which can happen if any weakref callback gets invoked), it
- looks like trash to gc too, and gc also tries to delete self
- then. But we're already deleting self. Double deallocation is
- a subtle disaster.
-
- Q. Why the bizarre (net-zero) manipulation of
- _PyTrash_delete_nesting around the trashcan macros?
-
- A. Some base classes (e.g. list) also use the trashcan mechanism.
- The following scenario used to be possible:
-
- - suppose the trashcan level is one below the trashcan limit
-
- - subtype_dealloc() is called
-
- - the trashcan limit is not yet reached, so the trashcan level
- is incremented and the code between trashcan begin and end is
- executed
-
- - this destroys much of the object's contents, including its
- slots and __dict__
-
- - basedealloc() is called; this is really list_dealloc(), or
- some other type which also uses the trashcan macros
-
- - the trashcan limit is now reached, so the object is put on the
- trashcan's to-be-deleted-later list
-
- - basedealloc() returns
-
- - subtype_dealloc() decrefs the object's type
-
- - subtype_dealloc() returns
-
- - later, the trashcan code starts deleting the objects from its
- to-be-deleted-later list
-
- - subtype_dealloc() is called *AGAIN* for the same object
-
- - at the very least (if the destroyed slots and __dict__ don't
- cause problems) the object's type gets decref'ed a second
- time, which is *BAD*!!!
-
- The remedy is to make sure that if the code between trashcan
- begin and end in subtype_dealloc() is called, the code between
- trashcan begin and end in basedealloc() will also be called.
- This is done by decrementing the level after passing into the
- trashcan block, and incrementing it just before leaving the
- block.
-
- But now it's possible that a chain of objects consisting solely
- of objects whose deallocator is subtype_dealloc() will defeat
- the trashcan mechanism completely: the decremented level means
- that the effective level never reaches the limit. Therefore, we
- *increment* the level *before* entering the trashcan block, and
- matchingly decrement it after leaving. This means the trashcan
- code will trigger a little early, but that's no big deal.
-
- Q. Are there any live examples of code in need of all this
- complexity?
-
- A. Yes. See SF bug 668433 for code that crashed (when Python was
- compiled in debug mode) before the trashcan level manipulations
- were added. For more discussion, see SF patches 581742, 575073
- and bug 574207.
- */
-}
-
-static PyTypeObject *
-solid_base(PyTypeObject *type)
-{
- PyTypeObject *base;
-
- if (type->tp_base)
- base = solid_base(type->tp_base);
- else
- base = &PyBaseObject_Type;
- if (extra_ivars(type, base))
- return type;
- else
- return base;
-}
-
-/* Calculate the best base amongst multiple base classes.
- This is the first one that's on the path to the "solid base". */
-
-static PyTypeObject *
-best_base(PyObject *bases)
-{
- Py_ssize_t i, n;
- PyTypeObject *base, *winner, *candidate, *base_i;
- PyObject *base_proto;
-
- assert(PyTuple_Check(bases));
- n = PyTuple_GET_SIZE(bases);
- assert(n > 0);
- base = NULL;
- winner = NULL;
- for (i = 0; i < n; i++) {
- base_proto = PyTuple_GET_ITEM(bases, i);
- if (PyClass_Check(base_proto))
- continue;
- if (!PyType_Check(base_proto)) {
- PyErr_SetString(
- PyExc_TypeError,
- "bases must be types");
- return NULL;
- }
- base_i = (PyTypeObject *)base_proto;
- if (base_i->tp_dict == NULL) {
- if (PyType_Ready(base_i) < 0)
- return NULL;
- }
- if (!PyType_HasFeature(base_i, Py_TPFLAGS_BASETYPE)) {
- PyErr_Format(PyExc_TypeError,
- "type '%.100s' is not an acceptable base type",
- base_i->tp_name);
- return NULL;
- }
- candidate = solid_base(base_i);
- if (winner == NULL) {
- winner = candidate;
- base = base_i;
- }
- else if (PyType_IsSubtype(winner, candidate))
- ;
- else if (PyType_IsSubtype(candidate, winner)) {
- winner = candidate;
- base = base_i;
- }
- else {
- PyErr_SetString(
- PyExc_TypeError,
- "multiple bases have "
- "instance lay-out conflict");
- return NULL;
- }
- }
- if (base == NULL)
- PyErr_SetString(PyExc_TypeError,
- "a new-style class can't have only classic bases");
- return base;
-}
-
-static const short slotoffsets[] = {
- -1, /* invalid slot */
-/* Generated by typeslots.py */
-0,
-0,
-offsetof(PyHeapTypeObject, as_mapping.mp_ass_subscript),
-offsetof(PyHeapTypeObject, as_mapping.mp_length),
-offsetof(PyHeapTypeObject, as_mapping.mp_subscript),
-offsetof(PyHeapTypeObject, as_number.nb_absolute),
-offsetof(PyHeapTypeObject, as_number.nb_add),
-offsetof(PyHeapTypeObject, as_number.nb_and),
-offsetof(PyHeapTypeObject, as_number.nb_nonzero),
-offsetof(PyHeapTypeObject, as_number.nb_divmod),
-offsetof(PyHeapTypeObject, as_number.nb_float),
-offsetof(PyHeapTypeObject, as_number.nb_floor_divide),
-offsetof(PyHeapTypeObject, as_number.nb_index),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_add),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_and),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_floor_divide),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_lshift),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_multiply),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_or),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_power),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_remainder),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_rshift),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_subtract),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_true_divide),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_xor),
-offsetof(PyHeapTypeObject, as_number.nb_int),
-offsetof(PyHeapTypeObject, as_number.nb_invert),
-offsetof(PyHeapTypeObject, as_number.nb_lshift),
-offsetof(PyHeapTypeObject, as_number.nb_multiply),
-offsetof(PyHeapTypeObject, as_number.nb_negative),
-offsetof(PyHeapTypeObject, as_number.nb_or),
-offsetof(PyHeapTypeObject, as_number.nb_positive),
-offsetof(PyHeapTypeObject, as_number.nb_power),
-offsetof(PyHeapTypeObject, as_number.nb_remainder),
-offsetof(PyHeapTypeObject, as_number.nb_rshift),
-offsetof(PyHeapTypeObject, as_number.nb_subtract),
-offsetof(PyHeapTypeObject, as_number.nb_true_divide),
-offsetof(PyHeapTypeObject, as_number.nb_xor),
-offsetof(PyHeapTypeObject, as_sequence.sq_ass_item),
-offsetof(PyHeapTypeObject, as_sequence.sq_concat),
-offsetof(PyHeapTypeObject, as_sequence.sq_contains),
-offsetof(PyHeapTypeObject, as_sequence.sq_inplace_concat),
-offsetof(PyHeapTypeObject, as_sequence.sq_inplace_repeat),
-offsetof(PyHeapTypeObject, as_sequence.sq_item),
-offsetof(PyHeapTypeObject, as_sequence.sq_length),
-offsetof(PyHeapTypeObject, as_sequence.sq_repeat),
-offsetof(PyHeapTypeObject, ht_type.tp_alloc),
-offsetof(PyHeapTypeObject, ht_type.tp_base),
-offsetof(PyHeapTypeObject, ht_type.tp_bases),
-offsetof(PyHeapTypeObject, ht_type.tp_call),
-offsetof(PyHeapTypeObject, ht_type.tp_clear),
-offsetof(PyHeapTypeObject, ht_type.tp_dealloc),
-offsetof(PyHeapTypeObject, ht_type.tp_del),
-offsetof(PyHeapTypeObject, ht_type.tp_descr_get),
-offsetof(PyHeapTypeObject, ht_type.tp_descr_set),
-offsetof(PyHeapTypeObject, ht_type.tp_doc),
-offsetof(PyHeapTypeObject, ht_type.tp_getattr),
-offsetof(PyHeapTypeObject, ht_type.tp_getattro),
-offsetof(PyHeapTypeObject, ht_type.tp_hash),
-offsetof(PyHeapTypeObject, ht_type.tp_init),
-offsetof(PyHeapTypeObject, ht_type.tp_is_gc),
-offsetof(PyHeapTypeObject, ht_type.tp_iter),
-offsetof(PyHeapTypeObject, ht_type.tp_iternext),
-offsetof(PyHeapTypeObject, ht_type.tp_methods),
-offsetof(PyHeapTypeObject, ht_type.tp_new),
-offsetof(PyHeapTypeObject, ht_type.tp_repr),
-offsetof(PyHeapTypeObject, ht_type.tp_richcompare),
-offsetof(PyHeapTypeObject, ht_type.tp_setattr),
-offsetof(PyHeapTypeObject, ht_type.tp_setattro),
-offsetof(PyHeapTypeObject, ht_type.tp_str),
-offsetof(PyHeapTypeObject, ht_type.tp_traverse),
-offsetof(PyHeapTypeObject, ht_type.tp_members),
-offsetof(PyHeapTypeObject, ht_type.tp_getset),
-offsetof(PyHeapTypeObject, ht_type.tp_free),
-offsetof(PyHeapTypeObject, as_number.nb_long),
-offsetof(PyHeapTypeObject, as_number.nb_divide),
-offsetof(PyHeapTypeObject, as_sequence.sq_slice),
-};
-
-PyObject *
-PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
-{
- auto res = reinterpret_cast<PyHeapTypeObject *>(PyType_GenericAlloc(&PyType_Type, 0));
- PyTypeObject *type, *base;
- PyObject *modname;
- auto res_start = reinterpret_cast<char *>(res);
- PyType_Slot *slot;
-
- /* Set the type name and qualname */
- auto s = const_cast<char *>(strrchr(spec->name, '.')); // C++11
- if (s == NULL)
- s = const_cast<char *>(spec->name);
- else
- s++;
-
- if (res == NULL)
- return NULL;
- type = &res->ht_type;
- /* The flags must be initialized early, before the GC traverses us */
- type->tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
- // was PyUnicode_FromString in Python 3
- res->ht_name = PyString_FromString(s);
- if (!res->ht_name)
- goto fail;
- // no ht_qualname in Python 2
- // res->ht_qualname = res->ht_name;
- // Py_INCREF(res->ht_qualname);
- type->tp_name = spec->name;
- if (!type->tp_name)
- goto fail;
-
- /* Adjust for empty tuple bases */
- if (!bases) {
- base = &PyBaseObject_Type;
- /* See whether Py_tp_base(s) was specified */
- for (slot = spec->slots; slot->slot; slot++) {
- if (slot->slot == Py_tp_base)
- base = (PyTypeObject *)slot->pfunc; // C++11
- else if (slot->slot == Py_tp_bases) {
- bases = (PyObject *)slot->pfunc; // C++11
- Py_INCREF(bases);
- }
- }
- if (!bases)
- bases = PyTuple_Pack(1, base);
- if (!bases)
- goto fail;
- }
- else
- Py_INCREF(bases);
-
- /* Calculate best base, and check that all bases are type objects */
- base = best_base(bases);
- if (base == NULL) {
- goto fail;
- }
- if (!PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) {
- PyErr_Format(PyExc_TypeError,
- "type '%.100s' is not an acceptable base type",
- base->tp_name);
- goto fail;
- }
-
- /* Initialize essential fields */
- // no async in Python 2
- // type->tp_as_async = &res->as_async;
- type->tp_as_number = &res->as_number;
- type->tp_as_sequence = &res->as_sequence;
- type->tp_as_mapping = &res->as_mapping;
- type->tp_as_buffer = &res->as_buffer;
- /* Set tp_base and tp_bases */
- type->tp_bases = bases;
- bases = NULL;
- Py_INCREF(base);
- type->tp_base = base;
-
- type->tp_basicsize = spec->basicsize;
- type->tp_itemsize = spec->itemsize;
-
- for (slot = spec->slots; slot->slot; slot++) {
- if (slot->slot < 0
- || (size_t)slot->slot >= Py_ARRAY_LENGTH(slotoffsets)) {
- PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
- goto fail;
- }
- if (slot->slot == Py_tp_base || slot->slot == Py_tp_bases)
- /* Processed above */
- continue;
- *reinterpret_cast<void **>(res_start + slotoffsets[slot->slot]) = slot->pfunc;
-
- /* need to make a copy of the docstring slot, which usually
- points to a static string literal */
- if (slot->slot == Py_tp_doc) {
- // No signature in Python 2
- // const char *old_doc = _PyType_DocWithoutSignature(type->tp_name, slot->pfunc);
- const char *old_doc = (const char *)slot->pfunc;
- size_t len = strlen(old_doc)+1;
- char *tp_doc = (char *)PyObject_MALLOC(len); // C++11
- if (tp_doc == NULL) {
- PyErr_NoMemory();
- goto fail;
- }
- memcpy(tp_doc, old_doc, len);
- type->tp_doc = tp_doc;
- }
- }
- if (type->tp_dealloc == NULL) {
- /* It's a heap type, so needs the heap types' dealloc.
- subtype_dealloc will call the base type's tp_dealloc, if
- necessary. */
- type->tp_dealloc = subtype_dealloc;
- }
-
- if (PyType_Ready(type) < 0)
- goto fail;
-
- // no ht_cached_keys in Python 2
- // if (type->tp_dictoffset) {
- // res->ht_cached_keys = _PyDict_NewKeysForClass();
- // }
-
- /* Set type.__module__ */
- s = (char *)strrchr(spec->name, '.'); // c++11
- if (s != NULL) {
- int err;
- // was PyUnicode_FromStringAndSize in Python 3
- modname = PyString_FromStringAndSize(
- spec->name, (Py_ssize_t)(s - spec->name));
- if (modname == NULL) {
- goto fail;
- }
- // no PyId_ things in Python 2
- // err = _PyDict_SetItemId(type->tp_dict, &PyId___module__, modname);
- err = PyDict_SetItem(type->tp_dict, Shiboken::PyMagicName::module(), modname);
- Py_DECREF(modname);
- if (err != 0)
- goto fail;
- } else {
- // no PyErr_WarnFormat in Python 2
- // if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- // "builtin type %.200s has no __module__ attribute",
- // spec->name))
- char msg[250];
- sprintf(msg, "builtin type %.200s has no __module__ attribute", spec->name);
- if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1))
- goto fail;
- }
-
- return reinterpret_cast<PyObject *>(res);
-
- fail:
- Py_DECREF(res);
- return NULL;
-}
-
-PyObject *
-PyType_FromSpec(PyType_Spec *spec)
-{
- return PyType_FromSpecWithBases(spec, NULL);
-}
-
-void *
-PyType_GetSlot(PyTypeObject *type, int slot)
-{
- if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE) || slot < 0) {
- PyErr_BadInternalCall();
- return NULL;
- }
- if ((size_t)slot >= Py_ARRAY_LENGTH(slotoffsets)) {
- /* Extension module requesting slot from a future version */
- return NULL;
- }
- return *reinterpret_cast<void **>(reinterpret_cast<char *>(type) + slotoffsets[slot]);
-}
-
-} // extern "C"
-#endif // PY_MAJOR_VERSION < 3
diff --git a/sources/shiboken2/libshiboken/typespec.h b/sources/shiboken2/libshiboken/typespec.h
deleted file mode 100644
index 193b654c2..000000000
--- a/sources/shiboken2/libshiboken/typespec.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** 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-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TYPESPEC_H
-#define TYPESPEC_H
-
-#include "sbkpython.h"
-#include "shibokenmacros.h"
-
-#if PY_MAJOR_VERSION < 3
-extern "C"
-{
-
-typedef struct{
- int slot; // slot is somehow reserved in Qt /* slot id, see below */
- void *pfunc; /* function pointer */
-} PyType_Slot;
-
-typedef struct{
- const char *name;
- int basicsize;
- int itemsize;
- unsigned int flags;
- PyType_Slot *slots; /* terminated by slot==0. */
-} PyType_Spec;
-
-LIBSHIBOKEN_API PyObject *PyType_FromSpec(PyType_Spec *);
-#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
-LIBSHIBOKEN_API PyObject *PyType_FromSpecWithBases(PyType_Spec *, PyObject *);
-#endif
-#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
-LIBSHIBOKEN_API void *PyType_GetSlot(PyTypeObject *, int);
-#endif
-
-// from typeslots.h
-/* Do not renumber the file; these numbers are part of the stable ABI. */
-/* Disabled, see #10181 */
-#undef Py_bf_getbuffer
-#undef Py_bf_releasebuffer
-#define Py_mp_ass_subscript 3
-#define Py_mp_length 4
-#define Py_mp_subscript 5
-#define Py_nb_absolute 6
-#define Py_nb_add 7
-#define Py_nb_and 8
-#define Py_nb_nonzero 9
-#define Py_nb_divmod 10
-#define Py_nb_float 11
-#define Py_nb_floor_divide 12
-#define Py_nb_index 13
-#define Py_nb_inplace_add 14
-#define Py_nb_inplace_and 15
-#define Py_nb_inplace_floor_divide 16
-#define Py_nb_inplace_lshift 17
-#define Py_nb_inplace_multiply 18
-#define Py_nb_inplace_or 19
-#define Py_nb_inplace_power 20
-#define Py_nb_inplace_remainder 21
-#define Py_nb_inplace_rshift 22
-#define Py_nb_inplace_subtract 23
-#define Py_nb_inplace_true_divide 24
-#define Py_nb_inplace_xor 25
-#define Py_nb_int 26
-#define Py_nb_invert 27
-#define Py_nb_lshift 28
-#define Py_nb_multiply 29
-#define Py_nb_negative 30
-#define Py_nb_or 31
-#define Py_nb_positive 32
-#define Py_nb_power 33
-#define Py_nb_remainder 34
-#define Py_nb_rshift 35
-#define Py_nb_subtract 36
-#define Py_nb_true_divide 37
-#define Py_nb_xor 38
-#define Py_sq_ass_item 39
-#define Py_sq_concat 40
-#define Py_sq_contains 41
-#define Py_sq_inplace_concat 42
-#define Py_sq_inplace_repeat 43
-#define Py_sq_item 44
-#define Py_sq_length 45
-#define Py_sq_repeat 46
-#define Py_tp_alloc 47
-#define Py_tp_base 48
-#define Py_tp_bases 49
-#define Py_tp_call 50
-#define Py_tp_clear 51
-#define Py_tp_dealloc 52
-#define Py_tp_del 53
-#define Py_tp_descr_get 54
-#define Py_tp_descr_set 55
-#define Py_tp_doc 56
-#define Py_tp_getattr 57
-#define Py_tp_getattro 58
-#define Py_tp_hash 59
-#define Py_tp_init 60
-#define Py_tp_is_gc 61
-#define Py_tp_iter 62
-#define Py_tp_iternext 63
-#define Py_tp_methods 64
-#define Py_tp_new 65
-#define Py_tp_repr 66
-#define Py_tp_richcompare 67
-#define Py_tp_setattr 68
-#define Py_tp_setattro 69
-#define Py_tp_str 70
-#define Py_tp_traverse 71
-#define Py_tp_members 72
-#define Py_tp_getset 73
-#define Py_tp_free 74
-#define Py_nb_long 75
-#define Py_nb_divide 76
-#define Py_sq_slice 77
-} // extern "C"
-#endif // PY_MAJOR_VERSION < 3
-#endif // TYPESPEC_H
diff --git a/sources/shiboken2/libshiboken/voidptr.cpp b/sources/shiboken2/libshiboken/voidptr.cpp
index 6ac3c131d..a21a4482f 100644
--- a/sources/shiboken2/libshiboken/voidptr.cpp
+++ b/sources/shiboken2/libshiboken/voidptr.cpp
@@ -219,11 +219,7 @@ PyObject *SbkVoidPtrObject_repr(PyObject *v)
auto *sbkObject = reinterpret_cast<SbkVoidPtrObject *>(v);
- #ifdef IS_PY3K
PyObject *s = PyUnicode_FromFormat("%s(%p, %zd, %s)",
- #else
- PyObject *s = PyBytes_FromFormat("%s(%p, %zd, %s)",
- #endif
Py_TYPE(sbkObject)->tp_name,
sbkObject->cptr,
sbkObject->size,
@@ -235,11 +231,7 @@ PyObject *SbkVoidPtrObject_repr(PyObject *v)
PyObject *SbkVoidPtrObject_str(PyObject *v)
{
auto *sbkObject = reinterpret_cast<SbkVoidPtrObject *>(v);
- #ifdef IS_PY3K
PyObject *s = PyUnicode_FromFormat("%s(Address %p, Size %zd, isWritable %s)",
- #else
- PyObject *s = PyBytes_FromFormat("%s(Address %p, Size %zd, isWritable %s)",
- #endif
Py_TYPE(sbkObject)->tp_name,
sbkObject->cptr,
sbkObject->size,
diff --git a/sources/shiboken2/shibokenmodule/CMakeLists.txt b/sources/shiboken2/shibokenmodule/CMakeLists.txt
index b14de5c9e..c182cf632 100644
--- a/sources/shiboken2/shibokenmodule/CMakeLists.txt
+++ b/sources/shiboken2/shibokenmodule/CMakeLists.txt
@@ -66,13 +66,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/signature/
"${CMAKE_CURRENT_BINARY_DIR}/files.dir/shibokensupport/signature/lib/enum_sig.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/signature/lib/tool.py"
"${CMAKE_CURRENT_BINARY_DIR}/files.dir/shibokensupport/signature/lib/tool.py" COPYONLY)
-if (PYTHON_VERSION_MAJOR EQUAL 3)
-else()
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/backport_inspect.py"
- "${CMAKE_CURRENT_BINARY_DIR}/files.dir/shibokensupport/backport_inspect.py" COPYONLY)
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/files.dir/shibokensupport/typing27.py"
- "${CMAKE_CURRENT_BINARY_DIR}/files.dir/shibokensupport/typing27.py" COPYONLY)
-endif()
+
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/files.dir"
DESTINATION "${PYTHON_SITE_PACKAGES}/shiboken2")
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/backport_inspect.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/backport_inspect.py
deleted file mode 100644
index 0f9598c64..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/backport_inspect.py
+++ /dev/null
@@ -1,900 +0,0 @@
-# This Python file uses the following encoding: utf-8
-# It has been edited by fix-complaints.py .
-
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## 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 Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## 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-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function
-
-"""
-PSF LICENSE AGREEMENT FOR PYTHON 3.7.0
-
-1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
- the Individual or Organization ("Licensee") accessing and otherwise using Python
- 3.7.0 software in source or binary form and its associated documentation.
-
-2. Subject to the terms and conditions of this License Agreement, PSF hereby
- grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
- analyze, test, perform and/or display publicly, prepare derivative works,
- distribute, and otherwise use Python 3.7.0 alone or in any derivative
- version, provided, however, that PSF's License Agreement and PSF's notice of
- copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights
- Reserved" are retained in Python 3.7.0 alone or in any derivative version
- prepared by Licensee.
-
-3. In the event Licensee prepares a derivative work that is based on or
- incorporates Python 3.7.0 or any part thereof, and wants to make the
- derivative work available to others as provided herein, then Licensee hereby
- agrees to include in any such work a brief summary of the changes made to Python
- 3.7.0.
-
-4. PSF is making Python 3.7.0 available to Licensee on an "AS IS" basis.
- PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
- EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
- WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
- USE OF PYTHON 3.7.0 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
-
-5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.7.0
- FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
- MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.7.0, OR ANY DERIVATIVE
- THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
-
-6. This License Agreement will automatically terminate upon a material breach of
- its terms and conditions.
-
-7. Nothing in this License Agreement shall be deemed to create any relationship
- of agency, partnership, or joint venture between PSF and Licensee. This License
- Agreement does not grant permission to use PSF trademarks or trade name in a
- trademark sense to endorse or promote products or services of Licensee, or any
- third party.
-
-8. By copying, installing or otherwise using Python 3.7.0, Licensee agrees
- to be bound by the terms and conditions of this License Agreement.
-"""
-
-__doc__ = """
- signature() - get a Signature object for the callable
-"""
-
-import sys
-from collections import OrderedDict
-
-CO_OPTIMIZED = 0x0001
-CO_NEWLOCALS = 0x0002
-CO_VARARGS = 0x0004
-CO_VARKEYWORDS = 0x0008
-CO_NESTED = 0x0010
-CO_GENERATOR = 0x0020
-CO_NOFREE = 0x0040
-
-
-###############################################################################
-### Function Signature Object (PEP 362)
-###############################################################################
-
-
-
-# PYSIDE-1286: We now use the added __qualname__ for classes.
-def _get_class_name(cls):
- return getattr(cls, "__qualname__", cls.__name__)
-
-# This function was changed: 'builtins' and 'qualname' don't exist.
-# We use '__builtin__' and '__(qual)?name__' instead.
-def formatannotation(annotation, base_module=None):
- if getattr(annotation, '__module__', None) == 'typing':
- # The replace must not be done on Python 2.7 because it
- # already happens somewhere else.
- return repr(annotation) ##.replace('typing.', '')
- if isinstance(annotation, type):
- if annotation.__module__ in ('__builtin__', base_module):
- return _get_class_name(annotation)
- return annotation.__module__ + '.' + _get_class_name(annotation)
- return repr(annotation)
-
-
-def _signature_is_functionlike(obj):
- """Private helper to test if `obj` is a duck type of FunctionType.
- A good example of such objects are functions compiled with
- Cython, which have all attributes that a pure Python function
- would have, but have their code statically compiled.
- """
-
- if not callable(obj) or isclass(obj):
- # All function-like objects are obviously callables,
- # and not classes.
- return False
-
- name = getattr(obj, '__name__', None)
- code = getattr(obj, '__code__', None)
- defaults = getattr(obj, '__defaults__', _void) # Important to use _void ...
- kwdefaults = getattr(obj, '__kwdefaults__', _void) # ... and not None here
- annotations = getattr(obj, '__annotations__', None)
-
- return (isinstance(code, types.CodeType) and
- isinstance(name, str) and
- (defaults is None or isinstance(defaults, tuple)) and
- (kwdefaults is None or isinstance(kwdefaults, dict)) and
- isinstance(annotations, dict))
-
-
-
-def _signature_from_function(cls, func):
- """Private helper: constructs Signature for the given python function."""
-
- is_duck_function = False
- if not isfunction(func):
- if _signature_is_functionlike(func):
- is_duck_function = True
- else:
- # If it's not a pure Python function, and not a duck type
- # of pure function:
- raise TypeError('{!r} is not a Python function'.format(func))
-
- Parameter = cls._parameter_cls
-
- # Parameter information.
- func_code = func.__code__
- pos_count = func_code.co_argcount
- arg_names = func_code.co_varnames
- positional = tuple(arg_names[:pos_count])
- keyword_only_count = 0 # func_code.co_kwonlyargcount
- keyword_only = arg_names[pos_count:(pos_count + keyword_only_count)]
- annotations = func.__annotations__
- defaults = func.__defaults__
- kwdefaults = func.__kwdefaults__
-
- if defaults:
- pos_default_count = len(defaults)
- else:
- pos_default_count = 0
-
- parameters = []
-
- # Non-keyword-only parameters w/o defaults.
- non_default_count = pos_count - pos_default_count
- for name in positional[:non_default_count]:
- annotation = annotations.get(name, _empty)
- parameters.append(Parameter(name, annotation=annotation,
- kind=_POSITIONAL_OR_KEYWORD))
-
- # ... w/ defaults.
- for offset, name in enumerate(positional[non_default_count:]):
- annotation = annotations.get(name, _empty)
- parameters.append(Parameter(name, annotation=annotation,
- kind=_POSITIONAL_OR_KEYWORD,
- default=defaults[offset]))
-
- # *args
- if func_code.co_flags & CO_VARARGS:
- name = arg_names[pos_count + keyword_only_count]
- annotation = annotations.get(name, _empty)
- parameters.append(Parameter(name, annotation=annotation,
- kind=_VAR_POSITIONAL))
-
- # Keyword-only parameters.
- for name in keyword_only:
- default = _empty
- if kwdefaults is not None:
- default = kwdefaults.get(name, _empty)
-
- annotation = annotations.get(name, _empty)
- parameters.append(Parameter(name, annotation=annotation,
- kind=_KEYWORD_ONLY,
- default=default))
- # **kwargs
- if func_code.co_flags & CO_VARKEYWORDS:
- index = pos_count + keyword_only_count
- if func_code.co_flags & CO_VARARGS:
- index += 1
-
- name = arg_names[index]
- annotation = annotations.get(name, _empty)
- parameters.append(Parameter(name, annotation=annotation,
- kind=_VAR_KEYWORD))
-
- # Is 'func' is a pure Python function - don't validate the
- # parameters list (for correct order and defaults), it should be OK.
- return cls(parameters,
- return_annotation=annotations.get('return', _empty),
- __validate_parameters__=is_duck_function)
-
-
-
-
-class _void(object):
- """A private marker - used in Parameter & Signature."""
-
-
-class _empty(object):
- """Marker object for Signature.empty and Parameter.empty."""
-
-
-class _ParameterKind(object): # (enum.IntEnum):
- POSITIONAL_ONLY = 0
- POSITIONAL_OR_KEYWORD = 1
- VAR_POSITIONAL = 2
- KEYWORD_ONLY = 3
- VAR_KEYWORD = 4
-
- def __str__(self):
- return self._name_
-
-
-_POSITIONAL_ONLY = _ParameterKind.POSITIONAL_ONLY
-_POSITIONAL_OR_KEYWORD = _ParameterKind.POSITIONAL_OR_KEYWORD
-_VAR_POSITIONAL = _ParameterKind.VAR_POSITIONAL
-_KEYWORD_ONLY = _ParameterKind.KEYWORD_ONLY
-_VAR_KEYWORD = _ParameterKind.VAR_KEYWORD
-
-
-class Parameter(object):
- """Represents a parameter in a function signature.
-
- Has the following public attributes:
-
- * name : str
- The name of the parameter as a string.
- * default : object
- The default value for the parameter if specified. If the
- parameter has no default value, this attribute is set to
- `Parameter.empty`.
- * annotation
- The annotation for the parameter if specified. If the
- parameter has no annotation, this attribute is set to
- `Parameter.empty`.
- * kind : str
- Describes how argument values are bound to the parameter.
- Possible values: `Parameter.POSITIONAL_ONLY`,
- `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`,
- `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`.
- """
-
- __slots__ = ('_name', '_kind', '_default', '_annotation')
-
- POSITIONAL_ONLY = _POSITIONAL_ONLY
- POSITIONAL_OR_KEYWORD = _POSITIONAL_OR_KEYWORD
- VAR_POSITIONAL = _VAR_POSITIONAL
- KEYWORD_ONLY = _KEYWORD_ONLY
- VAR_KEYWORD = _VAR_KEYWORD
-
- empty = _empty
-
- def __init__(self, name, kind, default=_empty, annotation=_empty):
-
- if kind not in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD,
- _VAR_POSITIONAL, _KEYWORD_ONLY, _VAR_KEYWORD):
- raise ValueError("invalid value for 'Parameter.kind' attribute")
- self._kind = kind
-
- if default is not _empty:
- if kind in (_VAR_POSITIONAL, _VAR_KEYWORD):
- msg = '{} parameters cannot have default values'.format(kind)
- raise ValueError(msg)
- self._default = default
- self._annotation = annotation
-
- if name is _empty:
- raise ValueError('name is a required attribute for Parameter')
-
- if not isinstance(name, str):
- raise TypeError("name must be a str, not a {!r}".format(name))
-
- if name[0] == '.' and name[1:].isdigit():
- # These are implicit arguments generated by comprehensions. In
- # order to provide a friendlier interface to users, we recast
- # their name as "implicitN" and treat them as positional-only.
- # See issue 19611.
- if kind != _POSITIONAL_OR_KEYWORD:
- raise ValueError(
- 'implicit arguments must be passed in as {}'.format(
- _POSITIONAL_OR_KEYWORD
- )
- )
- self._kind = _POSITIONAL_ONLY
- name = 'implicit{}'.format(name[1:])
-
- if not True: # name.isidentifier():
- raise ValueError('{!r} is not a valid parameter name'.format(name))
-
- self._name = name
-
- def __reduce__(self):
- return (type(self),
- (self._name, self._kind),
- {'_default': self._default,
- '_annotation': self._annotation})
-
- def __setstate__(self, state):
- self._default = state['_default']
- self._annotation = state['_annotation']
-
- @property
- def name(self):
- return self._name
-
- @property
- def default(self):
- return self._default
-
- @property
- def annotation(self):
- return self._annotation
-
- @property
- def kind(self):
- return self._kind
-
- def replace(self, name=_void, kind=_void,
- annotation=_void, default=_void):
- """Creates a customized copy of the Parameter."""
-
- if name is _void:
- name = self._name
-
- if kind is _void:
- kind = self._kind
-
- if annotation is _void:
- annotation = self._annotation
-
- if default is _void:
- default = self._default
-
- return type(self)(name, kind, default=default, annotation=annotation)
-
- def __str__(self):
- kind = self.kind
- formatted = self._name
-
- # Add annotation and default value
- if self._annotation is not _empty:
- formatted = '{}: {}'.format(formatted,
- formatannotation(self._annotation))
-
- if self._default is not _empty:
- formatted = '{}={}'.format(formatted, repr(self._default))
-
- if kind == _VAR_POSITIONAL:
- formatted = '*' + formatted
- elif kind == _VAR_KEYWORD:
- formatted = '**' + formatted
-
- return formatted
-
- def __repr__(self):
- return '<{} "{}">'.format(_get_class_name(self.__class__), self)
-
- def __hash__(self):
- return hash((self.name, self.kind, self.annotation, self.default))
-
- def __eq__(self, other):
- if self is other:
- return True
- if not isinstance(other, Parameter):
- return NotImplemented
- return (self._name == other._name and
- self._kind == other._kind and
- self._default == other._default and
- self._annotation == other._annotation)
-
-
-class BoundArguments(object):
- """Result of `Signature.bind` call. Holds the mapping of arguments
- to the function's parameters.
-
- Has the following public attributes:
-
- * arguments : OrderedDict
- An ordered mutable mapping of parameters' names to arguments' values.
- Does not contain arguments' default values.
- * signature : Signature
- The Signature object that created this instance.
- * args : tuple
- Tuple of positional arguments values.
- * kwargs : dict
- Dict of keyword arguments values.
- """
-
- __slots__ = ('arguments', '_signature', '__weakref__')
-
- def __init__(self, signature, arguments):
- self.arguments = arguments
- self._signature = signature
-
- @property
- def signature(self):
- return self._signature
-
- @property
- def args(self):
- args = []
- for param_name, param in self._signature.parameters.items():
- if param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY):
- break
-
- try:
- arg = self.arguments[param_name]
- except KeyError:
- # We're done here. Other arguments
- # will be mapped in 'BoundArguments.kwargs'
- break
- else:
- if param.kind == _VAR_POSITIONAL:
- # *args
- args.extend(arg)
- else:
- # plain argument
- args.append(arg)
-
- return tuple(args)
-
- @property
- def kwargs(self):
- kwargs = {}
- kwargs_started = False
- for param_name, param in self._signature.parameters.items():
- if not kwargs_started:
- if param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY):
- kwargs_started = True
- else:
- if param_name not in self.arguments:
- kwargs_started = True
- continue
-
- if not kwargs_started:
- continue
-
- try:
- arg = self.arguments[param_name]
- except KeyError:
- pass
- else:
- if param.kind == _VAR_KEYWORD:
- # **kwargs
- kwargs.update(arg)
- else:
- # plain keyword argument
- kwargs[param_name] = arg
-
- return kwargs
-
- def apply_defaults(self):
- """Set default values for missing arguments.
-
- For variable-positional arguments (*args) the default is an
- empty tuple.
-
- For variable-keyword arguments (**kwargs) the default is an
- empty dict.
- """
- arguments = self.arguments
- new_arguments = []
- for name, param in self._signature.parameters.items():
- try:
- new_arguments.append((name, arguments[name]))
- except KeyError:
- if param.default is not _empty:
- val = param.default
- elif param.kind is _VAR_POSITIONAL:
- val = ()
- elif param.kind is _VAR_KEYWORD:
- val = {}
- else:
- # This BoundArguments was likely produced by
- # Signature.bind_partial().
- continue
- new_arguments.append((name, val))
- self.arguments = OrderedDict(new_arguments)
-
- def __eq__(self, other):
- if self is other:
- return True
- if not isinstance(other, BoundArguments):
- return NotImplemented
- return (self.signature == other.signature and
- self.arguments == other.arguments)
-
- def __setstate__(self, state):
- self._signature = state['_signature']
- self.arguments = state['arguments']
-
- def __getstate__(self):
- return {'_signature': self._signature, 'arguments': self.arguments}
-
- def __repr__(self):
- args = []
- for arg, value in self.arguments.items():
- args.append('{}={!r}'.format(arg, value))
- return '<{} ({})>'.format(_get_class_name(self.__class__), ', '.join(args))
-
-
-class Signature(object):
- """A Signature object represents the overall signature of a function.
- It stores a Parameter object for each parameter accepted by the
- function, as well as information specific to the function itself.
-
- A Signature object has the following public attributes and methods:
-
- * parameters : OrderedDict
- An ordered mapping of parameters' names to the corresponding
- Parameter objects (keyword-only arguments are in the same order
- as listed in `code.co_varnames`).
- * return_annotation : object
- The annotation for the return type of the function if specified.
- If the function has no annotation for its return type, this
- attribute is set to `Signature.empty`.
- * bind(*args, **kwargs) -> BoundArguments
- Creates a mapping from positional and keyword arguments to
- parameters.
- * bind_partial(*args, **kwargs) -> BoundArguments
- Creates a partial mapping from positional and keyword arguments
- to parameters (simulating 'functools.partial' behavior.)
- """
-
- __slots__ = ('_return_annotation', '_parameters')
-
- _parameter_cls = Parameter
- _bound_arguments_cls = BoundArguments
-
- empty = _empty
-
- def __init__(self, parameters=None, return_annotation=_empty,
- __validate_parameters__=True):
- """Constructs Signature from the given list of Parameter
- objects and 'return_annotation'. All arguments are optional.
- """
-
- if parameters is None:
- params = OrderedDict()
- else:
- if __validate_parameters__:
- params = OrderedDict()
- top_kind = _POSITIONAL_ONLY
- kind_defaults = False
-
- for idx, param in enumerate(parameters):
- kind = param.kind
- name = param.name
-
- if kind < top_kind:
- msg = 'wrong parameter order: {!r} before {!r}'
- msg = msg.format(top_kind, kind)
- raise ValueError(msg)
- elif kind > top_kind:
- kind_defaults = False
- top_kind = kind
-
- if kind in (_POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD):
- if param.default is _empty:
- if kind_defaults:
- # No default for this parameter, but the
- # previous parameter of the same kind had
- # a default
- msg = 'non-default argument follows default ' \
- 'argument'
- raise ValueError(msg)
- else:
- # There is a default for this parameter.
- kind_defaults = True
-
- if name in params:
- msg = 'duplicate parameter name: {!r}'.format(name)
- raise ValueError(msg)
-
- params[name] = param
- else:
- params = OrderedDict(((param.name, param)
- for param in parameters))
-
- self._parameters = params # types.MappingProxyType(params)
- self._return_annotation = return_annotation
-
- @classmethod
- def from_function(cls, func):
- """Constructs Signature for the given python function."""
-
- warnings.warn("inspect.Signature.from_function() is deprecated, "
- "use Signature.from_callable()",
- DeprecationWarning, stacklevel=2)
- return _signature_from_function(cls, func)
-
- @classmethod
- def from_builtin(cls, func):
- """Constructs Signature for the given builtin function."""
-
- warnings.warn("inspect.Signature.from_builtin() is deprecated, "
- "use Signature.from_callable()",
- DeprecationWarning, stacklevel=2)
- return _signature_from_builtin(cls, func)
-
- @classmethod
- def from_callable(cls, obj, follow_wrapped=True):
- """Constructs Signature for the given callable object."""
- return _signature_from_callable(obj, sigcls=cls,
- follow_wrapper_chains=follow_wrapped)
-
- @property
- def parameters(self):
- return self._parameters
-
- @property
- def return_annotation(self):
- return self._return_annotation
-
- def replace(self, parameters=_void, return_annotation=_void):
- """Creates a customized copy of the Signature.
- Pass 'parameters' and/or 'return_annotation' arguments
- to override them in the new copy.
- """
-
- if parameters is _void:
- parameters = self.parameters.values()
-
- if return_annotation is _void:
- return_annotation = self._return_annotation
-
- return type(self)(parameters,
- return_annotation=return_annotation)
-
- def _hash_basis(self):
- params = tuple(param for param in self.parameters.values()
- if param.kind != _KEYWORD_ONLY)
-
- kwo_params = {param.name: param for param in self.parameters.values()
- if param.kind == _KEYWORD_ONLY}
-
- return params, kwo_params, self.return_annotation
-
- def __hash__(self):
- params, kwo_params, return_annotation = self._hash_basis()
- kwo_params = frozenset(kwo_params.values())
- return hash((params, kwo_params, return_annotation))
-
- def __eq__(self, other):
- if self is other:
- return True
- if not isinstance(other, Signature):
- return NotImplemented
- return self._hash_basis() == other._hash_basis()
-
- def _bind(self, args, kwargs, partial=False):
- """Private method. Don't use directly."""
-
- arguments = OrderedDict()
-
- parameters = iter(self.parameters.values())
- parameters_ex = ()
- arg_vals = iter(args)
-
- while True:
- # Let's iterate through the positional arguments and corresponding
- # parameters
- try:
- arg_val = next(arg_vals)
- except StopIteration:
- # No more positional arguments
- try:
- param = next(parameters)
- except StopIteration:
- # No more parameters. That's it. Just need to check that
- # we have no `kwargs` after this while loop
- break
- else:
- if param.kind == _VAR_POSITIONAL:
- # That's OK, just empty *args. Let's start parsing
- # kwargs
- break
- elif param.name in kwargs:
- if param.kind == _POSITIONAL_ONLY:
- msg = '{arg!r} parameter is positional only, ' \
- 'but was passed as a keyword'
- msg = msg.format(arg=param.name)
- raise TypeError(msg)# from None
- parameters_ex = (param,)
- break
- elif (param.kind == _VAR_KEYWORD or
- param.default is not _empty):
- # That's fine too - we have a default value for this
- # parameter. So, lets start parsing `kwargs`, starting
- # with the current parameter
- parameters_ex = (param,)
- break
- else:
- # No default, not VAR_KEYWORD, not VAR_POSITIONAL,
- # not in `kwargs`
- if partial:
- parameters_ex = (param,)
- break
- else:
- msg = 'missing a required argument: {arg!r}'
- msg = msg.format(arg=param.name)
- raise TypeError(msg)# from None
- else:
- # We have a positional argument to process
- try:
- param = next(parameters)
- except StopIteration:
- raise TypeError('too many positional arguments')# from None
- else:
- if param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY):
- # Looks like we have no parameter for this positional
- # argument
- raise TypeError(
- 'too many positional arguments')# from None
-
- if param.kind == _VAR_POSITIONAL:
- # We have an '*args'-like argument, let's fill it with
- # all positional arguments we have left and move on to
- # the next phase
- values = [arg_val]
- values.extend(arg_vals)
- arguments[param.name] = tuple(values)
- break
-
- if param.name in kwargs:
- raise TypeError(
- 'multiple values for argument {arg!r}'.format(
- arg=param.name))# from None
-
- arguments[param.name] = arg_val
-
- # Now, we iterate through the remaining parameters to process
- # keyword arguments
- kwargs_param = None
- for param in itertools.chain(parameters_ex, parameters):
- if param.kind == _VAR_KEYWORD:
- # Memorize that we have a '**kwargs'-like parameter
- kwargs_param = param
- continue
-
- if param.kind == _VAR_POSITIONAL:
- # Named arguments don't refer to '*args'-like parameters.
- # We only arrive here if the positional arguments ended
- # before reaching the last parameter before *args.
- continue
-
- param_name = param.name
- try:
- arg_val = kwargs.pop(param_name)
- except KeyError:
- # We have no value for this parameter. It's fine though,
- # if it has a default value, or it is an '*args'-like
- # parameter, left alone by the processing of positional
- # arguments.
- if (not partial and param.kind != _VAR_POSITIONAL and
- param.default is _empty):
- raise TypeError('missing a required argument: {arg!r}'. \
- format(arg=param_name))# from None
-
- else:
- if param.kind == _POSITIONAL_ONLY:
- # This should never happen in case of a properly built
- # Signature object (but let's have this check here
- # to ensure correct behavior just in case)
- raise TypeError('{arg!r} parameter is positional only, '
- 'but was passed as a keyword'. \
- format(arg=param.name))
-
- arguments[param_name] = arg_val
-
- if kwargs:
- if kwargs_param is not None:
- # Process our '**kwargs'-like parameter
- arguments[kwargs_param.name] = kwargs
- else:
- raise TypeError(
- 'got an unexpected keyword argument {arg!r}'.format(
- arg=next(iter(kwargs))))
-
- return self._bound_arguments_cls(self, arguments)
-
- def bind(*args, **kwargs):
- """Get a BoundArguments object, that maps the passed `args`
- and `kwargs` to the function's signature. Raises `TypeError`
- if the passed arguments can not be bound.
- """
- return args[0]._bind(args[1:], kwargs)
-
- def bind_partial(*args, **kwargs):
- """Get a BoundArguments object, that partially maps the
- passed `args` and `kwargs` to the function's signature.
- Raises `TypeError` if the passed arguments can not be bound.
- """
- return args[0]._bind(args[1:], kwargs, partial=True)
-
- def __reduce__(self):
- return (type(self),
- (tuple(self._parameters.values()),),
- {'_return_annotation': self._return_annotation})
-
- def __setstate__(self, state):
- self._return_annotation = state['_return_annotation']
-
- def __repr__(self):
- return '<{} {}>'.format(_get_class_name(self.__class__), self)
-
- def __str__(self):
- result = []
- render_pos_only_separator = False
- render_kw_only_separator = True
- for param in self.parameters.values():
- formatted = str(param)
-
- kind = param.kind
-
- if kind == _POSITIONAL_ONLY:
- render_pos_only_separator = True
- elif render_pos_only_separator:
- # It's not a positional-only parameter, and the flag
- # is set to 'True' (there were pos-only params before.)
- result.append('/')
- render_pos_only_separator = False
-
- if kind == _VAR_POSITIONAL:
- # OK, we have an '*args'-like parameter, so we won't need
- # a '*' to separate keyword-only arguments
- render_kw_only_separator = False
- elif kind == _KEYWORD_ONLY and render_kw_only_separator:
- # We have a keyword-only parameter to render and we haven't
- # rendered an '*args'-like parameter before, so add a '*'
- # separator to the parameters list ("foo(arg1, *, arg2)" case)
- result.append('*')
- # This condition should be only triggered once, so
- # reset the flag
- render_kw_only_separator = False
-
- result.append(formatted)
-
- if render_pos_only_separator:
- # There were only positional-only parameters, hence the
- # flag was not reset to 'False'
- result.append('/')
-
- rendered = '({})'.format(', '.join(result))
-
- if self.return_annotation is not _empty:
- anno = formatannotation(self.return_annotation)
- rendered += ' -> {}'.format(anno)
-
- return rendered
-
-
-def signature(obj, follow_wrapped=True):
- """Get a signature object for the passed callable."""
- return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
index 05de5b6de..c64abf9fb 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
@@ -246,6 +246,7 @@ type_map.update({
"qint64": int,
"qint8": int,
"qintptr": int,
+ "qsizetype": int,
"QList": ArrayLikeVariable,
"qlonglong": int,
"QMap": typing.Dict,
@@ -254,6 +255,7 @@ type_map.update({
"qreal": float,
"QSet": typing.Set,
"QString": str,
+ "QStringView": str,
"QStringList": StringList,
"quint16": int,
"quint32": int,
@@ -330,6 +332,7 @@ type_map.update({
type_map.update({
# Handling variables that are returned, eventually as Tuples:
+ "PySide2.QtQml.atomic[bool]": ResultVariable(bool), # QmlIncubationController::incubateWhile()
"bool*" : ResultVariable(bool),
"float*" : ResultVariable(float),
"int*" : ResultVariable(int),
@@ -340,6 +343,8 @@ type_map.update({
"qint64*" : ResultVariable(int),
"qreal*" : ResultVariable(float),
"QString*" : ResultVariable(str),
+ "qintptr*" : ResultVariable(int),
+ "quintptr*" : ResultVariable(int),
"quint16*" : ResultVariable(int),
"uint*" : ResultVariable(int),
"unsigned int*" : ResultVariable(int),
@@ -447,8 +452,8 @@ def init_PySide2_QtCore():
"DescriptorType(-1)": int, # Native handle of QSocketDescriptor
"false": False,
"list of QAbstractAnimation": typing.List[PySide2.QtCore.QAbstractAnimation],
- "list of QAbstractState": typing.List[PySide2.QtCore.QAbstractState],
"long long": int,
+ "size_t": int,
"NULL": None, # 5.6, MSVC
"nullptr": None, # 5.9
"PyByteArray": bytearray,
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/typing27.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/typing27.py
deleted file mode 100644
index 41ed456cc..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/typing27.py
+++ /dev/null
@@ -1,2636 +0,0 @@
-# This Python file uses the following encoding: utf-8
-# It has been edited by fix-complaints.py .
-
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## 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 Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## 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-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-"""
-PSF LICENSE AGREEMENT FOR PYTHON 3.7.0
-
-1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
- the Individual or Organization ("Licensee") accessing and otherwise using Python
- 3.7.0 software in source or binary form and its associated documentation.
-
-2. Subject to the terms and conditions of this License Agreement, PSF hereby
- grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
- analyze, test, perform and/or display publicly, prepare derivative works,
- distribute, and otherwise use Python 3.7.0 alone or in any derivative
- version, provided, however, that PSF's License Agreement and PSF's notice of
- copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights
- Reserved" are retained in Python 3.7.0 alone or in any derivative version
- prepared by Licensee.
-
-3. In the event Licensee prepares a derivative work that is based on or
- incorporates Python 3.7.0 or any part thereof, and wants to make the
- derivative work available to others as provided herein, then Licensee hereby
- agrees to include in any such work a brief summary of the changes made to Python
- 3.7.0.
-
-4. PSF is making Python 3.7.0 available to Licensee on an "AS IS" basis.
- PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
- EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
- WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
- USE OF PYTHON 3.7.0 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
-
-5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.7.0
- FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
- MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.7.0, OR ANY DERIVATIVE
- THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
-
-6. This License Agreement will automatically terminate upon a material breach of
- its terms and conditions.
-
-7. Nothing in this License Agreement shall be deemed to create any relationship
- of agency, partnership, or joint venture between PSF and Licensee. This License
- Agreement does not grant permission to use PSF trademarks or trade name in a
- trademark sense to endorse or promote products or services of Licensee, or any
- third party.
-
-8. By copying, installing or otherwise using Python 3.7.0, Licensee agrees
- to be bound by the terms and conditions of this License Agreement.
-"""
-
-# This is the typing module for Python 2.7
-# https://github.com/python/typing
-# 2019-08-22
-
-from __future__ import absolute_import, unicode_literals
-
-import abc
-from abc import abstractmethod, abstractproperty
-import collections
-import functools
-import re as stdlib_re # Avoid confusion with the re we export.
-import sys
-import types
-import copy
-try:
- import collections.abc as collections_abc
-except ImportError:
- import collections as collections_abc # Fallback for PY3.2.
-
-
-# Please keep __all__ alphabetized within each category.
-__all__ = [
- # Super-special typing primitives.
- 'Any',
- 'Callable',
- 'ClassVar',
- 'Final',
- 'Generic',
- 'Literal',
- 'Optional',
- 'Protocol',
- 'Tuple',
- 'Type',
- 'TypeVar',
- 'Union',
-
- # ABCs (from collections.abc).
- 'AbstractSet', # collections.abc.Set.
- 'GenericMeta', # subclass of abc.ABCMeta and a metaclass
- # for 'Generic' and ABCs below.
- 'ByteString',
- 'Container',
- 'ContextManager',
- 'Hashable',
- 'ItemsView',
- 'Iterable',
- 'Iterator',
- 'KeysView',
- 'Mapping',
- 'MappingView',
- 'MutableMapping',
- 'MutableSequence',
- 'MutableSet',
- 'Sequence',
- 'Sized',
- 'ValuesView',
-
- # Structural checks, a.k.a. protocols.
- 'Reversible',
- 'SupportsAbs',
- 'SupportsComplex',
- 'SupportsFloat',
- 'SupportsIndex',
- 'SupportsInt',
-
- # Concrete collection types.
- 'Counter',
- 'Deque',
- 'Dict',
- 'DefaultDict',
- 'List',
- 'Set',
- 'FrozenSet',
- 'NamedTuple', # Not really a type.
- 'TypedDict', # Not really a type.
- 'Generator',
-
- # One-off things.
- 'AnyStr',
- 'cast',
- 'final',
- 'get_type_hints',
- 'NewType',
- 'no_type_check',
- 'no_type_check_decorator',
- 'NoReturn',
- 'overload',
- 'runtime_checkable',
- 'Text',
- 'TYPE_CHECKING',
-]
-
-# The pseudo-submodules 're' and 'io' are part of the public
-# namespace, but excluded from __all__ because they might stomp on
-# legitimate imports of those modules.
-
-
-def _qualname(x):
- # PYSIDE-1286: Support __qualname__ in Python 2
- return getattr(x, "__qualname__", x.__name__)
-
-
-def _trim_name(nm):
- whitelist = ('_TypeAlias', '_ForwardRef', '_TypingBase', '_FinalTypingBase')
- if nm.startswith('_') and nm not in whitelist:
- nm = nm[1:]
- return nm
-
-
-class TypingMeta(type):
- """Metaclass for most types defined in typing module
- (not a part of public API).
-
- This also defines a dummy constructor (all the work for most typing
- constructs is done in __new__) and a nicer repr().
- """
-
- _is_protocol = False
-
- def __new__(cls, name, bases, namespace):
- return super(TypingMeta, cls).__new__(cls, str(name), bases, namespace)
-
- @classmethod
- def assert_no_subclassing(cls, bases):
- for base in bases:
- if isinstance(base, cls):
- raise TypeError("Cannot subclass %s" %
- (', '.join(map(_type_repr, bases)) or '()'))
-
- def __init__(self, *args, **kwds):
- pass
-
- def _eval_type(self, globalns, localns):
- """Override this in subclasses to interpret forward references.
-
- For example, List['C'] is internally stored as
- List[_ForwardRef('C')], which should evaluate to List[C],
- where C is an object found in globalns or localns (searching
- localns first, of course).
- """
- return self
-
- def _get_type_vars(self, tvars):
- pass
-
- def __repr__(self):
- qname = _trim_name(_qualname(self))
- return '%s.%s' % (self.__module__, qname)
-
-
-class _TypingBase(object):
- """Internal indicator of special typing constructs."""
- __metaclass__ = TypingMeta
- __slots__ = ('__weakref__',)
-
- def __init__(self, *args, **kwds):
- pass
-
- def __new__(cls, *args, **kwds):
- """Constructor.
-
- This only exists to give a better error message in case
- someone tries to subclass a special typing object (not a good idea).
- """
- if (len(args) == 3 and
- isinstance(args[0], str) and
- isinstance(args[1], tuple)):
- # Close enough.
- raise TypeError("Cannot subclass %r" % cls)
- return super(_TypingBase, cls).__new__(cls)
-
- # Things that are not classes also need these.
- def _eval_type(self, globalns, localns):
- return self
-
- def _get_type_vars(self, tvars):
- pass
-
- def __repr__(self):
- cls = type(self)
- qname = _trim_name(_qualname(cls))
- return '%s.%s' % (cls.__module__, qname)
-
- def __call__(self, *args, **kwds):
- raise TypeError("Cannot instantiate %r" % type(self))
-
-
-class _FinalTypingBase(_TypingBase):
- """Internal mix-in class to prevent instantiation.
-
- Prevents instantiation unless _root=True is given in class call.
- It is used to create pseudo-singleton instances Any, Union, Optional, etc.
- """
-
- __slots__ = ()
-
- def __new__(cls, *args, **kwds):
- self = super(_FinalTypingBase, cls).__new__(cls, *args, **kwds)
- if '_root' in kwds and kwds['_root'] is True:
- return self
- raise TypeError("Cannot instantiate %r" % cls)
-
- def __reduce__(self):
- return _trim_name(type(self).__name__)
-
-
-class _ForwardRef(_TypingBase):
- """Internal wrapper to hold a forward reference."""
-
- __slots__ = ('__forward_arg__', '__forward_code__',
- '__forward_evaluated__', '__forward_value__')
-
- def __init__(self, arg):
- super(_ForwardRef, self).__init__(arg)
- if not isinstance(arg, basestring):
- raise TypeError('Forward reference must be a string -- got %r' % (arg,))
- try:
- code = compile(arg, '<string>', 'eval')
- except SyntaxError:
- raise SyntaxError('Forward reference must be an expression -- got %r' %
- (arg,))
- self.__forward_arg__ = arg
- self.__forward_code__ = code
- self.__forward_evaluated__ = False
- self.__forward_value__ = None
-
- def _eval_type(self, globalns, localns):
- if not self.__forward_evaluated__ or localns is not globalns:
- if globalns is None and localns is None:
- globalns = localns = {}
- elif globalns is None:
- globalns = localns
- elif localns is None:
- localns = globalns
- self.__forward_value__ = _type_check(
- eval(self.__forward_code__, globalns, localns),
- "Forward references must evaluate to types.")
- self.__forward_evaluated__ = True
- return self.__forward_value__
-
- def __eq__(self, other):
- if not isinstance(other, _ForwardRef):
- return NotImplemented
- return (self.__forward_arg__ == other.__forward_arg__ and
- self.__forward_value__ == other.__forward_value__)
-
- def __hash__(self):
- return hash((self.__forward_arg__, self.__forward_value__))
-
- def __instancecheck__(self, obj):
- raise TypeError("Forward references cannot be used with isinstance().")
-
- def __subclasscheck__(self, cls):
- raise TypeError("Forward references cannot be used with issubclass().")
-
- def __repr__(self):
- return '_ForwardRef(%r)' % (self.__forward_arg__,)
-
-
-class _TypeAlias(_TypingBase):
- """Internal helper class for defining generic variants of concrete types.
-
- Note that this is not a type; let's call it a pseudo-type. It cannot
- be used in instance and subclass checks in parameterized form, i.e.
- ``isinstance(42, Match[str])`` raises ``TypeError`` instead of returning
- ``False``.
- """
-
- __slots__ = ('name', 'type_var', 'impl_type', 'type_checker')
-
- def __init__(self, name, type_var, impl_type, type_checker):
- """Initializer.
-
- Args:
- name: The name, e.g. 'Pattern'.
- type_var: The type parameter, e.g. AnyStr, or the
- specific type, e.g. str.
- impl_type: The implementation type.
- type_checker: Function that takes an impl_type instance.
- and returns a value that should be a type_var instance.
- """
- assert isinstance(name, basestring), repr(name)
- assert isinstance(impl_type, type), repr(impl_type)
- assert not isinstance(impl_type, TypingMeta), repr(impl_type)
- assert isinstance(type_var, (type, _TypingBase)), repr(type_var)
- self.name = name
- self.type_var = type_var
- self.impl_type = impl_type
- self.type_checker = type_checker
-
- def __repr__(self):
- return "%s[%s]" % (self.name, _type_repr(self.type_var))
-
- def __getitem__(self, parameter):
- if not isinstance(self.type_var, TypeVar):
- raise TypeError("%s cannot be further parameterized." % self)
- if self.type_var.__constraints__ and isinstance(parameter, type):
- if not issubclass(parameter, self.type_var.__constraints__):
- raise TypeError("%s is not a valid substitution for %s." %
- (parameter, self.type_var))
- if isinstance(parameter, TypeVar) and parameter is not self.type_var:
- raise TypeError("%s cannot be re-parameterized." % self)
- return self.__class__(self.name, parameter,
- self.impl_type, self.type_checker)
-
- def __eq__(self, other):
- if not isinstance(other, _TypeAlias):
- return NotImplemented
- return self.name == other.name and self.type_var == other.type_var
-
- def __hash__(self):
- return hash((self.name, self.type_var))
-
- def __instancecheck__(self, obj):
- if not isinstance(self.type_var, TypeVar):
- raise TypeError("Parameterized type aliases cannot be used "
- "with isinstance().")
- return isinstance(obj, self.impl_type)
-
- def __subclasscheck__(self, cls):
- if not isinstance(self.type_var, TypeVar):
- raise TypeError("Parameterized type aliases cannot be used "
- "with issubclass().")
- return issubclass(cls, self.impl_type)
-
-
-def _get_type_vars(types, tvars):
- for t in types:
- if isinstance(t, TypingMeta) or isinstance(t, _TypingBase):
- t._get_type_vars(tvars)
-
-
-def _type_vars(types):
- tvars = []
- _get_type_vars(types, tvars)
- return tuple(tvars)
-
-
-def _eval_type(t, globalns, localns):
- if isinstance(t, TypingMeta) or isinstance(t, _TypingBase):
- return t._eval_type(globalns, localns)
- return t
-
-
-def _type_check(arg, msg):
- """Check that the argument is a type, and return it (internal helper).
-
- As a special case, accept None and return type(None) instead.
- Also, _TypeAlias instances (e.g. Match, Pattern) are acceptable.
-
- The msg argument is a human-readable error message, e.g.
-
- "Union[arg, ...]: arg should be a type."
-
- We append the repr() of the actual value (truncated to 100 chars).
- """
- if arg is None:
- return type(None)
- if isinstance(arg, basestring):
- arg = _ForwardRef(arg)
- if (
- isinstance(arg, _TypingBase) and type(arg).__name__ == '_ClassVar' or
- not isinstance(arg, (type, _TypingBase)) and not callable(arg)
- ):
- raise TypeError(msg + " Got %.100r." % (arg,))
- # Bare Union etc. are not valid as type arguments
- if (
- type(arg).__name__ in ('_Union', '_Optional') and
- not getattr(arg, '__origin__', None) or
- isinstance(arg, TypingMeta) and arg._gorg in (Generic, Protocol)
- ):
- raise TypeError("Plain %s is not valid as type argument" % arg)
- return arg
-
-
-def _type_repr(obj):
- """Return the repr() of an object, special-casing types (internal helper).
-
- If obj is a type, we return a shorter version than the default
- type.__repr__, based on the module and qualified name, which is
- typically enough to uniquely identify a type. For everything
- else, we fall back on repr(obj).
- """
- if isinstance(obj, type) and not isinstance(obj, TypingMeta):
- if obj.__module__ == '__builtin__':
- return _qualname(obj)
- return '%s.%s' % (obj.__module__, _qualname(obj))
- if obj is Ellipsis:
- return '...'
- if isinstance(obj, types.FunctionType):
- return obj.__name__
- return repr(obj)
-
-
-class ClassVarMeta(TypingMeta):
- """Metaclass for _ClassVar"""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- self = super(ClassVarMeta, cls).__new__(cls, name, bases, namespace)
- return self
-
-
-class _ClassVar(_FinalTypingBase):
- """Special type construct to mark class variables.
-
- An annotation wrapped in ClassVar indicates that a given
- attribute is intended to be used as a class variable and
- should not be set on instances of that class. Usage::
-
- class Starship:
- stats = {} # type: ClassVar[Dict[str, int]] # class variable
- damage = 10 # type: int # instance variable
-
- ClassVar accepts only types and cannot be further subscribed.
-
- Note that ClassVar is not a class itself, and should not
- be used with isinstance() or issubclass().
- """
-
- __metaclass__ = ClassVarMeta
- __slots__ = ('__type__',)
-
- def __init__(self, tp=None, _root=False):
- self.__type__ = tp
-
- def __getitem__(self, item):
- cls = type(self)
- if self.__type__ is None:
- return cls(_type_check(item,
- '{} accepts only types.'.format(cls.__name__[1:])),
- _root=True)
- raise TypeError('{} cannot be further subscripted'
- .format(cls.__name__[1:]))
-
- def _eval_type(self, globalns, localns):
- return type(self)(_eval_type(self.__type__, globalns, localns),
- _root=True)
-
- def __repr__(self):
- r = super(_ClassVar, self).__repr__()
- if self.__type__ is not None:
- r += '[{}]'.format(_type_repr(self.__type__))
- return r
-
- def __hash__(self):
- return hash((type(self).__name__, self.__type__))
-
- def __eq__(self, other):
- if not isinstance(other, _ClassVar):
- return NotImplemented
- if self.__type__ is not None:
- return self.__type__ == other.__type__
- return self is other
-
-
-ClassVar = _ClassVar(_root=True)
-
-
-class _FinalMeta(TypingMeta):
- """Metaclass for _Final"""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- self = super(_FinalMeta, cls).__new__(cls, name, bases, namespace)
- return self
-
-
-class _Final(_FinalTypingBase):
- """A special typing construct to indicate that a name
- cannot be re-assigned or overridden in a subclass.
- For example:
-
- MAX_SIZE: Final = 9000
- MAX_SIZE += 1 # Error reported by type checker
-
- class Connection:
- TIMEOUT: Final[int] = 10
- class FastConnector(Connection):
- TIMEOUT = 1 # Error reported by type checker
-
- There is no runtime checking of these properties.
- """
-
- __metaclass__ = _FinalMeta
- __slots__ = ('__type__',)
-
- def __init__(self, tp=None, **kwds):
- self.__type__ = tp
-
- def __getitem__(self, item):
- cls = type(self)
- if self.__type__ is None:
- return cls(_type_check(item,
- '{} accepts only single type.'.format(cls.__name__[1:])),
- _root=True)
- raise TypeError('{} cannot be further subscripted'
- .format(cls.__name__[1:]))
-
- def _eval_type(self, globalns, localns):
- new_tp = _eval_type(self.__type__, globalns, localns)
- if new_tp == self.__type__:
- return self
- return type(self)(new_tp, _root=True)
-
- def __repr__(self):
- r = super(_Final, self).__repr__()
- if self.__type__ is not None:
- r += '[{}]'.format(_type_repr(self.__type__))
- return r
-
- def __hash__(self):
- return hash((type(self).__name__, self.__type__))
-
- def __eq__(self, other):
- if not isinstance(other, _Final):
- return NotImplemented
- if self.__type__ is not None:
- return self.__type__ == other.__type__
- return self is other
-
-
-Final = _Final(_root=True)
-
-
-def final(f):
- """This decorator can be used to indicate to type checkers that
- the decorated method cannot be overridden, and decorated class
- cannot be subclassed. For example:
-
- class Base:
- @final
- def done(self) -> None:
- ...
- class Sub(Base):
- def done(self) -> None: # Error reported by type checker
- ...
- @final
- class Leaf:
- ...
- class Other(Leaf): # Error reported by type checker
- ...
-
- There is no runtime checking of these properties.
- """
- return f
-
-
-class _LiteralMeta(TypingMeta):
- """Metaclass for _Literal"""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- self = super(_LiteralMeta, cls).__new__(cls, name, bases, namespace)
- return self
-
-
-class _Literal(_FinalTypingBase):
- """A type that can be used to indicate to type checkers that the
- corresponding value has a value literally equivalent to the
- provided parameter. For example:
-
- var: Literal[4] = 4
-
- The type checker understands that 'var' is literally equal to the
- value 4 and no other value.
-
- Literal[...] cannot be subclassed. There is no runtime checking
- verifying that the parameter is actually a value instead of a type.
- """
-
- __metaclass__ = _LiteralMeta
- __slots__ = ('__values__',)
-
- def __init__(self, values=None, **kwds):
- self.__values__ = values
-
- def __getitem__(self, item):
- cls = type(self)
- if self.__values__ is None:
- if not isinstance(item, tuple):
- item = (item,)
- return cls(values=item,
- _root=True)
- raise TypeError('{} cannot be further subscripted'
- .format(cls.__name__[1:]))
-
- def _eval_type(self, globalns, localns):
- return self
-
- def __repr__(self):
- r = super(_Literal, self).__repr__()
- if self.__values__ is not None:
- r += '[{}]'.format(', '.join(map(_type_repr, self.__values__)))
- return r
-
- def __hash__(self):
- return hash((type(self).__name__, self.__values__))
-
- def __eq__(self, other):
- if not isinstance(other, _Literal):
- return NotImplemented
- if self.__values__ is not None:
- return self.__values__ == other.__values__
- return self is other
-
-
-Literal = _Literal(_root=True)
-
-
-class AnyMeta(TypingMeta):
- """Metaclass for Any."""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- self = super(AnyMeta, cls).__new__(cls, name, bases, namespace)
- return self
-
-
-class _Any(_FinalTypingBase):
- """Special type indicating an unconstrained type.
-
- - Any is compatible with every type.
- - Any assumed to have all methods.
- - All values assumed to be instances of Any.
-
- Note that all the above statements are true from the point of view of
- static type checkers. At runtime, Any should not be used with instance
- or class checks.
- """
- __metaclass__ = AnyMeta
- __slots__ = ()
-
- def __instancecheck__(self, obj):
- raise TypeError("Any cannot be used with isinstance().")
-
- def __subclasscheck__(self, cls):
- raise TypeError("Any cannot be used with issubclass().")
-
-
-Any = _Any(_root=True)
-
-
-class NoReturnMeta(TypingMeta):
- """Metaclass for NoReturn."""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- self = super(NoReturnMeta, cls).__new__(cls, name, bases, namespace)
- return self
-
-
-class _NoReturn(_FinalTypingBase):
- """Special type indicating functions that never return.
- Example::
-
- from typing import NoReturn
-
- def stop() -> NoReturn:
- raise Exception('no way')
-
- This type is invalid in other positions, e.g., ``List[NoReturn]``
- will fail in static type checkers.
- """
- __metaclass__ = NoReturnMeta
- __slots__ = ()
-
- def __instancecheck__(self, obj):
- raise TypeError("NoReturn cannot be used with isinstance().")
-
- def __subclasscheck__(self, cls):
- raise TypeError("NoReturn cannot be used with issubclass().")
-
-
-NoReturn = _NoReturn(_root=True)
-
-
-class TypeVarMeta(TypingMeta):
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- return super(TypeVarMeta, cls).__new__(cls, name, bases, namespace)
-
-
-class TypeVar(_TypingBase):
- """Type variable.
-
- Usage::
-
- T = TypeVar('T') # Can be anything
- A = TypeVar('A', str, bytes) # Must be str or bytes
-
- Type variables exist primarily for the benefit of static type
- checkers. They serve as the parameters for generic types as well
- as for generic function definitions. See class Generic for more
- information on generic types. Generic functions work as follows:
-
- def repeat(x: T, n: int) -> List[T]:
- '''Return a list containing n references to x.'''
- return [x]*n
-
- def longest(x: A, y: A) -> A:
- '''Return the longest of two strings.'''
- return x if len(x) >= len(y) else y
-
- The latter example's signature is essentially the overloading
- of (str, str) -> str and (bytes, bytes) -> bytes. Also note
- that if the arguments are instances of some subclass of str,
- the return type is still plain str.
-
- At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError.
-
- Type variables defined with covariant=True or contravariant=True
- can be used do declare covariant or contravariant generic types.
- See PEP 484 for more details. By default generic types are invariant
- in all type variables.
-
- Type variables can be introspected. e.g.:
-
- T.__name__ == 'T'
- T.__constraints__ == ()
- T.__covariant__ == False
- T.__contravariant__ = False
- A.__constraints__ == (str, bytes)
- """
-
- __metaclass__ = TypeVarMeta
- __slots__ = ('__name__', '__bound__', '__constraints__',
- '__covariant__', '__contravariant__')
-
- def __init__(self, name, *constraints, **kwargs):
- super(TypeVar, self).__init__(name, *constraints, **kwargs)
- bound = kwargs.get('bound', None)
- covariant = kwargs.get('covariant', False)
- contravariant = kwargs.get('contravariant', False)
- self.__name__ = name
- if covariant and contravariant:
- raise ValueError("Bivariant types are not supported.")
- self.__covariant__ = bool(covariant)
- self.__contravariant__ = bool(contravariant)
- if constraints and bound is not None:
- raise TypeError("Constraints cannot be combined with bound=...")
- if constraints and len(constraints) == 1:
- raise TypeError("A single constraint is not allowed")
- msg = "TypeVar(name, constraint, ...): constraints must be types."
- self.__constraints__ = tuple(_type_check(t, msg) for t in constraints)
- if bound:
- self.__bound__ = _type_check(bound, "Bound must be a type.")
- else:
- self.__bound__ = None
-
- def _get_type_vars(self, tvars):
- if self not in tvars:
- tvars.append(self)
-
- def __repr__(self):
- if self.__covariant__:
- prefix = '+'
- elif self.__contravariant__:
- prefix = '-'
- else:
- prefix = '~'
- return prefix + self.__name__
-
- def __instancecheck__(self, instance):
- raise TypeError("Type variables cannot be used with isinstance().")
-
- def __subclasscheck__(self, cls):
- raise TypeError("Type variables cannot be used with issubclass().")
-
-
-# Some unconstrained type variables. These are used by the container types.
-# (These are not for export.)
-T = TypeVar('T') # Any type.
-KT = TypeVar('KT') # Key type.
-VT = TypeVar('VT') # Value type.
-T_co = TypeVar('T_co', covariant=True) # Any type covariant containers.
-V_co = TypeVar('V_co', covariant=True) # Any type covariant containers.
-VT_co = TypeVar('VT_co', covariant=True) # Value type covariant containers.
-T_contra = TypeVar('T_contra', contravariant=True) # Ditto contravariant.
-
-# A useful type variable with constraints. This represents string types.
-# (This one *is* for export!)
-AnyStr = TypeVar('AnyStr', bytes, unicode)
-
-
-def _replace_arg(arg, tvars, args):
- """An internal helper function: replace arg if it is a type variable
- found in tvars with corresponding substitution from args or
- with corresponding substitution sub-tree if arg is a generic type.
- """
-
- if tvars is None:
- tvars = []
- if hasattr(arg, '_subs_tree') and isinstance(arg, (GenericMeta, _TypingBase)):
- return arg._subs_tree(tvars, args)
- if isinstance(arg, TypeVar):
- for i, tvar in enumerate(tvars):
- if arg == tvar:
- return args[i]
- return arg
-
-
-# Special typing constructs Union, Optional, Generic, Callable and Tuple
-# use three special attributes for internal bookkeeping of generic types:
-# * __parameters__ is a tuple of unique free type parameters of a generic
-# type, for example, Dict[T, T].__parameters__ == (T,);
-# * __origin__ keeps a reference to a type that was subscripted,
-# e.g., Union[T, int].__origin__ == Union;
-# * __args__ is a tuple of all arguments used in subscripting,
-# e.g., Dict[T, int].__args__ == (T, int).
-
-
-def _subs_tree(cls, tvars=None, args=None):
- """An internal helper function: calculate substitution tree
- for generic cls after replacing its type parameters with
- substitutions in tvars -> args (if any).
- Repeat the same following __origin__'s.
-
- Return a list of arguments with all possible substitutions
- performed. Arguments that are generic classes themselves are represented
- as tuples (so that no new classes are created by this function).
- For example: _subs_tree(List[Tuple[int, T]][str]) == [(Tuple, int, str)]
- """
-
- if cls.__origin__ is None:
- return cls
- # Make of chain of origins (i.e. cls -> cls.__origin__)
- current = cls.__origin__
- orig_chain = []
- while current.__origin__ is not None:
- orig_chain.append(current)
- current = current.__origin__
- # Replace type variables in __args__ if asked ...
- tree_args = []
- for arg in cls.__args__:
- tree_args.append(_replace_arg(arg, tvars, args))
- # ... then continue replacing down the origin chain.
- for ocls in orig_chain:
- new_tree_args = []
- for arg in ocls.__args__:
- new_tree_args.append(_replace_arg(arg, ocls.__parameters__, tree_args))
- tree_args = new_tree_args
- return tree_args
-
-
-def _remove_dups_flatten(parameters):
- """An internal helper for Union creation and substitution: flatten Union's
- among parameters, then remove duplicates and strict subclasses.
- """
-
- # Flatten out Union[Union[...], ...].
- params = []
- for p in parameters:
- if isinstance(p, _Union) and p.__origin__ is Union:
- params.extend(p.__args__)
- elif isinstance(p, tuple) and len(p) > 0 and p[0] is Union:
- params.extend(p[1:])
- else:
- params.append(p)
- # Weed out strict duplicates, preserving the first of each occurrence.
- all_params = set(params)
- if len(all_params) < len(params):
- new_params = []
- for t in params:
- if t in all_params:
- new_params.append(t)
- all_params.remove(t)
- params = new_params
- assert not all_params, all_params
- # Weed out subclasses.
- # E.g. Union[int, Employee, Manager] == Union[int, Employee].
- # If object is present it will be sole survivor among proper classes.
- # Never discard type variables.
- # (In particular, Union[str, AnyStr] != AnyStr.)
- all_params = set(params)
- for t1 in params:
- if not isinstance(t1, type):
- continue
- if any(isinstance(t2, type) and issubclass(t1, t2)
- for t2 in all_params - {t1}
- if not (isinstance(t2, GenericMeta) and
- t2.__origin__ is not None)):
- all_params.remove(t1)
- return tuple(t for t in params if t in all_params)
-
-
-def _check_generic(cls, parameters):
- # Check correct count for parameters of a generic cls (internal helper).
- if not cls.__parameters__:
- raise TypeError("%s is not a generic class" % repr(cls))
- alen = len(parameters)
- elen = len(cls.__parameters__)
- if alen != elen:
- raise TypeError("Too %s parameters for %s; actual %s, expected %s" %
- ("many" if alen > elen else "few", repr(cls), alen, elen))
-
-
-_cleanups = []
-
-
-def _tp_cache(func):
- maxsize = 128
- cache = {}
- _cleanups.append(cache.clear)
-
- @functools.wraps(func)
- def inner(*args):
- key = args
- try:
- return cache[key]
- except TypeError:
- # Assume it's an unhashable argument.
- return func(*args)
- except KeyError:
- value = func(*args)
- if len(cache) >= maxsize:
- # If the cache grows too much, just start over.
- cache.clear()
- cache[key] = value
- return value
-
- return inner
-
-
-class UnionMeta(TypingMeta):
- """Metaclass for Union."""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- return super(UnionMeta, cls).__new__(cls, name, bases, namespace)
-
-
-class _Union(_FinalTypingBase):
- """Union type; Union[X, Y] means either X or Y.
-
- To define a union, use e.g. Union[int, str]. Details:
-
- - The arguments must be types and there must be at least one.
-
- - None as an argument is a special case and is replaced by
- type(None).
-
- - Unions of unions are flattened, e.g.::
-
- Union[Union[int, str], float] == Union[int, str, float]
-
- - Unions of a single argument vanish, e.g.::
-
- Union[int] == int # The constructor actually returns int
-
- - Redundant arguments are skipped, e.g.::
-
- Union[int, str, int] == Union[int, str]
-
- - When comparing unions, the argument order is ignored, e.g.::
-
- Union[int, str] == Union[str, int]
-
- - When two arguments have a subclass relationship, the least
- derived argument is kept, e.g.::
-
- class Employee: pass
- class Manager(Employee): pass
- Union[int, Employee, Manager] == Union[int, Employee]
- Union[Manager, int, Employee] == Union[int, Employee]
- Union[Employee, Manager] == Employee
-
- - Similar for object::
-
- Union[int, object] == object
-
- - You cannot subclass or instantiate a union.
-
- - You can use Optional[X] as a shorthand for Union[X, None].
- """
-
- __metaclass__ = UnionMeta
- __slots__ = ('__parameters__', '__args__', '__origin__', '__tree_hash__')
-
- def __new__(cls, parameters=None, origin=None, *args, **kwds):
- self = super(_Union, cls).__new__(cls, parameters, origin, *args, **kwds)
- if origin is None:
- self.__parameters__ = None
- self.__args__ = None
- self.__origin__ = None
- self.__tree_hash__ = hash(frozenset(('Union',)))
- return self
- if not isinstance(parameters, tuple):
- raise TypeError("Expected parameters=<tuple>")
- if origin is Union:
- parameters = _remove_dups_flatten(parameters)
- # It's not a union if there's only one type left.
- if len(parameters) == 1:
- return parameters[0]
- self.__parameters__ = _type_vars(parameters)
- self.__args__ = parameters
- self.__origin__ = origin
- # Pre-calculate the __hash__ on instantiation.
- # This improves speed for complex substitutions.
- subs_tree = self._subs_tree()
- if isinstance(subs_tree, tuple):
- self.__tree_hash__ = hash(frozenset(subs_tree))
- else:
- self.__tree_hash__ = hash(subs_tree)
- return self
-
- def _eval_type(self, globalns, localns):
- if self.__args__ is None:
- return self
- ev_args = tuple(_eval_type(t, globalns, localns) for t in self.__args__)
- ev_origin = _eval_type(self.__origin__, globalns, localns)
- if ev_args == self.__args__ and ev_origin == self.__origin__:
- # Everything is already evaluated.
- return self
- return self.__class__(ev_args, ev_origin, _root=True)
-
- def _get_type_vars(self, tvars):
- if self.__origin__ and self.__parameters__:
- _get_type_vars(self.__parameters__, tvars)
-
- def __repr__(self):
- if self.__origin__ is None:
- return super(_Union, self).__repr__()
- tree = self._subs_tree()
- if not isinstance(tree, tuple):
- return repr(tree)
- return tree[0]._tree_repr(tree)
-
- def _tree_repr(self, tree):
- arg_list = []
- for arg in tree[1:]:
- if not isinstance(arg, tuple):
- arg_list.append(_type_repr(arg))
- else:
- arg_list.append(arg[0]._tree_repr(arg))
- return super(_Union, self).__repr__() + '[%s]' % ', '.join(arg_list)
-
- @_tp_cache
- def __getitem__(self, parameters):
- if parameters == ():
- raise TypeError("Cannot take a Union of no types.")
- if not isinstance(parameters, tuple):
- parameters = (parameters,)
- if self.__origin__ is None:
- msg = "Union[arg, ...]: each arg must be a type."
- else:
- msg = "Parameters to generic types must be types."
- parameters = tuple(_type_check(p, msg) for p in parameters)
- if self is not Union:
- _check_generic(self, parameters)
- return self.__class__(parameters, origin=self, _root=True)
-
- def _subs_tree(self, tvars=None, args=None):
- if self is Union:
- return Union # Nothing to substitute
- tree_args = _subs_tree(self, tvars, args)
- tree_args = _remove_dups_flatten(tree_args)
- if len(tree_args) == 1:
- return tree_args[0] # Union of a single type is that type
- return (Union,) + tree_args
-
- def __eq__(self, other):
- if isinstance(other, _Union):
- return self.__tree_hash__ == other.__tree_hash__
- elif self is not Union:
- return self._subs_tree() == other
- else:
- return self is other
-
- def __hash__(self):
- return self.__tree_hash__
-
- def __instancecheck__(self, obj):
- raise TypeError("Unions cannot be used with isinstance().")
-
- def __subclasscheck__(self, cls):
- raise TypeError("Unions cannot be used with issubclass().")
-
-
-Union = _Union(_root=True)
-
-
-class OptionalMeta(TypingMeta):
- """Metaclass for Optional."""
-
- def __new__(cls, name, bases, namespace):
- cls.assert_no_subclassing(bases)
- return super(OptionalMeta, cls).__new__(cls, name, bases, namespace)
-
-
-class _Optional(_FinalTypingBase):
- """Optional type.
-
- Optional[X] is equivalent to Union[X, None].
- """
-
- __metaclass__ = OptionalMeta
- __slots__ = ()
-
- @_tp_cache
- def __getitem__(self, arg):
- arg = _type_check(arg, "Optional[t] requires a single type.")
- return Union[arg, type(None)]
-
-
-Optional = _Optional(_root=True)
-
-
-def _next_in_mro(cls):
- """Helper for Generic.__new__.
-
- Returns the class after the last occurrence of Generic or
- Generic[...] in cls.__mro__.
- """
- next_in_mro = object
- # Look for the last occurrence of Generic or Generic[...].
- for i, c in enumerate(cls.__mro__[:-1]):
- if isinstance(c, GenericMeta) and c._gorg is Generic:
- next_in_mro = cls.__mro__[i + 1]
- return next_in_mro
-
-
-def _make_subclasshook(cls):
- """Construct a __subclasshook__ callable that incorporates
- the associated __extra__ class in subclass checks performed
- against cls.
- """
- if isinstance(cls.__extra__, abc.ABCMeta):
- # The logic mirrors that of ABCMeta.__subclasscheck__.
- # Registered classes need not be checked here because
- # cls and its extra share the same _abc_registry.
- def __extrahook__(cls, subclass):
- res = cls.__extra__.__subclasshook__(subclass)
- if res is not NotImplemented:
- return res
- if cls.__extra__ in getattr(subclass, '__mro__', ()):
- return True
- for scls in cls.__extra__.__subclasses__():
- if isinstance(scls, GenericMeta):
- continue
- if issubclass(subclass, scls):
- return True
- return NotImplemented
- else:
- # For non-ABC extras we'll just call issubclass().
- def __extrahook__(cls, subclass):
- if cls.__extra__ and issubclass(subclass, cls.__extra__):
- return True
- return NotImplemented
- return classmethod(__extrahook__)
-
-
-class GenericMeta(TypingMeta, abc.ABCMeta):
- """Metaclass for generic types.
-
- This is a metaclass for typing.Generic and generic ABCs defined in
- typing module. User defined subclasses of GenericMeta can override
- __new__ and invoke super().__new__. Note that GenericMeta.__new__
- has strict rules on what is allowed in its bases argument:
- * plain Generic is disallowed in bases;
- * Generic[...] should appear in bases at most once;
- * if Generic[...] is present, then it should list all type variables
- that appear in other bases.
- In addition, type of all generic bases is erased, e.g., C[int] is
- stripped to plain C.
- """
-
- def __new__(cls, name, bases, namespace,
- tvars=None, args=None, origin=None, extra=None, orig_bases=None):
- """Create a new generic class. GenericMeta.__new__ accepts
- keyword arguments that are used for internal bookkeeping, therefore
- an override should pass unused keyword arguments to super().
- """
- if tvars is not None:
- # Called from __getitem__() below.
- assert origin is not None
- assert all(isinstance(t, TypeVar) for t in tvars), tvars
- else:
- # Called from class statement.
- assert tvars is None, tvars
- assert args is None, args
- assert origin is None, origin
-
- # Get the full set of tvars from the bases.
- tvars = _type_vars(bases)
- # Look for Generic[T1, ..., Tn].
- # If found, tvars must be a subset of it.
- # If not found, tvars is it.
- # Also check for and reject plain Generic,
- # and reject multiple Generic[...].
- gvars = None
- for base in bases:
- if base is Generic:
- raise TypeError("Cannot inherit from plain Generic")
- if (isinstance(base, GenericMeta) and
- base.__origin__ in (Generic, Protocol)):
- if gvars is not None:
- raise TypeError(
- "Cannot inherit from Generic[...] or"
- " Protocol[...] multiple times.")
- gvars = base.__parameters__
- if gvars is None:
- gvars = tvars
- else:
- tvarset = set(tvars)
- gvarset = set(gvars)
- if not tvarset <= gvarset:
- raise TypeError(
- "Some type variables (%s) "
- "are not listed in %s[%s]" %
- (", ".join(str(t) for t in tvars if t not in gvarset),
- "Generic" if any(b.__origin__ is Generic
- for b in bases) else "Protocol",
- ", ".join(str(g) for g in gvars)))
- tvars = gvars
-
- initial_bases = bases
- if extra is None:
- extra = namespace.get('__extra__')
- if extra is not None and type(extra) is abc.ABCMeta and extra not in bases:
- bases = (extra,) + bases
- bases = tuple(b._gorg if isinstance(b, GenericMeta) else b for b in bases)
-
- # remove bare Generic from bases if there are other generic bases
- if any(isinstance(b, GenericMeta) and b is not Generic for b in bases):
- bases = tuple(b for b in bases if b is not Generic)
- namespace.update({'__origin__': origin, '__extra__': extra})
- self = super(GenericMeta, cls).__new__(cls, name, bases, namespace)
- super(GenericMeta, self).__setattr__('_gorg',
- self if not origin else origin._gorg)
-
- self.__parameters__ = tvars
- # Be prepared that GenericMeta will be subclassed by TupleMeta
- # and CallableMeta, those two allow ..., (), or [] in __args___.
- self.__args__ = tuple(Ellipsis if a is _TypingEllipsis else
- () if a is _TypingEmpty else
- a for a in args) if args else None
- # Speed hack (https://github.com/python/typing/issues/196).
- self.__next_in_mro__ = _next_in_mro(self)
- # Preserve base classes on subclassing (__bases__ are type erased now).
- if orig_bases is None:
- self.__orig_bases__ = initial_bases
-
- # This allows unparameterized generic collections to be used
- # with issubclass() and isinstance() in the same way as their
- # collections.abc counterparts (e.g., isinstance([], Iterable)).
- if (
- '__subclasshook__' not in namespace and extra or
- # allow overriding
- getattr(self.__subclasshook__, '__name__', '') == '__extrahook__'
- ):
- self.__subclasshook__ = _make_subclasshook(self)
-
- if origin and hasattr(origin, '__qualname__'): # Fix for Python 3.2.
- self.__qualname__ = origin.__qualname__
- self.__tree_hash__ = (hash(self._subs_tree()) if origin else
- super(GenericMeta, self).__hash__())
- return self
-
- def __init__(self, *args, **kwargs):
- super(GenericMeta, self).__init__(*args, **kwargs)
- if isinstance(self.__extra__, abc.ABCMeta):
- self._abc_registry = self.__extra__._abc_registry
- self._abc_cache = self.__extra__._abc_cache
- elif self.__origin__ is not None:
- self._abc_registry = self.__origin__._abc_registry
- self._abc_cache = self.__origin__._abc_cache
-
- # _abc_negative_cache and _abc_negative_cache_version
- # realized as descriptors, since GenClass[t1, t2, ...] always
- # share subclass info with GenClass.
- # This is an important memory optimization.
- @property
- def _abc_negative_cache(self):
- if isinstance(self.__extra__, abc.ABCMeta):
- return self.__extra__._abc_negative_cache
- return self._gorg._abc_generic_negative_cache
-
- @_abc_negative_cache.setter
- def _abc_negative_cache(self, value):
- if self.__origin__ is None:
- if isinstance(self.__extra__, abc.ABCMeta):
- self.__extra__._abc_negative_cache = value
- else:
- self._abc_generic_negative_cache = value
-
- @property
- def _abc_negative_cache_version(self):
- if isinstance(self.__extra__, abc.ABCMeta):
- return self.__extra__._abc_negative_cache_version
- return self._gorg._abc_generic_negative_cache_version
-
- @_abc_negative_cache_version.setter
- def _abc_negative_cache_version(self, value):
- if self.__origin__ is None:
- if isinstance(self.__extra__, abc.ABCMeta):
- self.__extra__._abc_negative_cache_version = value
- else:
- self._abc_generic_negative_cache_version = value
-
- def _get_type_vars(self, tvars):
- if self.__origin__ and self.__parameters__:
- _get_type_vars(self.__parameters__, tvars)
-
- def _eval_type(self, globalns, localns):
- ev_origin = (self.__origin__._eval_type(globalns, localns)
- if self.__origin__ else None)
- ev_args = tuple(_eval_type(a, globalns, localns) for a
- in self.__args__) if self.__args__ else None
- if ev_origin == self.__origin__ and ev_args == self.__args__:
- return self
- return self.__class__(self.__name__,
- self.__bases__,
- dict(self.__dict__),
- tvars=_type_vars(ev_args) if ev_args else None,
- args=ev_args,
- origin=ev_origin,
- extra=self.__extra__,
- orig_bases=self.__orig_bases__)
-
- def __repr__(self):
- if self.__origin__ is None:
- return super(GenericMeta, self).__repr__()
- return self._tree_repr(self._subs_tree())
-
- def _tree_repr(self, tree):
- arg_list = []
- for arg in tree[1:]:
- if arg == ():
- arg_list.append('()')
- elif not isinstance(arg, tuple):
- arg_list.append(_type_repr(arg))
- else:
- arg_list.append(arg[0]._tree_repr(arg))
- return super(GenericMeta, self).__repr__() + '[%s]' % ', '.join(arg_list)
-
- def _subs_tree(self, tvars=None, args=None):
- if self.__origin__ is None:
- return self
- tree_args = _subs_tree(self, tvars, args)
- return (self._gorg,) + tuple(tree_args)
-
- def __eq__(self, other):
- if not isinstance(other, GenericMeta):
- return NotImplemented
- if self.__origin__ is None or other.__origin__ is None:
- return self is other
- return self.__tree_hash__ == other.__tree_hash__
-
- def __hash__(self):
- return self.__tree_hash__
-
- @_tp_cache
- def __getitem__(self, params):
- if not isinstance(params, tuple):
- params = (params,)
- if not params and self._gorg is not Tuple:
- raise TypeError(
- "Parameter list to %s[...] cannot be empty" % _qualname(self))
- msg = "Parameters to generic types must be types."
- params = tuple(_type_check(p, msg) for p in params)
- if self in (Generic, Protocol):
- # Generic can only be subscripted with unique type variables.
- if not all(isinstance(p, TypeVar) for p in params):
- raise TypeError(
- "Parameters to %s[...] must all be type variables" % self.__name__)
- if len(set(params)) != len(params):
- raise TypeError(
- "Parameters to %s[...] must all be unique" % self.__name__)
- tvars = params
- args = params
- elif self in (Tuple, Callable):
- tvars = _type_vars(params)
- args = params
- elif self.__origin__ in (Generic, Protocol):
- # Can't subscript Generic[...] or Protocol[...].
- raise TypeError("Cannot subscript already-subscripted %s" %
- repr(self))
- else:
- # Subscripting a regular Generic subclass.
- _check_generic(self, params)
- tvars = _type_vars(params)
- args = params
-
- prepend = (self,) if self.__origin__ is None else ()
- return self.__class__(self.__name__,
- prepend + self.__bases__,
- dict(self.__dict__),
- tvars=tvars,
- args=args,
- origin=self,
- extra=self.__extra__,
- orig_bases=self.__orig_bases__)
-
- def __subclasscheck__(self, cls):
- if self.__origin__ is not None:
- # This should only be modules within the standard
- # library. singledispatch is the only exception, because
- # it's a Python 2 backport of functools.singledispatch.
- if sys._getframe(1).f_globals['__name__'] not in ['abc', 'functools',
- 'singledispatch']:
- raise TypeError("Parameterized generics cannot be used with class "
- "or instance checks")
- return False
- if self is Generic:
- raise TypeError("Class %r cannot be used with class "
- "or instance checks" % self)
- return super(GenericMeta, self).__subclasscheck__(cls)
-
- def __instancecheck__(self, instance):
- # Since we extend ABC.__subclasscheck__ and
- # ABC.__instancecheck__ inlines the cache checking done by the
- # latter, we must extend __instancecheck__ too. For simplicity
- # we just skip the cache check -- instance checks for generic
- # classes are supposed to be rare anyways.
- if hasattr(instance, "__class__"):
- return issubclass(instance.__class__, self)
- return False
-
- def __setattr__(self, attr, value):
- # We consider all the subscripted genrics as proxies for original class
- if (
- attr.startswith('__') and attr.endswith('__') or
- attr.startswith('_abc_')
- ):
- super(GenericMeta, self).__setattr__(attr, value)
- else:
- super(GenericMeta, self._gorg).__setattr__(attr, value)
-
-
-def _copy_generic(self):
- """Hack to work around https://bugs.python.org/issue11480 on Python 2"""
- return self.__class__(self.__name__, self.__bases__, dict(self.__dict__),
- self.__parameters__, self.__args__, self.__origin__,
- self.__extra__, self.__orig_bases__)
-
-
-copy._copy_dispatch[GenericMeta] = _copy_generic
-
-
-# Prevent checks for Generic to crash when defining Generic.
-Generic = None
-
-
-def _generic_new(base_cls, cls, *args, **kwds):
- # Assure type is erased on instantiation,
- # but attempt to store it in __orig_class__
- if cls.__origin__ is None:
- if (base_cls.__new__ is object.__new__ and
- cls.__init__ is not object.__init__):
- return base_cls.__new__(cls)
- else:
- return base_cls.__new__(cls, *args, **kwds)
- else:
- origin = cls._gorg
- if (base_cls.__new__ is object.__new__ and
- cls.__init__ is not object.__init__):
- obj = base_cls.__new__(origin)
- else:
- obj = base_cls.__new__(origin, *args, **kwds)
- try:
- obj.__orig_class__ = cls
- except AttributeError:
- pass
- obj.__init__(*args, **kwds)
- return obj
-
-
-class Generic(object):
- """Abstract base class for generic types.
-
- A generic type is typically declared by inheriting from
- this class parameterized with one or more type variables.
- For example, a generic mapping type might be defined as::
-
- class Mapping(Generic[KT, VT]):
- def __getitem__(self, key: KT) -> VT:
- ...
- # Etc.
-
- This class can then be used as follows::
-
- def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
- try:
- return mapping[key]
- except KeyError:
- return default
- """
-
- __metaclass__ = GenericMeta
- __slots__ = ()
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Generic:
- raise TypeError("Type Generic cannot be instantiated; "
- "it can be used only as a base class")
- return _generic_new(cls.__next_in_mro__, cls, *args, **kwds)
-
-
-class _TypingEmpty(object):
- """Internal placeholder for () or []. Used by TupleMeta and CallableMeta
- to allow empty list/tuple in specific places, without allowing them
- to sneak in where prohibited.
- """
-
-
-class _TypingEllipsis(object):
- """Internal placeholder for ... (ellipsis)."""
-
-
-class TupleMeta(GenericMeta):
- """Metaclass for Tuple (internal)."""
-
- @_tp_cache
- def __getitem__(self, parameters):
- if self.__origin__ is not None or self._gorg is not Tuple:
- # Normal generic rules apply if this is not the first subscription
- # or a subscription of a subclass.
- return super(TupleMeta, self).__getitem__(parameters)
- if parameters == ():
- return super(TupleMeta, self).__getitem__((_TypingEmpty,))
- if not isinstance(parameters, tuple):
- parameters = (parameters,)
- if len(parameters) == 2 and parameters[1] is Ellipsis:
- msg = "Tuple[t, ...]: t must be a type."
- p = _type_check(parameters[0], msg)
- return super(TupleMeta, self).__getitem__((p, _TypingEllipsis))
- msg = "Tuple[t0, t1, ...]: each t must be a type."
- parameters = tuple(_type_check(p, msg) for p in parameters)
- return super(TupleMeta, self).__getitem__(parameters)
-
- def __instancecheck__(self, obj):
- if self.__args__ is None:
- return isinstance(obj, tuple)
- raise TypeError("Parameterized Tuple cannot be used "
- "with isinstance().")
-
- def __subclasscheck__(self, cls):
- if self.__args__ is None:
- return issubclass(cls, tuple)
- raise TypeError("Parameterized Tuple cannot be used "
- "with issubclass().")
-
-
-copy._copy_dispatch[TupleMeta] = _copy_generic
-
-
-class Tuple(tuple):
- """Tuple type; Tuple[X, Y] is the cross-product type of X and Y.
-
- Example: Tuple[T1, T2] is a tuple of two elements corresponding
- to type variables T1 and T2. Tuple[int, float, str] is a tuple
- of an int, a float and a string.
-
- To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].
- """
-
- __metaclass__ = TupleMeta
- __extra__ = tuple
- __slots__ = ()
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Tuple:
- raise TypeError("Type Tuple cannot be instantiated; "
- "use tuple() instead")
- return _generic_new(tuple, cls, *args, **kwds)
-
-
-class CallableMeta(GenericMeta):
- """ Metaclass for Callable."""
-
- def __repr__(self):
- if self.__origin__ is None:
- return super(CallableMeta, self).__repr__()
- return self._tree_repr(self._subs_tree())
-
- def _tree_repr(self, tree):
- if self._gorg is not Callable:
- return super(CallableMeta, self)._tree_repr(tree)
- # For actual Callable (not its subclass) we override
- # super(CallableMeta, self)._tree_repr() for nice formatting.
- arg_list = []
- for arg in tree[1:]:
- if not isinstance(arg, tuple):
- arg_list.append(_type_repr(arg))
- else:
- arg_list.append(arg[0]._tree_repr(arg))
- if arg_list[0] == '...':
- return repr(tree[0]) + '[..., %s]' % arg_list[1]
- return (repr(tree[0]) +
- '[[%s], %s]' % (', '.join(arg_list[:-1]), arg_list[-1]))
-
- def __getitem__(self, parameters):
- """A thin wrapper around __getitem_inner__ to provide the latter
- with hashable arguments to improve speed.
- """
-
- if self.__origin__ is not None or self._gorg is not Callable:
- return super(CallableMeta, self).__getitem__(parameters)
- if not isinstance(parameters, tuple) or len(parameters) != 2:
- raise TypeError("Callable must be used as "
- "Callable[[arg, ...], result].")
- args, result = parameters
- if args is Ellipsis:
- parameters = (Ellipsis, result)
- else:
- if not isinstance(args, list):
- raise TypeError("Callable[args, result]: args must be a list."
- " Got %.100r." % (args,))
- parameters = (tuple(args), result)
- return self.__getitem_inner__(parameters)
-
- @_tp_cache
- def __getitem_inner__(self, parameters):
- args, result = parameters
- msg = "Callable[args, result]: result must be a type."
- result = _type_check(result, msg)
- if args is Ellipsis:
- return super(CallableMeta, self).__getitem__((_TypingEllipsis, result))
- msg = "Callable[[arg, ...], result]: each arg must be a type."
- args = tuple(_type_check(arg, msg) for arg in args)
- parameters = args + (result,)
- return super(CallableMeta, self).__getitem__(parameters)
-
-
-copy._copy_dispatch[CallableMeta] = _copy_generic
-
-
-class Callable(object):
- """Callable type; Callable[[int], str] is a function of (int) -> str.
-
- The subscription syntax must always be used with exactly two
- values: the argument list and the return type. The argument list
- must be a list of types or ellipsis; the return type must be a single type.
-
- There is no syntax to indicate optional or keyword arguments,
- such function types are rarely used as callback types.
- """
-
- __metaclass__ = CallableMeta
- __extra__ = collections_abc.Callable
- __slots__ = ()
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Callable:
- raise TypeError("Type Callable cannot be instantiated; "
- "use a non-abstract subclass instead")
- return _generic_new(cls.__next_in_mro__, cls, *args, **kwds)
-
-
-def cast(typ, val):
- """Cast a value to a type.
-
- This returns the value unchanged. To the type checker this
- signals that the return value has the designated type, but at
- runtime we intentionally don't check anything (we want this
- to be as fast as possible).
- """
- return val
-
-
-def _get_defaults(func):
- """Internal helper to extract the default arguments, by name."""
- code = func.__code__
- pos_count = code.co_argcount
- arg_names = code.co_varnames
- arg_names = arg_names[:pos_count]
- defaults = func.__defaults__ or ()
- kwdefaults = func.__kwdefaults__
- res = dict(kwdefaults) if kwdefaults else {}
- pos_offset = pos_count - len(defaults)
- for name, value in zip(arg_names[pos_offset:], defaults):
- assert name not in res
- res[name] = value
- return res
-
-
-def get_type_hints(obj, globalns=None, localns=None):
- """In Python 2 this is not supported and always returns None."""
- return None
-
-
-def no_type_check(arg):
- """Decorator to indicate that annotations are not type hints.
-
- The argument must be a class or function; if it is a class, it
- applies recursively to all methods and classes defined in that class
- (but not to methods defined in its superclasses or subclasses).
-
- This mutates the function(s) or class(es) in place.
- """
- if isinstance(arg, type):
- arg_attrs = arg.__dict__.copy()
- for attr, val in arg.__dict__.items():
- if val in arg.__bases__ + (arg,):
- arg_attrs.pop(attr)
- for obj in arg_attrs.values():
- if isinstance(obj, types.FunctionType):
- obj.__no_type_check__ = True
- if isinstance(obj, type):
- no_type_check(obj)
- try:
- arg.__no_type_check__ = True
- except TypeError: # built-in classes
- pass
- return arg
-
-
-def no_type_check_decorator(decorator):
- """Decorator to give another decorator the @no_type_check effect.
-
- This wraps the decorator with something that wraps the decorated
- function in @no_type_check.
- """
-
- @functools.wraps(decorator)
- def wrapped_decorator(*args, **kwds):
- func = decorator(*args, **kwds)
- func = no_type_check(func)
- return func
-
- return wrapped_decorator
-
-
-def _overload_dummy(*args, **kwds):
- """Helper for @overload to raise when called."""
- raise NotImplementedError(
- "You should not call an overloaded function. "
- "A series of @overload-decorated functions "
- "outside a stub module should always be followed "
- "by an implementation that is not @overload-ed.")
-
-
-def overload(func):
- """Decorator for overloaded functions/methods.
-
- In a stub file, place two or more stub definitions for the same
- function in a row, each decorated with @overload. For example:
-
- @overload
- def utf8(value: None) -> None: ...
- @overload
- def utf8(value: bytes) -> bytes: ...
- @overload
- def utf8(value: str) -> bytes: ...
-
- In a non-stub file (i.e. a regular .py file), do the same but
- follow it with an implementation. The implementation should *not*
- be decorated with @overload. For example:
-
- @overload
- def utf8(value: None) -> None: ...
- @overload
- def utf8(value: bytes) -> bytes: ...
- @overload
- def utf8(value: str) -> bytes: ...
- def utf8(value):
- # implementation goes here
- """
- return _overload_dummy
-
-
-_PROTO_WHITELIST = ['Callable', 'Iterable', 'Iterator',
- 'Hashable', 'Sized', 'Container', 'Collection',
- 'Reversible', 'ContextManager']
-
-
-class _ProtocolMeta(GenericMeta):
- """Internal metaclass for Protocol.
-
- This exists so Protocol classes can be generic without deriving
- from Generic.
- """
- def __init__(cls, *args, **kwargs):
- super(_ProtocolMeta, cls).__init__(*args, **kwargs)
- if not cls.__dict__.get('_is_protocol', None):
- cls._is_protocol = any(b is Protocol or
- isinstance(b, _ProtocolMeta) and
- b.__origin__ is Protocol
- for b in cls.__bases__)
- if cls._is_protocol:
- for base in cls.__mro__[1:]:
- if not (base in (object, Generic) or
- base.__module__ == '_abcoll' and
- base.__name__ in _PROTO_WHITELIST or
- isinstance(base, TypingMeta) and base._is_protocol or
- isinstance(base, GenericMeta) and base.__origin__ is Generic):
- raise TypeError('Protocols can only inherit from other protocols,'
- ' got %r' % base)
- cls._callable_members_only = all(callable(getattr(cls, attr))
- for attr in cls._get_protocol_attrs())
-
- def _no_init(self, *args, **kwargs):
- if type(self)._is_protocol:
- raise TypeError('Protocols cannot be instantiated')
- cls.__init__ = _no_init
-
- def _proto_hook(cls, other):
- if not cls.__dict__.get('_is_protocol', None):
- return NotImplemented
- if not isinstance(other, type):
- # Similar error as for issubclass(1, int)
- # (also not a chance for old-style classes)
- raise TypeError('issubclass() arg 1 must be a new-style class')
- for attr in cls._get_protocol_attrs():
- for base in other.__mro__:
- if attr in base.__dict__:
- if base.__dict__[attr] is None:
- return NotImplemented
- break
- else:
- return NotImplemented
- return True
- if '__subclasshook__' not in cls.__dict__:
- cls.__subclasshook__ = classmethod(_proto_hook)
-
- def __instancecheck__(self, instance):
- # We need this method for situations where attributes are assigned in __init__
- if isinstance(instance, type):
- # This looks like a fundamental limitation of Python 2.
- # It cannot support runtime protocol metaclasses, On Python 2 classes
- # cannot be correctly inspected as instances of protocols.
- return False
- if ((not getattr(self, '_is_protocol', False) or
- self._callable_members_only) and
- issubclass(instance.__class__, self)):
- return True
- if self._is_protocol:
- if all(hasattr(instance, attr) and
- (not callable(getattr(self, attr)) or
- getattr(instance, attr) is not None)
- for attr in self._get_protocol_attrs()):
- return True
- return super(GenericMeta, self).__instancecheck__(instance)
-
- def __subclasscheck__(self, cls):
- if (self.__dict__.get('_is_protocol', None) and
- not self.__dict__.get('_is_runtime_protocol', None)):
- if (sys._getframe(1).f_globals['__name__'] in ['abc', 'functools'] or
- # This is needed because we remove subclasses from unions on Python 2.
- sys._getframe(2).f_globals['__name__'] == 'typing'):
- return False
- raise TypeError("Instance and class checks can only be used with"
- " @runtime_checkable protocols")
- if (self.__dict__.get('_is_runtime_protocol', None) and
- not self._callable_members_only):
- if sys._getframe(1).f_globals['__name__'] in ['abc', 'functools']:
- return super(GenericMeta, self).__subclasscheck__(cls)
- raise TypeError("Protocols with non-method members"
- " don't support issubclass()")
- return super(_ProtocolMeta, self).__subclasscheck__(cls)
-
- def _get_protocol_attrs(self):
- attrs = set()
- for base in self.__mro__[:-1]: # without object
- if base.__name__ in ('Protocol', 'Generic'):
- continue
- annotations = getattr(base, '__annotations__', {})
- for attr in list(base.__dict__.keys()) + list(annotations.keys()):
- if (not attr.startswith('_abc_') and attr not in (
- '__abstractmethods__', '__annotations__', '__weakref__',
- '_is_protocol', '_is_runtime_protocol', '__dict__',
- '__args__', '__slots__', '_get_protocol_attrs',
- '__next_in_mro__', '__parameters__', '__origin__',
- '__orig_bases__', '__extra__', '__tree_hash__',
- '__doc__', '__subclasshook__', '__init__', '__new__',
- '__module__', '_MutableMapping__marker',
- '__metaclass__', '_gorg', '_callable_members_only')):
- attrs.add(attr)
- return attrs
-
-
-class Protocol(object):
- """Base class for protocol classes. Protocol classes are defined as::
-
- class Proto(Protocol):
- def meth(self):
- # type: () -> int
- pass
-
- Such classes are primarily used with static type checkers that recognize
- structural subtyping (static duck-typing), for example::
-
- class C:
- def meth(self):
- # type: () -> int
- return 0
-
- def func(x):
- # type: (Proto) -> int
- return x.meth()
-
- func(C()) # Passes static type check
-
- See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable
- act as simple-minded runtime protocols that checks only the presence of
- given attributes, ignoring their type signatures.
-
- Protocol classes can be generic, they are defined as::
-
- class GenProto(Protocol[T]):
- def meth(self):
- # type: () -> T
- pass
- """
-
- __metaclass__ = _ProtocolMeta
- __slots__ = ()
- _is_protocol = True
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Protocol:
- raise TypeError("Type Protocol cannot be instantiated; "
- "it can be used only as a base class")
- return _generic_new(cls.__next_in_mro__, cls, *args, **kwds)
-
-
-def runtime_checkable(cls):
- """Mark a protocol class as a runtime protocol, so that it
- can be used with isinstance() and issubclass(). Raise TypeError
- if applied to a non-protocol class.
-
- This allows a simple-minded structural check very similar to the
- one-offs in collections.abc such as Hashable.
- """
- if not isinstance(cls, _ProtocolMeta) or not cls._is_protocol:
- raise TypeError('@runtime_checkable can be only applied to protocol classes,'
- ' got %r' % cls)
- cls._is_runtime_protocol = True
- return cls
-
-
-# Various ABCs mimicking those in collections.abc.
-# A few are simply re-exported for completeness.
-
-Hashable = collections_abc.Hashable # Not generic.
-
-
-class Iterable(Generic[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Iterable
-
-
-class Iterator(Iterable[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Iterator
-
-
-@runtime_checkable
-class SupportsInt(Protocol):
- __slots__ = ()
-
- @abstractmethod
- def __int__(self):
- pass
-
-
-@runtime_checkable
-class SupportsFloat(Protocol):
- __slots__ = ()
-
- @abstractmethod
- def __float__(self):
- pass
-
-
-@runtime_checkable
-class SupportsComplex(Protocol):
- __slots__ = ()
-
- @abstractmethod
- def __complex__(self):
- pass
-
-
-@runtime_checkable
-class SupportsIndex(Protocol):
- __slots__ = ()
-
- @abstractmethod
- def __index__(self):
- pass
-
-
-@runtime_checkable
-class SupportsAbs(Protocol[T_co]):
- __slots__ = ()
-
- @abstractmethod
- def __abs__(self):
- pass
-
-
-if hasattr(collections_abc, 'Reversible'):
- class Reversible(Iterable[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Reversible
-else:
- @runtime_checkable
- class Reversible(Protocol[T_co]):
- __slots__ = ()
-
- @abstractmethod
- def __reversed__(self):
- pass
-
-
-Sized = collections_abc.Sized # Not generic.
-
-
-class Container(Generic[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Container
-
-
-# Callable was defined earlier.
-
-
-class AbstractSet(Sized, Iterable[T_co], Container[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Set
-
-
-class MutableSet(AbstractSet[T]):
- __slots__ = ()
- __extra__ = collections_abc.MutableSet
-
-
-# NOTE: It is only covariant in the value type.
-class Mapping(Sized, Iterable[KT], Container[KT], Generic[KT, VT_co]):
- __slots__ = ()
- __extra__ = collections_abc.Mapping
-
-
-class MutableMapping(Mapping[KT, VT]):
- __slots__ = ()
- __extra__ = collections_abc.MutableMapping
-
-
-if hasattr(collections_abc, 'Reversible'):
- class Sequence(Sized, Reversible[T_co], Container[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Sequence
-else:
- class Sequence(Sized, Iterable[T_co], Container[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.Sequence
-
-
-class MutableSequence(Sequence[T]):
- __slots__ = ()
- __extra__ = collections_abc.MutableSequence
-
-
-class ByteString(Sequence[int]):
- pass
-
-
-ByteString.register(str)
-ByteString.register(bytearray)
-
-
-class List(list, MutableSequence[T]):
- __slots__ = ()
- __extra__ = list
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is List:
- raise TypeError("Type List cannot be instantiated; "
- "use list() instead")
- return _generic_new(list, cls, *args, **kwds)
-
-
-class Deque(collections.deque, MutableSequence[T]):
- __slots__ = ()
- __extra__ = collections.deque
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Deque:
- return collections.deque(*args, **kwds)
- return _generic_new(collections.deque, cls, *args, **kwds)
-
-
-class Set(set, MutableSet[T]):
- __slots__ = ()
- __extra__ = set
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Set:
- raise TypeError("Type Set cannot be instantiated; "
- "use set() instead")
- return _generic_new(set, cls, *args, **kwds)
-
-
-class FrozenSet(frozenset, AbstractSet[T_co]):
- __slots__ = ()
- __extra__ = frozenset
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is FrozenSet:
- raise TypeError("Type FrozenSet cannot be instantiated; "
- "use frozenset() instead")
- return _generic_new(frozenset, cls, *args, **kwds)
-
-
-class MappingView(Sized, Iterable[T_co]):
- __slots__ = ()
- __extra__ = collections_abc.MappingView
-
-
-class KeysView(MappingView[KT], AbstractSet[KT]):
- __slots__ = ()
- __extra__ = collections_abc.KeysView
-
-
-class ItemsView(MappingView[Tuple[KT, VT_co]],
- AbstractSet[Tuple[KT, VT_co]],
- Generic[KT, VT_co]):
- __slots__ = ()
- __extra__ = collections_abc.ItemsView
-
-
-class ValuesView(MappingView[VT_co]):
- __slots__ = ()
- __extra__ = collections_abc.ValuesView
-
-
-class ContextManager(Generic[T_co]):
- __slots__ = ()
-
- def __enter__(self):
- return self
-
- @abc.abstractmethod
- def __exit__(self, exc_type, exc_value, traceback):
- return None
-
- @classmethod
- def __subclasshook__(cls, C):
- if cls is ContextManager:
- # In Python 3.6+, it is possible to set a method to None to
- # explicitly indicate that the class does not implement an ABC
- # (https://bugs.python.org/issue25958), but we do not support
- # that pattern here because this fallback class is only used
- # in Python 3.5 and earlier.
- if (any("__enter__" in B.__dict__ for B in C.__mro__) and
- any("__exit__" in B.__dict__ for B in C.__mro__)):
- return True
- return NotImplemented
-
-
-class Dict(dict, MutableMapping[KT, VT]):
- __slots__ = ()
- __extra__ = dict
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Dict:
- raise TypeError("Type Dict cannot be instantiated; "
- "use dict() instead")
- return _generic_new(dict, cls, *args, **kwds)
-
-
-class DefaultDict(collections.defaultdict, MutableMapping[KT, VT]):
- __slots__ = ()
- __extra__ = collections.defaultdict
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is DefaultDict:
- return collections.defaultdict(*args, **kwds)
- return _generic_new(collections.defaultdict, cls, *args, **kwds)
-
-
-class Counter(collections.Counter, Dict[T, int]):
- __slots__ = ()
- __extra__ = collections.Counter
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Counter:
- return collections.Counter(*args, **kwds)
- return _generic_new(collections.Counter, cls, *args, **kwds)
-
-
-# Determine what base class to use for Generator.
-if hasattr(collections_abc, 'Generator'):
- # Sufficiently recent versions of 3.5 have a Generator ABC.
- _G_base = collections_abc.Generator
-else:
- # Fall back on the exact type.
- _G_base = types.GeneratorType
-
-
-class Generator(Iterator[T_co], Generic[T_co, T_contra, V_co]):
- __slots__ = ()
- __extra__ = _G_base
-
- def __new__(cls, *args, **kwds):
- if cls._gorg is Generator:
- raise TypeError("Type Generator cannot be instantiated; "
- "create a subclass instead")
- return _generic_new(_G_base, cls, *args, **kwds)
-
-
-# Internal type variable used for Type[].
-CT_co = TypeVar('CT_co', covariant=True, bound=type)
-
-
-# This is not a real generic class. Don't use outside annotations.
-class Type(Generic[CT_co]):
- """A special construct usable to annotate class objects.
-
- For example, suppose we have the following classes::
-
- class User: ... # Abstract base for User classes
- class BasicUser(User): ...
- class ProUser(User): ...
- class TeamUser(User): ...
-
- And a function that takes a class argument that's a subclass of
- User and returns an instance of the corresponding class::
-
- U = TypeVar('U', bound=User)
- def new_user(user_class: Type[U]) -> U:
- user = user_class()
- # (Here we could write the user object to a database)
- return user
-
- joe = new_user(BasicUser)
-
- At this point the type checker knows that joe has type BasicUser.
- """
- __slots__ = ()
- __extra__ = type
-
-
-def NamedTuple(typename, fields):
- """Typed version of namedtuple.
-
- Usage::
-
- Employee = typing.NamedTuple('Employee', [('name', str), ('id', int)])
-
- This is equivalent to::
-
- Employee = collections.namedtuple('Employee', ['name', 'id'])
-
- The resulting class has one extra attribute: _field_types,
- giving a dict mapping field names to types. (The field names
- are in the _fields attribute, which is part of the namedtuple
- API.)
- """
- fields = [(n, t) for n, t in fields]
- cls = collections.namedtuple(typename, [n for n, t in fields])
- cls._field_types = dict(fields)
- # Set the module to the caller's module (otherwise it'd be 'typing').
- try:
- cls.__module__ = sys._getframe(1).f_globals.get('__name__', '__main__')
- except (AttributeError, ValueError):
- pass
- return cls
-
-
-def _check_fails(cls, other):
- try:
- if sys._getframe(1).f_globals['__name__'] not in ['abc', 'functools', 'typing']:
- # Typed dicts are only for static structural subtyping.
- raise TypeError('TypedDict does not support instance and class checks')
- except (AttributeError, ValueError):
- pass
- return False
-
-
-def _dict_new(cls, *args, **kwargs):
- return dict(*args, **kwargs)
-
-
-def _typeddict_new(cls, _typename, _fields=None, **kwargs):
- total = kwargs.pop('total', True)
- if _fields is None:
- _fields = kwargs
- elif kwargs:
- raise TypeError("TypedDict takes either a dict or keyword arguments,"
- " but not both")
-
- ns = {'__annotations__': dict(_fields), '__total__': total}
- try:
- # Setting correct module is necessary to make typed dict classes pickleable.
- ns['__module__'] = sys._getframe(1).f_globals.get('__name__', '__main__')
- except (AttributeError, ValueError):
- pass
-
- return _TypedDictMeta(_typename, (), ns)
-
-
-class _TypedDictMeta(type):
- def __new__(cls, name, bases, ns, total=True):
- # Create new typed dict class object.
- # This method is called directly when TypedDict is subclassed,
- # or via _typeddict_new when TypedDict is instantiated. This way
- # TypedDict supports all three syntaxes described in its docstring.
- # Subclasses and instances of TypedDict return actual dictionaries
- # via _dict_new.
- ns['__new__'] = _typeddict_new if name == b'TypedDict' else _dict_new
- tp_dict = super(_TypedDictMeta, cls).__new__(cls, name, (dict,), ns)
-
- anns = ns.get('__annotations__', {})
- msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type"
- anns = {n: _type_check(tp, msg) for n, tp in anns.items()}
- for base in bases:
- anns.update(base.__dict__.get('__annotations__', {}))
- tp_dict.__annotations__ = anns
- if not hasattr(tp_dict, '__total__'):
- tp_dict.__total__ = total
- return tp_dict
-
- __instancecheck__ = __subclasscheck__ = _check_fails
-
-
-TypedDict = _TypedDictMeta(b'TypedDict', (dict,), {})
-TypedDict.__module__ = __name__
-TypedDict.__doc__ = \
- """A simple typed name space. At runtime it is equivalent to a plain dict.
-
- TypedDict creates a dictionary type that expects all of its
- instances to have a certain set of keys, with each key
- associated with a value of a consistent type. This expectation
- is not checked at runtime but is only enforced by type checkers.
- Usage::
-
- Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
-
- a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK
- b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check
-
- assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
-
- The type info could be accessed via Point2D.__annotations__. TypedDict
- supports an additional equivalent form::
-
- Point2D = TypedDict('Point2D', x=int, y=int, label=str)
- """
-
-
-def NewType(name, tp):
- """NewType creates simple unique types with almost zero
- runtime overhead. NewType(name, tp) is considered a subtype of tp
- by static type checkers. At runtime, NewType(name, tp) returns
- a dummy function that simply returns its argument. Usage::
-
- UserId = NewType('UserId', int)
-
- def name_by_id(user_id):
- # type: (UserId) -> str
- ...
-
- UserId('user') # Fails type check
-
- name_by_id(42) # Fails type check
- name_by_id(UserId(42)) # OK
-
- num = UserId(5) + 1 # type: int
- """
-
- def new_type(x):
- return x
-
- # Some versions of Python 2 complain because of making all strings unicode
- new_type.__name__ = str(name)
- new_type.__supertype__ = tp
- return new_type
-
-
-# Python-version-specific alias (Python 2: unicode; Python 3: str)
-Text = unicode
-
-
-# Constant that's True when type checking, but False here.
-TYPE_CHECKING = False
-
-
-class IO(Generic[AnyStr]):
- """Generic base class for TextIO and BinaryIO.
-
- This is an abstract, generic version of the return of open().
-
- NOTE: This does not distinguish between the different possible
- classes (text vs. binary, read vs. write vs. read/write,
- append-only, unbuffered). The TextIO and BinaryIO subclasses
- below capture the distinctions between text vs. binary, which is
- pervasive in the interface; however we currently do not offer a
- way to track the other distinctions in the type system.
- """
-
- __slots__ = ()
-
- @abstractproperty
- def mode(self):
- pass
-
- @abstractproperty
- def name(self):
- pass
-
- @abstractmethod
- def close(self):
- pass
-
- @abstractproperty
- def closed(self):
- pass
-
- @abstractmethod
- def fileno(self):
- pass
-
- @abstractmethod
- def flush(self):
- pass
-
- @abstractmethod
- def isatty(self):
- pass
-
- @abstractmethod
- def read(self, n=-1):
- pass
-
- @abstractmethod
- def readable(self):
- pass
-
- @abstractmethod
- def readline(self, limit=-1):
- pass
-
- @abstractmethod
- def readlines(self, hint=-1):
- pass
-
- @abstractmethod
- def seek(self, offset, whence=0):
- pass
-
- @abstractmethod
- def seekable(self):
- pass
-
- @abstractmethod
- def tell(self):
- pass
-
- @abstractmethod
- def truncate(self, size=None):
- pass
-
- @abstractmethod
- def writable(self):
- pass
-
- @abstractmethod
- def write(self, s):
- pass
-
- @abstractmethod
- def writelines(self, lines):
- pass
-
- @abstractmethod
- def __enter__(self):
- pass
-
- @abstractmethod
- def __exit__(self, type, value, traceback):
- pass
-
-
-class BinaryIO(IO[bytes]):
- """Typed version of the return of open() in binary mode."""
-
- __slots__ = ()
-
- @abstractmethod
- def write(self, s):
- pass
-
- @abstractmethod
- def __enter__(self):
- pass
-
-
-class TextIO(IO[unicode]):
- """Typed version of the return of open() in text mode."""
-
- __slots__ = ()
-
- @abstractproperty
- def buffer(self):
- pass
-
- @abstractproperty
- def encoding(self):
- pass
-
- @abstractproperty
- def errors(self):
- pass
-
- @abstractproperty
- def line_buffering(self):
- pass
-
- @abstractproperty
- def newlines(self):
- pass
-
- @abstractmethod
- def __enter__(self):
- pass
-
-
-class io(object):
- """Wrapper namespace for IO generic classes."""
-
- __all__ = ['IO', 'TextIO', 'BinaryIO']
- IO = IO
- TextIO = TextIO
- BinaryIO = BinaryIO
-
-
-io.__name__ = __name__ + b'.io'
-sys.modules[io.__name__] = io
-
-
-Pattern = _TypeAlias('Pattern', AnyStr, type(stdlib_re.compile('')),
- lambda p: p.pattern)
-Match = _TypeAlias('Match', AnyStr, type(stdlib_re.match('', '')),
- lambda m: m.re.pattern)
-
-
-class re(object):
- """Wrapper namespace for re type aliases."""
-
- __all__ = ['Pattern', 'Match']
- Pattern = Pattern
- Match = Match
-
-
-re.__name__ = __name__ + b'.re'
-sys.modules[re.__name__] = re
diff --git a/sources/shiboken2/tests/CMakeLists.txt b/sources/shiboken2/tests/CMakeLists.txt
index 2ba951de1..fcd3f43bd 100644
--- a/sources/shiboken2/tests/CMakeLists.txt
+++ b/sources/shiboken2/tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
if(BUILD_TESTS)
find_package(Qt${QT_MAJOR_VERSION}Test 5.12 REQUIRED)
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.cpp b/sources/shiboken2/tests/libsample/virtualmethods.cpp
index 8f9c8f64d..705835c0b 100644
--- a/sources/shiboken2/tests/libsample/virtualmethods.cpp
+++ b/sources/shiboken2/tests/libsample/virtualmethods.cpp
@@ -63,6 +63,11 @@ const Str & VirtualMethods::returnConstRef() const
return result;
}
+int VirtualMethods::stringViewLength(std::string_view in) const
+{
+ return int(in.size());
+}
+
double VirtualDaughter2::virtualMethod0(Point pt, int val, Complex cpx, bool b)
{
return 42 + VirtualMethods::virtualMethod0(pt, val, cpx, b);
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.h b/sources/shiboken2/tests/libsample/virtualmethods.h
index 4b2d25805..577f6919e 100644
--- a/sources/shiboken2/tests/libsample/virtualmethods.h
+++ b/sources/shiboken2/tests/libsample/virtualmethods.h
@@ -36,6 +36,9 @@
#include "libsamplemacros.h"
#include "strlist.h"
+#include <string_view>
+#include <string>
+
class LIBSAMPLE_API VirtualMethods
{
public:
@@ -108,6 +111,8 @@ public:
virtual const Str & returnConstRef() const;
+ virtual int stringViewLength(std::string_view in) const;
+
protected:
// PYSIDE-1388: Protected hack with final classes (see VirtualFinalDaughter).
void protectedMethod() {}
diff --git a/sources/shiboken2/tests/minimalbinding/listuser_test.py b/sources/shiboken2/tests/minimalbinding/listuser_test.py
index e69bce346..3668cb55f 100644
--- a/sources/shiboken2/tests/minimalbinding/listuser_test.py
+++ b/sources/shiboken2/tests/minimalbinding/listuser_test.py
@@ -29,6 +29,7 @@
##
#############################################################################
+from functools import reduce
import os
import sys
import unittest
@@ -38,11 +39,6 @@ from shiboken_paths import init_paths
init_paths()
from minimal import ListUser, Val, Obj
-from py3kcompat import IS_PY3K
-
-if IS_PY3K:
- import functools
- reduce = functools.reduce
class ExtListUser(ListUser):
diff --git a/sources/shiboken2/tests/minimalbinding/typedef_test.py b/sources/shiboken2/tests/minimalbinding/typedef_test.py
index 6595d0467..e8dd5cd16 100644
--- a/sources/shiboken2/tests/minimalbinding/typedef_test.py
+++ b/sources/shiboken2/tests/minimalbinding/typedef_test.py
@@ -29,6 +29,7 @@
##
#############################################################################
+from functools import reduce
import os
import sys
import unittest
@@ -37,7 +38,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
from minimal import *
-from py3kcompat import IS_PY3K
try:
import numpy as np
@@ -46,11 +46,6 @@ except ImportError as e:
np = None
-if IS_PY3K:
- import functools
- reduce = functools.reduce
-
-
class TypedefTest(unittest.TestCase):
def setUp(self):
diff --git a/sources/shiboken2/tests/otherbinding/module_reload_test.py b/sources/shiboken2/tests/otherbinding/module_reload_test.py
index 368425cd0..c63af188e 100644
--- a/sources/shiboken2/tests/otherbinding/module_reload_test.py
+++ b/sources/shiboken2/tests/otherbinding/module_reload_test.py
@@ -29,6 +29,7 @@
##
#############################################################################
+from importlib import reload
import os
import shutil
import sys
@@ -38,10 +39,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-from py3kcompat import IS_PY3K
-
-if IS_PY3K:
- from imp import reload
orig_path = os.path.join(os.path.dirname(__file__))
workdir = os.getcwd()
diff --git a/sources/shiboken2/tests/py3k.py b/sources/shiboken2/tests/py3k.py
deleted file mode 100644
index 5f2961a6a..000000000
--- a/sources/shiboken2/tests/py3k.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def printToFile(f, str):
- print(str, file=f)
diff --git a/sources/shiboken2/tests/py3kcompat.py b/sources/shiboken2/tests/py3kcompat.py
deleted file mode 100644
index 357ea4fba..000000000
--- a/sources/shiboken2/tests/py3kcompat.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*- coding: utf-8 -*-
-
-#############################################################################
-##
-## 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$
-##
-#############################################################################
-
-# Copy of ../../pyside2/tests/util/py3kcompat.py
-
-import sys
-
-IS_PY3K = sys.version_info[0] == 3
-
-if IS_PY3K:
- def b(s):
- if type(s) == bytes:
- return s
- return bytes(s, "UTF8")
-
- def buffer_(s):
- if s == None:
- return None
- elif type(s) == str:
- return bytes(s, "UTF8")
- elif type(s) == bytes:
- return s
- else:
- memoryview(s)
-
- def l(n):
- return n
-
- def unicode_(s):
- return s
-
- unicode = str
- unichr = chr
- long = int
- unichr = chr
- buffer = buffer_
-else:
- def b(s):
- return s
-
- def l(n):
- return long(n)
-
- def unicode_(s):
- if type(s) == str:
- import codecs
- c = codecs.lookup('utf-8')
- s2 = c.decode(s, 'ignore')
- return s2[0]
- return u'%s' % s
-
- unicode = unicode
- unichr = unichr
- long = long
- buffer = buffer
diff --git a/sources/shiboken2/tests/samplebinding/bug_704_test.py b/sources/shiboken2/tests/samplebinding/bug_704_test.py
index 28c90aba4..d7cb0acd6 100644
--- a/sources/shiboken2/tests/samplebinding/bug_704_test.py
+++ b/sources/shiboken2/tests/samplebinding/bug_704_test.py
@@ -36,7 +36,6 @@ import unittest
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-from py3kcompat import IS_PY3K
from sample import ObjectType
@@ -45,17 +44,11 @@ class NewStyle(object):
def name(self):
return "NewStyle"
-class OldStyle:
- def name(self):
- return "OldStyle"
def defineNewStyle():
class MyObjectNew(ObjectType, NewStyle):
pass
-def defineOldStyle():
- class MyObjectOld(ObjectType, OldStyle):
- pass
class ObjectTypeTest(unittest.TestCase):
'''Test cases to avoid declaring Shiboken classes with multiple inheritance from old style classes.'''
@@ -63,10 +56,6 @@ class ObjectTypeTest(unittest.TestCase):
def testObjectTypeNewStype(self):
defineNewStyle()
- def testObjectTypeOldStype(self):
- # Py 3k doesn't have old style classes
- if not IS_PY3K:
- self.assertRaises(TypeError, defineOldStyle)
if __name__ == '__main__':
diff --git a/sources/shiboken2/tests/samplebinding/bytearray_test.py b/sources/shiboken2/tests/samplebinding/bytearray_test.py
index f1094e54e..af887493b 100644
--- a/sources/shiboken2/tests/samplebinding/bytearray_test.py
+++ b/sources/shiboken2/tests/samplebinding/bytearray_test.py
@@ -38,7 +38,6 @@ from shiboken_paths import init_paths
init_paths()
from os.path import isdir
from sample import ByteArray
-from py3kcompat import b
class ByteArrayBufferProtocolTest(unittest.TestCase):
@@ -102,14 +101,14 @@ class ByteArrayOperatorAt(unittest.TestCase):
string = 'abcdefgh'
obj = ByteArray(string)
for i in range(len(string)):
- self.assertEqual(obj[i], b(string[i]))
+ self.assertEqual(obj[i], bytes(string[i], "UTF8"))
def testInRangeReverse(self):
# ByteArray[x] where x is a valid index (reverse order).
string = 'abcdefgh'
obj = ByteArray(string)
for i in range(len(string)-1, 0, -1):
- self.assertEqual(obj[i], b(string[i]))
+ self.assertEqual(obj[i], bytes(string[i], "UTF8"))
def testOutOfRange(self):
# ByteArray[x] where x is out of index.
@@ -120,7 +119,7 @@ class ByteArrayOperatorAt(unittest.TestCase):
def testNullStrings(self):
ba = ByteArray('\x00')
self.assertEqual(ba.at(0), '\x00')
- self.assertEqual(ba[0], b('\x00'))
+ self.assertEqual(ba[0], bytes('\x00', "UTF8"))
class ByteArrayOperatorLen(unittest.TestCase):
@@ -144,7 +143,7 @@ class ByteArrayAndPythonStr(unittest.TestCase):
self.assertEqual(ByteArray('aaa').__str__(), 'aaa')
def testPythonStrAndNull(self):
- s1 = b('123\000321')
+ s1 = bytes('123\000321', "UTF8")
ba = ByteArray(s1)
s2 = ba.data()
self.assertEqual(s1, s2)
diff --git a/sources/shiboken2/tests/samplebinding/duck_punching_test.py b/sources/shiboken2/tests/samplebinding/duck_punching_test.py
index 3f9d69b47..11c55d00b 100644
--- a/sources/shiboken2/tests/samplebinding/duck_punching_test.py
+++ b/sources/shiboken2/tests/samplebinding/duck_punching_test.py
@@ -39,15 +39,12 @@ import unittest
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from shiboken_paths import init_paths
init_paths()
-from py3kcompat import IS_PY3K
from sample import VirtualMethods, SimpleFile, Point
def MethodTypeCompat(func, instance):
- if IS_PY3K:
- return types.MethodType(func, instance)
- else:
- return types.MethodType(func, instance, type(instance))
+ return types.MethodType(func, instance)
+
class Duck(VirtualMethods):
def __init__(self):
diff --git a/sources/shiboken2/tests/samplebinding/enum_test.py b/sources/shiboken2/tests/samplebinding/enum_test.py
index 0beb72033..2ebc8d406 100644
--- a/sources/shiboken2/tests/samplebinding/enum_test.py
+++ b/sources/shiboken2/tests/samplebinding/enum_test.py
@@ -44,7 +44,6 @@ import shiboken2
import sample
from sample import SampleNamespace, ObjectType, Event
-from py3kcompat import IS_PY3K, b
def createTempFile():
if sys.version_info >= (2, 6):
@@ -133,13 +132,7 @@ class EnumTest(unittest.TestCase):
def testEnumTpPrintImplementation(self):
'''Without SbkEnum.tp_print 'print' returns the enum represented as an int.'''
tmpfile = createTempFile()
- if IS_PY3K:
- from py3k import printToFile
- printToFile(tmpfile, Event.ANY_EVENT)
- else:
- sys.stdout = tmpfile
- print(Event.ANY_EVENT)
- sys.stdout = sys.__stdout__
+ print(Event.ANY_EVENT, file=tmpfile)
tmpfile.seek(0)
text = tmpfile.read().strip()
tmpfile.close()
diff --git a/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py b/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py
index ebecf9ad8..94f2a5de7 100644
--- a/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py
+++ b/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py
@@ -40,7 +40,6 @@ from shiboken_paths import init_paths
init_paths()
import sys
import sample
-from py3kcompat import IS_PY3K, l, long
# Hardcode the limits of the underlying C-types depending on architecture and memory
# model (taking MSVC using LLP64 into account).
@@ -48,7 +47,7 @@ cIntMin = -2147483648
cIntMax = 2147483647
cLongMin = cIntMin
cLongMax = cIntMax
-maxRepresentableInt = sys.maxsize if IS_PY3K else sys.maxint
+maxRepresentableInt = sys.maxsize
is64bitArchitecture = maxRepresentableInt > 2**32
if is64bitArchitecture and sys.platform != 'win32':
cLongMin = -9223372036854775808
@@ -81,13 +80,13 @@ class FloatImplicitConvert(NumericTester):
def testFloatAsUInt(self):
'''Float as unsigned Int'''
- self.check_value(3.14, 3, sample.acceptUInt, long)
+ self.check_value(3.14, 3, sample.acceptUInt, int)
self.assertRaises(OverflowError, sample.acceptUInt, -3.14)
def testFloatAsULong(self):
'''Float as unsigned Long'''
#FIXME Breaking with SystemError "bad argument to internal function"
- self.check_value(3.14, 3, sample.acceptULong, long)
+ self.check_value(3.14, 3, sample.acceptULong, int)
self.assertRaises(OverflowError, sample.acceptULong, -3.14)
def testFloatAsDouble(self):
@@ -112,12 +111,12 @@ class IntImplicitConvert(NumericTester):
def testIntAsUInt(self):
'''Int as unsigned Int'''
- self.check_value(3, 3, sample.acceptUInt, long)
+ self.check_value(3, 3, sample.acceptUInt, int)
self.assertRaises(OverflowError, sample.acceptUInt, -3)
def testIntAsULong(self):
'''Int as unsigned Long'''
- self.check_value(3, 3, sample.acceptULong, long)
+ self.check_value(3, 3, sample.acceptULong, int)
self.assertRaises(OverflowError, sample.acceptULong, -3)
def testFloatAsDouble(self):
@@ -130,27 +129,27 @@ class LongImplicitConvert(NumericTester):
def testLongAsInt(self):
'''Long as Int'''
- self.check_value(l(24224), 24224, sample.acceptInt, int)
+ self.check_value(24224, 24224, sample.acceptInt, int)
self.assertRaises(OverflowError, sample.acceptInt, cIntMax + 20)
def testLongAsLong(self):
'''Long as Long'''
- self.check_value(l(2405), 2405, sample.acceptLong, int)
+ self.check_value(2405, 2405, sample.acceptLong, int)
self.assertRaises(OverflowError, sample.acceptLong, cLongMax + 20)
def testLongAsUInt(self):
'''Long as unsigned Int'''
- self.check_value(l(260), 260, sample.acceptUInt, long)
+ self.check_value(260, 260, sample.acceptUInt, int)
self.assertRaises(OverflowError, sample.acceptUInt, -42)
def testLongAsULong(self):
'''Long as unsigned Long'''
- self.check_value(l(128), 128, sample.acceptULong, long)
- self.assertRaises(OverflowError, sample.acceptULong, l(-334))
+ self.check_value(128, 128, sample.acceptULong, int)
+ self.assertRaises(OverflowError, sample.acceptULong, -334)
def testLongAsDouble(self):
'''Float as double'''
- self.check_value(l(42), 42, sample.acceptDouble, float)
+ self.check_value(42, 42, sample.acceptDouble, float)
if __name__ == '__main__':
diff --git a/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py b/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py
deleted file mode 100644
index e0f864636..000000000
--- a/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-#############################################################################
-##
-## Copyright (C) 2016 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$
-##
-#############################################################################
-
-import os
-import sys
-import unittest
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from shiboken_paths import init_paths
-init_paths()
-
-import sample
-from py3kcompat import IS_PY3K
-
-class OldStyle:
- pass
-
-class NewStyle(object):
- pass
-
-class OldStyleNumber:
- def __init__(self, value):
- self.value = value
- def __trunc__(self):
- return self.value
-
-class NewStyleNumber(object):
- def __init__(self, value):
- self.value = value
- def __int__(self):
- return int(self.value)
- def __trunc__(self):
- return self.value
-
-class TestOldStyleClassAsNumber(unittest.TestCase):
-
- def testBasic(self):
- '''For the sake of calibration...'''
- self.assertEqual(sample.acceptInt(123), 123)
-
- def testOldStyleClassPassedAsInteger(self):
- '''Old-style classes aren't numbers and shouldn't be accepted.'''
- obj = OldStyle()
- self.assertRaises(TypeError, sample.acceptInt, obj)
-
- def testNewStyleClassPassedAsInteger(self):
- '''New-style classes aren't numbers and shouldn't be accepted.'''
- obj = NewStyle()
- self.assertRaises(TypeError, sample.acceptInt, obj)
-
- def testOldStyleClassWithNumberProtocol(self):
- obj = OldStyleNumber(123)
- self.assertEqual(sample.acceptInt(obj), obj.value)
-
- def testNewStyleClassWithNumberProtocol(self):
- obj = NewStyleNumber(123)
- self.assertEqual(sample.acceptInt(obj), obj.value)
-
-if __name__ == "__main__" and not IS_PY3K:
- unittest.main()
-
diff --git a/sources/shiboken2/tests/samplebinding/overflow_test.py b/sources/shiboken2/tests/samplebinding/overflow_test.py
index 56a5d98c7..237bb6615 100644
--- a/sources/shiboken2/tests/samplebinding/overflow_test.py
+++ b/sources/shiboken2/tests/samplebinding/overflow_test.py
@@ -40,7 +40,7 @@ from shiboken_paths import init_paths
init_paths()
from sample import *
-from py3kcompat import IS_PY3K, long
+
class OverflowTest(unittest.TestCase):
'''Test case for overflowing C++ numeric types.'''
@@ -56,7 +56,7 @@ class OverflowTest(unittest.TestCase):
'''C++ function receives an long long argument and raise OverflowError if the value is negative.'''
val = 100
self.assertEqual(doubleLongLong(val), 2 * val)
- val = long(100)
+ val = int(100)
self.assertEqual(doubleLongLong(val), 2 * val)
val = (2 << 64) + 1
self.assertRaises(OverflowError, doubleLongLong, val)
@@ -65,11 +65,11 @@ class OverflowTest(unittest.TestCase):
'''C++ function receives an unsigned long long argument and raise OverflowError if the value is negative.'''
val = 100
self.assertEqual(doubleUnsignedLongLong(val), 2 * val)
- val = long(100)
+ val = int(100)
self.assertEqual(doubleUnsignedLongLong(val), 2 * val)
val = -100
self.assertRaises(OverflowError, doubleUnsignedLongLong, val)
- val = long(-200)
+ val = int(-200)
self.assertRaises(OverflowError, doubleUnsignedLongLong, val)
def testOverflow(self):
diff --git a/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py b/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py
index dbd318091..9444f9066 100644
--- a/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py
+++ b/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py
@@ -38,7 +38,7 @@ from shiboken_paths import init_paths
init_paths()
from sample import Overload, Str
-from py3kcompat import b
+
class OverloadTest(unittest.TestCase):
@@ -59,11 +59,11 @@ class OverloadTest(unittest.TestCase):
def testStringArgumentAsBuffer(self):
overload = Overload()
- self.assertEqual(overload.strBufferOverloads(b'', 0), Overload.Function1)
+ self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), Overload.Function1)
def testBufferArgument(self):
overload = Overload()
- self.assertEqual(overload.strBufferOverloads(b(''), 0), Overload.Function1)
+ self.assertEqual(overload.strBufferOverloads(bytes('', "UTF-8"), 0), Overload.Function1)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py b/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py
index 206a65ce9..f9504227c 100644
--- a/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py
+++ b/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py
@@ -42,10 +42,6 @@ from shiboken_paths import init_paths
init_paths()
from sample import ObjectType
-from py3kcompat import IS_PY3K
-
-if IS_PY3K:
- string.letters = string.ascii_letters
class DeleteChildInPython(unittest.TestCase):
@@ -55,7 +51,7 @@ class DeleteChildInPython(unittest.TestCase):
'''Delete child in python should not invalidate child'''
parent = ObjectType()
child = ObjectType(parent)
- name = ''.join(random.sample(string.letters, 5))
+ name = ''.join(random.sample(string.ascii_letters, 5))
child.setObjectName(name)
del child
diff --git a/sources/shiboken2/tests/samplebinding/point_test.py b/sources/shiboken2/tests/samplebinding/point_test.py
index 36e6bc642..c2159e7d5 100644
--- a/sources/shiboken2/tests/samplebinding/point_test.py
+++ b/sources/shiboken2/tests/samplebinding/point_test.py
@@ -40,7 +40,6 @@ from shiboken_paths import init_paths
init_paths()
from sample import Point
-from py3kcompat import unicode
class PointTest(unittest.TestCase):
'''Test case for Point class, including operator overloads.'''
@@ -100,12 +99,12 @@ class PointTest(unittest.TestCase):
def testAddedOperator(self):
p = Point(0.0, 0.0)
- r = p - unicode('Hi')
- self.assertEqual(r, unicode('Hi'))
+ r = p - 'Hi'
+ self.assertEqual(r, 'Hi')
# now the reverse op.
- r = unicode('Hi') - p
- self.assertEqual(r, unicode('Hi'))
+ r = 'Hi' - p
+ self.assertEqual(r, 'Hi')
def testModifiedMethod(self):
pt1 = Point(0.0, 0.0)
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 595afb9ae..d0ccbb349 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -25,6 +25,7 @@
<primitive-type name="long long"/>
<primitive-type name="unsigned long long"/>
<primitive-type name="std::string"/>
+ <primitive-type name="std::string_view" view-on="std::string"/>
<primitive-type name="ObjectType::Identifier"/>
<primitive-type name="Foo::HANDLE" target-lang-api-name="PyLong"/>
@@ -101,23 +102,14 @@
<native-to-target>
if (!%in)
Py_RETURN_NONE;
- #ifdef IS_PY3K
- return PyCapsule_New(%in, 0, 0);
- #else
- return PyCObject_FromVoidPtr(%in, 0);
- #endif
+ return PyCapsule_New(%in, nullptr, nullptr);
</native-to-target>
<target-to-native>
<add-conversion type="PyNone">
%out = 0;
</add-conversion>
<add-conversion check="checkPyCapsuleOrPyCObject(%in)" type="PyObject">
- void* ptr;
- #ifdef IS_PY3K
- ptr = PyCapsule_GetPointer(%in, 0);
- #else
- ptr = PyCObject_AsVoidPtr(%in);
- #endif
+ void *ptr = PyCapsule_GetPointer(%in, nullptr);
%out = (%OUTTYPE)ptr;
</add-conversion>
</target-to-native>
@@ -127,11 +119,7 @@
<inject-code class="native" position="beginning">
static bool checkPyCapsuleOrPyCObject(PyObject* pyObj)
{
- #ifdef IS_PY3K
return PyCapsule_CheckExact(pyObj);
- #else
- return PyCObject_Check(pyObj);
- #endif
}
</inject-code>
@@ -139,20 +127,11 @@
<include file-name="handle.h" location="local"/>
<conversion-rule>
<native-to-target>
- #ifdef IS_PY3K
- return PyCapsule_New(&amp;%in, 0, 0);
- #else
- return PyCObject_FromVoidPtr(&amp;%in, 0);
- #endif
+ return PyCapsule_New(&amp;%in, nullptr, nullptr);
</native-to-target>
<target-to-native>
<add-conversion check="checkPyCapsuleOrPyCObject(%in)" type="PyObject">
- void* ptr;
- #ifdef IS_PY3K
- ptr = PyCapsule_GetPointer(%in, 0);
- #else
- ptr = PyCObject_AsVoidPtr(%in);
- #endif
+ void *ptr = PyCapsule_GetPointer(%in, nullptr);
%out = *((%OUTTYPE*)ptr);
</add-conversion>
</target-to-native>
diff --git a/sources/shiboken2/tests/samplebinding/virtualmethods_test.py b/sources/shiboken2/tests/samplebinding/virtualmethods_test.py
index 2d3198071..07b79c489 100644
--- a/sources/shiboken2/tests/samplebinding/virtualmethods_test.py
+++ b/sources/shiboken2/tests/samplebinding/virtualmethods_test.py
@@ -133,6 +133,11 @@ class VirtualMethodsTest(unittest.TestCase):
self.assertTrue(eevd.grand_grand_daughter_name_called)
self.assertEqual(eevd.name().prepend(self.prefix_from_codeinjection), name)
+ def testStringView(self):
+ virtual_methods = VirtualMethods()
+ self.assertEqual(virtual_methods.stringViewLength('bla'), 3)
+
+
class PrettyErrorMessageTest(unittest.TestCase):
def testIt(self):
obj = ExtendedVirtualMethods()
diff --git a/sources/shiboken2/tests/shiboken_paths.py b/sources/shiboken2/tests/shiboken_paths.py
index ba0da9189..1072aa501 100644
--- a/sources/shiboken2/tests/shiboken_paths.py
+++ b/sources/shiboken2/tests/shiboken_paths.py
@@ -107,7 +107,7 @@ def shiboken_paths(include_shiboken_tests=False):
src_dir = os.path.dirname(os.path.abspath(__file__))
python_dirs = []
if include_shiboken_tests:
- python_dirs.append(src_dir) # For py3kcompat
+ python_dirs.append(src_dir) # For shiboken_test_helper
shiboken_dir = os.path.join(get_build_dir(), 'shiboken2')
python_dirs.append(os.path.join(shiboken_dir, 'shibokenmodule'))
lib_dirs = [os.path.join(shiboken_dir, 'libshiboken')]
diff --git a/sources/shiboken2/tests/test_generator/CMakeLists.txt b/sources/shiboken2/tests/test_generator/CMakeLists.txt
index 07611e32c..b48ae37da 100644
--- a/sources/shiboken2/tests/test_generator/CMakeLists.txt
+++ b/sources/shiboken2/tests/test_generator/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
project(test_generator)
set(dummy_generator_SRC dummygenerator.cpp)